Search in sources :

Example 6 with StatusType

use of org.keycloak.dom.saml.v2.protocol.StatusType in project keycloak by keycloak.

the class SAML2LogoutResponseBuilder method buildModel.

public StatusResponseType buildModel() throws ConfigurationException {
    StatusResponseType statusResponse = new StatusResponseType(IDGenerator.create("ID_"), XMLTimeUtil.getIssueInstant());
    // Status
    StatusType statusType = new StatusType();
    StatusCodeType statusCodeType = new StatusCodeType();
    statusCodeType.setValue(JBossSAMLURIConstants.STATUS_SUCCESS.getUri());
    statusType.setStatusCode(statusCodeType);
    statusResponse.setStatus(statusType);
    statusResponse.setInResponseTo(logoutRequestID);
    statusResponse.setIssuer(issuer);
    statusResponse.setDestination(destination);
    if (!this.extensions.isEmpty()) {
        ExtensionsType extensionsType = new ExtensionsType();
        for (NodeGenerator extension : this.extensions) {
            extensionsType.addExtension(extension);
        }
        statusResponse.setExtensions(extensionsType);
    }
    return statusResponse;
}
Also used : StatusType(org.keycloak.dom.saml.v2.protocol.StatusType) ExtensionsType(org.keycloak.dom.saml.v2.protocol.ExtensionsType) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType) StatusResponseType(org.keycloak.dom.saml.v2.protocol.StatusResponseType)

Example 7 with StatusType

use of org.keycloak.dom.saml.v2.protocol.StatusType in project keycloak by keycloak.

the class JBossSAMLAuthnResponseFactory method createStatusTypeForResponder.

/**
 * <p>Create a <code>StatusType</code> with a top-level <code>org.picketlink.common.constants.JBossSAMLURIConstants.STATUS_RESPONDER</code>
 * and a second-level code reflecting the given <code>statusCodeURI</code>.</p>
 *
 * @param statusCodeURI The second-level code.
 *
 * @return
 */
public static StatusType createStatusTypeForResponder(String statusCodeURI) {
    StatusCodeType topLevelCode = new StatusCodeType();
    topLevelCode.setValue(JBossSAMLURIConstants.STATUS_RESPONDER.getUri());
    StatusCodeType secondLevelCode = new StatusCodeType();
    secondLevelCode.setValue(URI.create(statusCodeURI));
    topLevelCode.setStatusCode(secondLevelCode);
    StatusType statusType = new StatusType();
    statusType.setStatusCode(topLevelCode);
    return statusType;
}
Also used : StatusType(org.keycloak.dom.saml.v2.protocol.StatusType) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType)

Example 8 with StatusType

use of org.keycloak.dom.saml.v2.protocol.StatusType in project keycloak by keycloak.

the class JBossSAMLAuthnResponseFactory method createStatusType.

/**
 * Create a StatusType given the status code uri
 *
 * @param statusCodeURI
 *
 * @return
 */
public static StatusType createStatusType(String statusCodeURI) {
    StatusCodeType sct = new StatusCodeType();
    sct.setValue(URI.create(statusCodeURI));
    StatusType statusType = new StatusType();
    statusType.setStatusCode(sct);
    return statusType;
}
Also used : StatusType(org.keycloak.dom.saml.v2.protocol.StatusType) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType)

Example 9 with StatusType

use of org.keycloak.dom.saml.v2.protocol.StatusType in project keycloak by keycloak.

the class SamlProtocolUtils method buildArtifactResponse.

/**
 * Takes a saml object (an object that will be part of resulting ArtifactResponse), and inserts it as the body of
 * an ArtifactResponse. The ArtifactResponse is returned as ArtifactResponseType
 *
 * @param samlObject a Saml object
 * @param issuer issuer of the resulting ArtifactResponse, should be the same as issuer of the samlObject
 * @param statusCode status code of the resulting response
 * @return An ArtifactResponse containing the saml object.
 */
public static ArtifactResponseType buildArtifactResponse(SAML2Object samlObject, NameIDType issuer, URI statusCode) throws ConfigurationException, ProcessingException {
    ArtifactResponseType artifactResponse = new ArtifactResponseType(IDGenerator.create("ID_"), XMLTimeUtil.getIssueInstant());
    // Status
    StatusType statusType = new StatusType();
    StatusCodeType statusCodeType = new StatusCodeType();
    statusCodeType.setValue(statusCode);
    statusType.setStatusCode(statusCodeType);
    artifactResponse.setStatus(statusType);
    artifactResponse.setIssuer(issuer);
    artifactResponse.setAny(samlObject);
    return artifactResponse;
}
Also used : StatusType(org.keycloak.dom.saml.v2.protocol.StatusType) ArtifactResponseType(org.keycloak.dom.saml.v2.protocol.ArtifactResponseType) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType)

Example 10 with StatusType

use of org.keycloak.dom.saml.v2.protocol.StatusType in project keycloak by keycloak.

the class SAMLResponseWriter method write.

/**
 * Write a {@code StatusResponseType}
 *
 * @param response
 * @param qname QName of the starting element
 * @param out
 *
 * @throws ProcessingException
 */
public void write(StatusResponseType response, QName qname) throws ProcessingException {
    if (qname == null) {
        StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS_RESPONSE_TYPE.get(), JBossSAMLURIConstants.PROTOCOL_NSURI.get());
    } else {
        StaxUtil.writeStartElement(writer, qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI());
    }
    StaxUtil.writeNameSpace(writer, PROTOCOL_PREFIX, JBossSAMLURIConstants.PROTOCOL_NSURI.get());
    StaxUtil.writeNameSpace(writer, ASSERTION_PREFIX, JBossSAMLURIConstants.ASSERTION_NSURI.get());
    StaxUtil.writeDefaultNameSpace(writer, JBossSAMLURIConstants.ASSERTION_NSURI.get());
    writeBaseAttributes(response);
    NameIDType issuer = response.getIssuer();
    write(issuer, new QName(JBossSAMLURIConstants.ASSERTION_NSURI.get(), JBossSAMLConstants.ISSUER.get()));
    Element sig = response.getSignature();
    if (sig != null) {
        StaxUtil.writeDOMElement(writer, sig);
    }
    ExtensionsType extensions = response.getExtensions();
    if (extensions != null && extensions.getAny() != null && !extensions.getAny().isEmpty()) {
        write(extensions);
    }
    StatusType status = response.getStatus();
    write(status);
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : QName(javax.xml.namespace.QName) StatusType(org.keycloak.dom.saml.v2.protocol.StatusType) Element(org.w3c.dom.Element) ExtensionsType(org.keycloak.dom.saml.v2.protocol.ExtensionsType) NameIDType(org.keycloak.dom.saml.v2.assertion.NameIDType)

Aggregations

StatusType (org.keycloak.dom.saml.v2.protocol.StatusType)8 StatusCodeType (org.keycloak.dom.saml.v2.protocol.StatusCodeType)5 ExtensionsType (org.keycloak.dom.saml.v2.protocol.ExtensionsType)4 StatusResponseType (org.keycloak.dom.saml.v2.protocol.StatusResponseType)4 Element (org.w3c.dom.Element)4 QName (javax.xml.namespace.QName)3 NameIDType (org.keycloak.dom.saml.v2.assertion.NameIDType)3 ArtifactResponseType (org.keycloak.dom.saml.v2.protocol.ArtifactResponseType)3 ResponseType (org.keycloak.dom.saml.v2.protocol.ResponseType)3 StatusDetailType (org.keycloak.dom.saml.v2.protocol.StatusDetailType)2 StartElement (javax.xml.stream.events.StartElement)1 VerificationException (org.keycloak.common.VerificationException)1 AssertionType (org.keycloak.dom.saml.v2.assertion.AssertionType)1 EncryptedAssertionType (org.keycloak.dom.saml.v2.assertion.EncryptedAssertionType)1 AuthnRequestType (org.keycloak.dom.saml.v2.protocol.AuthnRequestType)1 LogoutRequestType (org.keycloak.dom.saml.v2.protocol.LogoutRequestType)1 SAMLDocumentHolder (org.keycloak.saml.processing.core.saml.v2.common.SAMLDocumentHolder)1