Search in sources :

Example 1 with RegisterSiteParams

use of io.jans.ca.common.params.RegisterSiteParams in project jans by JanssenProject.

the class RegisterSiteOperation method validateParametersAndFallbackIfNeeded.

private void validateParametersAndFallbackIfNeeded(RegisterSiteParams params) {
    if (StringUtils.isNotBlank(params.getClientId()) && StringUtils.isBlank(params.getClientSecret())) {
        throw new HttpException(ErrorResponseCode.INVALID_CLIENT_SECRET_REQUIRED);
    }
    if (StringUtils.isNotBlank(params.getClientSecret()) && StringUtils.isBlank(params.getClientId())) {
        throw new HttpException(ErrorResponseCode.INVALID_CLIENT_ID_REQUIRED);
    }
    Rp fallback = getConfigurationService().defaultRp();
    // op_configuration_endpoint
    LOG.info("Either 'op_configuration_endpoint' or 'op_host' should be set. jans_client_api will now check which of these parameter is available.");
    if (StringUtils.isBlank(params.getOpConfigurationEndpoint())) {
        LOG.warn("'op_configuration_endpoint' is not set for parameter: " + params + ". Look up at configuration file for fallback of 'op_configuration_endpoint'.");
        String fallbackOpConfigurationEndpoint = fallback.getOpConfigurationEndpoint();
        if (StringUtils.isNotBlank(fallbackOpConfigurationEndpoint)) {
            LOG.warn("Fallback to op_configuration_endpoint: " + fallbackOpConfigurationEndpoint + ", from configuration file.");
            params.setOpConfigurationEndpoint(fallbackOpConfigurationEndpoint);
        }
    }
    // op_host
    if (Strings.isNullOrEmpty(params.getOpHost()) && Strings.isNullOrEmpty(params.getOpConfigurationEndpoint())) {
        LOG.error("Either 'op_configuration_endpoint' or 'op_host' should be set. Parameter: " + params);
        throw new HttpException(ErrorResponseCode.INVALID_OP_HOST_AND_CONFIGURATION_ENDPOINT);
    }
    // grant_type
    List<String> grantTypes = Lists.newArrayList();
    if (params.getGrantTypes() != null && !params.getGrantTypes().isEmpty()) {
        grantTypes.addAll(params.getGrantTypes());
    }
    if (grantTypes.isEmpty() && fallback.getGrantType() != null && !fallback.getGrantType().isEmpty()) {
        grantTypes.addAll(fallback.getGrantType());
    }
    if (!grantTypes.contains(GrantType.CLIENT_CREDENTIALS.getValue()) && getConfigurationService().getConfiguration().getAddClientCredentialsGrantTypeAutomaticallyDuringClientRegistration()) {
        grantTypes.add(GrantType.CLIENT_CREDENTIALS.getValue());
    }
    params.setGrantTypes(grantTypes);
    // post_logout_redirect_uri
    if (params.getPostLogoutRedirectUris() != null && params.getPostLogoutRedirectUris().isEmpty() && fallback.getPostLogoutRedirectUris() != null && !fallback.getPostLogoutRedirectUris().isEmpty()) {
        params.setPostLogoutRedirectUris(fallback.getPostLogoutRedirectUris());
    }
    // response_type
    List<String> responseTypes = Lists.newArrayList();
    if (params.getResponseTypes() != null && !params.getResponseTypes().isEmpty()) {
        responseTypes.addAll(params.getResponseTypes());
    }
    if (responseTypes.isEmpty() && fallback.getResponseTypes() != null && !fallback.getResponseTypes().isEmpty()) {
        responseTypes.addAll(fallback.getResponseTypes());
    }
    if (responseTypes.isEmpty()) {
        responseTypes.add("code");
    }
    params.setResponseTypes(responseTypes);
    // redirect_uris
    if (params.getRedirectUris() == null || params.getRedirectUris().isEmpty()) {
        params.setRedirectUris(fallback.getRedirectUris());
    }
    Set<String> redirectUris = Sets.newLinkedHashSet();
    if (params.getRedirectUris() != null && !params.getRedirectUris().isEmpty() && params.getRedirectUris().stream().allMatch(uri -> Utils.isValidUrl(uri))) {
        redirectUris.addAll(params.getRedirectUris());
    } else {
        throw new HttpException(ErrorResponseCode.INVALID_REDIRECT_URI);
    }
    final Boolean autoRegister = getConfigurationService().getConfiguration().getUma2AuthRegisterClaimsGatheringEndpointAsRedirectUriOfClient();
    if (autoRegister != null && autoRegister && !redirectUris.isEmpty()) {
        String first = redirectUris.iterator().next();
        if (first.contains(getDiscoveryService().getConnectDiscoveryResponse(params.getOpConfigurationEndpoint(), params.getOpHost(), params.getOpDiscoveryPath()).getIssuer())) {
            final UmaMetadata discovery = getDiscoveryService().getUmaDiscovery(params.getOpConfigurationEndpoint(), params.getOpHost(), params.getOpDiscoveryPath());
            String autoRedirectUri = discovery.getClaimsInteractionEndpoint() + "?authentication=true";
            LOG.trace("Register claims interaction endpoint as redirect_uri: " + autoRedirectUri);
            redirectUris.add(autoRedirectUri);
        } else {
            LOG.trace("Skip auto registration of claims interaction endpoint as redirect_uri because OP host for different uri's is different which will not pass AS redirect_uri's validation (same host must be present).");
        }
    }
    params.setRedirectUris(Lists.newArrayList(redirectUris));
    // claims_redirect_uri
    if ((params.getClaimsRedirectUri() == null || params.getClaimsRedirectUri().isEmpty()) && (fallback.getClaimsRedirectUri() != null && !fallback.getClaimsRedirectUri().isEmpty())) {
        params.setClaimsRedirectUri(fallback.getClaimsRedirectUri());
    }
    Set<String> claimsRedirectUris = Sets.newHashSet();
    if (params.getClaimsRedirectUri() != null && !params.getClaimsRedirectUri().isEmpty()) {
        claimsRedirectUris.addAll(params.getClaimsRedirectUri());
    }
    params.setClaimsRedirectUri(Lists.newArrayList(claimsRedirectUris));
    // scope
    if (params.getScope() == null || params.getScope().isEmpty()) {
        params.setScope(fallback.getScope());
    }
    if (params.getScope() == null || params.getScope().isEmpty()) {
        throw new HttpException(ErrorResponseCode.INVALID_SCOPE);
    }
    // acr_values
    if (params.getAcrValues() == null || params.getAcrValues().isEmpty()) {
        params.setAcrValues(fallback.getAcrValues());
    }
    // client_jwks_uri
    if (Strings.isNullOrEmpty(params.getClientJwksUri()) && !Strings.isNullOrEmpty(fallback.getClientJwksUri())) {
        params.setClientJwksUri(fallback.getClientJwksUri());
    }
    // contacts
    if (params.getContacts() == null || params.getContacts().isEmpty()) {
        params.setContacts(fallback.getContacts());
    }
    // ui_locales
    if (params.getUiLocales() == null || params.getUiLocales().isEmpty()) {
        params.setUiLocales(fallback.getUiLocales());
    }
    // claims_locales
    if ((params.getClaimsLocales() == null || params.getClaimsLocales().isEmpty()) && (fallback.getClaimsLocales() != null && !fallback.getClaimsLocales().isEmpty())) {
        params.setClaimsLocales(fallback.getClaimsLocales());
    }
    // client_name
    if (StringUtils.isBlank(params.getClientName()) && StringUtils.isNotBlank(fallback.getClientName())) {
        params.setClientName(fallback.getClientName());
    }
    // client_jwks_uri
    if (StringUtils.isBlank(params.getClientJwksUri()) && StringUtils.isNotBlank(fallback.getClientJwksUri())) {
        params.setClientJwksUri(fallback.getClientJwksUri());
    }
    // token_endpoint_auth_method
    if (StringUtils.isBlank(params.getClientTokenEndpointAuthMethod()) && StringUtils.isNotBlank(fallback.getTokenEndpointAuthMethod())) {
        params.setClientTokenEndpointAuthMethod(fallback.getTokenEndpointAuthMethod());
    }
    // token_endpoint_auth_signing_alg
    if (StringUtils.isBlank(params.getClientTokenEndpointAuthSigningAlg()) && StringUtils.isNotBlank(fallback.getTokenEndpointAuthSigningAlg())) {
        params.setClientTokenEndpointAuthSigningAlg(fallback.getTokenEndpointAuthSigningAlg());
    }
    // request_uris
    if ((params.getClientRequestUris() == null || params.getClientRequestUris().isEmpty()) && (fallback.getRequestUris() != null && !fallback.getRequestUris().isEmpty())) {
        params.setClientRequestUris(fallback.getRequestUris());
    }
    // front_channel_logout_uris
    if (StringUtils.isBlank(params.getClientFrontchannelLogoutUri()) && StringUtils.isNotBlank(fallback.getFrontChannelLogoutUri())) {
        params.setClientFrontchannelLogoutUri(fallback.getFrontChannelLogoutUri());
    }
    // sector_identifier_uri
    if (StringUtils.isBlank(params.getClientSectorIdentifierUri()) && StringUtils.isNotBlank(fallback.getSectorIdentifierUri())) {
        params.setClientSectorIdentifierUri(fallback.getSectorIdentifierUri());
    }
    // client_id
    if (StringUtils.isBlank(params.getClientId()) && StringUtils.isNotBlank(fallback.getClientId())) {
        params.setClientId(fallback.getClientId());
    }
    // client_secret
    if (StringUtils.isBlank(params.getClientSecret()) && StringUtils.isNotBlank(fallback.getClientSecret())) {
        params.setClientSecret(fallback.getClientSecret());
    }
    // access_token_signing_alg
    if (StringUtils.isBlank(params.getAccessTokenSigningAlg()) && StringUtils.isNotBlank(fallback.getAccessTokenSigningAlg())) {
        params.setAccessTokenSigningAlg(fallback.getAccessTokenSigningAlg());
    }
    // logo_uri
    if (StringUtils.isBlank(params.getLogoUri()) && StringUtils.isNotBlank(fallback.getLogoUri())) {
        params.setLogoUri(fallback.getLogoUri());
    }
    // client_uri
    if (StringUtils.isBlank(params.getClientUri()) && StringUtils.isNotBlank(fallback.getClientUri())) {
        params.setClientUri(fallback.getClientUri());
    }
    // policy_uri
    if (StringUtils.isBlank(params.getPolicyUri()) && StringUtils.isNotBlank(fallback.getPolicyUri())) {
        params.setPolicyUri(fallback.getPolicyUri());
    }
    // tos_uri
    if (StringUtils.isBlank(params.getTosUri()) && StringUtils.isNotBlank(fallback.getTosUri())) {
        params.setTosUri(fallback.getTosUri());
    }
    // jwks
    if (StringUtils.isBlank(params.getJwks()) && StringUtils.isNotBlank(fallback.getJwks())) {
        params.setJwks(fallback.getJwks());
    }
    // id_token_binding_cnf
    if (StringUtils.isBlank(params.getIdTokenBindingCnf()) && StringUtils.isNotBlank(fallback.getIdTokenBindingCnf())) {
        params.setIdTokenBindingCnf(fallback.getIdTokenBindingCnf());
    }
    // tls_client_auth_subject_dn
    if (StringUtils.isBlank(params.getTlsClientAuthSubjectDn()) && StringUtils.isNotBlank(fallback.getTlsClientAuthSubjectDn())) {
        params.setTlsClientAuthSubjectDn(fallback.getTlsClientAuthSubjectDn());
    }
    // id_token_signed_response_alg
    if (StringUtils.isBlank(params.getIdTokenSignedResponseAlg()) && StringUtils.isNotBlank(fallback.getIdTokenSignedResponseAlg())) {
        params.setIdTokenSignedResponseAlg(fallback.getIdTokenSignedResponseAlg());
    }
    // id_token_encrypted_response_alg
    if (StringUtils.isBlank(params.getIdTokenEncryptedResponseAlg()) && StringUtils.isNotBlank(fallback.getIdTokenEncryptedResponseAlg())) {
        params.setIdTokenEncryptedResponseAlg(fallback.getIdTokenEncryptedResponseAlg());
    }
    // id_token_encrypted_response_enc
    if (StringUtils.isBlank(params.getIdTokenEncryptedResponseEnc()) && StringUtils.isNotBlank(fallback.getIdTokenEncryptedResponseEnc())) {
        params.setIdTokenEncryptedResponseEnc(fallback.getIdTokenEncryptedResponseEnc());
    }
    // user_info_signed_response_alg
    if (StringUtils.isBlank(params.getUserInfoSignedResponseAlg()) && StringUtils.isNotBlank(fallback.getUserInfoSignedResponseAlg())) {
        params.setUserInfoSignedResponseAlg(fallback.getUserInfoSignedResponseAlg());
    }
    // user_info_encrypted_response_alg
    if (StringUtils.isBlank(params.getUserInfoEncryptedResponseAlg()) && StringUtils.isNotBlank(fallback.getUserInfoEncryptedResponseAlg())) {
        params.setUserInfoEncryptedResponseAlg(fallback.getUserInfoEncryptedResponseAlg());
    }
    // user_info_encrypted_response_enc
    if (StringUtils.isBlank(params.getUserInfoEncryptedResponseEnc()) && StringUtils.isNotBlank(fallback.getUserInfoEncryptedResponseEnc())) {
        params.setUserInfoEncryptedResponseEnc(fallback.getUserInfoEncryptedResponseEnc());
    }
    // request_object_signing_alg
    if (StringUtils.isBlank(params.getRequestObjectSigningAlg()) && StringUtils.isNotBlank(fallback.getRequestObjectSigningAlg())) {
        params.setRequestObjectSigningAlg(fallback.getRequestObjectSigningAlg());
    }
    // request_object_encryption_alg
    if (StringUtils.isBlank(params.getRequestObjectEncryptionAlg()) && StringUtils.isNotBlank(fallback.getRequestObjectEncryptionAlg())) {
        params.setRequestObjectEncryptionAlg(fallback.getRequestObjectEncryptionAlg());
    }
    // request_object_encryption_enc
    if (StringUtils.isBlank(params.getRequestObjectEncryptionEnc()) && StringUtils.isNotBlank(fallback.getRequestObjectEncryptionEnc())) {
        params.setRequestObjectEncryptionEnc(fallback.getRequestObjectEncryptionEnc());
    }
    // default_max_age
    if (params.getDefaultMaxAge() == null && fallback.getDefaultMaxAge() != null) {
        params.setDefaultMaxAge(fallback.getDefaultMaxAge());
    }
    // initiate_login_uri
    if (StringUtils.isBlank(params.getInitiateLoginUri()) && StringUtils.isNotBlank(fallback.getInitiateLoginUri())) {
        params.setInitiateLoginUri(fallback.getInitiateLoginUri());
    }
    // authorized_origins
    if ((params.getAuthorizedOrigins() == null || params.getAuthorizedOrigins().isEmpty()) && (fallback.getAuthorizedOrigins() != null && !fallback.getAuthorizedOrigins().isEmpty())) {
        params.setAuthorizedOrigins(fallback.getAuthorizedOrigins());
    }
    // access_token_lifetime
    if (params.getAccessTokenLifetime() == null && fallback.getAccessTokenLifetime() != null) {
        params.setAccessTokenLifetime(fallback.getAccessTokenLifetime());
    }
    // software_id
    if (StringUtils.isBlank(params.getSoftwareId()) && StringUtils.isNotBlank(fallback.getSoftwareId())) {
        params.setSoftwareId(fallback.getSoftwareId());
    }
    // software_version
    if (StringUtils.isBlank(params.getSoftwareVersion()) && StringUtils.isNotBlank(fallback.getSoftwareVersion())) {
        params.setSoftwareVersion(fallback.getSoftwareVersion());
    }
    // software_statement
    if (StringUtils.isBlank(params.getSoftwareStatement()) && StringUtils.isNotBlank(fallback.getSoftwareStatement())) {
        params.setSoftwareStatement(fallback.getSoftwareStatement());
    }
    // custom_attributes
    if ((params.getCustomAttributes() == null || params.getCustomAttributes().isEmpty()) && (fallback.getCustomAttributes() != null && !fallback.getCustomAttributes().isEmpty())) {
        params.setCustomAttributes(fallback.getCustomAttributes());
    }
    // access_token_as_jwt
    if (params.getAccessTokenAsJwt() == null) {
        params.setAccessTokenAsJwt(fallback.getAccessTokenAsJwt());
    }
    // rpt_as_jwt
    if (params.getRptAsJwt() == null) {
        params.setRptAsJwt(fallback.getRptAsJwt());
    }
    // front_channel_logout_session_required
    if (params.getFrontChannelLogoutSessionRequired() == null) {
        params.setFrontChannelLogoutSessionRequired(fallback.getFrontChannelLogoutSessionRequired());
    }
    // run_introspection_script_beforeaccess_token_as_jwt_creation_and_include_claims
    if (params.getRunIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims() == null) {
        params.setRunIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims(fallback.getRunIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims());
    }
    // require_auth_time
    if (params.getRequireAuthTime() == null) {
        params.setRequireAuthTime(fallback.getRequireAuthTime());
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) SubjectType(io.jans.as.model.common.SubjectType) RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) Utils(io.jans.ca.server.Utils) LoggerFactory(org.slf4j.LoggerFactory) RegisterRequestMapper(io.jans.ca.server.mapper.RegisterRequestMapper) BlockEncryptionAlgorithm(io.jans.as.model.crypto.encryption.BlockEncryptionAlgorithm) NumberUtils(org.apache.commons.lang.math.NumberUtils) ArrayList(java.util.ArrayList) HttpException(io.jans.ca.server.HttpException) Strings(com.google.common.base.Strings) ApplicationType(io.jans.as.model.register.ApplicationType) ErrorResponseCode(io.jans.ca.common.ErrorResponseCode) IOpResponse(io.jans.ca.common.response.IOpResponse) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) RegisterClient(io.jans.as.client.RegisterClient) Command(io.jans.ca.common.Command) Logger(org.slf4j.Logger) Set(java.util.Set) SignatureAlgorithm(io.jans.as.model.crypto.signature.SignatureAlgorithm) UUID(java.util.UUID) RegisterRequest(io.jans.as.client.RegisterRequest) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Sets(com.google.common.collect.Sets) Injector(com.google.inject.Injector) UmaMetadata(io.jans.as.model.uma.UmaMetadata) RegisterResponse(io.jans.as.client.RegisterResponse) List(java.util.List) AuthenticationMethod(io.jans.as.model.common.AuthenticationMethod) Preconditions(com.google.common.base.Preconditions) GrantType(io.jans.as.model.common.GrantType) KeyEncryptionAlgorithm(io.jans.as.model.crypto.encryption.KeyEncryptionAlgorithm) Rp(io.jans.ca.server.service.Rp) UmaMetadata(io.jans.as.model.uma.UmaMetadata) HttpException(io.jans.ca.server.HttpException) Rp(io.jans.ca.server.service.Rp)

Example 2 with RegisterSiteParams

use of io.jans.ca.common.params.RegisterSiteParams in project jans by JanssenProject.

the class RegisterSiteTest method registerSite.

public static RegisterSiteResponse registerSite(ClientInterface client, String opHost, String redirectUrls, String postLogoutRedirectUrls, String logoutUri, boolean syncClientFromOp) {
    final RegisterSiteParams params = new RegisterSiteParams();
    params.setOpHost(opHost);
    params.setPostLogoutRedirectUris(Lists.newArrayList(postLogoutRedirectUrls.split(" ")));
    params.setClientFrontchannelLogoutUri(logoutUri);
    params.setRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
    params.setScope(Lists.newArrayList("openid", "uma_protection", "profile", "jans_client_api"));
    params.setResponseTypes(Lists.newArrayList("code", "id_token", "token"));
    params.setGrantTypes(Lists.newArrayList(GrantType.AUTHORIZATION_CODE.getValue(), GrantType.OXAUTH_UMA_TICKET.getValue(), GrantType.CLIENT_CREDENTIALS.getValue()));
    params.setSyncClientFromOp(syncClientFromOp);
    params.setSyncClientPeriodInSeconds(0);
    final RegisterSiteResponse resp = client.registerSite(params);
    assertNotNull(resp);
    assertTrue(!Strings.isNullOrEmpty(resp.getRpId()));
    return resp;
}
Also used : RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse)

Example 3 with RegisterSiteParams

use of io.jans.ca.common.params.RegisterSiteParams in project jans by JanssenProject.

the class RegisterSiteTest method register_withOpConfigurationEndpoint.

@Parameters({ "host", "opConfigurationEndpoint", "redirectUrls", "logoutUrl", "postLogoutRedirectUrls" })
@Test
public static void register_withOpConfigurationEndpoint(String host, String opConfigurationEndpoint, String redirectUrls, String logoutUrl, String postLogoutRedirectUrls) {
    // more specific site registration
    final RegisterSiteParams params = new RegisterSiteParams();
    params.setOpConfigurationEndpoint(opConfigurationEndpoint);
    params.setPostLogoutRedirectUris(Lists.newArrayList(postLogoutRedirectUrls.split(" ")));
    params.setClientFrontchannelLogoutUri(logoutUrl);
    params.setRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
    params.setAcrValues(new ArrayList<String>());
    params.setGrantTypes(Lists.newArrayList(GrantType.AUTHORIZATION_CODE.getValue(), GrantType.OXAUTH_UMA_TICKET.getValue(), GrantType.CLIENT_CREDENTIALS.getValue()));
    params.setScope(Lists.newArrayList("openid", "uma_protection", "profile"));
    params.setResponseTypes(Lists.newArrayList("code", "id_token", "token"));
    params.setClientName("rp-client-extension-up" + System.currentTimeMillis());
    params.setClientTokenEndpointAuthMethod("client_secret_basic");
    params.setClientTokenEndpointAuthSigningAlg("HS256");
    params.setClaimsRedirectUri(Lists.newArrayList("https://client.example.org"));
    params.setAccessTokenSigningAlg("HS256");
    params.setRptAsJwt(true);
    params.setAccessTokenAsJwt(true);
    params.setFrontChannelLogoutSessionRequired(true);
    params.setRunIntrospectionScriptBeforeAccessTokenAsJwtCreationAndIncludeClaims(true);
    params.setRequireAuthTime(true);
    params.setLogoUri("https://client.example.org/authorization/page3");
    params.setClientUri("https://client.example.org/authorization/page3");
    params.setPolicyUri("https://client.example.org/authorization/page3");
    params.setTosUri("https://client.example.org/authorization/page3");
    params.setJwks("{\"key1\": \"value1\", \"key2\": \"value2\"}");
    params.setIdTokenBindingCnf("4NRB1-0XZABZI9E6-5SM3R");
    params.setTlsClientAuthSubjectDn("www.test-updated.com");
    params.setSubjectType("pairwise");
    params.setIdTokenSignedResponseAlg("HS256");
    params.setIdTokenEncryptedResponseAlg("RSA1_5");
    params.setIdTokenEncryptedResponseEnc("A128CBC+HS256");
    params.setUserInfoSignedResponseAlg("HS256");
    params.setUserInfoEncryptedResponseAlg("RSA1_5");
    params.setUserInfoEncryptedResponseEnc("A128CBC+HS256");
    params.setRequestObjectSigningAlg("HS256");
    params.setRequestObjectEncryptionAlg("RSA1_5");
    params.setRequestObjectEncryptionEnc("A128CBC+HS256");
    params.setDefaultMaxAge(100000000);
    params.setInitiateLoginUri("https://client.example.org/authorization/page2");
    params.setAuthorizedOrigins(Lists.newArrayList("beem://www.test.com", "fb://app.local.url"));
    params.setAccessTokenLifetime(100000000);
    params.setSoftwareId("4NRB1-0XZABZI9E6-5SM3R");
    params.setSoftwareVersion("2.0");
    Map<String, String> customAttributes = new HashMap<>();
    customAttributes.put("k1", "v1");
    customAttributes.put("k2", "v2");
    params.setCustomAttributes(customAttributes);
    RegisterSiteResponse resp = Tester.newClient(host).registerSite(params);
    assertNotNull(resp);
    assertNotNull(resp.getRpId());
}
Also used : RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 4 with RegisterSiteParams

use of io.jans.ca.common.params.RegisterSiteParams in project jans by JanssenProject.

the class UpdateSiteTest method update.

@Parameters({ "host", "opHost" })
@Test
public void update(String host, String opHost) throws IOException {
    String authorizationRedirectUri = "https://client.example.com/cb";
    String anotherRedirectUri = "https://client.example.com/another";
    String logoutUri = "https://client.example.com/logout";
    final RegisterSiteParams registerParams = new RegisterSiteParams();
    registerParams.setOpHost(opHost);
    registerParams.setClientFrontchannelLogoutUri(logoutUri);
    registerParams.setRedirectUris(Lists.newArrayList(authorizationRedirectUri, anotherRedirectUri, logoutUri));
    registerParams.setAcrValues(Lists.newArrayList("basic"));
    registerParams.setScope(Lists.newArrayList("openid", "profile"));
    registerParams.setGrantTypes(Lists.newArrayList("authorization_code"));
    registerParams.setResponseTypes(Lists.newArrayList("code"));
    registerParams.setAcrValues(Lists.newArrayList("acrBefore"));
    RegisterSiteResponse registerResponse = Tester.newClient(host).registerSite(registerParams);
    assertNotNull(registerResponse);
    assertNotNull(registerResponse.getRpId());
    String rpId = registerResponse.getRpId();
    Rp fetchedRp = fetchRp(host, registerResponse);
    assertEquals(authorizationRedirectUri, fetchedRp.getRedirectUri());
    assertEquals(Lists.newArrayList("acrBefore"), fetchedRp.getAcrValues());
    final UpdateSiteParams updateParams = new UpdateSiteParams();
    updateParams.setRpId(rpId);
    updateParams.setRedirectUris(Lists.newArrayList(anotherRedirectUri));
    updateParams.setScope(Lists.newArrayList("profile"));
    updateParams.setAcrValues(Lists.newArrayList("acrAfter"));
    UpdateSiteResponse updateResponse = Tester.newClient(host).updateSite(Tester.getAuthorization(registerResponse), null, updateParams);
    assertNotNull(updateResponse);
    fetchedRp = fetchRp(host, registerResponse);
    assertEquals(anotherRedirectUri, fetchedRp.getRedirectUri());
    assertEquals(Lists.newArrayList("acrAfter"), fetchedRp.getAcrValues());
}
Also used : RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) UpdateSiteParams(io.jans.ca.common.params.UpdateSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Rp(io.jans.ca.server.service.Rp) UpdateSiteResponse(io.jans.ca.common.response.UpdateSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 5 with RegisterSiteParams

use of io.jans.ca.common.params.RegisterSiteParams in project jans by JanssenProject.

the class SetupClientTest method setupClient.

@Parameters({ "host", "opHost", "redirectUrls", "logoutUrl", "postLogoutRedirectUrls" })
@Test
public void setupClient(String host, String opHost, String redirectUrls, String logoutUrl, String postLogoutRedirectUrls) {
    RegisterSiteResponse resp = setupClient(Tester.newClient(host), opHost, redirectUrls, postLogoutRedirectUrls, logoutUrl);
    assertResponse(resp);
    // more specific client setup
    final RegisterSiteParams params = new RegisterSiteParams();
    params.setOpHost(opHost);
    params.setRedirectUris(Lists.newArrayList(redirectUrls.split(" ")));
    params.setPostLogoutRedirectUris(Lists.newArrayList(postLogoutRedirectUrls.split(" ")));
    params.setClientFrontchannelLogoutUri(logoutUrl);
    params.setAcrValues(new ArrayList<String>());
    params.setScope(Lists.newArrayList("openid", "profile"));
    params.setGrantTypes(Lists.newArrayList("authorization_code"));
    params.setResponseTypes(Lists.newArrayList("code"));
    resp = Tester.newClient(host).registerSite(params);
    assertResponse(resp);
}
Also used : RegisterSiteParams(io.jans.ca.common.params.RegisterSiteParams) RegisterSiteResponse(io.jans.ca.common.response.RegisterSiteResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Aggregations

RegisterSiteParams (io.jans.ca.common.params.RegisterSiteParams)13 RegisterSiteResponse (io.jans.ca.common.response.RegisterSiteResponse)13 Parameters (org.testng.annotations.Parameters)5 Test (org.testng.annotations.Test)5 Jwt (io.jans.as.model.jwt.Jwt)2 Command (io.jans.ca.common.Command)2 Rp (io.jans.ca.server.service.Rp)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Injector (com.google.inject.Injector)1 RegisterClient (io.jans.as.client.RegisterClient)1 RegisterRequest (io.jans.as.client.RegisterRequest)1 RegisterResponse (io.jans.as.client.RegisterResponse)1 AuthenticationMethod (io.jans.as.model.common.AuthenticationMethod)1 GrantType (io.jans.as.model.common.GrantType)1 SubjectType (io.jans.as.model.common.SubjectType)1 BlockEncryptionAlgorithm (io.jans.as.model.crypto.encryption.BlockEncryptionAlgorithm)1 KeyEncryptionAlgorithm (io.jans.as.model.crypto.encryption.KeyEncryptionAlgorithm)1