use of org.wso2.carbon.identity.sso.saml.dto.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);
}
use of org.wso2.carbon.identity.sso.saml.dto.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;
}
use of org.wso2.carbon.identity.sso.saml.dto.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);
}
use of org.wso2.carbon.identity.sso.saml.dto.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();
}
}
use of org.wso2.carbon.identity.sso.saml.dto.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;
}
Aggregations