Search in sources :

Example 1 with SAMLSSOServiceProviderDTO

use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.

the class AbstractApplicationAuthzTestCase method createSAMLApp.

protected void createSAMLApp(String applicationName, boolean singleLogout, boolean signResponse, boolean signAssertion) throws RemoteException, IdentitySAMLSSOConfigServiceIdentityException {
    SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
    samlssoServiceProviderDTO.setIssuer(applicationName);
    samlssoServiceProviderDTO.setAssertionConsumerUrls(new String[] { String.format(ACS_URL, applicationName) });
    samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl(String.format(ACS_URL, applicationName));
    samlssoServiceProviderDTO.setNameIDFormat(NAMEID_FORMAT);
    samlssoServiceProviderDTO.setDoSingleLogout(singleLogout);
    samlssoServiceProviderDTO.setLoginPageURL(LOGIN_URL);
    samlssoServiceProviderDTO.setDoSignResponse(signResponse);
    samlssoServiceProviderDTO.setDoSignAssertions(signAssertion);
    ssoConfigServiceClient.addServiceProvider(samlssoServiceProviderDTO);
}
Also used : SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO)

Example 2 with SAMLSSOServiceProviderDTO

use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.

the class AbstractIdentityFederationTestCase method createSAML2WebSSOConfiguration.

public String createSAML2WebSSOConfiguration(int portOffset, SAMLSSOServiceProviderDTO samlssoServiceProviderDTO) throws Exception {
    samlSSOConfigServiceClients.get(portOffset).addServiceProvider(samlssoServiceProviderDTO);
    SAMLSSOServiceProviderInfoDTO serviceProviders = samlSSOConfigServiceClients.get(portOffset).getServiceProviders();
    if (serviceProviders != null && serviceProviders.getServiceProviders() != null) {
        for (SAMLSSOServiceProviderDTO serviceProvider : serviceProviders.getServiceProviders()) {
            if (samlssoServiceProviderDTO.getIssuer().equals(serviceProvider.getIssuer())) {
                return serviceProvider.getAttributeConsumingServiceIndex();
            }
        }
    }
    return null;
}
Also used : SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO) SAMLSSOServiceProviderInfoDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderInfoDTO)

Example 3 with SAMLSSOServiceProviderDTO

use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO 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 4 with SAMLSSOServiceProviderDTO

use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.

the class OAuth2ServiceSAML2BearerGrantTestCase method testSAML2BearerInvalidAudience.

@Test
public void testSAML2BearerInvalidAudience() throws RemoteException, IdentitySAMLSSOConfigServiceIdentityException {
    try {
        client = HttpClientBuilder.create().build();
        // Set some invalid audience.
        ServiceProvider application = appMgtclient.getApplication(SERVICE_PROVIDER_NAME);
        SAMLSSOServiceProviderDTO[] serviceProviders = ssoConfigServiceClient.getServiceProviders().getServiceProviders();
        SAMLSSOServiceProviderDTO serviceProvider = null;
        for (SAMLSSOServiceProviderDTO serviceProviderDTO : serviceProviders) {
            if ("travelocity.com".equals(serviceProviderDTO.getIssuer())) {
                serviceProvider = serviceProviderDTO;
                break;
            }
        }
        Assert.assertNotNull(serviceProvider, "No service provider exists for issuer travelocity.com");
        serviceProvider.setRequestedAudiences(new String[] {});
        ssoConfigServiceClient.removeServiceProvider("travelocity.com");
        ssoConfigServiceClient.addServiceProvider(serviceProvider);
        appMgtclient.updateApplicationData(application);
        // Get a SAML response.
        String samlResponse = getSAMLResponse();
        // Extract the assertion from SAML response.
        String samlAssersion = getSAMLAssersion(samlResponse);
        // Send the extracted SAML assertion to token endpoint in SAML2 bearer grant.
        HttpResponse httpResponse = sendSAMLAssertion(samlAssersion);
        // We should get an http 400 error code.
        Assert.assertEquals(httpResponse.getStatusLine().getStatusCode(), 400);
        // We should get a non empty error message.
        Assert.assertTrue(StringUtils.isNotBlank(IOUtils.toString(httpResponse.getEntity().getContent())));
    } catch (Exception e) {
        Assert.fail("SAML Bearer Grant test failed with an exception.", e);
    } finally {
        // Restore the default service provider.
        ssoConfigServiceClient.removeServiceProvider("travelocity.com");
        ssoConfigServiceClient.addServiceProvider(createDefaultSSOServiceProviderDTO());
        // We have to initiate the http client again or other tests will fail.
        client = HttpClientBuilder.create().build();
    }
}
Also used : SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO) ServiceProvider(org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider) HttpResponse(org.apache.http.HttpResponse) 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) Test(org.testng.annotations.Test)

Example 5 with SAMLSSOServiceProviderDTO

use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.

the class SAMLIdentityFederationTestCase method getSAMLSSOServiceProviderDTO.

private SAMLSSOServiceProviderDTO getSAMLSSOServiceProviderDTO(String issuerName, String acsUrl) {
    SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
    samlssoServiceProviderDTO.setIssuer(issuerName);
    samlssoServiceProviderDTO.setAssertionConsumerUrls(new String[] { acsUrl });
    samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl(acsUrl);
    samlssoServiceProviderDTO.setNameIDFormat(SAML_NAME_ID_FORMAT);
    samlssoServiceProviderDTO.setDoSignAssertions(true);
    samlssoServiceProviderDTO.setDoSignResponse(true);
    samlssoServiceProviderDTO.setDoSingleLogout(true);
    samlssoServiceProviderDTO.setEnableAttributeProfile(true);
    samlssoServiceProviderDTO.setEnableAttributesByDefault(true);
    return samlssoServiceProviderDTO;
}
Also used : SAMLSSOServiceProviderDTO(org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO)

Aggregations

SAMLSSOServiceProviderDTO (org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO)34 IOException (java.io.IOException)7 RemoteException (java.rmi.RemoteException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 Test (org.testng.annotations.Test)5 IdentitySAMLSSOConfigServiceIdentityException (org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException)5 SAXException (org.xml.sax.SAXException)5 SAMLSSOServiceProviderDTO (org.wso2.carbon.identity.sso.saml.dto.SAMLSSOServiceProviderDTO)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 XPathExpressionException (javax.xml.xpath.XPathExpressionException)3 HttpResponse (org.apache.http.HttpResponse)3 ConfigurationException (org.opensaml.xml.ConfigurationException)3 ValidationException (org.opensaml.xml.validation.ValidationException)3 IdentityException (org.wso2.carbon.identity.base.IdentityException)3 TransformerException (javax.xml.transform.TransformerException)2 Assertion (org.opensaml.saml2.core.Assertion)2 EncryptedAssertion (org.opensaml.saml2.core.EncryptedAssertion)2 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)2 Property (org.wso2.carbon.identity.application.common.model.Property)2 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)2