Search in sources :

Example 6 with InboundAuthenticationConfig

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

the class AbstractAdaptiveAuthenticationTestCase method createServiceProvider.

protected ServiceProvider createServiceProvider(String appName, ApplicationManagementServiceClient applicationManagementServiceClient, OauthAdminClient oauthAdminClient, String script) throws Exception {
    OAuthConsumerAppDTO[] appDtos = oauthAdminClient.getAllOAuthApplicationData();
    for (OAuthConsumerAppDTO appDto : appDtos) {
        if (appDto.getApplicationName().equals(appName)) {
            consumerKey = appDto.getOauthConsumerKey();
            consumerSecret = appDto.getOauthConsumerSecret();
        }
    }
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(appName);
    serviceProvider.setDescription("This is a test Service Provider for conditional authentication flow test.");
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(appName);
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(consumerKey);
    requestConfig.setInboundAuthType("oauth2");
    if (StringUtils.isNotBlank(consumerSecret)) {
        Property property = new Property();
        property.setName("oauthConsumerSecret");
        property.setValue(consumerSecret);
        Property[] properties = { property };
        requestConfig.setProperties(properties);
    }
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    LocalAndOutboundAuthenticationConfig outboundAuthConfig = createLocalAndOutboundAuthenticationConfig();
    outboundAuthConfig.setEnableAuthorization(false);
    AuthenticationScriptConfig config = new AuthenticationScriptConfig();
    config.setContent(script);
    config.setEnabled(true);
    outboundAuthConfig.setAuthenticationScriptConfig(config);
    serviceProvider.setLocalAndOutBoundAuthenticationConfig(outboundAuthConfig);
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
    return serviceProvider;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig) InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) AuthenticationScriptConfig(org.wso2.carbon.identity.application.common.model.script.xsd.AuthenticationScriptConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.xsd.Property) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProviderProperty)

Example 7 with InboundAuthenticationConfig

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

the class CrossProtocolLogoutTestCase method createServiceProvider.

private ServiceProvider createServiceProvider() throws Exception {
    ServiceProvider serviceProvider = new ServiceProvider();
    serviceProvider.setApplicationName(OIDC_APP_NAME);
    applicationManagementServiceClient.createApplication(serviceProvider);
    serviceProvider = applicationManagementServiceClient.getApplication(OIDC_APP_NAME);
    serviceProvider.getApplicationID();
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(oidcAppClientId);
    requestConfig.setInboundAuthType("oauth2");
    if (StringUtils.isNotBlank(oidcAppClientSecret)) {
        Property property = new Property();
        property.setName("oauthConsumerSecret");
        property.setValue(oidcAppClientSecret);
        Property[] properties = { property };
        requestConfig.setProperties(properties);
    }
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    applicationManagementServiceClient.updateApplicationData(serviceProvider);
    return 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 8 with InboundAuthenticationConfig

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

the class AbstractAnalyticsLoginTestCase 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.getApp().getArtifact());
    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 9 with InboundAuthenticationConfig

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

the class OAuth2ServiceSAML2BearerGrantTestCase method createDefaultSAMLApplication.

/**
 * Create and attach the SAML application to a service provider for testing.
 *
 * @throws Exception
 */
private void createDefaultSAMLApplication() throws Exception {
    ServiceProvider serviceProvider = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
    InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
    inboundAuthenticationRequestConfig.setInboundAuthType("samlsso");
    inboundAuthenticationRequestConfig.setInboundAuthKey("travelocity.com");
    InboundAuthenticationRequestConfig[] inboundAuthenticationRequestConfigs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
    List<InboundAuthenticationRequestConfig> inboundAuthenticationRequestConfigsList = new ArrayList<>(Arrays.asList(inboundAuthenticationRequestConfigs));
    inboundAuthenticationRequestConfigsList.add(inboundAuthenticationRequestConfig);
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(inboundAuthenticationRequestConfigsList.toArray(new InboundAuthenticationRequestConfig[0]));
    serviceProvider.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = createDefaultSSOServiceProviderDTO();
    boolean isCreated = ssoConfigServiceClient.addServiceProvider(samlssoServiceProviderDTO);
    if (!isCreated) {
        throw new Exception("App creation failed.");
    }
    appMgtclient.updateApplicationData(serviceProvider);
}
Also used : InboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig) SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) ArrayList(java.util.ArrayList) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) TransformerException(javax.xml.transform.TransformerException) IdentitySAMLSSOConfigServiceIdentityException(org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException) IOException(java.io.IOException) RemoteException(java.rmi.RemoteException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 10 with InboundAuthenticationConfig

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

the class RequestPathBasicAuthenticationSSOTest 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(createSAMLServiceProviderDTO(ISSUER_TRAVELOCITY_COM));
    ssoConfigServiceClient.addServiceProvider(createSAMLServiceProviderDTO(ISSUER_AVIS_COM));
    serviceProviderTravelocity = new ServiceProvider();
    serviceProviderTravelocity.setApplicationName(SERVICE_PROVIDER_NAME_TRAVELOCITY);
    serviceProviderTravelocity.setDescription(SERVICE_PROVIDER_DESC);
    appMgtclient.createApplication(serviceProviderTravelocity);
    serviceProviderTravelocity = appMgtclient.getApplication(SERVICE_PROVIDER_NAME_TRAVELOCITY);
    InboundAuthenticationConfig inboundAuthenticationConfig = new InboundAuthenticationConfig();
    InboundAuthenticationRequestConfig requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(ISSUER_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 });
    serviceProviderTravelocity.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    RequestPathAuthenticatorConfig requestPathAuthenticatorConfig = new RequestPathAuthenticatorConfig();
    requestPathAuthenticatorConfig.setName("BasicAuthRequestPathAuthenticator");
    serviceProviderTravelocity.setRequestPathAuthenticatorConfigs(new RequestPathAuthenticatorConfig[] { requestPathAuthenticatorConfig });
    appMgtclient.updateApplicationData(serviceProviderTravelocity);
    serviceProviderTravelocity = appMgtclient.getApplication(SERVICE_PROVIDER_NAME_TRAVELOCITY);
    serviceProviderAvis = new ServiceProvider();
    serviceProviderAvis.setApplicationName(SERVICE_PROVIDER_NAME_AVIS);
    serviceProviderAvis.setDescription(SERVICE_PROVIDER_DESC);
    appMgtclient.createApplication(serviceProviderAvis);
    serviceProviderAvis = appMgtclient.getApplication(SERVICE_PROVIDER_NAME_AVIS);
    inboundAuthenticationConfig = new InboundAuthenticationConfig();
    requestConfig = new InboundAuthenticationRequestConfig();
    requestConfig.setInboundAuthKey(ISSUER_AVIS_COM);
    requestConfig.setInboundAuthType("samlsso");
    attributeConsumerServiceIndexProp = new Property();
    attributeConsumerServiceIndexProp.setName("attrConsumServiceIndex");
    attributeConsumerServiceIndexProp.setValue("1239245949");
    requestConfig.setProperties(new Property[] { attributeConsumerServiceIndexProp });
    inboundAuthenticationConfig.setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { requestConfig });
    serviceProviderAvis.setInboundAuthenticationConfig(inboundAuthenticationConfig);
    appMgtclient.updateApplicationData(serviceProviderAvis);
    serviceProviderAvis = appMgtclient.getApplication(SERVICE_PROVIDER_NAME_AVIS);
}
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)

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