if (addVer != null) {
ctx.setAction(getAction(packet));
}
ctx.setSecurityPolicyVersion(spVersion.namespaceUri);
try {
MessagePolicy policy = null;
PolicyAlternativeHolder applicableAlternative =
resolveAlternative(packet, isSCMessage);
if (packet.getMessage().isFault()) {
policy = getOutgoingFaultPolicy(packet);
} else if (isRMMessage(packet) || isMakeConnectionMessage(packet)) {
SecurityPolicyHolder holder = applicableAlternative.getOutProtocolPM().get("RM");
policy = holder.getMessagePolicy();
} else if (isSCCancel(packet)) {
SecurityPolicyHolder holder = applicableAlternative.getOutProtocolPM().get("SC-CANCEL");
policy = holder.getMessagePolicy();
} else {
policy = getOutgoingXWSSecurityPolicy(packet, isSCMessage);
}
if (debug && policy != null) {
policy.dumpMessages(true);
}
//this might mislead if there is a bug in code above
//but we are doing this check for cases such as no-fault-security-policy
if (policy != null) {
ctx.setSecurityPolicy(policy);
}
if (isTrustMessage(packet)) {
ctx.isTrustMessage(true);
}
// set the policy, issued-token-map, and extraneous properties
//ctx.setIssuedTokenContextMap(issuedTokenContextMap);
if (isSCMessage) {
ctx.setAlgorithmSuite(policy.getAlgorithmSuite());
} else {
ctx.setAlgorithmSuite(getAlgoSuite(getBindingAlgorithmSuite(packet)));
}
ctx.setSecurityEnvironment(secEnv);
ctx.isInboundMessage(false);