Search in sources :

Example 26 with NameIDType

use of org.keycloak.dom.saml.v2.assertion.NameIDType in project keycloak by keycloak.

the class AssertionUtil method createAssertionSubject.

/**
 * Given a user name, create a {@code SubjectType} that can then be inserted into an assertion
 *
 * @param userName
 *
 * @return
 */
public static SubjectType createAssertionSubject(String userName) {
    SubjectType assertionSubject = new SubjectType();
    STSubType subType = new STSubType();
    NameIDType anil = new NameIDType();
    anil.setValue(userName);
    subType.addBaseID(anil);
    assertionSubject.setSubType(subType);
    return assertionSubject;
}
Also used : STSubType(org.keycloak.dom.saml.v2.assertion.SubjectType.STSubType) SubjectType(org.keycloak.dom.saml.v2.assertion.SubjectType) NameIDType(org.keycloak.dom.saml.v2.assertion.NameIDType)

Example 27 with NameIDType

use of org.keycloak.dom.saml.v2.assertion.NameIDType in project keycloak by keycloak.

the class AssertionUtil method createAssertion.

/**
 * Create an assertion
 *
 * @param id
 * @param issuer
 *
 * @return
 */
public static AssertionType createAssertion(String id, NameIDType issuer) {
    XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
    AssertionType assertion = new AssertionType(id, issueInstant);
    assertion.setIssuer(issuer);
    return assertion;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) EncryptedAssertionType(org.keycloak.dom.saml.v2.assertion.EncryptedAssertionType) SAML11AssertionType(org.keycloak.dom.saml.v1.assertion.SAML11AssertionType) AssertionType(org.keycloak.dom.saml.v2.assertion.AssertionType)

Example 28 with NameIDType

use of org.keycloak.dom.saml.v2.assertion.NameIDType in project keycloak by keycloak.

the class SAMLAssertionFactory method createNameID.

/**
 * <p>
 * Creates a {@code NameIDType} instance with the specified values.
 * </p>
 *
 * @param format a {@code String} representing the name format.
 * @param qualifier a {@code String} representing the name qualifier.
 * @param value a {@code String} representing the name value.
 *
 * @return the constructed {@code NameIDType} instance.
 */
public static NameIDType createNameID(String format, String qualifier, String value) {
    NameIDType nameID = new NameIDType();
    if (format != null)
        nameID.setFormat(URI.create(format));
    nameID.setNameQualifier(qualifier);
    nameID.setValue(value);
    return nameID;
}
Also used : NameIDType(org.keycloak.dom.saml.v2.assertion.NameIDType)

Example 29 with NameIDType

use of org.keycloak.dom.saml.v2.assertion.NameIDType in project keycloak by keycloak.

the class SAMLAssertionFactory method createSubject.

/**
 * <p>
 * Creates a {@code SubjectType} object with the specified values.
 * </p>
 *
 * @param nameID the identifier of the subject.
 * @param confirmation the {@code SubjectConfirmationType} that is used to establish the correspondence between the
 * subject
 * and claims of SAML statements.
 *
 * @return the constructed {@code SubjectType} instance.
 */
public static SubjectType createSubject(NameIDType nameID, SubjectConfirmationType confirmation) {
    SubjectType subject = new SubjectType();
    if (nameID != null) {
        SubjectType.STSubType subType = new SubjectType.STSubType();
        subType.addConfirmation(confirmation);
        subType.addBaseID(nameID);
        subject.setSubType(subType);
    }
    return subject;
}
Also used : SubjectType(org.keycloak.dom.saml.v2.assertion.SubjectType)

Example 30 with NameIDType

use of org.keycloak.dom.saml.v2.assertion.NameIDType in project keycloak by keycloak.

the class SAMLAssertionFactory method createSubjectConfirmation.

/**
 * <p>
 * Creates a {@code SubjectConfirmationType} object with the specified values.
 * </p>
 *
 * @param nameID the identifier of the confirmation.
 * @param confirmationMethod a {@code String} representing the confirmation method.
 * @param keyInfoData the {@code KeyInfoConfirmationDataType} instance that contains the proof of possession key.
 *
 * @return the constructed {@code SubjectConfirmationType} instance.
 */
public static SubjectConfirmationType createSubjectConfirmation(NameIDType nameID, String confirmationMethod, KeyInfoConfirmationDataType keyInfoData) {
    SubjectConfirmationType subjectConfirmation = new SubjectConfirmationType();
    subjectConfirmation.setNameID(nameID);
    subjectConfirmation.setMethod(confirmationMethod);
    subjectConfirmation.setSubjectConfirmationData(keyInfoData);
    return subjectConfirmation;
}
Also used : SubjectConfirmationType(org.keycloak.dom.saml.v2.assertion.SubjectConfirmationType)

Aggregations

NameIDType (org.keycloak.dom.saml.v2.assertion.NameIDType)54 AssertionType (org.keycloak.dom.saml.v2.assertion.AssertionType)22 Element (org.w3c.dom.Element)21 Test (org.junit.Test)20 ResponseType (org.keycloak.dom.saml.v2.protocol.ResponseType)19 SubjectType (org.keycloak.dom.saml.v2.assertion.SubjectType)15 QName (javax.xml.namespace.QName)12 List (java.util.List)11 URI (java.net.URI)9 AudienceRestrictionType (org.keycloak.dom.saml.v2.assertion.AudienceRestrictionType)8 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)7 ExtensionsType (org.keycloak.dom.saml.v2.protocol.ExtensionsType)7 StatusResponseType (org.keycloak.dom.saml.v2.protocol.StatusResponseType)7 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)7 Document (org.w3c.dom.Document)7 InputStream (java.io.InputStream)5 HashMap (java.util.HashMap)5 AttributeStatementType (org.keycloak.dom.saml.v2.assertion.AttributeStatementType)5 AuthnStatementType (org.keycloak.dom.saml.v2.assertion.AuthnStatementType)5 EncryptedAssertionType (org.keycloak.dom.saml.v2.assertion.EncryptedAssertionType)5