Search in sources :

Example 1 with SingleSignOnService

use of org.keycloak.adapters.saml.SamlDeployment.IDP.SingleSignOnService in project keycloak by keycloak.

the class AbstractInitiateLogin method buildSaml2AuthnRequestBuilder.

public static SAML2AuthnRequestBuilder buildSaml2AuthnRequestBuilder(SamlDeployment deployment) {
    String issuerURL = deployment.getEntityID();
    String nameIDPolicyFormat = deployment.getNameIDPolicyFormat();
    if (nameIDPolicyFormat == null) {
        nameIDPolicyFormat = JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.get();
    }
    SingleSignOnService sso = deployment.getIDP().getSingleSignOnService();
    SAML2AuthnRequestBuilder authnRequestBuilder = new SAML2AuthnRequestBuilder().destination(sso.getRequestBindingUrl()).issuer(issuerURL).forceAuthn(deployment.isForceAuthentication()).isPassive(deployment.isIsPassive()).nameIdPolicy(SAML2NameIDPolicyBuilder.format(nameIDPolicyFormat).setAllowCreate(Boolean.TRUE));
    if (sso.getResponseBinding() != null) {
        String protocolBinding = JBossSAMLURIConstants.SAML_HTTP_REDIRECT_BINDING.get();
        if (sso.getResponseBinding() == SamlDeployment.Binding.POST) {
            protocolBinding = JBossSAMLURIConstants.SAML_HTTP_POST_BINDING.get();
        }
        authnRequestBuilder.protocolBinding(protocolBinding);
    }
    if (sso.getAssertionConsumerServiceUrl() != null) {
        authnRequestBuilder.assertionConsumerUrl(sso.getAssertionConsumerServiceUrl());
    }
    return authnRequestBuilder;
}
Also used : SingleSignOnService(org.keycloak.adapters.saml.SamlDeployment.IDP.SingleSignOnService) SAML2AuthnRequestBuilder(org.keycloak.saml.SAML2AuthnRequestBuilder)

Aggregations

SingleSignOnService (org.keycloak.adapters.saml.SamlDeployment.IDP.SingleSignOnService)1 SAML2AuthnRequestBuilder (org.keycloak.saml.SAML2AuthnRequestBuilder)1