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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations