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));
private RegisterResponse registerOpenIdClient() { logger.info("Registering OpenId client"); String clientName = this.appConfiguration.getApplicationName() + " client"; RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, clientName, Arrays.asList(this.appConfiguration.getOpenIdRedirectUrl())); registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_BASIC); RegisterClient registerClient = new RegisterClient(openIdConfiguration.getRegistrationEndpoint()); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); if ((response == null) || (response.getStatus() != 200)) { throw new ConfigurationException("Failed to register new client"); } return response; }
final RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList(contactEmail1, contactEmailNewValue)); registerRequest.setLogoUri(logoUriNewValue); registerRequest.setClientUri(clientUriNewValue); registerRequestContent = registerRequest.getJSONParameters().toString(4); } catch (Exception e) { e.printStackTrace(); RegisterRequest r = RegisterRequest.fromJson(entity, true); assertTrue(r.getContacts() != null && r.getContacts().contains(contactEmailNewValue)); assertTrue(r.getClientUri().equals(clientUriNewValue)); assertTrue(r.getLogoUri().equals(logoUriNewValue)); } catch (JSONException e) { e.printStackTrace();
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setIdTokenSignedResponseAlg(SignatureAlgorithm.HS256); registerRequest.setSectorIdentifierUri(sectorIdentifierUri);
showTitle("requestClientAssociate2"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList("javier@gluu.org", "javier.rojas.blum@gmail.com")); 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.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);
@Parameters({ "registerPath", "redirectUris", "clientJwksUri" }) @Test public void requestParameterMethodES512Step1(final String registerPath, final String redirectUris, final String jwksUri) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request(); String registerRequestContent = null; try { List<ResponseType> responseTypes = Arrays.asList(ResponseType.TOKEN); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setJwksUri(jwksUri); registerRequest.setResponseTypes(responseTypes); registerRequest.setRequestObjectSigningAlg(SignatureAlgorithm.ES512); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); registerRequestContent = registerRequest.getJSONParameters().toString(4); } catch (JSONException e) { fail(e.getMessage(), e); } Response response = request.post(Entity.json(registerRequestContent)); String entity = response.readEntity(String.class); showResponse("requestParameterMethodES512Step1", response, entity); ResponseAsserter responseAsserter = ResponseAsserter.of(response.getStatus(), entity); responseAsserter.assertRegisterResponse(); clientId3 = responseAsserter.getJson().getJson().getString(RegisterResponseParam.CLIENT_ID.toString()); }
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setJwksUri(jwksUri); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.PRIVATE_KEY_JWT); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); registerRequest.setGrantTypes(grantTypes); String registerRequestContent = registerRequest.getJSONParameters().toString(4);
showTitle("OC5:FeatureTest-Uses Dynamic Registration"); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(Arrays.asList("javier@gluu.org", "javier.rojas.blum@gmail.com")); 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);
List<String> contacts = Arrays.asList(contactEmail1, contactEmail2); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setContacts(contacts); registerRequest.setScope(Arrays.asList("openid", "clientinfo", "profile", "email", "invalid_scope")); registerRequest.setLogoUri("http://www.gluu.org/wp-content/themes/gluursn/images/logo.png"); registerRequest.setClientUri("http://www.gluu.org/company/team"); 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.setRequestObjectSigningAlg(SignatureAlgorithm.RS256); registerRequestContent = registerRequest.getJSONParameters().toString(4); } catch (JSONException e) { e.printStackTrace();
final RegisterRequest registerRequest = new RegisterRequest(registrationAccessToken2); registerRequest.setHttpMethod(HttpMethod.PUT); registerRequest.setRedirectUris(Arrays.asList("https://localhost:8443/auth")); registerRequest.setPostLogoutRedirectUris(Arrays.asList("https://localhost:8443/auth")); registerRequest.setApplicationType(ApplicationType.WEB); registerRequest.setClientName(clientName); registerRequest.setSubjectType(SubjectType.PUBLIC); registerRequest.setGrantTypes(Arrays.asList(GrantType.IMPLICIT)); registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN)); registerRequest.setScope(Arrays.asList("openid", "address", "profile", "email", "phone", "clientinfo", "invalid_scope")); registerRequest.setTokenEndpointAuthMethod(AuthenticationMethod.CLIENT_SECRET_POST); registerRequest.setFrontChannelLogoutSessionRequired(true); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true");
private RegisterResponse registerClient( final String redirectUris, List<ResponseType> responseTypes, List<String> scopes, String sectorIdentifierUri) { RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setScope(scopes); registerRequest.setSubjectType(SubjectType.PAIRWISE); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); 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.getClientIdIssuedAt()); assertNotNull(registerResponse.getClientSecretExpiresAt()); return registerResponse; }
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, null, StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setIdTokenSignedResponseAlg(SignatureAlgorithm.ES256); registerRequest.setPostLogoutRedirectUris(StringUtils.spaceSeparatedToList(postLogoutRedirectUri)); registerRequest.setJwksUri(clientJwksUri); registerRequest.setSubjectType(SubjectType.PUBLIC); registerRequest.setRequireAuthTime(true); registerRequest.setDefaultMaxAge(3600); registerRequest.setGrantTypes(grantTypes);
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSubjectType(SubjectType.PAIRWISE); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); registerRequest.setClaims(Arrays.asList( "iname", "o")); GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS ); registerRequest.setGrantTypes(grantTypes); String registerRequestContent = registerRequest.getJSONParameters().toString(4);
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN)); registerRequest.setPostLogoutRedirectUris(Arrays.asList(postLogoutRedirectUri)); registerRequest.setFrontChannelLogoutUris(Lists.newArrayList(logoutUri)); registerRequest.setSectorIdentifierUri(sectorIdentifierUri);
private RegisterResponse registerClient(final String redirectUris, final List<ResponseType> responseTypes, final List<GrantType> grantTypes, final String sectorIdentifierUri) { RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setGrantTypes(grantTypes); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.setSubjectType(SubjectType.PAIRWISE); 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.getClientIdIssuedAt()); assertNotNull(registerResponse.getClientSecretExpiresAt()); return registerResponse; }
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(Arrays.asList(ResponseType.TOKEN, ResponseType.ID_TOKEN)); registerRequest.setPostLogoutRedirectUris(Arrays.asList(postLogoutRedirectUri)); registerRequest.setFrontChannelLogoutUris(Lists.newArrayList(postLogoutRedirectUri)); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); registerRequestContent = registerRequest.getJSONParameters().toString(4); } catch (JSONException e) { e.printStackTrace();
@Parameters({"registerPath", "redirectUris"}) @Test public void dynamicClientRegistration(final String registerPath, final String redirectUris) throws Exception { Builder request = ResteasyClientBuilder.newClient().target(url.toString() + registerPath).request(); List<ResponseType> responseTypes = Arrays.asList(ResponseType.CODE, ResponseType.TOKEN, ResponseType.ID_TOKEN); RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); List<GrantType> grantTypes = Arrays.asList( GrantType.RESOURCE_OWNER_PASSWORD_CREDENTIALS ); registerRequest.setGrantTypes(grantTypes); String registerRequestContent = registerRequest.getJSONParameters().toString(4); Response response = request.post(Entity.json(registerRequestContent)); String entity = response.readEntity(String.class); showResponse("dynamicClientRegistration", response, entity); assertEquals(response.getStatus(), 200, "Unexpected response code. " + entity); assertNotNull(entity, "Unexpected result: " + entity); try { final RegisterResponse registerResponse = RegisterResponse.valueOf(entity); ClientTestUtil.assert_(registerResponse); clientId = registerResponse.getClientId(); clientSecret = registerResponse.getClientSecret(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage() + "\nResponse was: " + entity); } }
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUri)); registerRequest.setJwksUri(jwksUri); registerRequest.setResponseTypes(responseTypes); registerRequest.setGrantTypes(grantTypes); registerRequest.setContacts(contacts);
RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth test app", StringUtils.spaceSeparatedToList(redirectUris)); registerRequest.setResponseTypes(responseTypes); registerRequest.setGrantTypes(grantTypes); registerRequest.setSectorIdentifierUri(sectorIdentifierUri); registerRequest.addCustomAttribute("oxAuthTrustedClient", "true"); registerRequest.addCustomAttribute("myCustomAttr1", customAttrValue1);
@Parameters({"redirectUris"}) @Test public void registerWithHttpFail(final String redirectUris) throws Exception { showTitle("registerWithHttpFail"); List<String> redirectUriList = Lists.newArrayList(StringUtils.spaceSeparatedToList(redirectUris)); redirectUriList.add("http://www.example.com/cb"); // URI with HTTP schema RegisterRequest registerRequest = new RegisterRequest(ApplicationType.WEB, "oxAuth web test app with HTTP schema in URI", redirectUriList); registerRequest.setSubjectType(SubjectType.PUBLIC); RegisterClient registerClient = new RegisterClient(registrationEndpoint); registerClient.setExecutor(clientExecutor(true)); registerClient.setRequest(registerRequest); RegisterResponse response = registerClient.exec(); showClient(registerClient); assertEquals(response.getStatus(), 400); assertNotNull(response.getEntity()); assertNotNull(response.getErrorType()); assertNotNull(response.getErrorDescription()); } }