use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutMessageImpl method extractRequest.
private LogoutWrapper<LogoutRequest> extractRequest(String samlObject) throws LogoutSecurityException, XMLStreamException {
try {
Document requestDoc = StaxUtils.read(new ByteArrayInputStream(samlObject.getBytes(StandardCharsets.UTF_8)));
XMLObject requestXmlObject = OpenSAMLUtil.fromDom(requestDoc.getDocumentElement());
if (LogoutRequest.class.isAssignableFrom(requestXmlObject.getClass())) {
return new LogoutWrapperImpl<>((LogoutRequest) requestXmlObject);
}
return null;
} catch (WSSecurityException e) {
throw new LogoutSecurityException(e);
}
}
use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutMessageImpl method signSamlGet.
private URI signSamlGet(LogoutWrapper samlObject, URI target, String relayState, String requestType) throws LogoutSecurityException, SignatureException, IOException {
try {
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement("root"));
SamlSecurity samlSecurity = new SamlSecurity();
String encodedResponse = URLEncoder.encode(samlSecurity.deflateAndBase64Encode(DOM2Writer.nodeToString(OpenSAMLUtil.toDom((XMLObject) samlObject.getMessage(), doc, false))), "UTF-8");
String requestToSign = String.format("%s=%s&%s=%s", requestType, encodedResponse, SSOConstants.RELAY_STATE, relayState);
UriBuilder uriBuilder = UriBuilder.fromUri(target);
uriBuilder.queryParam(requestType, encodedResponse);
uriBuilder.queryParam(SSOConstants.RELAY_STATE, relayState);
new SimpleSign(systemCrypto).signUriString(requestToSign, uriBuilder);
return uriBuilder.build();
} catch (WSSecurityException e) {
throw new LogoutSecurityException(e);
}
}
Aggregations