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);
}
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();
}
}
Aggregations