policyEnforcer.registerSecurityEvent(operationSecurityEvent);
List<XMLSecurityConstants.ContentType> protectionOrder = new LinkedList<XMLSecurityConstants.ContentType>();
protectionOrder.add(XMLSecurityConstants.ContentType.SIGNATURE);
protectionOrder.add(XMLSecurityConstants.ContentType.ENCRYPTION);
EncryptedPartSecurityEvent encryptedPartSecurityEvent = new EncryptedPartSecurityEvent(null, true, protectionOrder);
encryptedPartSecurityEvent.setElementPath(WSSConstants.SOAP_11_BODY_PATH);
policyEnforcer.registerSecurityEvent(encryptedPartSecurityEvent);
List<QName> headerPath = new ArrayList<QName>();
headerPath.addAll(WSSConstants.SOAP_11_HEADER_PATH);
headerPath.add(new QName("http://example.org", "a"));
encryptedPartSecurityEvent.setElementPath(headerPath);
policyEnforcer.registerSecurityEvent(encryptedPartSecurityEvent);
//additional encryptedParts are also allowed!
headerPath = new ArrayList<QName>();
headerPath.addAll(WSSConstants.SOAP_11_HEADER_PATH);
headerPath.add(new QName("http://example.org", "b"));
encryptedPartSecurityEvent.setElementPath(headerPath);
policyEnforcer.registerSecurityEvent(encryptedPartSecurityEvent);
policyEnforcer.doFinal();
}