org.opensaml.saml.saml2.core.LogoutResponse Java Examples
The following examples show how to use
org.opensaml.saml.saml2.core.LogoutResponse.
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 HttpResponse fail(ServiceRequestContext ctx, LogoutRequest logoutRequest, SamlEndpoint sloResEndpoint) { // Try to send a LogoutResponse with the following status code. It's one of the top-level status code // which is defined in SAML 2.0 specifications. // // "urn:oasis:names:tc:SAML:2.0:status:Responder" // - The request could not be performed due to an error on the part of the SAML responder // or SAML authority. final LogoutResponse failureResponse = createLogoutResponse(logoutRequest, StatusCode.RESPONDER); try { return respond(failureResponse, sloResEndpoint); } catch (SamlException e) { return fail(ctx, e); } }
Example #2
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 #3
Source File: AbstractSamlResponseCreator.java From cxf-fediz with Apache License 2.0 | 6 votes |
protected Element createLogoutResponse(Idp idp, String statusValue, String destination, String requestID) throws Exception { Document doc = DOMUtils.newDocument(); Status status = SAML2PResponseComponentBuilder.createStatus(statusValue, null); String issuer = useRealmForIssuer ? idp.getRealm() : idp.getIdpUrl().toString(); LogoutResponse response = SAML2PResponseComponentBuilder.createSAMLLogoutResponse(requestID, issuer, status, destination); // Sign the LogoutResponse signResponse(response, idp); Element policyElement = OpenSAMLUtil.toDom(response, doc); doc.appendChild(policyElement); return policyElement; }
Example #4
Source File: SAML2PResponseComponentBuilder.java From cxf-fediz with Apache License 2.0 | 6 votes |
public static LogoutResponse createSAMLLogoutResponse( String inResponseTo, String issuer, Status status, String destination ) { if (logoutResponseBuilder == null) { logoutResponseBuilder = (SAMLObjectBuilder<LogoutResponse>) builderFactory.getBuilder(LogoutResponse.DEFAULT_ELEMENT_NAME); } LogoutResponse response = logoutResponseBuilder.buildObject(); response.setID("_" + UUID.randomUUID().toString()); response.setIssueInstant(new DateTime()); response.setInResponseTo(inResponseTo); response.setIssuer(createIssuer(issuer)); response.setStatus(status); response.setVersion(SAMLVersion.VERSION_20); response.setDestination(destination); return response; }
Example #5
Source File: SAMLLogoutTest.java From cxf-fediz with Apache License 2.0 | 6 votes |
private Element createLogoutResponse(String statusValue, String destination, boolean sign, String requestID) throws Exception { DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Status status = SAML2PResponseComponentBuilder.createStatus(statusValue, null); LogoutResponse response = SAML2PResponseComponentBuilder.createSAMLLogoutResponse(requestID, TEST_IDP_ISSUER, status, destination); // Sign the LogoutResponse if (sign) { signResponse(response, "mystskey"); } Element policyElement = OpenSAMLUtil.toDom(response, doc); doc.appendChild(policyElement); return policyElement; }
Example #6
Source File: SAMLResponseTest.java From cxf-fediz with Apache License 2.0 | 6 votes |
private Element createLogoutResponse(String statusValue, String destination, boolean sign, String requestID) throws Exception { DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Status status = SAML2PResponseComponentBuilder.createStatus(statusValue, null); LogoutResponse response = SAML2PResponseComponentBuilder.createSAMLLogoutResponse(requestID, TEST_IDP_ISSUER, status, destination); // Sign the LogoutResponse if (sign) { signResponse(response, "mystskey"); } Element policyElement = OpenSAMLUtil.toDom(response, doc); doc.appendChild(policyElement); return policyElement; }
Example #7
Source File: SAML2PResponseComponentBuilder.java From cxf-fediz with Apache License 2.0 | 6 votes |
public static LogoutResponse createSAMLLogoutResponse( String inResponseTo, String issuer, Status status, String destination ) { if (logoutResponseBuilder == null) { logoutResponseBuilder = (SAMLObjectBuilder<LogoutResponse>) builderFactory.getBuilder(LogoutResponse.DEFAULT_ELEMENT_NAME); } LogoutResponse response = logoutResponseBuilder.buildObject(); response.setID(UUID.randomUUID().toString()); response.setIssueInstant(new DateTime()); response.setInResponseTo(inResponseTo); response.setIssuer(createIssuer(issuer)); response.setStatus(status); response.setVersion(SAMLVersion.VERSION_20); response.setDestination(destination); return response; }
Example #8
Source File: SamlClient.java From saml-client with MIT License | 5 votes |
/** * Decodes and validates an SAML response returned by an identity provider. * * @param encodedResponse the encoded response returned by the identity provider. * @param method The HTTP method used by the request * @return An {@link SamlResponse} object containing information decoded from the SAML response. * @throws SamlException if the signature is invalid, or if any other error occurs. */ public SamlLogoutResponse decodeAndValidateSamlLogoutResponse( String encodedResponse, String method) throws SamlException { LogoutResponse logoutResponse = (LogoutResponse) parseResponse(encodedResponse, method); ValidatorUtils.validate(logoutResponse, responseIssuer, credentials); return new SamlLogoutResponse(logoutResponse.getStatus()); }
Example #9
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 #10
Source File: SamlSingleLogoutFunction.java From armeria with Apache License 2.0 | 5 votes |
private HttpResponse respond(LogoutResponse logoutResponse, SamlEndpoint sloResEndpoint) { if (sloResEndpoint.bindingProtocol() == SamlBindingProtocol.HTTP_REDIRECT) { return responseWithLocation(toRedirectionUrl( logoutResponse, sloResEndpoint.toUriString(), SAML_RESPONSE, signingCredential, signatureAlgorithm, null)); } else { final String value = toSignedBase64(logoutResponse, signingCredential, signatureAlgorithm); final HttpData body = getSsoForm(sloResEndpoint.toUriString(), SAML_RESPONSE, value, null); return HttpResponse.of(HttpStatus.OK, MediaType.HTML_UTF_8, body); } }
Example #11
Source File: ValidatorUtils.java From saml-client with MIT License | 3 votes |
/** * Validate. * * @param response the response * @param responseIssuer the response issuer * @param credentials the credentials * @throws SamlException the saml exception */ public static void validate( LogoutResponse response, String responseIssuer, List<Credential> credentials) throws SamlException { validateResponse(response, responseIssuer); validateSignature(response, credentials); }