use of org.opensaml.saml.saml2.core.StatusCode in project ddf by codice.
the class LoginFilter method createStatus.
/**
* Creates the status object for the response.
*
* @param statusCodeValue
* @param statusMessage
* @return Status
*/
private static Status createStatus(String statusCodeValue, String statusMessage) {
if (statusBuilder == null) {
statusBuilder = (SAMLObjectBuilder<Status>) builderFactory.getBuilder(Status.DEFAULT_ELEMENT_NAME);
}
if (statusCodeBuilder == null) {
statusCodeBuilder = (SAMLObjectBuilder<StatusCode>) builderFactory.getBuilder(StatusCode.DEFAULT_ELEMENT_NAME);
}
if (statusMessageBuilder == null) {
statusMessageBuilder = (SAMLObjectBuilder<StatusMessage>) builderFactory.getBuilder(StatusMessage.DEFAULT_ELEMENT_NAME);
}
Status status = statusBuilder.buildObject();
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(statusCodeValue);
status.setStatusCode(statusCode);
if (statusMessage != null) {
StatusMessage statusMessageObject = statusMessageBuilder.buildObject();
statusMessageObject.setMessage(statusMessage);
status.setStatusMessage(statusMessageObject);
}
return status;
}
use of org.opensaml.saml.saml2.core.StatusCode in project syncope by apache.
the class SAML2PResponseComponentBuilder method createStatus.
public static Status createStatus(final String statusCodeValue, final String statusMessage) {
if (statusBuilder == null) {
statusBuilder = new StatusBuilder();
}
if (statusCodeBuilder == null) {
statusCodeBuilder = new StatusCodeBuilder();
}
if (statusMessageBuilder == null) {
statusMessageBuilder = new StatusMessageBuilder();
}
Status status = statusBuilder.buildObject();
StatusCode statusCode = statusCodeBuilder.buildObject();
statusCode.setValue(statusCodeValue);
status.setStatusCode(statusCode);
if (statusMessage != null) {
StatusMessage statusMessageObject = statusMessageBuilder.buildObject();
statusMessageObject.setMessage(statusMessage);
status.setStatusMessage(statusMessageObject);
}
return status;
}
use of org.opensaml.saml.saml2.core.StatusCode in project pac4j by pac4j.
the class SAML2LogoutResponseValidator method validateSamlProtocolResponse.
/**
* Validates the SAML protocol response:
* - IssueInstant
* - Issuer
* - StatusCode
* - Signature
*
* @param response the response
* @param context the context
* @param engine the engine
*/
protected final void validateSamlProtocolResponse(final Response response, final SAML2MessageContext context, final SignatureTrustEngine engine) {
if (!StatusCode.SUCCESS.equals(response.getStatus().getStatusCode().getValue())) {
String status = response.getStatus().getStatusCode().getValue();
if (response.getStatus().getStatusMessage() != null) {
status += " / " + response.getStatus().getStatusMessage().getMessage();
}
throw new SAMLException("Logout response is not success ; actual " + status);
}
if (response.getSignature() != null) {
final String entityId = context.getSAMLPeerEntityContext().getEntityId();
validateSignature(response.getSignature(), entityId, engine);
context.getSAMLPeerEntityContext().setAuthenticated(true);
}
if (!isIssueInstantValid(response.getIssueInstant())) {
throw new SAMLIssueInstantException("Response issue instant is too old or in the future");
}
final SAMLMessageStorage messageStorage = context.getSAMLMessageStorage();
if (messageStorage != null && response.getInResponseTo() != null) {
final XMLObject xmlObject = messageStorage.retrieveMessage(response.getInResponseTo());
if (xmlObject == null) {
throw new SAMLInResponseToMismatchException("InResponseToField of the Response doesn't correspond to sent message " + response.getInResponseTo());
} else if (!(xmlObject instanceof LogoutRequest)) {
throw new SAMLInResponseToMismatchException("Sent request was of different type than the expected LogoutRequest " + response.getInResponseTo());
}
}
verifyEndpoint(context.getSAMLEndpointContext().getEndpoint(), response.getDestination());
if (response.getIssuer() != null) {
validateIssuer(response.getIssuer(), context);
}
}
use of org.opensaml.saml.saml2.core.StatusCode in project spring-security by spring-projects.
the class TestOpenSamlObjects method status.
static Status status(String code) {
Status status = new StatusBuilder().buildObject();
StatusCode statusCode = new StatusCodeBuilder().buildObject();
statusCode.setValue(code);
status.setStatusCode(statusCode);
return status;
}
use of org.opensaml.saml.saml2.core.StatusCode in project ddf by codice.
the class LogoutMessageImpl method buildLogoutResponse.
@Override
public LogoutWrapper<LogoutResponse> buildLogoutResponse(String issuerOrEntityId, String topLevelStatusCode, String secondLevelStatusCode, String inResponseTo) {
Validate.notNull(issuerOrEntityId, ISSUER_CANNOT_BE_NULL_MSG);
Validate.notNull(topLevelStatusCode, "Top level Status Code cannot be null");
Validate.notNull(secondLevelStatusCode, "Second level Status Code cannot be null");
Status status = SamlProtocol.createStatus(topLevelStatusCode);
StatusCode statusCode = SamlProtocol.createStatusCode(secondLevelStatusCode);
status.getStatusCode().setStatusCode(statusCode);
return SamlProtocol.createLogoutResponse(SamlProtocol.createIssuer(issuerOrEntityId), status, inResponseTo, generateId());
}
Aggregations