Search in sources :

Example 1 with IdentitySAMLSSOConfigServiceIdentityException

use of org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException 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 IdentitySAMLSSOConfigServiceIdentityException

use of org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException 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)

Aggregations

SAMLSSOServiceProviderDTO (org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO)2 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 HttpResponse (org.apache.http.HttpResponse)1 Test (org.testng.annotations.Test)1 ServiceProvider (org.wso2.carbon.identity.application.common.model.xsd.ServiceProvider)1 IdentitySAMLSSOConfigServiceIdentityException (org.wso2.carbon.identity.sso.saml.stub.IdentitySAMLSSOConfigServiceIdentityException)1 SAXException (org.xml.sax.SAXException)1