Search in sources :

Example 16 with Server

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();
}
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) Map(java.util.Map) HashMap(java.util.HashMap)

Example 17 with Server

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;
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry)

Example 18 with Server

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);
}
Also used : Server(org.apache.cxf.endpoint.Server) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 19 with Server

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);
            }
        }
    }
}
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) ManagedEndpoint(org.apache.cxf.endpoint.ManagedEndpoint) InstrumentationManager(org.apache.cxf.management.InstrumentationManager)

Example 20 with Server

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);
            }
        }
    });
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) Server(org.apache.cxf.endpoint.Server) FactoryBeanListener(org.apache.cxf.service.factory.FactoryBeanListener) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager)

Aggregations

Server (org.apache.cxf.endpoint.Server)199 Test (org.junit.Test)119 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)52 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 Resource (org.apache.cxf.ws.transfer.resource.Resource)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)44 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)33 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 Service (org.apache.cxf.service.Service)27 Bus (org.apache.cxf.Bus)25 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Endpoint (org.apache.cxf.endpoint.Endpoint)21 ArrayList (java.util.ArrayList)18 QName (javax.xml.namespace.QName)18 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)18 Document (org.w3c.dom.Document)18