use of org.apache.cxf.jaxrs.security.JAASAuthenticationFilter in project tesb-rt-se by Talend.
the class AuxiliaryStorageRestServiceSecurityProvider method init.
public void init() {
if (Authentication.NO == auxiliaryStorageAuthentication) {
return;
}
// TODO: !!! find more correct way to enable/switch(?) security on provider endpoint
Bus serverBus = server.getBus();
ServerRegistry registry = serverBus.getExtension(ServerRegistry.class);
List<Server> servers = registry.getServers();
for (Server sr : servers) {
EndpointInfo ei = sr.getEndpoint().getEndpointInfo();
if (null != ei && ei.getAddress().endsWith(server.getAddress())) {
registry.unregister(sr);
sr.destroy();
}
}
@SuppressWarnings("unchecked") List<Object> providers = (List<Object>) server.getProviders();
if (Authentication.BASIC == auxiliaryStorageAuthentication) {
JAASAuthenticationFilter jaasAuthFilter = new JAASAuthenticationFilter();
jaasAuthFilter.setContextName("karaf");
providers.add(jaasAuthFilter);
server.setProviders(providers);
}
if (Authentication.SAML == auxiliaryStorageAuthentication) {
Map<String, Object> endpointProps = new HashMap<String, Object>();
endpointProps.put(SecurityConstants.SIGNATURE_PROPERTIES, signatureProperties);
endpointProps.put(SecurityConstants.SIGNATURE_USERNAME, signatureUsername);
endpointProps.put(ENDPOINT_SIGNATURE_PASSWORD, signaturePassword);
endpointProps.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(signatureUsername, signaturePassword));
Map<String, Object> properties = server.getProperties();
if (null == properties) {
properties = new HashMap<String, Object>();
}
properties.putAll(endpointProps);
server.setProperties(properties);
SamlHeaderInHandler samlHandler = new SamlHeaderInHandler();
providers.add(samlHandler);
server.setProviders(providers);
}
server.create();
}
use of org.apache.cxf.jaxrs.security.JAASAuthenticationFilter in project tesb-rt-se by Talend.
the class SAMServiceSecurityProvider method init.
public void init() {
final EsbSecurityConstants esbSecurity = EsbSecurityConstants.fromString(authenticationType);
if (EsbSecurityConstants.NO == esbSecurity) {
return;
}
Bus serverBus = server.getBus();
ServerRegistry registry = serverBus.getExtension(ServerRegistry.class);
List<Server> servers = registry.getServers();
for (Server sr : servers) {
EndpointInfo ei = sr.getEndpoint().getEndpointInfo();
if (null != ei && ei.getAddress().endsWith(server.getAddress())) {
registry.unregister(sr);
sr.destroy();
}
}
@SuppressWarnings("unchecked") List<Object> providers = (List<Object>) server.getProviders();
Map<String, Object> endpointProperties = new HashMap<String, Object>();
if (EsbSecurityConstants.BASIC == esbSecurity) {
JAASAuthenticationFilter authenticationFilter = new JAASAuthenticationFilter();
authenticationFilter.setContextName("karaf");
providers.add(authenticationFilter);
server.setProviders(providers);
} else if (EsbSecurityConstants.SAML == esbSecurity) {
endpointProperties.put(SecurityConstants.SIGNATURE_PROPERTIES, getSignatureProperties());
endpointProperties.put(SecurityConstants.SIGNATURE_USERNAME, getSignatureUsername());
endpointProperties.put(ENDPOINT_SIGNATURE_PASSWORD, getSignaturePassword());
endpointProperties.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(getSignatureUsername(), getSignaturePassword()));
Map<String, Object> properties = server.getProperties();
if (null == properties)
properties = new HashMap<String, Object>();
properties.putAll(endpointProperties);
server.setProperties(properties);
SamlHeaderInHandler samlHandler = new SamlHeaderInHandler();
providers.add(samlHandler);
server.setProviders(providers);
}
server.create();
}
Aggregations