use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutRequestService method getSamlpRedirectLogoutRequest.
private Response getSamlpRedirectLogoutRequest(String relayState, LogoutWrapper<LogoutRequest> logoutRequest) throws IOException, SignatureException, LogoutSecurityException, URISyntaxException {
LOGGER.debug("Configuring SAML Response for Redirect.");
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement(ROOT_NODE_NAME));
if (logoutMessage == null) {
throw new LogoutSecurityException("Logout message not ready yet.");
}
URI location = logoutMessage.signSamlGetRequest(logoutRequest, new URI(idpMetadata.getSingleLogoutLocation()), relayState);
String redirectUpdated = String.format(redirectPage, location.toString());
Response.ResponseBuilder ok = Response.ok(redirectUpdated);
return ok.build();
}
use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutRequestService method getSamlpRedirectLogoutResponse.
private Response getSamlpRedirectLogoutResponse(String relayState, LogoutWrapper<LogoutResponse> samlResponse) throws IOException, SignatureException, LogoutSecurityException, URISyntaxException {
LOGGER.debug("Configuring SAML Response for Redirect.");
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement(ROOT_NODE_NAME));
if (logoutMessage == null) {
throw new LogoutSecurityException("Logout message is not ready yet.");
}
URI location = logoutMessage.signSamlGetResponse(samlResponse, new URI(idpMetadata.getSingleLogoutLocation()), relayState);
return Response.ok(HtmlResponseTemplate.getRedirectPage(location.toString())).build();
}
use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutMessageImpl method extractXmlObject.
@Override
public LogoutWrapper<SignableSAMLObject> extractXmlObject(String samlLogoutResponse) throws LogoutSecurityException, XMLStreamException {
try {
Document responseDoc = StaxUtils.read(new ByteArrayInputStream(samlLogoutResponse.getBytes(StandardCharsets.UTF_8)));
XMLObject xmlObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
if (xmlObject instanceof SignableSAMLObject) {
return new LogoutWrapperImpl<>((SignableSAMLObject) xmlObject);
}
return null;
} catch (WSSecurityException e) {
throw new LogoutSecurityException(e);
}
}
use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutMessageImpl method getElementFromSaml.
@Override
public Element getElementFromSaml(LogoutWrapper xmlObject) throws LogoutSecurityException {
try {
Document doc = DOMUtils.createDocument();
doc.appendChild(doc.createElement("root"));
return OpenSAMLUtil.toDom((XMLObject) xmlObject.getMessage(), doc);
} catch (WSSecurityException e) {
throw new LogoutSecurityException(e);
}
}
use of ddf.security.samlp.LogoutSecurityException in project ddf by codice.
the class LogoutMessageImpl method extractResponse.
private LogoutWrapper<LogoutResponse> extractResponse(String samlObject) throws LogoutSecurityException, XMLStreamException {
try {
Document responseDoc = StaxUtils.read(new ByteArrayInputStream(samlObject.getBytes(StandardCharsets.UTF_8)));
XMLObject responseXmlObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
if (LogoutResponse.class.isAssignableFrom(responseXmlObject.getClass())) {
return new LogoutWrapperImpl<>((LogoutResponse) responseXmlObject);
}
return null;
} catch (WSSecurityException e) {
throw new LogoutSecurityException(e);
}
}
Aggregations