Search in sources :

Example 1 with OIDCApplication

use of org.wso2.identity.integration.test.oidc.bean.OIDCApplication in project product-is by wso2.

the class OIDCAuthCodeGrantSSOTestCase method testAuthzRequestWithoutValidSessionForIDENTITY5581.

@Test(groups = "wso2.is", description = "Test authz endpoint before creating a valid session")
public void testAuthzRequestWithoutValidSessionForIDENTITY5581() throws Exception {
    // When accessing the below endpoint from with invalid session it should provide a message with login_required
    OIDCApplication application = applications.get(OIDCUtilTest.playgroundAppOneAppName);
    URI uri = new URIBuilder(OAuth2Constant.APPROVAL_URL).addParameter("client_id", application.getClientId()).addParameter("scope", "openid").addParameter("response_type", "code").addParameter("prompt", "none").addParameter("redirect_uri", application.getCallBackURL()).build();
    HttpResponse httpResponse = sendGetRequest(client, uri.toString());
    String contentData = DataExtractUtil.getContentData(httpResponse);
    Assert.assertTrue(contentData.contains("login_required"));
    EntityUtils.consume(httpResponse.getEntity());
}
Also used : HttpResponse(org.apache.http.HttpResponse) OIDCApplication(org.wso2.identity.integration.test.oidc.bean.OIDCApplication) URI(java.net.URI) URIBuilder(org.apache.http.client.utils.URIBuilder) Test(org.testng.annotations.Test)

Example 2 with OIDCApplication

use of org.wso2.identity.integration.test.oidc.bean.OIDCApplication in project product-is by wso2.

the class OIDCAbstractUIIntegrationTest method createApplication.

/**
 * Register an OIDC application in OP
 *
 * @param application application instance
 * @throws Exception
 */
public void createApplication(OIDCApplication application) throws Exception {
    log.info("Creating application " + application.getApplicationName());
    OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO();
    appDTO.setApplicationName(application.getApplicationName());
    appDTO.setCallbackUrl(application.getCallBackURL());
    appDTO.setOAuthVersion(OIDCUITestConstants.OAUTH_VERSION_2);
    appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm");
    oauthAdminClient.registerOAuthApplicationData(appDTO);
    OAuthConsumerAppDTO[] appDtos = oauthAdminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(application.getApplicationName())) {
            application.setClientId(appDto.getOauthConsumerKey());
            application.setClientSecret(appDto.getOauthConsumerSecret());
        }
    }
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(application.getApplicationName());
    serviceProvider.setDescription(application.getApplicationName());
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(application.getApplicationName());
    ClaimConfig claimConfig = null;
    if (!application.getRequiredClaims().isEmpty()) {
        claimConfig = new ClaimConfig();
        for (String claimUri : application.getRequiredClaims()) {
            Claim claim = new Claim();
            claim.setClaimUri(claimUri);
            ClaimMapping claimMapping = new ClaimMapping();
            claimMapping.setRequested(true);
            claimMapping.setLocalClaim(claim);
            claimMapping.setRemoteClaim(claim);
            claimConfig.addClaimMappings(claimMapping);
        }
    }
    serviceProvider.setClaimConfig(claimConfig);
    serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
    List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
    if (application.getClientId() != null) {
        InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
        inboundAuthenticationRequestConfig.setInboundAuthKey(application.getClientId());
        inboundAuthenticationRequestConfig.setInboundAuthType(OIDCUITestConstants.OAUTH_2);
        if (StringUtils.isNotBlank(application.getClientSecret())) {
            Property property = new Property();
            property.setName(OIDCUITestConstants.OAUTH_CONSUMER_SECRET);
            property.setValue(application.getClientSecret());
            Property[] properties = { property };
            inboundAuthenticationRequestConfig.setProperties(properties);
        }
        authRequestList.add(inboundAuthenticationRequestConfig);
    }
    if (authRequestList.size() > 0) {
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
    }
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
}
Also used : OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) ArrayList(java.util.ArrayList) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig) ClaimMapping(org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping) ClaimConfig(org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) Property(org.wso2.carbon.identity.application.common.model.xsd.Property) Claim(org.wso2.carbon.identity.application.common.model.xsd.Claim)

Example 3 with OIDCApplication

use of org.wso2.identity.integration.test.oidc.bean.OIDCApplication in project product-is by wso2.

the class OIDCAbstractIntegrationTest method createApplication.

/**
 * Register an OIDC application in OP
 *
 * @param application application instance
 * @throws Exception
 */
public void createApplication(OIDCApplication application) throws Exception {
    ServiceProvider serviceProvider = new ServiceProvider();
    createApplication(serviceProvider, application);
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)

Example 4 with OIDCApplication

use of org.wso2.identity.integration.test.oidc.bean.OIDCApplication in project product-is by wso2.

the class OIDCAbstractIntegrationTest method createApplication.

public ServiceProvider createApplication(ServiceProvider serviceProvider, OIDCApplication application) throws Exception {
    log.info("Creating application " + application.getApplicationName());
    OAuthConsumerAppDTO appDTO = new OAuthConsumerAppDTO();
    appDTO.setApplicationName(application.getApplicationName());
    appDTO.setCallbackUrl(application.getCallBackURL());
    appDTO.setOAuthVersion(OAuth2Constant.OAUTH_VERSION_2);
    appDTO.setGrantTypes("authorization_code implicit password client_credentials refresh_token " + "urn:ietf:params:oauth:grant-type:saml2-bearer iwa:ntlm");
    adminClient.registerOAuthApplicationData(appDTO);
    OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(application.getApplicationName())) {
            application.setClientId(appDto.getOauthConsumerKey());
            application.setClientSecret(appDto.getOauthConsumerSecret());
        }
    }
    serviceProvider.setApplicationName(application.getApplicationName());
    serviceProvider.setDescription(application.getApplicationName());
    appMgtclient.createApplication(serviceProvider);
    serviceProvider = appMgtclient.getApplication(application.getApplicationName());
    ClaimConfig claimConfig = null;
    if (!application.getRequiredClaims().isEmpty()) {
        claimConfig = new ClaimConfig();
        for (String claimUri : application.getRequiredClaims()) {
            Claim claim = new Claim();
            claim.setClaimUri(claimUri);
            ClaimMapping claimMapping = new ClaimMapping();
            claimMapping.setRequested(true);
            claimMapping.setLocalClaim(claim);
            claimMapping.setRemoteClaim(claim);
            claimConfig.addClaimMappings(claimMapping);
        }
    }
    serviceProvider.setClaimConfig(claimConfig);
    serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
    List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
    if (application.getClientId() != null) {
        InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
        inboundAuthenticationRequestConfig.setInboundAuthKey(application.getClientId());
        inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
        if (StringUtils.isNotBlank(application.getClientSecret())) {
            Property property = new Property();
            property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
            property.setValue(application.getClientSecret());
            Property[] properties = { property };
            inboundAuthenticationRequestConfig.setProperties(properties);
        }
        authRequestList.add(inboundAuthenticationRequestConfig);
    }
    if (authRequestList.size() > 0) {
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
    }
    updateApplication(serviceProvider);
    return serviceProvider;
}
Also used : ClaimMapping(org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping) ClaimConfig(org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) ArrayList(java.util.ArrayList) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.xsd.Property) Claim(org.wso2.carbon.identity.application.common.model.xsd.Claim) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig)

Example 5 with OIDCApplication

use of org.wso2.identity.integration.test.oidc.bean.OIDCApplication in project product-is by wso2.

the class OIDCAuthCodeGrantSSODifferentSubjectIDTestCase method createApplication.

@Override
public void createApplication(OIDCApplication application) throws Exception {
    super.createApplication(application);
    ServiceProvider serviceProvider = appMgtclient.getApplication(application.getApplicationName());
    serviceProvider.getLocalAndOutBoundAuthenticationConfig().setSubjectClaimUri(application.getSubjectClaimURI());
    appMgtclient.updateApplicationData(serviceProvider);
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)

Aggregations

OIDCApplication (org.wso2.identity.integration.test.oidc.bean.OIDCApplication)7 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)6 Claim (org.wso2.carbon.identity.application.common.model.xsd.Claim)5 ClaimConfig (org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig)5 ClaimMapping (org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping)5 ArrayList (java.util.ArrayList)4 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)4 OutboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig)4 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)4 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)2 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)2 URI (java.net.URI)1 HttpResponse (org.apache.http.HttpResponse)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1 Test (org.testng.annotations.Test)1 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)1 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig)1