use of org.apache.cxf.endpoint.Server 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();
}
use of org.apache.cxf.endpoint.Server in project steve by RWTH-i5-IDSG.
the class MediatorInInterceptor method initServerLookupMap.
/**
* Iterate over all available servers registered on the bus and build a map
* consisting of (namespace, server) pairs for later lookup, so we can
* redirect to the version-specific implementation according to the namespace
* of the incoming message.
*/
private static Map<String, Server> initServerLookupMap(Bus bus) {
String exceptionMsg = "The services are not created and/or registered to the bus yet.";
ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
if (serverRegistry == null) {
throw new RuntimeException(exceptionMsg);
}
List<Server> temp = serverRegistry.getServers();
if (temp.isEmpty()) {
throw new RuntimeException(exceptionMsg);
}
Map<String, Server> actualServers = new HashMap<>(temp.size() - 1);
for (Server server : temp) {
EndpointInfo info = server.getEndpoint().getEndpointInfo();
String address = info.getAddress();
// exclude the 'dummy' routing server
if (CONFIG.getRouterEndpointPath().equals(address)) {
continue;
}
String serverNamespace = info.getName().getNamespaceURI();
actualServers.put(serverNamespace, server);
}
return actualServers;
}
use of org.apache.cxf.endpoint.Server in project tutorials by eugenp.
the class RestfulServer method main.
public static void main(String[] args) throws Exception {
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
factoryBean.setResourceClasses(CourseRepository.class);
factoryBean.setResourceProvider(new SingletonResourceProvider(new CourseRepository()));
factoryBean.setAddress("http://localhost:8080/");
Server server = factoryBean.create();
System.out.println("Server ready...");
Thread.sleep(60 * 1000);
System.out.println("Server exiting");
server.destroy();
System.exit(0);
}
use of org.apache.cxf.endpoint.Server in project fabric8 by fabric8io.
the class EnableJMXFeature method initialize.
@Override
public void initialize(Bus bus) {
List<Server> servers = new ArrayList<Server>();
ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
servers.addAll(serverRegistry.getServers());
for (Iterator<Server> iter = servers.iterator(); iter.hasNext(); ) {
Server server = (Server) iter.next();
ManagedApi mApi = new ManagedApi(bus, server.getEndpoint(), server);
ManagedEndpoint mEndpoint = new ManagedEndpoint(bus, server.getEndpoint(), server);
InstrumentationManager iMgr = bus.getExtension(InstrumentationManager.class);
if (iMgr == null) {
iMgr = new InstrumentationManagerImpl(bus);
}
((InstrumentationManagerImpl) iMgr).setUsePlatformMBeanServer(true);
((InstrumentationManagerImpl) iMgr).setCreateMBServerConnectorFactory(false);
((InstrumentationManagerImpl) iMgr).setEnabled(true);
((InstrumentationManagerImpl) iMgr).init();
if (iMgr != null) {
try {
iMgr.register(mApi);
iMgr.register(mEndpoint);
} catch (JMException jmex) {
jmex.printStackTrace();
LOG.log(Level.WARNING, "Registering ManagedApi failed.", jmex);
}
}
}
}
use of org.apache.cxf.endpoint.Server in project fabric8 by fabric8io.
the class ManagedApiFeature method initialize.
@Override
public void initialize(final Bus bus) {
FactoryBeanListenerManager factoryBeanListenerManager = bus.getExtension(FactoryBeanListenerManager.class);
if (factoryBeanListenerManager == null) {
factoryBeanListenerManager = new FactoryBeanListenerManager(bus);
}
factoryBeanListenerManager.addListener(new FactoryBeanListener() {
@Override
public void handleEvent(Event arg0, AbstractServiceFactoryBean arg1, Object... arg2) {
if (arg0.equals(Event.SERVER_CREATED) && (arg2[0] instanceof Server)) {
Server server = (Server) arg2[0];
initialize(server, bus);
}
}
});
}
Aggregations