@Override
public boolean assertEvent(SecurityEvent securityEvent) throws WSSPolicyException {
//todo attachments
SignedPartSecurityEvent signedPartSecurityEvent = (SignedPartSecurityEvent) securityEvent;
SignedParts signedParts = (SignedParts) getAssertion();
if (signedParts.isBody()
&& WSSUtils.pathMatches(WSSConstants.SOAP_11_BODY_PATH, signedPartSecurityEvent.getElementPath(), true, false)) {
if (signedPartSecurityEvent.isSigned()) {
setAsserted(true);
return true;
} else {
setAsserted(false);
setErrorMessage("Element " + WSSUtils.pathAsString(signedPartSecurityEvent.getElementPath()) + " must be signed");
return false;
}
}
//body processed above. so this must be a header element
if (signedParts.isSignAllHeaders()) {
if (signedPartSecurityEvent.isSigned()) {
setAsserted(true);
return true;
} else {
setAsserted(false);
setErrorMessage("Element " + WSSUtils.pathAsString(signedPartSecurityEvent.getElementPath()) + " must be signed");
return false;
}
} else {
for (int i = 0; i < signedParts.getHeaders().size(); i++) {
Header header = signedParts.getHeaders().get(i);
QName headerQName = new QName(header.getNamespace(), header.getName() == null ? "" : header.getName());
List<QName> header11Path = new LinkedList<QName>();
header11Path.addAll(WSSConstants.SOAP_11_HEADER_PATH);
header11Path.add(headerQName);
if (WSSUtils.pathMatches(header11Path, signedPartSecurityEvent.getElementPath(), true, header.getName() == null)) {
if (signedPartSecurityEvent.isSigned()) {
setAsserted(true);
return true;
} else {
setAsserted(false);
setErrorMessage("Element " + WSSUtils.pathAsString(signedPartSecurityEvent.getElementPath()) + " must be signed");
return false;
}
}
}
}