use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.
the class SAMLFederationWithFileBasedSPAndIDPTestCase method getSAMLSSOServiceProviderDTO.
protected 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;
}
use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.
the class TestPassiveSTSFederation 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.setEnableAttributesByDefault(true);
return samlssoServiceProviderDTO;
}
use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.
the class TenantDropDownTestCase method createSsoServiceProviderDTO.
private SAMLSSOServiceProviderDTO createSsoServiceProviderDTO() {
SAMLSSOServiceProviderDTO samlssoServiceProviderDTO = new SAMLSSOServiceProviderDTO();
samlssoServiceProviderDTO.setIssuer(SAML_ISSUER);
samlssoServiceProviderDTO.setAssertionConsumerUrls(new String[] { String.format(ACS_URL, SAML_ISSUER) });
samlssoServiceProviderDTO.setDefaultAssertionConsumerUrl(String.format(ACS_URL, SAML_ISSUER));
samlssoServiceProviderDTO.setAttributeConsumingServiceIndex(ATTRIBUTE_CS_INDEX_VALUE);
samlssoServiceProviderDTO.setNameIDFormat(NAMEID_FORMAT);
samlssoServiceProviderDTO.setDoSignAssertions(false);
samlssoServiceProviderDTO.setDoSignResponse(false);
samlssoServiceProviderDTO.setDoSingleLogout(true);
samlssoServiceProviderDTO.setLoginPageURL(LOGIN_URL);
return samlssoServiceProviderDTO;
}
use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.
the class SAML2SSOTestBase method getAssertionFromSAMLResponse.
/**
* Extract SAML Assertion from the SAML Response.
*
* @param samlResponse SAML Response.
* @param samlssoSPDTO SAMLSSO service Provider DTO.
* @param x509Credential x509Credential instance.
* @return SAML Response instance.
* @throws Exception
*/
public Assertion getAssertionFromSAMLResponse(Response samlResponse, SAMLSSOServiceProviderDTO samlssoSPDTO, X509Credential x509Credential) throws Exception {
Assertion assertion = null;
if (samlssoSPDTO.getDoEnableEncryptedAssertion()) {
List<EncryptedAssertion> encryptedAssertions = samlResponse.getEncryptedAssertions();
EncryptedAssertion encryptedAssertion = null;
if (!CollectionUtils.isEmpty(encryptedAssertions)) {
encryptedAssertion = encryptedAssertions.get(0);
try {
assertion = getDecryptedAssertion(encryptedAssertion, x509Credential);
} catch (Exception e) {
if (log.isDebugEnabled()) {
log.debug("Assertion decryption failure : ", e);
}
throw new Exception("Unable to decrypt the SAML2 Assertion", e);
}
}
} else {
List<Assertion> assertions = samlResponse.getAssertions();
if (assertions != null && !assertions.isEmpty()) {
assertion = assertions.get(0);
}
}
if (assertion == null && !isNoPassive(samlResponse)) {
throw new Exception("SAML2 Assertion not found in the Response");
}
return assertion;
}
use of org.wso2.carbon.identity.sso.saml.stub.types.SAMLSSOServiceProviderDTO in project product-is by wso2.
the class SAML2SSOTestBase method sendSAMLAuthenticationRequest.
/**
* Send SAML2 Authentication request and get the SessionDataKey from IDP.
*
* @param client Closable HTTP Client.
* @param saml2AuthRequest SAML2 authentication request.
* @param samlConfig SAML configuration.
* @param samlssoServiceProviderDTO SAMLSSO Service Provider DTO.
* @param x509Credential x509Credential implementation.
* @param userAgent
* @return HTTP Response with SessionDataKey from the IDP.
* @throws Exception
*/
public HttpResponse sendSAMLAuthenticationRequest(CloseableHttpClient client, AuthnRequest saml2AuthRequest, SAMLConfig samlConfig, SAMLSSOServiceProviderDTO samlssoServiceProviderDTO, X509Credential x509Credential, String userAgent) throws Exception {
HttpResponse response;
if (SAMLConstants.SAML2_POST_BINDING_URI.equals(samlConfig.getHttpBinding())) {
String samlPostRequest = buildSAMLPOSTRequest(saml2AuthRequest, samlConfig, x509Credential);
response = sendSAMLPostMessage(client, samlSSOIDPUrl, SAML_REQUEST_PARAM, samlPostRequest, samlConfig, userAgent);
EntityUtils.consume(response.getEntity());
response = sendRedirectRequest(response, userAgent, samlssoServiceProviderDTO.getDefaultAssertionConsumerUrl(), client);
} else if (SAMLConstants.SAML2_REDIRECT_BINDING_URI.equals(samlConfig.getHttpBinding())) {
String redirectRequest = buildRedirectRequest(saml2AuthRequest, samlConfig, samlSSOIDPUrl, x509Credential);
response = sendGetRequest(client, redirectRequest, null, new Header[] { new BasicHeader(HttpHeaders.USER_AGENT, userAgent) });
} else {
throw new Exception("Unsupported HTTP binding format " + samlConfig.getHttpBinding());
}
return response;
}
Aggregations