Search in sources :

Example 6 with StatusCodeBuilder

use of org.opensaml.saml.saml2.core.impl.StatusCodeBuilder in project cxf by apache.

the class SAML2PResponseComponentBuilder method createStatus.

@SuppressWarnings("unchecked")
public 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;
}
Also used : Status(org.opensaml.saml.saml2.core.Status) StatusCode(org.opensaml.saml.saml2.core.StatusCode) StatusMessage(org.opensaml.saml.saml2.core.StatusMessage)

Example 7 with StatusCodeBuilder

use of org.opensaml.saml.saml2.core.impl.StatusCodeBuilder in project ddf by codice.

the class SamlAssertionValidatorImpl 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;
}
Also used : Status(org.opensaml.saml.saml2.core.Status) StatusCode(org.opensaml.saml.saml2.core.StatusCode) StatusMessage(org.opensaml.saml.saml2.core.StatusMessage)

Example 8 with StatusCodeBuilder

use of org.opensaml.saml.saml2.core.impl.StatusCodeBuilder in project cloudstack by apache.

the class SAML2LoginAPIAuthenticatorCmdTest method buildMockResponse.

private Response buildMockResponse() throws Exception {
    Response samlMessage = new ResponseBuilder().buildObject();
    samlMessage.setID("foo");
    samlMessage.setVersion(SAMLVersion.VERSION_20);
    samlMessage.setIssueInstant(new DateTime(0));
    Issuer issuer = new IssuerBuilder().buildObject();
    issuer.setValue("MockedIssuer");
    samlMessage.setIssuer(issuer);
    Status status = new StatusBuilder().buildObject();
    StatusCode statusCode = new StatusCodeBuilder().buildObject();
    statusCode.setValue(StatusCode.SUCCESS_URI);
    status.setStatusCode(statusCode);
    samlMessage.setStatus(status);
    Assertion assertion = new AssertionBuilder().buildObject();
    Subject subject = new SubjectBuilder().buildObject();
    NameID nameID = new NameIDBuilder().buildObject();
    nameID.setValue("SOME-UNIQUE-ID");
    nameID.setFormat(NameIDType.PERSISTENT);
    subject.setNameID(nameID);
    assertion.setSubject(subject);
    AuthnStatement authnStatement = new AuthnStatementBuilder().buildObject();
    authnStatement.setSessionIndex("Some Session String");
    assertion.getAuthnStatements().add(authnStatement);
    AttributeStatement attributeStatement = new AttributeStatementBuilder().buildObject();
    assertion.getAttributeStatements().add(attributeStatement);
    samlMessage.getAssertions().add(assertion);
    return samlMessage;
}
Also used : Status(org.opensaml.saml2.core.Status) AttributeStatementBuilder(org.opensaml.saml2.core.impl.AttributeStatementBuilder) StatusCodeBuilder(org.opensaml.saml2.core.impl.StatusCodeBuilder) Issuer(org.opensaml.saml2.core.Issuer) NameID(org.opensaml.saml2.core.NameID) Assertion(org.opensaml.saml2.core.Assertion) AssertionBuilder(org.opensaml.saml2.core.impl.AssertionBuilder) AuthnStatementBuilder(org.opensaml.saml2.core.impl.AuthnStatementBuilder) StatusCode(org.opensaml.saml2.core.StatusCode) DateTime(org.joda.time.DateTime) Subject(org.opensaml.saml2.core.Subject) Response(org.opensaml.saml2.core.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) NameIDBuilder(org.opensaml.saml2.core.impl.NameIDBuilder) AttributeStatement(org.opensaml.saml2.core.AttributeStatement) AuthnStatement(org.opensaml.saml2.core.AuthnStatement) StatusBuilder(org.opensaml.saml2.core.impl.StatusBuilder) IssuerBuilder(org.opensaml.saml2.core.impl.IssuerBuilder) ResponseBuilder(org.opensaml.saml2.core.impl.ResponseBuilder) SubjectBuilder(org.opensaml.saml2.core.impl.SubjectBuilder)

Example 9 with StatusCodeBuilder

use of org.opensaml.saml.saml2.core.impl.StatusCodeBuilder in project spring-security by spring-projects.

the class TestOpenSamlObjects method assertingPartyLogoutResponse.

public static LogoutResponse assertingPartyLogoutResponse(RelyingPartyRegistration registration) {
    LogoutResponseBuilder logoutResponseBuilder = new LogoutResponseBuilder();
    LogoutResponse logoutResponse = logoutResponseBuilder.buildObject();
    logoutResponse.setID("id");
    StatusBuilder statusBuilder = new StatusBuilder();
    StatusCodeBuilder statusCodeBuilder = new StatusCodeBuilder();
    StatusCode code = statusCodeBuilder.buildObject();
    code.setValue(StatusCode.SUCCESS);
    Status status = statusBuilder.buildObject();
    status.setStatusCode(code);
    logoutResponse.setStatus(status);
    IssuerBuilder issuerBuilder = new IssuerBuilder();
    Issuer issuer = issuerBuilder.buildObject();
    issuer.setValue(registration.getAssertingPartyDetails().getEntityId());
    logoutResponse.setIssuer(issuer);
    logoutResponse.setDestination(registration.getSingleLogoutServiceResponseLocation());
    return logoutResponse;
}
Also used : Status(org.opensaml.saml.saml2.core.Status) StatusCodeBuilder(org.opensaml.saml.saml2.core.impl.StatusCodeBuilder) LogoutResponseBuilder(org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder) LogoutResponse(org.opensaml.saml.saml2.core.LogoutResponse) Issuer(org.opensaml.saml.saml2.core.Issuer) StatusBuilder(org.opensaml.saml.saml2.core.impl.StatusBuilder) IssuerBuilder(org.opensaml.saml.saml2.core.impl.IssuerBuilder) StatusCode(org.opensaml.saml.saml2.core.StatusCode)

Aggregations

StatusCode (org.opensaml.saml.saml2.core.StatusCode)8 Status (org.opensaml.saml.saml2.core.Status)7 StatusMessage (org.opensaml.saml.saml2.core.StatusMessage)5 StatusBuilder (org.opensaml.saml.saml2.core.impl.StatusBuilder)3 StatusCodeBuilder (org.opensaml.saml.saml2.core.impl.StatusCodeBuilder)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DateTime (org.joda.time.DateTime)1 Issuer (org.opensaml.saml.saml2.core.Issuer)1 LogoutResponse (org.opensaml.saml.saml2.core.LogoutResponse)1 IssuerBuilder (org.opensaml.saml.saml2.core.impl.IssuerBuilder)1 LogoutResponseBuilder (org.opensaml.saml.saml2.core.impl.LogoutResponseBuilder)1 StatusMessageBuilder (org.opensaml.saml.saml2.core.impl.StatusMessageBuilder)1 Assertion (org.opensaml.saml2.core.Assertion)1 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)1 AuthnStatement (org.opensaml.saml2.core.AuthnStatement)1 Issuer (org.opensaml.saml2.core.Issuer)1 NameID (org.opensaml.saml2.core.NameID)1 Response (org.opensaml.saml2.core.Response)1 Status (org.opensaml.saml2.core.Status)1 StatusCode (org.opensaml.saml2.core.StatusCode)1