Search in sources :

Example 16 with OutboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig in project product-is by wso2.

the class OAuth2RoleClaimTestCase method createApplication.

public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO) throws Exception {
    OAuthConsumerAppDTO appDtoResult = null;
    adminClient.registerOAuthApplicationData(appDTO);
    OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) {
            appDtoResult = appDto;
            consumerKey = appDto.getOauthConsumerKey();
            consumerSecret = appDto.getOauthConsumerSecret();
        }
    }
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
    serviceProvider.setDescription(SERVICE_PROVIDER_DESC);
    appMgtclient.createApplication(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
    ClaimConfig claimConfig = new ClaimConfig();
    Claim emailClaim = new Claim();
    emailClaim.setClaimUri(EMAIL_CLAIM_URI);
    ClaimMapping emailClaimMapping = new ClaimMapping();
    emailClaimMapping.setRequested(true);
    emailClaimMapping.setLocalClaim(emailClaim);
    emailClaimMapping.setRemoteClaim(emailClaim);
    Claim roleClaim = new Claim();
    roleClaim.setClaimUri(ROLES_CLAIM_URI);
    ClaimMapping roleClaimMapping = new ClaimMapping();
    roleClaimMapping.setRequested(true);
    roleClaimMapping.setLocalClaim(roleClaim);
    roleClaimMapping.setRemoteClaim(roleClaim);
    claimConfig.setClaimMappings(new org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping[] { emailClaimMapping, roleClaimMapping });
    serviceProvider.setClaimConfig(claimConfig);
    serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
    List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<InboundAuthenticationRequestConfig>();
    if (consumerKey != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(consumerKey);
        opicAuthenticationRequest.setInboundAuthType("oauth2");
        if (consumerSecret != null && !consumerSecret.isEmpty()) {
            Property property = new Property();
            property.setName("oauthConsumerSecret");
            property.setValue(consumerSecret);
            Property[] properties = { property };
            opicAuthenticationRequest.setProperties(properties);
        }
        authRequestList.add(opicAuthenticationRequest);
    }
    String passiveSTSRealm = SERVICE_PROVIDER_NAME;
    if (passiveSTSRealm != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm);
        opicAuthenticationRequest.setInboundAuthType("passivests");
        authRequestList.add(opicAuthenticationRequest);
    }
    String openidRealm = SERVICE_PROVIDER_NAME;
    if (openidRealm != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(openidRealm);
        opicAuthenticationRequest.setInboundAuthType("openid");
        authRequestList.add(opicAuthenticationRequest);
    }
    if (authRequestList.size() > 0) {
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
    }
    appMgtclient.updateApplicationData(serviceProvider);
    return appDtoResult;
}
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 17 with OutboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig 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 18 with OutboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig in project product-is by wso2.

the class OIDCFederatedIdpInitLogoutTest method updateServiceProviderWithOIDCConfigs.

private void updateServiceProviderWithOIDCConfigs(int portOffset, String applicationName, String callbackUrl, String backChannelLogoutUrl, ServiceProvider serviceProvider) throws Exception {
    OIDCApplication application = new OIDCApplication(applicationName, OAuth2Constant.TRAVELOCITY_APP_CONTEXT_ROOT, callbackUrl);
    OAuthConsumerAppDTO appDTO = getOAuthConsumerAppDTO(application);
    appDTO.setBackChannelLogoutUrl(backChannelLogoutUrl);
    OAuthConsumerAppDTO[] appDtos = createOIDCConfiguration(portOffset, appDTO);
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(application.getApplicationName())) {
            application.setClientId(appDto.getOauthConsumerKey());
            application.setClientSecret(appDto.getOauthConsumerSecret());
        }
    }
    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());
        secondaryISClientID = application.getClientId();
        inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
        if (StringUtils.isNotBlank(application.getClientSecret())) {
            org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
            property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
            property.setValue(application.getClientSecret());
            secondaryISClientSecret = application.getClientSecret();
            org.wso2.carbon.identity.application.common.model.xsd.Property[] properties = { property };
            inboundAuthenticationRequestConfig.setProperties(properties);
        }
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { inboundAuthenticationRequestConfig });
        authRequestList.add(inboundAuthenticationRequestConfig);
    }
    super.updateServiceProvider(PORT_OFFSET_1, 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) OIDCApplication(org.wso2.identity.integration.test.oidc.bean.OIDCApplication) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) Claim(org.wso2.carbon.identity.application.common.model.xsd.Claim)

Example 19 with OutboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig in project product-is by wso2.

the class OIDCIdentityFederationTestCase method updateServiceProviderWithOIDCConfigs.

private void updateServiceProviderWithOIDCConfigs(int portOffset, String applicationName, String callbackUrl, ServiceProvider serviceProvider) throws Exception {
    OIDCApplication application = new OIDCApplication(applicationName, OAuth2Constant.TRAVELOCITY_APP_CONTEXT_ROOT, callbackUrl);
    OAuthConsumerAppDTO appDTO = getOAuthConsumerAppDTO(application);
    OAuthConsumerAppDTO[] appDtos = createOIDCConfiguration(portOffset, appDTO);
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(application.getApplicationName())) {
            application.setClientId(appDto.getOauthConsumerKey());
            application.setClientSecret(appDto.getOauthConsumerSecret());
        }
    }
    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());
        secondaryISClientID = application.getClientId();
        inboundAuthenticationRequestConfig.setInboundAuthType(OAuth2Constant.OAUTH_2);
        if (StringUtils.isNotBlank(application.getClientSecret())) {
            org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
            property.setName(OAuth2Constant.OAUTH_CONSUMER_SECRET);
            property.setValue(application.getClientSecret());
            secondaryISClientSecret = application.getClientSecret();
            org.wso2.carbon.identity.application.common.model.xsd.Property[] properties = { property };
            inboundAuthenticationRequestConfig.setProperties(properties);
        }
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { inboundAuthenticationRequestConfig });
        authRequestList.add(inboundAuthenticationRequestConfig);
    }
    super.updateServiceProvider(PORT_OFFSET_1, 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) OIDCApplication(org.wso2.identity.integration.test.oidc.bean.OIDCApplication) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) Claim(org.wso2.carbon.identity.application.common.model.xsd.Claim)

Example 20 with OutboundProvisioningConfig

use of org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig in project product-is by wso2.

the class OAuth2ServiceAbstractIntegrationTest method createApplication.

/**
 * Create Application with a given appDTO
 *
 * @return OAuthConsumerAppDTO
 * @throws Exception
 */
public OAuthConsumerAppDTO createApplication(OAuthConsumerAppDTO appDTO) throws Exception {
    OAuthConsumerAppDTO appDtoResult = null;
    adminClient.registerOAuthApplicationData(appDTO);
    OAuthConsumerAppDTO[] appDtos = adminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(OAuth2Constant.OAUTH_APPLICATION_NAME)) {
            appDtoResult = appDto;
            consumerKey = appDto.getOauthConsumerKey();
            consumerSecret = appDto.getOauthConsumerSecret();
        }
    }
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
    serviceProvider.setDescription(SERVICE_PROVIDER_DESC);
    serviceProvider.setManagementApp(true);
    appMgtclient.createApplication(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
    serviceProvider = setServiceProviderClaimConfig(serviceProvider);
    serviceProvider.setOutboundProvisioningConfig(new OutboundProvisioningConfig());
    List<InboundAuthenticationRequestConfig> authRequestList = new ArrayList<>();
    if (consumerKey != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(consumerKey);
        opicAuthenticationRequest.setInboundAuthType("oauth2");
        if (consumerSecret != null && !consumerSecret.isEmpty()) {
            Property property = new Property();
            property.setName("oauthConsumerSecret");
            property.setValue(consumerSecret);
            Property[] properties = { property };
            opicAuthenticationRequest.setProperties(properties);
        }
        authRequestList.add(opicAuthenticationRequest);
    }
    String passiveSTSRealm = SERVICE_PROVIDER_NAME;
    if (passiveSTSRealm != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(passiveSTSRealm);
        opicAuthenticationRequest.setInboundAuthType("passivests");
        authRequestList.add(opicAuthenticationRequest);
    }
    String openidRealm = SERVICE_PROVIDER_NAME;
    if (openidRealm != null) {
        InboundAuthenticationRequestConfig opicAuthenticationRequest = new InboundAuthenticationRequestConfig();
        opicAuthenticationRequest.setInboundAuthKey(openidRealm);
        opicAuthenticationRequest.setInboundAuthType("openid");
        authRequestList.add(opicAuthenticationRequest);
    }
    if (authRequestList.size() > 0) {
        serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(authRequestList.toArray(new InboundAuthenticationRequestConfig[authRequestList.size()]));
    }
    appMgtclient.updateApplicationData(serviceProvider);
    return appDtoResult;
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) 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) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig)

Aggregations

ArrayList (java.util.ArrayList)16 OutboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.OutboundProvisioningConfig)14 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)10 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)8 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)7 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)6 Claim (org.wso2.carbon.identity.application.common.model.xsd.Claim)6 ClaimConfig (org.wso2.carbon.identity.application.common.model.xsd.ClaimConfig)6 ClaimMapping (org.wso2.carbon.identity.application.common.model.xsd.ClaimMapping)6 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)6 OutboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig)5 Test (org.testng.annotations.Test)4 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.ProvisioningConnectorConfig)4 JustInTimeProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.JustInTimeProvisioningConfig)4 IdentityProvider (org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider)3 InboundProvisioningConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundProvisioningConfig)3 ProvisioningConnectorConfig (org.wso2.carbon.identity.application.common.model.xsd.ProvisioningConnectorConfig)3 PreparedStatement (java.sql.PreparedStatement)2 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)2 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)2