private void recalcEffectivePolicy(SoapMessage message,
String namespace,
Policy policy) {
Exchange ex = message.getExchange();
Bus bus = ex.get(Bus.class);
PolicyEngine pe = bus.getExtension(PolicyEngine.class);
if (null == pe) {
return;
}
Destination destination = ex.getDestination();
try {
Endpoint endpoint = message.getExchange().get(Endpoint.class);
TokenStore store = (TokenStore)message.getContextualProperty(TokenStore.class.getName());
if (store == null) {
store = new MemoryTokenStore();
endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store);
}
endpoint = STSUtils.createSTSEndpoint(bus,
namespace,
null,
destination.getAddress().getAddress().getValue(),
message.getVersion().getBindingId(),
policy,
null);
endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store);
message.getExchange().put(TokenStore.class.getName(), store);
EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination);
List<Interceptor> interceptors = ep.getInterceptors();
for (Interceptor i : interceptors) {
message.getInterceptorChain().add(i);
}