String actor = (String)message.getContextualProperty(SecurityConstants.ACTOR);
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
// extract Assertion information
if (aim != null) {
AbstractBinding transport = null;
ais = getAllAssertionsByLocalname(aim, SPConstants.TRANSPORT_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
transport = (AbstractBinding)ai.getAssertion();
ai.setAsserted(true);
}
}
ais = getAllAssertionsByLocalname(aim, SPConstants.ASYMMETRIC_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
transport = (AbstractBinding)ai.getAssertion();
ai.setAsserted(true);
}
}
ais = getAllAssertionsByLocalname(aim, SPConstants.SYMMETRIC_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
transport = (AbstractBinding)ai.getAssertion();
ai.setAsserted(true);
}
}
if (transport == null && isRequestor(message)) {
Policy policy = new Policy();
transport = new TransportBinding(org.apache.wss4j.policy.SPConstants.SPVersion.SP11,
policy);
}
if (transport != null) {
WSSecHeader secHeader = new WSSecHeader(actor, mustUnderstand);
Element el = null;
try {
el = secHeader.insertSecurityHeader(saaj.getSOAPPart());
} catch (WSSecurityException e) {
throw new SoapFault(
new Message("SECURITY_FAILED", LOG), e, message.getVersion().getSender()
);
}
try {
//move to end
SAAJUtils.getHeader(saaj).removeChild(el);
SAAJUtils.getHeader(saaj).appendChild(el);
} catch (SOAPException e) {
//ignore
}
WSSConfig config = (WSSConfig)message.getContextualProperty(WSSConfig.class.getName());
if (config == null) {
config = WSSConfig.getNewInstance();
}
translateProperties(message);
String asymSignatureAlgorithm =
(String)message.getContextualProperty(SecurityConstants.ASYMMETRIC_SIGNATURE_ALGORITHM);
if (asymSignatureAlgorithm != null && transport.getAlgorithmSuite() != null) {
transport.getAlgorithmSuite().setAsymmetricSignature(asymSignatureAlgorithm);
}
if (transport instanceof TransportBinding) {
new TransportBindingHandler(config, (TransportBinding)transport, saaj,
secHeader, aim, message).handleBinding();