@Test public void testSerialize() { RegisteredClient c = new RegisteredClient(); c.setClientId("s6BhdRkqt3"); c.setClientSecret("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk"); c.setClientSecretExpiresAt(new Date(1577858400L * 1000L)); c.setRegistrationAccessToken("this.is.an.access.token.value.ffx83"); c.setRegistrationClientUri("https: c.setApplicationType(ClientDetailsEntity.AppType.WEB); c.setRedirectUris(ImmutableSet.of("https: c.setClientName("My Example"); c.setResponseTypes(ImmutableSet.of("code", "token")); c.setGrantTypes(ImmutableSet.of("authorization_code", "implicit")); c.setLogoUri("https: c.setSubjectType(ClientDetailsEntity.SubjectType.PAIRWISE); c.setSectorIdentifierUri("https: c.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.SECRET_BASIC); c.setJwksUri("https: c.setUserInfoEncryptedResponseAlg(JWEAlgorithm.RSA1_5); c.setUserInfoEncryptedResponseEnc(EncryptionMethod.A128CBC_HS256); c.setContacts(ImmutableSet.of("ve7jtb@example.org", "mary@example.org")); c.setRequestUris(ImmutableSet.of("https: JsonObject j = ClientDetailsEntityJsonProcessor.serialize(c); assertEquals("s6BhdRkqt3", j.get("client_id").getAsString()); assertEquals("ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk", j.get("client_secret").getAsString()); assertEquals(1577858400L, j.get("client_secret_expires_at").getAsNumber()); assertEquals("this.is.an.access.token.value.ffx83", j.get("registration_access_token").getAsString()); assertEquals("https: assertEquals(ClientDetailsEntity.AppType.WEB.getValue(), j.get("application_type").getAsString()); for (JsonElement e : j.get("redirect_uris").getAsJsonArray()) { assertTrue(ImmutableSet.of("https: } assertEquals("My Example", j.get("client_name").getAsString()); for (JsonElement e : j.get("response_types").getAsJsonArray()) { assertTrue(ImmutableSet.of("code", "token").contains(e.getAsString())); } for (JsonElement e : j.get("grant_types").getAsJsonArray()) { assertTrue(ImmutableSet.of("authorization_code", "implicit").contains(e.getAsString())); } assertEquals("https: assertEquals(ClientDetailsEntity.SubjectType.PAIRWISE.getValue(), j.get("subject_type").getAsString()); assertEquals("https: assertEquals(ClientDetailsEntity.AuthMethod.SECRET_BASIC.getValue(), j.get("token_endpoint_auth_method").getAsString()); assertEquals("https: assertEquals(JWEAlgorithm.RSA1_5.getName(), j.get("userinfo_encrypted_response_alg").getAsString()); assertEquals(EncryptionMethod.A128CBC_HS256.getName(), j.get("userinfo_encrypted_response_enc").getAsString()); for (JsonElement e : j.get("contacts").getAsJsonArray()) { assertTrue(ImmutableSet.of("ve7jtb@example.org", "mary@example.org").contains(e.getAsString())); } for (JsonElement e : j.get("request_uris").getAsJsonArray()) { assertTrue(ImmutableSet.of("https: } }
public static JsonObject serialize(RegisteredClient c) { JsonObject o = new JsonObject(); o.addProperty("client_id", c.getClientId()); if (c.getClientSecret() != null) { o.addProperty("client_secret", c.getClientSecret()); if (c.getClientSecretExpiresAt() == null) { o.addProperty("client_secret_expires_at", 0); } else { o.addProperty("client_secret_expires_at", c.getClientSecretExpiresAt().getTime() / 1000L); } } if (c.getClientIdIssuedAt() != null) { o.addProperty("client_id_issued_at", c.getClientIdIssuedAt().getTime() / 1000L); } else if (c.getCreatedAt() != null) { o.addProperty("client_id_issued_at", c.getCreatedAt().getTime() / 1000L); } if (c.getRegistrationAccessToken() != null) { o.addProperty("registration_access_token", c.getRegistrationAccessToken()); } if (c.getRegistrationClientUri() != null) { o.addProperty("registration_client_uri", c.getRegistrationClientUri()); } o.add("redirect_uris", getAsArray(c.getRedirectUris())); o.addProperty("client_name", c.getClientName()); o.addProperty("client_uri", c.getClientUri()); o.addProperty("logo_uri", c.getLogoUri()); o.add("contacts", getAsArray(c.getContacts())); o.addProperty("tos_uri", c.getTosUri()); o.addProperty("token_endpoint_auth_method", c.getTokenEndpointAuthMethod() != null ? c.getTokenEndpointAuthMethod().getValue() : null); o.addProperty("scope", c.getScope() != null ? Joiner.on(" ").join(c.getScope()) : null); o.add("grant_types", getAsArray(c.getGrantTypes())); o.add("response_types", getAsArray(c.getResponseTypes())); o.addProperty("policy_uri", c.getPolicyUri()); o.addProperty("jwks_uri", c.getJwksUri()); o.addProperty("application_type", c.getApplicationType() != null ? c.getApplicationType().getValue() : null); o.addProperty("sector_identifier_uri", c.getSectorIdentifierUri()); o.addProperty("subject_type", c.getSubjectType() != null ? c.getSubjectType().getValue() : null); o.addProperty("request_object_signing_alg", c.getRequestObjectSigningAlg() != null ? c.getRequestObjectSigningAlg().getName() : null); o.addProperty("userinfo_signed_response_alg", c.getUserInfoSignedResponseAlg() != null ? c.getUserInfoSignedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_alg", c.getUserInfoEncryptedResponseAlg() != null ? c.getUserInfoEncryptedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getName() : null); o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getName() : null); o.addProperty("token_endpoint_auth_signing_alg", c.getTokenEndpointAuthSigningAlg() != null ? c.getTokenEndpointAuthSigningAlg().getName() : null); o.addProperty("default_max_age", c.getDefaultMaxAge()); o.addProperty("require_auth_time", c.getRequireAuthTime()); o.add("default_acr_values", getAsArray(c.getDefaultACRvalues())); o.addProperty("initiate_login_uri", c.getInitiateLoginUri()); o.addProperty("post_logout_redirect_uri", c.getPostLogoutRedirectUri()); o.add("request_uris", getAsArray(c.getRequestUris())); return o; }
ClientDetailsEntityJsonProcessor { public static JsonObject serialize(RegisteredClient c) { JsonObject o = new JsonObject(); o.addProperty("client_id", c.getClientId()); if (c.getClientSecret() != null) { o.addProperty("client_secret", c.getClientSecret()); if (c.getClientSecretExpiresAt() == null) { o.addProperty("client_secret_expires_at", 0); } else { o.addProperty("client_secret_expires_at", c.getClientSecretExpiresAt().getTime() / 1000L); } } if (c.getClientIdIssuedAt() != null) { o.addProperty("client_id_issued_at", c.getClientIdIssuedAt().getTime() / 1000L); } else if (c.getCreatedAt() != null) { o.addProperty("client_id_issued_at", c.getCreatedAt().getTime() / 1000L); } if (c.getRegistrationAccessToken() != null) { o.addProperty("registration_access_token", c.getRegistrationAccessToken()); } if (c.getRegistrationClientUri() != null) { o.addProperty("registration_client_uri", c.getRegistrationClientUri()); } o.add("redirect_uris", getAsArray(c.getRedirectUris())); o.addProperty("client_name", c.getClientName()); o.addProperty("client_uri", c.getClientUri()); o.addProperty("logo_uri", c.getLogoUri()); o.add("contacts", getAsArray(c.getContacts())); o.addProperty("tos_uri", c.getTosUri()); o.addProperty("token_endpoint_auth_method", c.getTokenEndpointAuthMethod() != null ? c.getTokenEndpointAuthMethod().getValue() : null); o.addProperty("scope", c.getScope() != null ? Joiner.on(" ").join(c.getScope()) : null); o.add("grant_types", getAsArray(c.getGrantTypes())); o.add("response_types", getAsArray(c.getResponseTypes())); o.addProperty("policy_uri", c.getPolicyUri()); o.addProperty("jwks_uri", c.getJwksUri()); o.addProperty("application_type", c.getApplicationType() != null ? c.getApplicationType().getValue() : null); o.addProperty("sector_identifier_uri", c.getSectorIdentifierUri()); o.addProperty("subject_type", c.getSubjectType() != null ? c.getSubjectType().getValue() : null); o.addProperty("request_object_signing_alg", c.getRequestObjectSigningAlg() != null ? c.getRequestObjectSigningAlg().getName() : null); o.addProperty("userinfo_signed_response_alg", c.getUserInfoSignedResponseAlg() != null ? c.getUserInfoSignedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_alg", c.getUserInfoEncryptedResponseAlg() != null ? c.getUserInfoEncryptedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getName() : null); o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getName() : null); o.addProperty("token_endpoint_auth_signing_alg", c.getTokenEndpointAuthSigningAlg() != null ? c.getTokenEndpointAuthSigningAlg().getName() : null); o.addProperty("default_max_age", c.getDefaultMaxAge()); o.addProperty("require_auth_time", c.getRequireAuthTime()); o.add("default_acr_values", getAsArray(c.getDefaultACRvalues())); o.addProperty("initiate_login_uri", c.getInitiateLoginUri()); o.addProperty("post_logout_redirect_uri", c.getPostLogoutRedirectUri()); o.add("request_uris", getAsArray(c.getRequestUris())); return o; } }
ClientDetailsEntityJsonProcessor { public static JsonObject serialize(RegisteredClient c) { JsonObject o = new JsonObject(); o.addProperty("client_id", c.getClientId()); if (c.getClientSecret() != null) { o.addProperty("client_secret", c.getClientSecret()); if (c.getClientSecretExpiresAt() == null) { o.addProperty("client_secret_expires_at", 0); } else { o.addProperty("client_secret_expires_at", c.getClientSecretExpiresAt().getTime() / 1000L); } } if (c.getClientIdIssuedAt() != null) { o.addProperty("client_id_issued_at", c.getClientIdIssuedAt().getTime() / 1000L); } else if (c.getCreatedAt() != null) { o.addProperty("client_id_issued_at", c.getCreatedAt().getTime() / 1000L); } if (c.getRegistrationAccessToken() != null) { o.addProperty("registration_access_token", c.getRegistrationAccessToken()); } if (c.getRegistrationClientUri() != null) { o.addProperty("registration_client_uri", c.getRegistrationClientUri()); } o.add("redirect_uris", getAsArray(c.getRedirectUris())); o.addProperty("client_name", c.getClientName()); o.addProperty("client_uri", c.getClientUri()); o.addProperty("logo_uri", c.getLogoUri()); o.add("contacts", getAsArray(c.getContacts())); o.addProperty("tos_uri", c.getTosUri()); o.addProperty("token_endpoint_auth_method", c.getTokenEndpointAuthMethod() != null ? c.getTokenEndpointAuthMethod().getValue() : null); o.addProperty("scope", c.getScope() != null ? Joiner.on(" ").join(c.getScope()) : null); o.add("grant_types", getAsArray(c.getGrantTypes())); o.add("response_types", getAsArray(c.getResponseTypes())); o.addProperty("policy_uri", c.getPolicyUri()); o.addProperty("jwks_uri", c.getJwksUri()); o.addProperty("application_type", c.getApplicationType() != null ? c.getApplicationType().getValue() : null); o.addProperty("sector_identifier_uri", c.getSectorIdentifierUri()); o.addProperty("subject_type", c.getSubjectType() != null ? c.getSubjectType().getValue() : null); o.addProperty("request_object_signing_alg", c.getRequestObjectSigningAlg() != null ? c.getRequestObjectSigningAlg().getName() : null); o.addProperty("userinfo_signed_response_alg", c.getUserInfoSignedResponseAlg() != null ? c.getUserInfoSignedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_alg", c.getUserInfoEncryptedResponseAlg() != null ? c.getUserInfoEncryptedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getName() : null); o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getName() : null); o.addProperty("token_endpoint_auth_signing_alg", c.getTokenEndpointAuthSigningAlg() != null ? c.getTokenEndpointAuthSigningAlg().getName() : null); o.addProperty("default_max_age", c.getDefaultMaxAge()); o.addProperty("require_auth_time", c.getRequireAuthTime()); o.add("default_acr_values", getAsArray(c.getDefaultACRvalues())); o.addProperty("initiate_login_uri", c.getInitiateLoginUri()); o.addProperty("post_logout_redirect_uri", c.getPostLogoutRedirectUri()); o.add("request_uris", getAsArray(c.getRequestUris())); return o; }  }
ClientDetailsEntityJsonProcessor { public static JsonObject serialize(RegisteredClient c) { JsonObject o = new JsonObject(); o.addProperty("client_id", c.getClientId()); if (c.getClientSecret() != null) { o.addProperty("client_secret", c.getClientSecret()); if (c.getClientSecretExpiresAt() == null) { o.addProperty("client_secret_expires_at", 0); } else { o.addProperty("client_secret_expires_at", c.getClientSecretExpiresAt().getTime() / 1000L); } } if (c.getClientIdIssuedAt() != null) { o.addProperty("client_id_issued_at", c.getClientIdIssuedAt().getTime() / 1000L); } else if (c.getCreatedAt() != null) { o.addProperty("client_id_issued_at", c.getCreatedAt().getTime() / 1000L); } if (c.getRegistrationAccessToken() != null) { o.addProperty("registration_access_token", c.getRegistrationAccessToken()); } if (c.getRegistrationClientUri() != null) { o.addProperty("registration_client_uri", c.getRegistrationClientUri()); } o.add("redirect_uris", getAsArray(c.getRedirectUris())); o.addProperty("client_name", c.getClientName()); o.addProperty("client_uri", c.getClientUri()); o.addProperty("logo_uri", c.getLogoUri()); o.add("contacts", getAsArray(c.getContacts())); o.addProperty("tos_uri", c.getTosUri()); o.addProperty("token_endpoint_auth_method", c.getTokenEndpointAuthMethod() != null ? c.getTokenEndpointAuthMethod().getValue() : null); o.addProperty("scope", c.getScope() != null ? Joiner.on(" ").join(c.getScope()) : null); o.add("grant_types", getAsArray(c.getGrantTypes())); o.add("response_types", getAsArray(c.getResponseTypes())); o.addProperty("policy_uri", c.getPolicyUri()); o.addProperty("jwks_uri", c.getJwksUri()); o.addProperty("application_type", c.getApplicationType() != null ? c.getApplicationType().getValue() : null); o.addProperty("sector_identifier_uri", c.getSectorIdentifierUri()); o.addProperty("subject_type", c.getSubjectType() != null ? c.getSubjectType().getValue() : null); o.addProperty("request_object_signing_alg", c.getRequestObjectSigningAlg() != null ? c.getRequestObjectSigningAlg().getName() : null); o.addProperty("userinfo_signed_response_alg", c.getUserInfoSignedResponseAlg() != null ? c.getUserInfoSignedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_alg", c.getUserInfoEncryptedResponseAlg() != null ? c.getUserInfoEncryptedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getName() : null); o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getName() : null); o.addProperty("token_endpoint_auth_signing_alg", c.getTokenEndpointAuthSigningAlg() != null ? c.getTokenEndpointAuthSigningAlg().getName() : null); o.addProperty("default_max_age", c.getDefaultMaxAge()); o.addProperty("require_auth_time", c.getRequireAuthTime()); o.add("default_acr_values", getAsArray(c.getDefaultACRvalues())); o.addProperty("initiate_login_uri", c.getInitiateLoginUri()); o.addProperty("post_logout_redirect_uri", c.getPostLogoutRedirectUri()); o.add("request_uris", getAsArray(c.getRequestUris())); return o; }  static ClientDetailsEntity parse(String jsonString); static ClientDetailsEntity parse(JsonElement jsonEl); static RegisteredClient parseRegistered(String jsonString); static RegisteredClient parseRegistered(JsonElement jsonEl); static JsonObject serialize(RegisteredClient c); }
ClientDetailsEntityJsonProcessor { public static JsonObject serialize(RegisteredClient c) { JsonObject o = new JsonObject(); o.addProperty("client_id", c.getClientId()); if (c.getClientSecret() != null) { o.addProperty("client_secret", c.getClientSecret()); if (c.getClientSecretExpiresAt() == null) { o.addProperty("client_secret_expires_at", 0); } else { o.addProperty("client_secret_expires_at", c.getClientSecretExpiresAt().getTime() / 1000L); } } if (c.getClientIdIssuedAt() != null) { o.addProperty("client_id_issued_at", c.getClientIdIssuedAt().getTime() / 1000L); } else if (c.getCreatedAt() != null) { o.addProperty("client_id_issued_at", c.getCreatedAt().getTime() / 1000L); } if (c.getRegistrationAccessToken() != null) { o.addProperty("registration_access_token", c.getRegistrationAccessToken()); } if (c.getRegistrationClientUri() != null) { o.addProperty("registration_client_uri", c.getRegistrationClientUri()); } o.add("redirect_uris", getAsArray(c.getRedirectUris())); o.addProperty("client_name", c.getClientName()); o.addProperty("client_uri", c.getClientUri()); o.addProperty("logo_uri", c.getLogoUri()); o.add("contacts", getAsArray(c.getContacts())); o.addProperty("tos_uri", c.getTosUri()); o.addProperty("token_endpoint_auth_method", c.getTokenEndpointAuthMethod() != null ? c.getTokenEndpointAuthMethod().getValue() : null); o.addProperty("scope", c.getScope() != null ? Joiner.on(" ").join(c.getScope()) : null); o.add("grant_types", getAsArray(c.getGrantTypes())); o.add("response_types", getAsArray(c.getResponseTypes())); o.addProperty("policy_uri", c.getPolicyUri()); o.addProperty("jwks_uri", c.getJwksUri()); o.addProperty("application_type", c.getApplicationType() != null ? c.getApplicationType().getValue() : null); o.addProperty("sector_identifier_uri", c.getSectorIdentifierUri()); o.addProperty("subject_type", c.getSubjectType() != null ? c.getSubjectType().getValue() : null); o.addProperty("request_object_signing_alg", c.getRequestObjectSigningAlg() != null ? c.getRequestObjectSigningAlg().getName() : null); o.addProperty("userinfo_signed_response_alg", c.getUserInfoSignedResponseAlg() != null ? c.getUserInfoSignedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_alg", c.getUserInfoEncryptedResponseAlg() != null ? c.getUserInfoEncryptedResponseAlg().getName() : null); o.addProperty("userinfo_encrypted_response_enc", c.getUserInfoEncryptedResponseEnc() != null ? c.getUserInfoEncryptedResponseEnc().getName() : null); o.addProperty("id_token_signed_response_alg", c.getIdTokenSignedResponseAlg() != null ? c.getIdTokenSignedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_alg", c.getIdTokenEncryptedResponseAlg() != null ? c.getIdTokenEncryptedResponseAlg().getName() : null); o.addProperty("id_token_encrypted_response_enc", c.getIdTokenEncryptedResponseEnc() != null ? c.getIdTokenEncryptedResponseEnc().getName() : null); o.addProperty("token_endpoint_auth_signing_alg", c.getTokenEndpointAuthSigningAlg() != null ? c.getTokenEndpointAuthSigningAlg().getName() : null); o.addProperty("default_max_age", c.getDefaultMaxAge()); o.addProperty("require_auth_time", c.getRequireAuthTime()); o.add("default_acr_values", getAsArray(c.getDefaultACRvalues())); o.addProperty("initiate_login_uri", c.getInitiateLoginUri()); o.addProperty("post_logout_redirect_uri", c.getPostLogoutRedirectUri()); o.add("request_uris", getAsArray(c.getRequestUris())); return o; }  static ClientDetailsEntity parse(String jsonString); static ClientDetailsEntity parse(JsonElement jsonEl); static RegisteredClient parseRegistered(String jsonString); static RegisteredClient parseRegistered(JsonElement jsonEl); static JsonObject serialize(RegisteredClient c);  }