use of org.keycloak.dom.saml.v2.protocol.NameIDPolicyType in project keycloak by keycloak.
the class SAML2Request method createAuthnRequestType.
/**
* Create an authentication request
*
* @param id
* @param assertionConsumerURL
* @param destination
* @param issuerValue
* @param protocolBindingUri
*
* @return
*
* @throws ConfigurationException
*/
public AuthnRequestType createAuthnRequestType(String id, String assertionConsumerURL, String destination, String issuerValue, URI protocolBinding) throws ConfigurationException {
XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
AuthnRequestType authnRequest = new AuthnRequestType(id, issueInstant);
authnRequest.setAssertionConsumerServiceURL(URI.create(assertionConsumerURL));
authnRequest.setProtocolBinding(protocolBinding);
if (destination != null) {
authnRequest.setDestination(URI.create(destination));
}
// Create an issuer
NameIDType issuer = new NameIDType();
issuer.setValue(issuerValue);
authnRequest.setIssuer(issuer);
// Create a default NameIDPolicy
NameIDPolicyType nameIDPolicy = new NameIDPolicyType();
nameIDPolicy.setAllowCreate(Boolean.TRUE);
nameIDPolicy.setFormat(this.nameIDFormat == null ? null : URI.create(this.nameIDFormat));
authnRequest.setNameIDPolicy(nameIDPolicy);
return authnRequest;
}
use of org.keycloak.dom.saml.v2.protocol.NameIDPolicyType in project keycloak by keycloak.
the class AuthnRequestNameIdFormatTest method testRedirectLoginNameIdPolicyEmail.
@Test
public void testRedirectLoginNameIdPolicyEmail() throws Exception {
NameIDPolicyType nameIdPolicy = new NameIDPolicyType();
nameIdPolicy.setFormat(JBossSAMLURIConstants.NAMEID_FORMAT_EMAIL.getUri());
testLoginWithNameIdPolicy(Binding.REDIRECT, Binding.REDIRECT, nameIdPolicy, is("bburke@redhat.com"));
}
use of org.keycloak.dom.saml.v2.protocol.NameIDPolicyType in project keycloak by keycloak.
the class AuthnRequestNameIdFormatTest method testRedirectLoginNameIdPolicyUnspecified.
@Test
public void testRedirectLoginNameIdPolicyUnspecified() throws Exception {
NameIDPolicyType nameIdPolicy = new NameIDPolicyType();
nameIdPolicy.setFormat(JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.getUri());
testLoginWithNameIdPolicy(Binding.REDIRECT, Binding.REDIRECT, nameIdPolicy, is("bburke"));
}
use of org.keycloak.dom.saml.v2.protocol.NameIDPolicyType in project keycloak by keycloak.
the class AuthnRequestNameIdFormatTest method testPostLoginNameIdPolicyPersistent.
@Test
public void testPostLoginNameIdPolicyPersistent() throws Exception {
NameIDPolicyType nameIdPolicy = new NameIDPolicyType();
nameIdPolicy.setFormat(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.getUri());
testLoginWithNameIdPolicy(Binding.POST, Binding.POST, nameIdPolicy, startsWith("G-"));
}
use of org.keycloak.dom.saml.v2.protocol.NameIDPolicyType in project keycloak by keycloak.
the class AuthnRequestNameIdFormatTest method testRedirectLoginNameIdPolicyPersistent.
@Test
public void testRedirectLoginNameIdPolicyPersistent() throws Exception {
NameIDPolicyType nameIdPolicy = new NameIDPolicyType();
nameIdPolicy.setFormat(JBossSAMLURIConstants.NAMEID_FORMAT_PERSISTENT.getUri());
testLoginWithNameIdPolicy(Binding.REDIRECT, Binding.REDIRECT, nameIdPolicy, startsWith("G-"));
}
Aggregations