157 RegisteredClient c =
new RegisteredClient();
159 c.setClientId(
"s6BhdRkqt3");
160 c.setClientSecret(
"ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk");
161 c.setClientSecretExpiresAt(
new Date(1577858400L * 1000L));
162 c.setRegistrationAccessToken(
"this.is.an.access.token.value.ffx83");
163 c.setRegistrationClientUri(
"https://server.example.com/connect/register?client_id=s6BhdRkqt3");
164 c.setApplicationType(ClientDetailsEntity.AppType.WEB);
165 c.setRedirectUris(ImmutableSet.of(
"https://client.example.org/callback",
"https://client.example.org/callback2"));
166 c.setClientName(
"My Example");
167 c.setResponseTypes(ImmutableSet.of(
"code",
"token"));
168 c.setGrantTypes(ImmutableSet.of(
"authorization_code",
"implicit"));
169 c.setLogoUri(
"https://client.example.org/logo.png");
170 c.setSubjectType(ClientDetailsEntity.SubjectType.PAIRWISE);
171 c.setSectorIdentifierUri(
"https://other.example.net/file_of_redirect_uris.json");
172 c.setTokenEndpointAuthMethod(ClientDetailsEntity.AuthMethod.SECRET_BASIC);
173 c.setJwksUri(
"https://client.example.org/my_public_keys.jwks");
174 c.setUserInfoEncryptedResponseAlg(JWEAlgorithm.RSA1_5);
175 c.setUserInfoEncryptedResponseEnc(EncryptionMethod.A128CBC_HS256);
176 c.setContacts(ImmutableSet.of(
"ve7jtb@example.org",
"mary@example.org"));
177 c.setRequestUris(ImmutableSet.of(
"https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"));
179 JsonObject j = ClientDetailsEntityJsonProcessor.serialize(c);
181 assertEquals(
"s6BhdRkqt3", j.get(
"client_id").getAsString());
182 assertEquals(
"ZJYCqe3GGRvdrudKyZS0XhGv_Z45DuKhCUk0gBR1vZk", j.get(
"client_secret").getAsString());
183 assertEquals(1577858400L, j.get(
"client_secret_expires_at").getAsNumber());
184 assertEquals(
"this.is.an.access.token.value.ffx83", j.get(
"registration_access_token").getAsString());
185 assertEquals(
"https://server.example.com/connect/register?client_id=s6BhdRkqt3", j.get(
"registration_client_uri").getAsString());
186 assertEquals(ClientDetailsEntity.AppType.WEB.getValue(), j.get(
"application_type").getAsString());
187 for (JsonElement e : j.get(
"redirect_uris").getAsJsonArray()) {
188 assertTrue(ImmutableSet.of(
"https://client.example.org/callback",
"https://client.example.org/callback2").contains(e.getAsString()));
190 assertEquals(
"My Example", j.get(
"client_name").getAsString());
191 for (JsonElement e : j.get(
"response_types").getAsJsonArray()) {
192 assertTrue(ImmutableSet.of(
"code",
"token").contains(e.getAsString()));
194 for (JsonElement e : j.get(
"grant_types").getAsJsonArray()) {
195 assertTrue(ImmutableSet.of(
"authorization_code",
"implicit").contains(e.getAsString()));
197 assertEquals(
"https://client.example.org/logo.png", j.get(
"logo_uri").getAsString());
198 assertEquals(ClientDetailsEntity.SubjectType.PAIRWISE.getValue(), j.get(
"subject_type").getAsString());
199 assertEquals(
"https://other.example.net/file_of_redirect_uris.json", j.get(
"sector_identifier_uri").getAsString());
200 assertEquals(ClientDetailsEntity.AuthMethod.SECRET_BASIC.getValue(), j.get(
"token_endpoint_auth_method").getAsString());
201 assertEquals(
"https://client.example.org/my_public_keys.jwks", j.get(
"jwks_uri").getAsString());
202 assertEquals(JWEAlgorithm.RSA1_5.getName(), j.get(
"userinfo_encrypted_response_alg").getAsString());
203 assertEquals(EncryptionMethod.A128CBC_HS256.getName(), j.get(
"userinfo_encrypted_response_enc").getAsString());
204 for (JsonElement e : j.get(
"contacts").getAsJsonArray()) {
205 assertTrue(ImmutableSet.of(
"ve7jtb@example.org",
"mary@example.org").contains(e.getAsString()));
207 for (JsonElement e : j.get(
"request_uris").getAsJsonArray()) {
208 assertTrue(ImmutableSet.of(
"https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA").contains(e.getAsString()));