Java Code Examples for org.gluu.oxauth.client.RegisterRequest#setSectorIdentifierUri()
The following examples show how to use
org.gluu.oxauth.client.RegisterRequest#setSectorIdentifierUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientWhiteListBlackListRedirectUris.java From oxAuth with MIT License | 6 votes |
@Parameters({"redirectUris", "sectorIdentifierUri"}) @Test public void requestClientAssociate(final String redirectUris, final String sectorIdentifierUri) throws Exception { showTitle("requestClientAssociate"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); registerClient.setExecutor(clientExecutor(true)); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); assertNotNull(response.getClaims().get(SCOPE.toString())); registrationAccessToken1 = response.getRegistrationAccessToken(); registrationClientUri1 = response.getRegistrationClientUri(); }
Example 2
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 6 votes |
@Parameters({"redirectUris", "sectorIdentifierUri"}) @Test public void requestClientAssociate3(final String redirectUris, final String sectorIdentifierUri) throws Exception { showTitle("requestClientAssociate3"); String softwareId = UUID.randomUUID().toString(); String softwareVersion = "version_3.1.5"; RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSoftwareId(softwareId); registerRequest.setSoftwareVersion(softwareVersion); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); assertTrue(response.getClaims().containsKey(SOFTWARE_ID.toString())); assertEquals(response.getClaims().get(SOFTWARE_ID.toString()), softwareId); assertTrue(response.getClaims().containsKey(SOFTWARE_VERSION.toString())); assertEquals(response.getClaims().get(SOFTWARE_VERSION.toString()), softwareVersion); }
Example 3
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 6 votes |
@Parameters({"redirectUris", "sectorIdentifierUri"}) @Test public void registerWithApplicationTypeNativeAndSubjectTypePairwise( final String redirectUris, final String sectorIdentifierUri) throws Exception { showTitle("registerWithApplicationTypeNativeAndSubjectTypePairwise"); List<String> redirectUriList = Lists.newArrayList(StringUtils.spaceSeparatedToList(redirectUris)); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.NATIVE, "oxAuth native test app", redirectUriList); registerRequest.setSubjectType(SubjectType.PAIRWISE); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setExecutor(clientExecutor(true)); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); }
Example 4
Source File: RejectsSectorIdentifierNotContainingRegisteredRedirectUriValues.java From oxAuth with MIT License | 6 votes |
@Parameters({"sectorIdentifierUri"}) @Test public void rejectsSectorIdentifierNotContainingRegisteredRedirectUriValues(final String sectorIdentifierUri) throws Exception { showTitle("OC5:FeatureTest-Rejects Sector Identifier Not Containing Registered redirect uri Values"); List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList("https://not_registered")); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setResponseTypes(responseTypes); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); RegisterResponse registerResponse = registerClient.exec(); showClient(registerClient); assertEquals(registerResponse.getStatus(), 400, "Unexpected response code: " + registerResponse.getStatus()); assertNotNull(registerResponse.getErrorType(), "The error type is null"); assertNotNull(registerResponse.getErrorDescription(), "The error description is null"); }
Example 5
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 5 votes |
@Parameters({"redirectUris", "sectorIdentifierUri"}) @Test // ATTENTION : uncomment test annotation only if 112-customAttributes.ldif (located in server test resources) // is loaded by ldap server. public void requestClientRegistrationWithCustomAttributes( final String redirectUris, final String sectorIdentifierUri) throws Exception { showTitle("requestClientRegistrationWithCustomAttributes"); final RegisterRequest request = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); // custom attribute must be declared in oxauth-config.xml in dynamic-registration-custom-attribute tag request.addCustomAttribute("myCustomAttr1", "customAttrValue1"); request.addCustomAttribute("myCustomAttr2", "customAttrValue2"); request.setSectorIdentifierUri(sectorIdentifierUri); final RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(request); final RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); }
Example 6
Source File: EnablesDynamicRegistration.java From oxAuth with MIT License | 5 votes |
@Parameters({"redirectUris", "sectorIdentifierUri", "clientJwksUri"}) @Test public void enablesDynamicRegistration(final String redirectUris, final String sectorIdentifierUri, final String clientJwksUri) throws Exception { showTitle("OC5:FeatureTest-Enables Dynamic Registration"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList("[email protected]", "[email protected]")); registerRequest.setLogoUri("http://www.gluu.org/wp-content/themes/gluursn/images/logo.png"); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT); registerRequest.setPolicyUri("http://www.gluu.org/policy"); registerRequest.setJwksUri(clientJwksUri); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSubjectType(SubjectType.PUBLIC); registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getRegistrationClientUri()); assertNotNull(response.getClientIdIssuedAt()); assertNotNull(response.getClientSecretExpiresAt()); }
Example 7
Source File: UsesDynamicRegistration.java From oxAuth with MIT License | 5 votes |
@Parameters({"redirectUris", "sectorIdentifierUri", "clientJwksUri"}) @Test public void usesDynamicRegistration(final String redirectUris, final String sectorIdentifierUri, final String clientJwksUri) throws Exception { showTitle("OC5:FeatureTest-Uses Dynamic Registration"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList("[email protected]", "[email protected]")); registerRequest.setLogoUri("http://www.gluu.org/wp-content/themes/gluursn/images/logo.png"); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT); registerRequest.setPolicyUri("http://www.gluu.org/policy"); registerRequest.setJwksUri(clientJwksUri); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSubjectType(SubjectType.PUBLIC); registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getRegistrationClientUri()); assertNotNull(response.getClientIdIssuedAt()); assertNotNull(response.getClientSecretExpiresAt()); }
Example 8
Source File: RegistrationAction.java From oxAuth with MIT License | 4 votes |
public void exec() { try { RegisterRequest request = new RegisterRequest(applicationType, clientName, StringUtils.spaceSeparatedToList(redirectUris)); request.setClaimsRedirectUris(StringUtils.spaceSeparatedToList(claimsRedirectUris)); request.setResponseTypes(responseTypes); request.setGrantTypes(grantTypes); request.setContacts(StringUtils.spaceSeparatedToList(contacts)); request.setLogoUri(logoUri); request.setClientUri(clientUri); request.setPolicyUri(policyUri); request.setTosUri(tosUri); request.setJwksUri(jwksUri); request.setSectorIdentifierUri(sectorIdentifierUri); request.setSubjectType(subjectType); request.setIdTokenSignedResponseAlg(idTokenSignedResponseAlg); request.setIdTokenEncryptedResponseAlg(idTokenEncryptedResponseAlg); request.setIdTokenEncryptedResponseEnc(idTokenEncryptedResponseEnc); request.setUserInfoSignedResponseAlg(userInfoSignedResponseAlg); request.setUserInfoEncryptedResponseAlg(userInfoEncryptedResponseAlg); request.setUserInfoEncryptedResponseEnc(userInfoEncryptedResponseEnc); request.setRequestObjectSigningAlg(requestObjectSigningAlg); request.setRequestObjectEncryptionAlg(requestObjectEncryptionAlg); request.setRequestObjectEncryptionEnc(requestObjectEncryptionEnc); request.setTokenEndpointAuthMethod(tokenEndpointAuthMethod); request.setTokenEndpointAuthSigningAlg(tokenEndpointAuthSigningAlg); request.setDefaultMaxAge(defaultMaxAge); request.setRequireAuthTime(requireAuthTime); request.setDefaultAcrValues(StringUtils.spaceSeparatedToList(defaultAcrValues)); request.setInitiateLoginUri(initiateLoginUri); request.setPostLogoutRedirectUris(StringUtils.spaceSeparatedToList(postLogoutRedirectUris)); request.setRequestUris(StringUtils.spaceSeparatedToList(requestUris)); request.setFrontChannelLogoutUris(Lists.newArrayList(logoutUri)); request.setFrontChannelLogoutSessionRequired(logoutSessionRequired); // CIBA request.setBackchannelTokenDeliveryMode(backchannelTokenDeliveryMode); request.setBackchannelClientNotificationEndpoint(backchannelClientNotificationEndpoint); request.setBackchannelAuthenticationRequestSigningAlg(backchannelAuthenticationRequestSigningAlg); request.setBackchannelUserCodeParameter(backchannelUserCodeParameter); RegisterClient client = new RegisterClient(registrationEndpoint); client.setRequest(request); RegisterResponse response = client.exec(); if (response.getStatus() >= 200 && response.getStatus() <= 299) { registrationClientUri = response.getRegistrationClientUri(); registrationAccessToken = response.getRegistrationAccessToken(); authorizationAction.setClientId(response.getClientId()); authorizationAction.setClientSecret(response.getClientSecret()); if (request.getRedirectUris() != null && request.getRedirectUris().size() > 0) { authorizationAction.setRedirectUri(request.getRedirectUris().get(0)); } tokenAction.setClientId(response.getClientId()); tokenAction.setClientSecret(response.getClientSecret()); backchannelAuthenticationAction.setClientId(response.getClientId()); backchannelAuthenticationAction.setClientSecret(response.getClientSecret()); backchannelAuthenticationAction.setBackchannelTokenDeliveryMode(request.getBackchannelTokenDeliveryMode()); } showResults = true; requestString = client.getRequestAsString(); responseString = client.getResponseAsString(); } catch (Exception e) { log.error(e.getMessage(), e); } }
Example 9
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 4 votes |
@Parameters({"redirectUris", "sectorIdentifierUri"}) @Test public void requestClientAssociate1(final String redirectUris, final String sectorIdentifierUri) throws Exception { showTitle("requestClientAssociate1"); // 1. Register Client RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setGrantTypes(Arrays.asList( AUTHORIZATION_CODE, IMPLICIT, RESOURCE_OWNER_PASSWORD_CREDENTIALS, CLIENT_CREDENTIALS, REFRESH_TOKEN, OXAUTH_UMA_TICKET)); registerRequest.setResponseTypes(Arrays.asList( CODE, TOKEN, ID_TOKEN )); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); RegisterResponse registerResponse = registerClient.exec(); showClient(registerClient); assertEquals(registerResponse.getStatus(), 200, "Unexpected response code: " + registerResponse.getEntity()); assertNotNull(registerResponse.getClientId()); assertNotNull(registerResponse.getClientSecret()); assertNotNull(registerResponse.getRegistrationAccessToken()); assertNotNull(registerResponse.getClientSecretExpiresAt()); String registrationAccessToken = registerResponse.getRegistrationAccessToken(); String registrationClientUri = registerResponse.getRegistrationClientUri(); // 2. Client Update String newClientName = "New Client Name"; RegisterRequest clientUpdateRequest = new RegisterRequest(registrationAccessToken); clientUpdateRequest.setHttpMethod(HttpMethod.PUT); clientUpdateRequest.setClientName(newClientName); RegisterClient clientUpdateClient = new RegisterClient(registrationClientUri); clientUpdateClient.setRequest(clientUpdateRequest); RegisterResponse clientUpdateResponse = clientUpdateClient.exec(); showClient(clientUpdateClient); assertEquals(clientUpdateResponse.getStatus(), 200, "Unexpected response code: " + clientUpdateResponse.getEntity()); assertEquals(clientUpdateResponse.getClaims().get(CLIENT_NAME.toString()), newClientName); assertEquals(clientUpdateResponse.getClientId(), registerResponse.getClientId()); assertEquals(clientUpdateResponse.getClientSecret(), registerResponse.getClientSecret()); assertEquals(clientUpdateResponse.getRegistrationAccessToken(), registerResponse.getRegistrationAccessToken()); assertEquals(clientUpdateResponse.getRegistrationClientUri(), registerResponse.getRegistrationClientUri()); assertEquals(clientUpdateResponse.getClientIdIssuedAt(), registerResponse.getClientIdIssuedAt()); assertEquals(clientUpdateResponse.getClientSecretExpiresAt(), registerResponse.getClientSecretExpiresAt()); assertEquals(clientUpdateResponse.getResponseTypes(), registerResponse.getResponseTypes()); assertEquals(clientUpdateResponse.getGrantTypes(), registerResponse.getGrantTypes()); assertEquals(clientUpdateResponse.getClaims().get(REDIRECT_URIS.toString()), registerResponse.getClaims().get(REDIRECT_URIS.toString())); assertEquals(clientUpdateResponse.getClaims().get(APPLICATION_TYPE.toString()), registerResponse.getClaims().get(APPLICATION_TYPE.toString())); assertEquals(clientUpdateResponse.getClaims().get(SECTOR_IDENTIFIER_URI.toString()), registerResponse.getClaims().get(SECTOR_IDENTIFIER_URI.toString())); assertEquals(clientUpdateResponse.getClaims().get(SUBJECT_TYPE.toString()), registerResponse.getClaims().get(SUBJECT_TYPE.toString())); assertEquals(clientUpdateResponse.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()), registerResponse.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString())); assertEquals(clientUpdateResponse.getClaims().get(TOKEN_ENDPOINT_AUTH_METHOD.toString()), registerResponse.getClaims().get(TOKEN_ENDPOINT_AUTH_METHOD.toString())); assertEquals(clientUpdateResponse.getClaims().get(REQUIRE_AUTH_TIME.toString()), registerResponse.getClaims().get(REQUIRE_AUTH_TIME.toString())); assertEquals(clientUpdateResponse.getClaims().get(RPT_AS_JWT.toString()), registerResponse.getClaims().get(RPT_AS_JWT.toString())); assertEquals(clientUpdateResponse.getClaims().get(ACCESS_TOKEN_AS_JWT.toString()), registerResponse.getClaims().get(ACCESS_TOKEN_AS_JWT.toString())); assertEquals(clientUpdateResponse.getClaims().get(ACCESS_TOKEN_SIGNING_ALG.toString()), registerResponse.getClaims().get(ACCESS_TOKEN_SIGNING_ALG.toString())); assertEquals(clientUpdateResponse.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString()), registerResponse.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString())); assertNotNull(clientUpdateResponse.getClaims().get(SCOPE.toString())); assertNotNull(registerResponse.getClaims().get(SCOPE.toString())); List<String> clientUpdateResponseScopes = Util.splittedStringAsList(clientUpdateResponse.getClaims().get(SCOPE.toString()), " "); List<String> registerResponseScopes = Util.splittedStringAsList(registerResponse.getClaims().get(SCOPE.toString()), " "); Collections.sort(clientUpdateResponseScopes); Collections.sort(registerResponseScopes); assertEquals(clientUpdateResponseScopes,registerResponseScopes); }
Example 10
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 4 votes |
@Parameters({"redirectUris", "sectorIdentifierUri", "logoutUri"}) @Test public void requestClientAssociate2(final String redirectUris, final String sectorIdentifierUri, final String logoutUri) throws Exception { showTitle("requestClientAssociate2"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList("[email protected]", "[email protected]")); registerRequest.setScope(Arrays.asList("openid", "address", "profile", "email", "phone", "clientinfo", "invalid_scope")); registerRequest.setLogoUri("http://www.gluu.org/wp-content/themes/gluursn/images/logo.png"); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT); registerRequest.setPolicyUri("http://www.gluu.org/policy"); registerRequest.setJwksUri("http://www.gluu.org/jwks"); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSubjectType(SubjectType.PAIRWISE); registerRequest.setRequestUris(Arrays.asList("http://www.gluu.org/request")); registerRequest.setFrontChannelLogoutUris(Lists.newArrayList(logoutUri)); registerRequest.setFrontChannelLogoutSessionRequired(true); registerRequest.setBackchannelLogoutUris(Lists.newArrayList(logoutUri)); registerRequest.setBackchannelLogoutSessionRequired(true); registerRequest.setIdTokenSignedResponseAlg(SignatureAlgorithm.RS512); registerRequest.setIdTokenEncryptedResponseAlg(KeyEncryptionAlgorithm.RSA1_5); registerRequest.setIdTokenEncryptedResponseEnc(BlockEncryptionAlgorithm.A128CBC_PLUS_HS256); registerRequest.setUserInfoSignedResponseAlg(SignatureAlgorithm.RS384); registerRequest.setUserInfoEncryptedResponseAlg(KeyEncryptionAlgorithm.A128KW); registerRequest.setUserInfoEncryptedResponseEnc(BlockEncryptionAlgorithm.A128GCM); registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); registerRequest.setRequestObjectEncryptionAlg(KeyEncryptionAlgorithm.A256KW); registerRequest.setRequestObjectEncryptionEnc(BlockEncryptionAlgorithm.A256CBC_PLUS_HS512); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT); registerRequest.setTokenEndpointAuthSigningAlg(SignatureAlgorithm.ES256); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); registerClient.setExecutor(clientExecutor(true)); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); assertNotNull(response.getClaims().get(SCOPE.toString())); assertTrue(Boolean.parseBoolean(response.getClaims().get(BACKCHANNEL_LOGOUT_SESSION_REQUIRED.toString()))); assertEquals(logoutUri, new JSONArray(response.getClaims().get(BACKCHANNEL_LOGOUT_URI.toString())).getString(0)); assertNotNull(response.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString())); assertTrue(Boolean.parseBoolean(response.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString()))); assertNotNull(response.getClaims().get(FRONT_CHANNEL_LOGOUT_URI.toString())); assertEquals(logoutUri, new JSONArray(response.getClaims().get(FRONT_CHANNEL_LOGOUT_URI.toString())).getString(0)); assertNotNull(response.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString())); assertEquals(SignatureAlgorithm.RS512, SignatureAlgorithm.fromString(response.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()))); assertNotNull(response.getClaims().get(ID_TOKEN_ENCRYPTED_RESPONSE_ALG.toString())); assertEquals(KeyEncryptionAlgorithm.RSA1_5, KeyEncryptionAlgorithm.fromName(response.getClaims().get(ID_TOKEN_ENCRYPTED_RESPONSE_ALG.toString()))); assertNotNull(response.getClaims().get(ID_TOKEN_ENCRYPTED_RESPONSE_ENC.toString())); assertEquals(BlockEncryptionAlgorithm.A128CBC_PLUS_HS256, BlockEncryptionAlgorithm.fromName(response.getClaims().get(ID_TOKEN_ENCRYPTED_RESPONSE_ENC.toString()))); assertNotNull(response.getClaims().get(USERINFO_SIGNED_RESPONSE_ALG.toString())); assertEquals(SignatureAlgorithm.RS384, SignatureAlgorithm.fromString(response.getClaims().get(USERINFO_SIGNED_RESPONSE_ALG.toString()))); assertNotNull(response.getClaims().get(USERINFO_ENCRYPTED_RESPONSE_ALG.toString())); assertEquals(KeyEncryptionAlgorithm.A128KW, KeyEncryptionAlgorithm.fromName(response.getClaims().get(USERINFO_ENCRYPTED_RESPONSE_ALG.toString()))); assertNotNull(response.getClaims().get(USERINFO_ENCRYPTED_RESPONSE_ENC.toString())); assertEquals(BlockEncryptionAlgorithm.A128GCM, BlockEncryptionAlgorithm.fromName(response.getClaims().get(USERINFO_ENCRYPTED_RESPONSE_ENC.toString()))); assertNotNull(response.getClaims().get(REQUEST_OBJECT_SIGNING_ALG.toString())); assertEquals(SignatureAlgorithm.RS256, SignatureAlgorithm.fromString(response.getClaims().get(REQUEST_OBJECT_SIGNING_ALG.toString()))); assertNotNull(response.getClaims().get(REQUEST_OBJECT_ENCRYPTION_ALG.toString())); assertEquals(KeyEncryptionAlgorithm.A256KW, KeyEncryptionAlgorithm.fromName(response.getClaims().get(REQUEST_OBJECT_ENCRYPTION_ALG.toString()))); assertNotNull(response.getClaims().get(REQUEST_OBJECT_ENCRYPTION_ENC.toString())); assertEquals(BlockEncryptionAlgorithm.A256CBC_PLUS_HS512, BlockEncryptionAlgorithm.fromName(response.getClaims().get(REQUEST_OBJECT_ENCRYPTION_ENC.toString()))); assertNotNull(response.getClaims().get(TOKEN_ENDPOINT_AUTH_METHOD.toString())); assertEquals(AuthenticationMethod.CLIENT_SECRET_JWT, AuthenticationMethod.fromString(response.getClaims().get(TOKEN_ENDPOINT_AUTH_METHOD.toString()))); assertNotNull(response.getClaims().get(TOKEN_ENDPOINT_AUTH_SIGNING_ALG.toString())); assertEquals(SignatureAlgorithm.ES256, SignatureAlgorithm.fromString(response.getClaims().get(TOKEN_ENDPOINT_AUTH_SIGNING_ALG.toString()))); JSONArray scopesJsonArray = new JSONArray(StringUtils.spaceSeparatedToList(response.getClaims().get(SCOPE.toString()))); List<String> scopes = new ArrayList<String>(); for (int i = 0; i < scopesJsonArray.length(); i++) { scopes.add(scopesJsonArray.get(i).toString()); } assertTrue(scopes.contains("openid")); assertTrue(scopes.contains("address")); assertTrue(scopes.contains("email")); assertTrue(scopes.contains("profile")); assertTrue(scopes.contains("phone")); assertTrue(scopes.contains("clientinfo")); registrationAccessToken1 = response.getRegistrationAccessToken(); registrationClientUri1 = response.getRegistrationClientUri(); }
Example 11
Source File: RegistrationRestWebServiceHttpTest.java From oxAuth with MIT License | 4 votes |
@Parameters({"redirectUris", "sectorIdentifierUri", "logoutUri"}) @Test public void requestClientAssociate3(final String redirectUris, final String sectorIdentifierUri, final String logoutUri) throws Exception { showTitle("requestClientAssociate3"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setPostLogoutRedirectUris(Lists.newArrayList(logoutUri)); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); // registerRequest.setSubjectType(SubjectType.PAIRWISE); registerRequest.setGrantTypes(Arrays.asList(GrantType.IMPLICIT)); registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN)); registerRequest.setScope(Arrays.asList("openid", "profile", "email")); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_POST); registerRequest.setFrontChannelLogoutSessionRequired(true); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setRequest(registerRequest); registerClient.setExecutor(clientExecutor(true)); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 200, "Unexpected response code: " + response.getEntity()); assertNotNull(response.getClientId()); assertNotNull(response.getClientSecret()); assertNotNull(response.getRegistrationAccessToken()); assertNotNull(response.getClientSecretExpiresAt()); assertNotNull(response.getClaims().get(SCOPE.toString())); assertNotNull(response.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString())); assertTrue(Boolean.parseBoolean(response.getClaims().get(FRONT_CHANNEL_LOGOUT_SESSION_REQUIRED.toString()))); assertNotNull(response.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString())); assertEquals(SignatureAlgorithm.RS256, SignatureAlgorithm.fromString(response.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString()))); assertEquals(AuthenticationMethod.CLIENT_SECRET_POST, AuthenticationMethod.fromString(response.getClaims().get(TOKEN_ENDPOINT_AUTH_METHOD.toString()))); JSONArray scopesJsonArray = new JSONArray(StringUtils.spaceSeparatedToList(response.getClaims().get(SCOPE.toString()))); List<String> scopes = new ArrayList<String>(); for (int i = 0; i < scopesJsonArray.length(); i++) { scopes.add(scopesJsonArray.get(i).toString()); } assertTrue(scopes.contains("openid")); assertTrue(scopes.contains("email")); assertTrue(scopes.contains("profile")); registrationAccessToken2 = response.getRegistrationAccessToken(); registrationClientUri2 = response.getRegistrationClientUri(); }
Example 12
Source File: SupportRegistrationRead.java From oxAuth with MIT License | 4 votes |
@Parameters({"redirectUris", "redirectUri", "userId", "userSecret", "sectorIdentifierUri"}) @Test public void supportRegistrationRead( final String redirectUris, final String redirectUri, final String userId, final String userSecret, final String sectorIdentifierUri) throws Exception { showTitle("OC5:FeatureTest-Support Registration Read"); List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE); // 1. Register client RegisterRequest registerRequest1 = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest1.setContacts(Arrays.asList("[email protected]", "[email protected]")); registerRequest1.setLogoUri("http://www.gluu.org/wp-content/themes/gluursn/images/logo.png"); registerRequest1.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_JWT); registerRequest1.setPolicyUri("http://www.gluu.org/policy"); registerRequest1.setJwksUri("http://www.gluu.org/jwks"); registerRequest1.setSectorIdentifierUri(sectorIdentifierUri); registerRequest1.setSubjectType(SubjectType.PUBLIC); registerRequest1.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); registerRequest1.setRequestUris(Arrays.asList("http://www.gluu.org/request")); RegisterClient registerClient1 = new RegisterClient(registrationEndpoint); registerClient1.setRequest(registerRequest1); RegisterResponse registerResponse1 = registerClient1.exec(); showClient(registerClient1); assertEquals(registerResponse1.getStatus(), 200, "Unexpected response code: " + registerResponse1.getEntity()); assertNotNull(registerResponse1.getClientId()); assertNotNull(registerResponse1.getClientSecret()); assertNotNull(registerResponse1.getRegistrationAccessToken()); assertNotNull(registerResponse1.getClientSecretExpiresAt()); assertNotNull(registerResponse1.getClaims().get(SCOPE.toString())); String clientId = registerResponse1.getClientId(); String registrationAccessToken = registerResponse1.getRegistrationAccessToken(); String registrationClientUri = registerResponse1.getRegistrationClientUri(); // 2. Client Read RegisterRequest registerRequest2 = new RegisterRequest(registrationAccessToken); RegisterClient registerClient2 = new RegisterClient(registrationClientUri); registerClient2.setRequest(registerRequest2); RegisterResponse registerResponse2 = registerClient2.exec(); showClient(registerClient2); assertEquals(registerResponse2.getStatus(), 200, "Unexpected response code: " + registerResponse2.getEntity()); assertNotNull(registerResponse2.getClientId()); assertNotNull(registerResponse2.getClientSecret()); assertNotNull(registerResponse2.getRegistrationAccessToken()); assertNotNull(registerResponse2.getRegistrationClientUri()); assertNotNull(registerResponse2.getClientSecretExpiresAt()); assertNotNull(registerResponse2.getClaims().get(APPLICATION_TYPE.toString())); assertNotNull(registerResponse2.getClaims().get(POLICY_URI.toString())); assertNotNull(registerResponse2.getClaims().get(REQUEST_OBJECT_SIGNING_ALG.toString())); assertNotNull(registerResponse2.getClaims().get(CONTACTS.toString())); assertNotNull(registerResponse2.getClaims().get(SECTOR_IDENTIFIER_URI.toString())); assertNotNull(registerResponse2.getClaims().get(SUBJECT_TYPE.toString())); assertNotNull(registerResponse2.getClaims().get(ID_TOKEN_SIGNED_RESPONSE_ALG.toString())); assertNotNull(registerResponse2.getClaims().get(JWKS_URI.toString())); assertNotNull(registerResponse2.getClaims().get(CLIENT_NAME.toString())); assertNotNull(registerResponse2.getClaims().get(LOGO_URI.toString())); assertNotNull(registerResponse2.getClaims().get(REQUEST_URIS.toString())); assertNotNull(registerResponse2.getClaims().get(SCOPE.toString())); }