Search in sources :

Example 11 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class OIDCFederatedIdpInitLogoutTest method createServiceProviderInSecondaryIS.

private void createServiceProviderInSecondaryIS() throws Exception {
    super.addServiceProvider(PORT_OFFSET_1, FEDERATED_IS_SP_NAME);
    ServiceProvider serviceProvider = getServiceProvider(PORT_OFFSET_1, FEDERATED_IS_SP_NAME);
    Assert.assertNotNull(serviceProvider, "Failed to create service provider 'travelocity' in primary IS");
    updateServiceProviderWithSAMLConfigs(PORT_OFFSET_1, FEDERATED_IS_SAML_ISSUER_NAME, FEDERATED_IS_SAML_ACS_URL, serviceProvider);
    updateServiceProvider(PORT_OFFSET_1, serviceProvider);
    serviceProvider = getServiceProvider(PORT_OFFSET_1, FEDERATED_IS_SP_NAME);
    InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
    boolean success = false;
    if (configs != null) {
        for (InboundAuthenticationRequestConfig config : configs) {
            if (FEDERATED_IS_SP_INBOUND_AUTH_TYPE_SAMLSSO.equals(config.getInboundAuthType())) {
                success = true;
                break;
            }
        }
    }
    Assert.assertTrue(success, "Failed to update service provider with inbound SAML2 configs in primary IS");
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)

Example 12 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class OIDCIdentityFederationTestCase method createServiceProviderInPrimaryIS.

private void createServiceProviderInPrimaryIS() throws Exception {
    super.addServiceProvider(PORT_OFFSET_0, PRIMARY_IS_SP_NAME);
    ServiceProvider serviceProvider = getServiceProvider(PORT_OFFSET_0, PRIMARY_IS_SP_NAME);
    Assert.assertNotNull(serviceProvider, "Failed to create service provider 'travelocity' in primary IS");
    updateServiceProviderWithSAMLConfigs(PORT_OFFSET_0, PRIMARY_IS_SAML_ISSUER_NAME, PRIMARY_IS_SAML_ACS_URL, serviceProvider);
    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(PRIMARY_IS_IDP_NAME);
    org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig oidcAuthnConfig = new org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig();
    oidcAuthnConfig.setName(PRIMARY_IS_IDP_AUTHENTICATOR_NAME_OIDC);
    oidcAuthnConfig.setDisplayName("openidconnect");
    idP.setFederatedAuthenticatorConfigs(new org.wso2.carbon.identity.application.common.model.xsd.FederatedAuthenticatorConfig[] { oidcAuthnConfig });
    authStep.setFederatedIdentityProviders(new org.wso2.carbon.identity.application.common.model.xsd.IdentityProvider[] { idP });
    serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationSteps(new AuthenticationStep[] { authStep });
    serviceProvider.getLocalAndOutBoundAuthenticationConfig().setAuthenticationType(PRIMARY_IS_SP_AUTHENTICATION_TYPE);
    updateServiceProvider(PORT_OFFSET_0, serviceProvider);
    serviceProvider = getServiceProvider(PORT_OFFSET_0, PRIMARY_IS_SP_NAME);
    InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
    boolean success = false;
    if (configs != null) {
        for (InboundAuthenticationRequestConfig config : configs) {
            if (PRIMARY_IS_SP_INBOUND_AUTH_TYPE_SAMLSSO.equals(config.getInboundAuthType())) {
                success = true;
                break;
            }
        }
    }
    Assert.assertTrue(success, "Failed to update service provider with inbound SAML2 configs in primary IS");
    Assert.assertTrue(PRIMARY_IS_SP_AUTHENTICATION_TYPE.equals(serviceProvider.getLocalAndOutBoundAuthenticationConfig().getAuthenticationType()), "Failed to update local and out bound configs in primary IS");
}
Also used : FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.idp.xsd.FederatedAuthenticatorConfig) AuthenticationStep(org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep) IdentityProvider(org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)

Example 13 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class SAMLIdentityFederationTestCase method updateServiceProviderWithSAMLConfigs.

private void updateServiceProviderWithSAMLConfigs(int portOffset, String issuerName, String acsUrl, ServiceProvider serviceProvider) throws Exception {
    String attributeConsumingServiceIndex = super.createSAML2WebSSOConfiguration(portOffset, getSAMLSSOServiceProviderDTO(issuerName, acsUrl));
    Assert.assertNotNull(attributeConsumingServiceIndex, "Failed to create SAML2 Web SSO configuration for issuer '" + issuerName + "'");
    InboundAuthenticationRequestConfig samlAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();
    samlAuthenticationRequestConfig.setInboundAuthKey(issuerName);
    samlAuthenticationRequestConfig.setInboundAuthType(INBOUND_AUTH_TYPE);
    org.wso2.carbon.identity.application.common.model.xsd.Property property = new org.wso2.carbon.identity.application.common.model.xsd.Property();
    property.setName("attrConsumServiceIndex");
    property.setValue(attributeConsumingServiceIndex);
    samlAuthenticationRequestConfig.setProperties(new org.wso2.carbon.identity.application.common.model.xsd.Property[] { property });
    serviceProvider.getInboundAuthenticationConfig().setInboundAuthenticationRequestConfigs(new InboundAuthenticationRequestConfig[] { samlAuthenticationRequestConfig });
}
Also used : InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Property(org.wso2.carbon.identity.application.common.model.idp.xsd.Property)

Example 14 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class SAMLFederationWithFileBasedSPAndIDPTestCase method testCreateServiceProviderInSecondaryIS.

@Test(groups = "wso2.is", description = "Check create service provider in secondary IS")
public void testCreateServiceProviderInSecondaryIS() throws Exception {
    super.addServiceProvider(PORT_OFFSET_1, SECONDARY_IS_SERVICE_PROVIDER_NAME);
    ServiceProvider serviceProvider = getServiceProvider(PORT_OFFSET_1, SECONDARY_IS_SERVICE_PROVIDER_NAME);
    Assert.assertNotNull(serviceProvider, "Failed to create service provider 'secondarySP' in secondary IS");
    // Set SAML configurations
    updateServiceProviderWithSAMLConfigs(PORT_OFFSET_1, SECONDARY_IS_SAML_ISSUER_NAME, String.format(COMMON_AUTH_URL, DEFAULT_PORT + PORT_OFFSET_0), serviceProvider);
    // Set claim configurations
    serviceProvider.getClaimConfig().setLocalClaimDialect(false);
    serviceProvider.getClaimConfig().setClaimMappings(getClaimMappingsForSPInSecondaryIS());
    updateServiceProvider(PORT_OFFSET_1, serviceProvider);
    serviceProvider = getServiceProvider(PORT_OFFSET_1, SECONDARY_IS_SERVICE_PROVIDER_NAME);
    InboundAuthenticationRequestConfig[] configs = serviceProvider.getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();
    boolean success = false;
    if (configs != null) {
        for (InboundAuthenticationRequestConfig config : configs) {
            if (SECONDARY_IS_SAML_ISSUER_NAME.equals(config.getInboundAuthKey()) && INBOUND_AUTH_TYPE.equals(config.getInboundAuthType())) {
                success = true;
                break;
            }
        }
    }
    Assert.assertTrue(success, "Failed to update service provider with inbound SAML2 configs in secondary IS");
}
Also used : ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) InboundAuthenticationRequestConfig(org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig) Test(org.testng.annotations.Test)

Example 15 with SAML2

use of org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.StandardInboundProtocols.SAML2 in project product-is by wso2.

the class TestPassiveSTS method testPassiveSAML2AssertionWithoutWReply.

@Test(alwaysRun = true, description = "Test PassiveSTS SAML2 Assertion with WReply URL in passive-sts request", dependsOnMethods = { "testPassiveSAML2Assertion" })
public void testPassiveSAML2AssertionWithoutWReply() throws Exception {
    String passiveParams = "?wa=wsignin1.0&wtrealm=PassiveSTSSampleApp";
    String wreqParam = "&wreq=%3Cwst%3ARequestSecurityToken+xmlns%3Awst%3D%22http%3A%2F%2Fdocs.oasis-open.org" + "%2Fws-sx%2Fws-trust%2F200512%22%3E%3Cwst%3ATokenType%3Ehttp%3A%2F%2Fdocs.oasis-open.org" + "%2Fwss%2Foasis-wss-saml-token-profile-1.1%23SAMLV2.0%3C%2Fwst%3ATokenType%3E%3C%2Fwst" + "%3ARequestSecurityToken%3E";
    passiveParams = appendTenantDomainQueryParam(passiveParams);
    HttpGet request = new HttpGet(this.passiveStsURL + passiveParams + wreqParam);
    HttpResponse response = client.execute(request);
    Assert.assertNotNull(response, "PassiveSTSSampleApp invoke response is null for tenant domain: " + tenantDomain);
    int responseCode = response.getStatusLine().getStatusCode();
    Assert.assertEquals(responseCode, 200, "Invalid Response for tenant domain: " + tenantDomain);
    HttpEntity entity = response.getEntity();
    String responseString = EntityUtils.toString(entity, "UTF-8");
    Assert.assertTrue(responseString.contains("urn:oasis:names:tc:SAML:2.0:assertion"), "No SAML2 Assertion found for the SAML2 request without WReply in passive-sts request for " + "tenant domain: " + tenantDomain);
}
Also used : HttpEntity(org.apache.http.HttpEntity) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Aggregations

Test (org.testng.annotations.Test)16 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)14 HttpResponse (org.apache.http.HttpResponse)11 IOException (java.io.IOException)10 RemoteException (java.rmi.RemoteException)9 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)9 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)9 IdentitySAMLSSOConfigServiceIdentityException (org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException)9 SAXException (org.xml.sax.SAXException)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 ArrayList (java.util.ArrayList)7 XPathExpressionException (javax.xml.xpath.XPathExpressionException)7 ConfigurationException (org.opensaml.xml.ConfigurationException)7 ValidationException (org.opensaml.xml.validation.ValidationException)7 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)7 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)7 Property (org.wso2.carbon.identity.application.common.model.idp.xsd.Property)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)4