Java Code Examples for org.opensaml.saml.saml2.core.Status#setStatusCode()
The following examples show how to use
org.opensaml.saml.saml2.core.Status#setStatusCode() .
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: SamlSingleLogoutFunction.java From armeria with Apache License 2.0 | 6 votes |
private LogoutResponse createLogoutResponse(LogoutRequest logoutRequest, String statusCode) { final StatusCode success = build(StatusCode.DEFAULT_ELEMENT_NAME); success.setValue(statusCode); final Status status = build(Status.DEFAULT_ELEMENT_NAME); status.setStatusCode(success); final Issuer me = build(Issuer.DEFAULT_ELEMENT_NAME); me.setValue(entityId); final LogoutResponse logoutResponse = build(LogoutResponse.DEFAULT_ELEMENT_NAME); logoutResponse.setIssuer(me); logoutResponse.setID(requestIdManager.newId()); logoutResponse.setIssueInstant(DateTime.now()); logoutResponse.setStatus(status); logoutResponse.setInResponseTo(logoutRequest.getID()); return logoutResponse; }
Example 2
Source File: SAML2PResponseComponentBuilder.java From syncope with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: MockSamlIdpServer.java From deprecated-security-advanced-modules with Apache License 2.0 | 5 votes |
private Status createStatus(String statusCodeValue) { Status status = createSamlElement(Status.class); StatusCode statusCode = createSamlElement(StatusCode.class); statusCode.setValue(statusCodeValue); status.setStatusCode(statusCode); return status; }
Example 4
Source File: AbstractSaml20ObjectBuilder.java From springboot-shiro-cas-mybatis with MIT License | 5 votes |
/** * Create a new SAML status object. * * @param codeValue the code value * @param statusMessage the status message * @return the status */ public Status newStatus(final String codeValue, final String statusMessage) { final Status status = newSamlObject(Status.class); final StatusCode code = newSamlObject(StatusCode.class); code.setValue(codeValue); status.setStatusCode(code); if (StringUtils.isNotBlank(statusMessage)) { final StatusMessage message = newSamlObject(StatusMessage.class); message.setMessage(statusMessage); status.setStatusMessage(message); } return status; }
Example 5
Source File: SamlClient.java From saml-client with MIT License | 5 votes |
/** * Gets saml logout response. * * @param status the status code @See StatusCode.java * @param statMsg the status message * @return saml logout response * @throws SamlException the saml exception */ public String getSamlLogoutResponse(final String status, final String statMsg) throws SamlException { LogoutResponse response = (LogoutResponse) buildSamlObject(LogoutResponse.DEFAULT_ELEMENT_NAME); response.setID("z" + UUID.randomUUID().toString()); // ADFS needs IDs to start with a letter response.setVersion(SAMLVersion.VERSION_20); response.setIssueInstant(DateTime.now()); Issuer issuer = (Issuer) buildSamlObject(Issuer.DEFAULT_ELEMENT_NAME); issuer.setValue(relyingPartyIdentifier); response.setIssuer(issuer); //Status Status stat = (Status) buildSamlObject(Status.DEFAULT_ELEMENT_NAME); StatusCode statCode = new StatusCodeBuilder().buildObject(); statCode.setValue(status); stat.setStatusCode(statCode); if (statMsg != null) { StatusMessage statMessage = new StatusMessageBuilder().buildObject(); statMessage.setMessage(statMsg); stat.setStatusMessage(statMessage); } response.setStatus(stat); //Add a signature into the response signSAMLObject(response); StringWriter stringWriter; try { stringWriter = marshallXmlObject(response); } catch (MarshallingException ex) { throw new SamlException("Error while marshalling SAML request to XML", ex); } logger.trace("Issuing SAML Logout request: " + stringWriter.toString()); return Base64.encodeBase64String(stringWriter.toString().getBytes(StandardCharsets.UTF_8)); }
Example 6
Source File: SAML2PResponseComponentBuilder.java From cxf with Apache License 2.0 | 5 votes |
@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; }
Example 7
Source File: SAML2PResponseComponentBuilder.java From cxf-fediz with Apache License 2.0 | 5 votes |
@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; }
Example 8
Source File: SAML2PResponseComponentBuilder.java From cxf-fediz with Apache License 2.0 | 5 votes |
@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; }
Example 9
Source File: SAML2PResponseComponentBuilder.java From cxf-fediz with Apache License 2.0 | 5 votes |
@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; }
Example 10
Source File: SamlServiceProviderTest.java From armeria with Apache License 2.0 | 4 votes |
private static Response getAuthResponse(String recipient) throws Exception { // IdP entity ID final Issuer issuer = build(Issuer.DEFAULT_ELEMENT_NAME); issuer.setValue("http://idp.example.com/post"); final Assertion assertion = build(Assertion.DEFAULT_ELEMENT_NAME); final Subject subject = build(Subject.DEFAULT_ELEMENT_NAME); final SubjectConfirmation subjectConfirmation = build(SubjectConfirmation.DEFAULT_ELEMENT_NAME); final SubjectConfirmationData data = build(SubjectConfirmationData.DEFAULT_ELEMENT_NAME); data.setInResponseTo(requestIdManager.newId()); data.setNotOnOrAfter(DateTime.now().plusMinutes(1)); data.setRecipient(recipient); subjectConfirmation.setSubjectConfirmationData(data); subjectConfirmation.setMethod("urn:oasis:names:tc:SAML:2.0:cm:bearer"); subject.getSubjectConfirmations().add(subjectConfirmation); assertion.setSubject(subject); assertion.setIssuer(XMLObjectSupport.cloneXMLObject(issuer)); assertion.setIssueInstant(DateTime.now()); assertion.setID(requestIdManager.newId()); final AuthnStatement authnStatement = build(AuthnStatement.DEFAULT_ELEMENT_NAME); authnStatement.setSessionIndex("1"); assertion.getAuthnStatements().add(authnStatement); final Conditions conditions = build(Conditions.DEFAULT_ELEMENT_NAME); conditions.setNotBefore(DateTime.now().minusMinutes(1)); conditions.setNotOnOrAfter(DateTime.now().plusMinutes(1)); final AudienceRestriction audienceRestriction = build(AudienceRestriction.DEFAULT_ELEMENT_NAME); final Audience audience = build(Audience.DEFAULT_ELEMENT_NAME); // Set SP entity ID as an audience. audience.setAudienceURI(spEntityId); audienceRestriction.getAudiences().add(audience); conditions.getAudienceRestrictions().add(audienceRestriction); assertion.setConditions(conditions); sign(assertion, idpCredential, signatureAlgorithm); final Response response = build(Response.DEFAULT_ELEMENT_NAME); response.getAssertions().add(assertion); response.setID(requestIdManager.newId()); response.setIssuer(issuer); response.setIssueInstant(DateTime.now()); final Status status = build(Status.DEFAULT_ELEMENT_NAME); final StatusCode statusCode = build(StatusCode.DEFAULT_ELEMENT_NAME); statusCode.setValue(StatusCode.SUCCESS); status.setStatusCode(statusCode); response.setStatus(status); return response; }