use of org.apache.cxf.interceptor.security.JAASLoginInterceptor in project wildfly-camel by wildfly-extras.
the class CXFWSJAASAuthenticationIntegrationTest method configureCamelContext.
private CamelContext configureCamelContext(String password) throws Exception {
CamelContext camelctx = new DefaultCamelContext();
CxfComponent component = new CxfComponent(camelctx);
CxfEndpoint consumerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
consumerEndpoint.setServiceClass(Endpoint.class);
List<Interceptor<? extends Message>> inInterceptors = consumerEndpoint.getInInterceptors();
JAASLoginInterceptor interceptor = new JAASLoginInterceptor();
interceptor.setContextName("other");
inInterceptors.add(interceptor);
CxfEndpoint producerEndpoint = new CxfEndpoint("http://localhost:8080/webservices/greeting", component);
producerEndpoint.setServiceClass(Endpoint.class);
producerEndpoint.setUsername("user1");
producerEndpoint.setPassword(password);
Map<String, Object> properties = producerEndpoint.getProperties();
if (properties == null) {
producerEndpoint.setProperties(new HashMap<>());
}
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to(producerEndpoint);
from(consumerEndpoint).process(exchange -> {
Object[] args = exchange.getIn().getBody(Object[].class);
exchange.getOut().setBody("Hello " + args[0]);
});
}
});
return camelctx;
}
use of org.apache.cxf.interceptor.security.JAASLoginInterceptor in project cxf by apache.
the class JAASServer method createTestJaasLoginInterceptor.
private JAASLoginInterceptor createTestJaasLoginInterceptor() {
JAASLoginInterceptor jaasInt = new JAASLoginInterceptor();
jaasInt.setReportFault(true);
Configuration config = new Configuration() {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
Map<String, String> options = new HashMap<>();
AppConfigurationEntry configEntry = new AppConfigurationEntry(TestUserPasswordLoginModule.class.getName(), LoginModuleControlFlag.REQUIRED, options);
return Collections.singleton(configEntry).toArray(new AppConfigurationEntry[] {});
}
};
jaasInt.setLoginConfig(config);
return jaasInt;
}
use of org.apache.cxf.interceptor.security.JAASLoginInterceptor in project tesb-rt-se by Talend.
the class SAMServiceSecurityProvider method init.
@PostConstruct
public void init() {
final EsbSecurityConstants esbSecurity = EsbSecurityConstants.fromString(authenticationType);
if (EsbSecurityConstants.NO == esbSecurity) {
return;
}
Bus bus = serviceEndpoint.getBus();
List<Policy> policies = new ArrayList<Policy>();
WSPolicyFeature policyFeature = new WSPolicyFeature();
policyFeature.setPolicies(policies);
Map<String, Object> properties = serviceEndpoint.getProperties();
if (null == properties) {
properties = new HashMap<String, Object>();
}
if (EsbSecurityConstants.BASIC == esbSecurity) {
JAASLoginInterceptor interceptor = new JAASLoginInterceptor();
interceptor.setContextName("karaf");
serviceEndpoint.getInInterceptors().add(interceptor);
} else if (EsbSecurityConstants.USERNAMETOKEN == esbSecurity) {
policies.add(loadPolicy(policyUsernameToken, bus));
JAASUsernameTokenValidator jaasUTValidator = new JAASUsernameTokenValidator();
jaasUTValidator.setContextName("karaf");
properties.put(SecurityConstants.USERNAME_TOKEN_VALIDATOR, jaasUTValidator);
serviceEndpoint.setProperties(properties);
} else if (EsbSecurityConstants.SAML == esbSecurity) {
policies.add(loadPolicy(policySaml, bus));
properties.put(SecurityConstants.SIGNATURE_PROPERTIES, getSignatureProperties());
properties.put(SecurityConstants.SIGNATURE_USERNAME, getSignatureUsername());
properties.put(ENDPOINT_SIGNATURE_PASSWORD, getSignaturePassword());
properties.put(SecurityConstants.CALLBACK_HANDLER, new WSPasswordCallbackHandler(getSignatureUsername(), getSignaturePassword()));
serviceEndpoint.setProperties(properties);
}
serviceEndpoint.getFeatures().add(policyFeature);
ServerRegistry registry = bus.getExtension(ServerRegistry.class);
List<Server> servers = registry.getServers();
for (Server server : servers) {
if (server.getEndpoint().getService() == serviceEndpoint.getService()) {
policyFeature.initialize(server, bus);
}
}
}
Aggregations