Search in sources :

Example 1 with ServerRegistry

use of org.apache.cxf.endpoint.ServerRegistry in project fabric8 by jboss-fuse.

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);
        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);
            } catch (JMException jmex) {
                jmex.printStackTrace();
                LOG.log(Level.WARNING, "Registering ManagedApi failed.", jmex);
            }
        }
    }
}
Also used : InstrumentationManagerImpl(org.apache.cxf.management.jmx.InstrumentationManagerImpl) Server(org.apache.cxf.endpoint.Server) ArrayList(java.util.ArrayList) JMException(javax.management.JMException) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) InstrumentationManager(org.apache.cxf.management.InstrumentationManager)

Example 2 with ServerRegistry

use of org.apache.cxf.endpoint.ServerRegistry in project tesb-rt-se by Talend.

the class LocatorRegistrarTest method addRegisteredServers.

private Bus addRegisteredServers(Bus bus, List<Server> registeredServers) {
    ServerRegistry sr = createMock(ServerRegistry.class);
    expect(sr.getServers()).andStubReturn(registeredServers);
    expect(bus.getExtension(ServerRegistry.class)).andStubReturn(sr);
    return null;
}
Also used : ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 3 with ServerRegistry

use of org.apache.cxf.endpoint.ServerRegistry in project tesb-rt-se by Talend.

the class SingleBusLocatorRegistrarTest method addRegisteredServers.

private Bus addRegisteredServers(Bus bus, List<Server> registeredServers) {
    ServerRegistry sr = createMock(ServerRegistry.class);
    expect(sr.getServers()).andStubReturn(registeredServers);
    expect(bus.getExtension(ServerRegistry.class)).andStubReturn(sr);
    return null;
}
Also used : ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 4 with ServerRegistry

use of org.apache.cxf.endpoint.ServerRegistry in project tesb-rt-se by Talend.

the class SingleBusLocatorRegistrar method registerAvailableServers.

private void registerAvailableServers() {
    ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
    List<Server> servers = serverRegistry.getServers();
    for (Server server : servers) {
        registerServer(server);
    }
}
Also used : Server(org.apache.cxf.endpoint.Server) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 5 with ServerRegistry

use of org.apache.cxf.endpoint.ServerRegistry 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();
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SamlHeaderInHandler(org.apache.cxf.rs.security.saml.SamlHeaderInHandler) JAASAuthenticationFilter(org.apache.cxf.jaxrs.security.JAASAuthenticationFilter) List(java.util.List)

Aggregations

ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)23 Server (org.apache.cxf.endpoint.Server)18 Bus (org.apache.cxf.Bus)13 ArrayList (java.util.ArrayList)5 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)5 HashMap (java.util.HashMap)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Test (org.junit.Test)4 Fault (org.apache.cxf.interceptor.Fault)3 List (java.util.List)2 PostConstruct (javax.annotation.PostConstruct)2 JMException (javax.management.JMException)2 QName (javax.xml.namespace.QName)2 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)2 JAASAuthenticationFilter (org.apache.cxf.jaxrs.security.JAASAuthenticationFilter)2 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)2 InstrumentationManagerImpl (org.apache.cxf.management.jmx.InstrumentationManagerImpl)2 Exchange (org.apache.cxf.message.Exchange)2 SamlHeaderInHandler (org.apache.cxf.rs.security.saml.SamlHeaderInHandler)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2