Search in sources :

Example 26 with InboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig in project identity-inbound-auth-oauth by wso2-extensions.

the class DCRMService method updateServiceProviderWithOAuthAppDetails.

private void updateServiceProviderWithOAuthAppDetails(ServiceProvider serviceProvider, OAuthConsumerAppDTO createdApp, String applicationOwner, String tenantDomain) throws DCRMException {
    // Update created service provider, InboundAuthenticationConfig with OAuth application info.
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    List<InboundAuthenticationRequestConfig> inboundAuthenticationRequestConfigs = new ArrayList<>();
    InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
    inboundAuthenticationRequestConfig.setInboundAuthKey(createdApp.getOauthConsumerKey());
    inboundAuthenticationRequestConfig.setInboundAuthType(AUTH_TYPE_OAUTH_2);
    inboundAuthenticationRequestConfigs.add(inboundAuthenticationRequestConfig);
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigs.toArray(new InboundAuthenticationRequestConfig[inboundAuthenticationRequestConfigs.size()]));
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    // Set SaaS app option
    serviceProvider.setSaasApp(false);
    // Update the Service Provider app to add OAuthApp as an Inbound Authentication Config
    updateServiceProvider(serviceProvider, tenantDomain, applicationOwner);
}
Also used : InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig) ArrayList(java.util.ArrayList) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)

Example 27 with InboundAuthenticationConfig

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

the class SAMLWithRequestPathAuthenticationTest method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    logManger = new AuthenticatorClient(backendURL);
    adminUsername = userInfo.getUserName();
    adminPassword = userInfo.getPassword();
    logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null);
    ssoConfigServiceClient = new SAMLSSOConfigServiceClient(backendURL, sessionCookie);
    client = HttpClientBuilder.create().build();
    isURL = backendURL.substring(0, backendURL.indexOf("services/"));
    ssoConfigServiceClient.addServiceProvider(createSsoServiceProviderDTO());
    serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(SERVICE_PROVIDER_NAME);
    serviceProvider.setDescription(SERVICE_PROVIDER_Desc);
    appMgtclient.createApplication(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey("travelocity.com");
    requestConfig.setInboundAuthType("samlsso");
    Property attributeConsumerServiceIndexProp = new Property();
    attributeConsumerServiceIndexProp.setName("attrConsumServiceIndex");
    attributeConsumerServiceIndexProp.setValue("1239245949");
    requestConfig.setProperties(new Property[] { attributeConsumerServiceIndexProp });
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    RequestPathAuthenticatorConfig requestPathAuthenticatorConfig = new RequestPathAuthenticatorConfig();
    requestPathAuthenticatorConfig.setName("BasicAuthRequestPathAuthenticator");
    serviceProvider.setRequestPathAuthenticatorConfigs(new RequestPathAuthenticatorConfig[] { requestPathAuthenticatorConfig });
    appMgtclient.updateApplicationData(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
}
Also used : AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ApplicationManagementServiceClient(org.wso2.identity.integration.common.clients.application.mgt.ApplicationManagementServiceClient) SAMLSSOConfigServiceClient(org.wso2.identity.integration.common.clients.sso.saml.SAMLSSOConfigServiceClient) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) RequestPathAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.xsd.RequestPathAuthenticatorConfig) Property(org.wso2.carbon.identity.application.common.model.xsd.Property) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with InboundAuthenticationConfig

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

the class SAMLFederationDynamicQueryParametersTestCase method testCreateServiceProviderWithSAMLConfigsAndSAMLFedIdp.

@Test(groups = "wso2.is", description = "Test Service Provider creation with SAML Federated IDP Authentication", dependsOnMethods = { "testIdpWithDynamicQueryParams" })
public void testCreateServiceProviderWithSAMLConfigsAndSAMLFedIdp() throws Exception {
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(SERVICE_PROVIDER);
    appMgtclient.createApplication(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER);
    Assert.assertNotNull(serviceProvider, "Service Provider creation has failed.");
    // Set SAML Inbound for the service provider.
    ssoConfigServiceClient.addServiceProvider(createSsoServiceProviderDTOForTravelocityApp());
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(INBOUND_AUTH_KEY);
    requestConfig.setInboundAuthType(INBOUND_AUTH_TYPE);
    org.wso2.carbon.identity.application.common.model.xsd.Property attributeConsumerServiceIndexProp = new org.wso2.carbon.identity.application.common.model.xsd.Property();
    attributeConsumerServiceIndexProp.setName("attrConsumServiceIndex");
    attributeConsumerServiceIndexProp.setValue("1239245949");
    requestConfig.setProperties(new org.wso2.carbon.identity.application.common.model.xsd.Property[] { attributeConsumerServiceIndexProp });
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    // Add SAML IDP as authentication step.
    AuthenticationStep authStep = new AuthenticationStep();
    org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider idP = new org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider();
    idP.setIdentityProviderName(IDENTITY_PROVIDER_NAME);
    org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig saml2SSOAuthnConfig = new org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig();
    saml2SSOAuthnConfig.setName("SAMLSSOAuthenticator");
    saml2SSOAuthnConfig.setDisplayName("samlsso");
    idP.setFederatedAuthenticatorConfigs(new org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig[] { saml2SSOAuthnConfig });
    authStep.setFederatedIdentityProviders(new org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider[] { idP });
    serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
    serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType(FEDERATED_AUTHENTICATION_TYPE);
    appMgtclient.updateApplicationData(serviceProvider);
    serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER);
    Assert.assertNotNull(serviceProvider);
    Assert.assertNotNull(serviceProvider.getInboundAuthenticationConfig());
    InboundAuthenticationRequestConfig[] inboundAuthenticationRequestConfigs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
    Assert.assertNotNull(inboundAuthenticationRequestConfigs);
    boolean inboundAuthUpdateSuccess = false;
    for (InboundAuthenticationRequestConfig config : inboundAuthenticationRequestConfigs) {
        if (INBOUND_AUTH_KEY.equals(config.getInboundAuthKey()) && INBOUND_AUTH_TYPE.equals(config.getInboundAuthType())) {
            inboundAuthUpdateSuccess = true;
            break;
        }
    }
    Assert.assertTrue(inboundAuthUpdateSuccess, "Failed to update service provider with SAML inbound configs.");
    Assert.assertNotNull(serviceProvider.getLocalAndOutBoundAuthenticationConfig());
    Assert.assertEquals(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType(), FEDERATED_AUTHENTICATION_TYPE);
}
Also used : InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property) Test(org.testng.annotations.Test)

Example 29 with InboundAuthenticationConfig

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

the class SAMLInvalidIssuerTestCase method createApplication.

public void createApplication(SAMLConfig config, String appName) throws Exception {
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(appName);
    serviceProvider.setDescription("This is a test Service Provider");
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(appName);
    serviceProvider.getClaimConfig().setClaimMappings(getClaimMappings());
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthType(INBOUND_AUTH_TYPE);
    requestConfig.setInboundAuthKey(ISSUER_NAME);
    Property attributeConsumerServiceIndexProp = new Property();
    attributeConsumerServiceIndexProp.setName(ATTRIBUTE_CS_INDEX_NAME);
    attributeConsumerServiceIndexProp.setValue(ATTRIBUTE_CS_INDEX_VALUE);
    requestConfig.setProperties(new Property[] { attributeConsumerServiceIndexProp });
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
}
Also used : InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.xsd.Property)

Example 30 with InboundAuthenticationConfig

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

the class SAMLLocalAndOutboundAuthenticatorsTestCase method createApplication.

private void createApplication() throws Exception {
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(APPLICATION_NAME);
    serviceProvider.setDescription("This is a test Service Provider");
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(APPLICATION_NAME);
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthType(INBOUND_AUTH_TYPE);
    requestConfig.setInboundAuthKey(config.getApplication().getArtifact());
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    serviceProvider.setLocalAndOutBoundAuthenticationConfig(config.getAuthenticator().getLocalAndOutboundAuthenticationConfig());
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
}
Also used : InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)

Aggregations

InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig)21 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)21 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)19 InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationConfig)16 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)15 Property (org.wso2.carbon.identity.application.common.model.xsd.Property)15 ArrayList (java.util.ArrayList)9 Property (org.wso2.carbon.identity.application.common.model.Property)7 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)6 RequestPathAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.xsd.RequestPathAuthenticatorConfig)5 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)4 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig)4 PreparedStatement (java.sql.PreparedStatement)3 SQLException (java.sql.SQLException)3 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)3 ServiceProviderProperty (org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 APIError (org.wso2.carbon.identity.api.server.common.error.APIError)2 AuthenticationStep (org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)2