use of org.talend.esb.locator.service.LocatorServiceConstants.EsbSecurity in project tesb-rt-se by Talend.
the class PolicyProviderImpl method init.
@PostConstruct
public void init() {
final EsbSecurity esbSecurity = EsbSecurity.fromString((String) serviceAutentication);
if (EsbSecurity.NO == esbSecurity)
return;
Bus currentBus = BusFactory.getThreadDefaultBus();
policyBuilder = currentBus.getExtension(PolicyBuilder.class);
List<Policy> policies = new ArrayList<Policy>();
if (EsbSecurity.TOKEN == esbSecurity) {
policies.add(getTokenPolicy());
} else if (EsbSecurity.SAML == esbSecurity) {
policies.add(getSamlPolicy());
}
Map<String, Object> endpointProps = new HashMap<String, Object>();
if (EsbSecurity.TOKEN == esbSecurity) {
JAASUsernameTokenValidator jaasUTValidator = new JAASUsernameTokenValidator();
jaasUTValidator.setContextName("karaf");
endpointProps.put(SecurityConstants.USERNAME_TOKEN_VALIDATOR, jaasUTValidator);
}
if (EsbSecurity.SAML == esbSecurity) {
endpointProps.put(SecurityConstants.SIGNATURE_PROPERTIES, getSignatureProperties());
endpointProps.put(SecurityConstants.SIGNATURE_USERNAME, getSignatureUsername());
endpointProps.put(ENDPOINT_SIGNATURE_PASSWORD, getSignaturePassword());
endpointProps.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(getSignatureUsername(), getSignaturePassword()));
}
locatorEndpoint.setProperties(endpointProps);
WSPolicyFeature policyFeature = new WSPolicyFeature();
policyFeature.setPolicies(policies);
locatorEndpoint.getFeatures().add(policyFeature);
ServerRegistry registry = currentBus.getExtension(ServerRegistry.class);
List<Server> servers = registry.getServers();
for (Server sr : servers) {
if (sr.getEndpoint().getService() == locatorEndpoint.getService())
policyFeature.initialize(sr, currentBus);
}
}
Aggregations