Java Code Examples for org.opensaml.saml2.core.StatusCode#setValue()

The following examples show how to use org.opensaml.saml2.core.StatusCode#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultResponseBuilder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private Status buildStatus(String status, String statMsg) {

        Status stat = new StatusBuilder().buildObject();

        // Set the status code
        StatusCode statCode = new StatusCodeBuilder().buildObject();
        statCode.setValue(status);
        stat.setStatusCode(statCode);

        // Set the status Message
        if (statMsg != null) {
            StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
            statMesssage.setMessage(statMsg);
            stat.setStatusMessage(statMesssage);
        }

        return stat;
    }
 
Example 2
Source File: ErrorResponseBuilder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Build the StatusCode for Status of Response
 *
 * @param parentStatusCode
 * @param childStatusCode
 * @return
 */
private StatusCode buildStatusCode(String parentStatusCode, StatusCode childStatusCode) throws IdentityException {

    if (parentStatusCode == null) {
        throw IdentityException.error("Invalid SAML Response Status Code");
    }

    StatusCode statusCode = new StatusCodeBuilder().buildObject();
    statusCode.setValue(parentStatusCode);

    //Set the status Message
    if (childStatusCode != null) {
        statusCode.setStatusCode(childStatusCode);
        return statusCode;
    } else {
        return statusCode;
    }
}
 
Example 3
Source File: SingleLogoutMessageBuilder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private Status buildStatus(String status, String statMsg) {

        Status stat = new StatusBuilder().buildObject();

        //Set the status code
        StatusCode statCode = new StatusCodeBuilder().buildObject();
        statCode.setValue(status);
        stat.setStatusCode(statCode);

        //Set the status Message
        if (statMsg != null) {
            StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
            statMesssage.setMessage(statMsg);
            stat.setStatusMessage(statMesssage);
        }

        return stat;
    }
 
Example 4
Source File: SAMLResponseBuilder.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Get status
 *
 * @param status
 * @param statMsg
 * @return Status object
 */
private Status buildStatus(String status, String statMsg) {

    Status stat = new StatusBuilder().buildObject();

    // Set the status code
    StatusCode statCode = new StatusCodeBuilder().buildObject();
    statCode.setValue(status);
    stat.setStatusCode(statCode);

    // Set the status Message
    if (statMsg != null) {
        StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
        statMesssage.setMessage(statMsg);
        stat.setStatusMessage(statMesssage);
    }

    return stat;
}
 
Example 5
Source File: StatusCodeUnmarshaller.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    StatusCode statusCode = (StatusCode) samlObject;

    if (attribute.getLocalName().equals(StatusCode.VALUE_ATTRIB_NAME)) {
        statusCode.setValue(attribute.getValue());
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
Example 6
Source File: ErrorResponseBuilder.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private static Status buildStatus() {

        Status stat = new StatusBuilder().buildObject();

        //Set the status code
        StatusCode statCode = new StatusCodeBuilder().buildObject();
        statCode.setValue("urn:oasis:names:tc:SAML:2.0:status:Responder");
        stat.setStatusCode(statCode);
        StatusMessage statMesssage = new StatusMessageBuilder().buildObject();
        statMesssage.setMessage("Error when processing the Authentication Request");
        stat.setStatusMessage(statMesssage);

        return stat;
    }
 
Example 7
Source File: SamlAssertionProducer.java    From saml-generator with Apache License 2.0 5 votes vote down vote up
private Status createStatus() {
	StatusCodeBuilder statusCodeBuilder = new StatusCodeBuilder();
	StatusCode statusCode = statusCodeBuilder.buildObject();
	statusCode.setValue(StatusCode.SUCCESS_URI);

	StatusBuilder statusBuilder = new StatusBuilder();
	Status status = statusBuilder.buildObject();
	status.setStatusCode(statusCode);

	return status;
}
 
Example 8
Source File: SAML2LoginAPIAuthenticatorCmdTest.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: StatusGenerator.java    From MaxKey with Apache License 2.0 4 votes vote down vote up
public StatusCode builderStatusCode(String value){
	StatusCode statusCode = (StatusCode) new StatusCodeBuilder().buildObject();
	statusCode.setValue(value);
	
	return statusCode;
}