Search in sources :

Example 1 with StatusCodeType

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

the class SAMLResponseWriter method write.

/**
 * Write a {@code StatusType} to stream
 *
 * @param status
 * @param out
 *
 * @throws ProcessingException
 */
public void write(StatusType status) throws ProcessingException {
    StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS.get(), JBossSAMLURIConstants.PROTOCOL_NSURI.get());
    StatusCodeType statusCodeType = status.getStatusCode();
    write(statusCodeType);
    String statusMessage = status.getStatusMessage();
    if (StringUtil.isNotNull(statusMessage)) {
        StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS_MESSAGE.get(), JBossSAMLURIConstants.PROTOCOL_NSURI.get());
        StaxUtil.writeEndElement(writer);
    }
    StatusDetailType statusDetail = status.getStatusDetail();
    if (statusDetail != null)
        write(statusDetail);
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : StatusDetailType(org.keycloak.dom.saml.v2.protocol.StatusDetailType) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType)

Example 2 with StatusCodeType

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

the class SAMLResponseWriter method write.

/**
 * Write a {@code StatusCodeType} to stream
 *
 * @param statusCodeType
 * @param out
 *
 * @throws ProcessingException
 */
public void write(StatusCodeType statusCodeType) throws ProcessingException {
    StaxUtil.writeStartElement(writer, PROTOCOL_PREFIX, JBossSAMLConstants.STATUS_CODE.get(), JBossSAMLURIConstants.PROTOCOL_NSURI.get());
    URI value = statusCodeType.getValue();
    if (value != null) {
        StaxUtil.writeAttribute(writer, JBossSAMLConstants.VALUE.get(), value.toASCIIString());
    }
    StatusCodeType subStatusCode = statusCodeType.getStatusCode();
    if (subStatusCode != null)
        write(subStatusCode);
    StaxUtil.writeEndElement(writer);
    StaxUtil.flush(writer);
}
Also used : PROTOCOL_NSURI(org.keycloak.saml.common.constants.JBossSAMLURIConstants.PROTOCOL_NSURI) URI(java.net.URI) StatusCodeType(org.keycloak.dom.saml.v2.protocol.StatusCodeType)

Example 3 with StatusCodeType

use of org.keycloak.dom.saml.v2.protocol.StatusCodeType 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 4 with StatusCodeType

use of org.keycloak.dom.saml.v2.protocol.StatusCodeType 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 5 with StatusCodeType

use of org.keycloak.dom.saml.v2.protocol.StatusCodeType 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)

Aggregations

StatusCodeType (org.keycloak.dom.saml.v2.protocol.StatusCodeType)10 StatusType (org.keycloak.dom.saml.v2.protocol.StatusType)4 StatusResponseType (org.keycloak.dom.saml.v2.protocol.StatusResponseType)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Response (javax.ws.rs.core.Response)2 QName (javax.xml.namespace.QName)2 SOAPHeaderElement (javax.xml.soap.SOAPHeaderElement)2 SOAPMessage (javax.xml.soap.SOAPMessage)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 Test (org.junit.Test)2 AbstractSamlTest (org.keycloak.testsuite.saml.AbstractSamlTest)2 Document (org.w3c.dom.Document)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 URI (java.net.URI)1 Invocation (javax.ws.rs.client.Invocation)1 NewCookie (javax.ws.rs.core.NewCookie)1 SOAPHeader (javax.xml.soap.SOAPHeader)1