Search in sources :

Example 1 with ResourceManager

use of org.apache.cxf.resource.ResourceManager in project camel by apache.

the class CxfEndpoint method setupHandlers.

protected void setupHandlers(ClientFactoryBean factoryBean, Client client) throws Exception {
    if (factoryBean instanceof JaxWsClientFactoryBean && handlers != null) {
        AnnotationHandlerChainBuilder builder = new AnnotationHandlerChainBuilder();
        Method m = factoryBean.getClass().getMethod("getServiceFactory");
        JaxWsServiceFactoryBean sf = (JaxWsServiceFactoryBean) m.invoke(factoryBean);
        @SuppressWarnings("rawtypes") List<Handler> chain = new ArrayList<Handler>(handlers);
        chain.addAll(builder.buildHandlerChainFromClass(sf.getServiceClass(), sf.getEndpointInfo().getName(), sf.getServiceQName(), factoryBean.getBindingId()));
        if (!chain.isEmpty()) {
            ResourceManager resourceManager = getBus().getExtension(ResourceManager.class);
            List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
            resourceManager = new DefaultResourceManager(resolvers);
            resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
            ResourceInjector injector = new ResourceInjector(resourceManager);
            for (Handler<?> h : chain) {
                if (Proxy.isProxyClass(h.getClass()) && getServiceClass() != null) {
                    injector.inject(h, getServiceClass());
                    injector.construct(h, getServiceClass());
                } else {
                    injector.inject(h);
                    injector.construct(h);
                }
            }
        }
        ((JaxWsEndpointImpl) client.getEndpoint()).getJaxwsBinding().setHandlerChain(chain);
    }
}
Also used : JaxWsClientFactoryBean(org.apache.cxf.jaxws.JaxWsClientFactoryBean) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) AnnotationHandlerChainBuilder(org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder) ModCountCopyOnWriteArrayList(org.apache.cxf.common.util.ModCountCopyOnWriteArrayList) ArrayList(java.util.ArrayList) CookieHandler(org.apache.camel.http.common.cookie.CookieHandler) Handler(javax.xml.ws.handler.Handler) Method(java.lang.reflect.Method) ResourceManager(org.apache.cxf.resource.ResourceManager) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)

Example 2 with ResourceManager

use of org.apache.cxf.resource.ResourceManager in project tomee by apache.

the class PojoEndpoint method injectCxfResources.

private ResourceInjector injectCxfResources(final Object implementor) {
    ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
    final List<ResourceResolver> resolvers = resourceManager.getResourceResolvers();
    resourceManager = new DefaultResourceManager(resolvers);
    if (!resourceManager.getResourceResolvers().contains(WEB_SERVICE_CONTEXT_RESOURCE_RESOLVER)) {
        resourceManager.addResourceResolver(WEB_SERVICE_CONTEXT_RESOURCE_RESOLVER);
    }
    final ResourceInjector injector = new ResourceInjector(resourceManager);
    injector.inject(implementor);
    return injector;
}
Also used : DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceResolver(org.apache.cxf.resource.ResourceResolver) WebServiceContextResourceResolver(org.apache.cxf.jaxws.context.WebServiceContextResourceResolver) DefaultResourceManager(org.apache.cxf.resource.DefaultResourceManager) ResourceManager(org.apache.cxf.resource.ResourceManager) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector)

Example 3 with ResourceManager

use of org.apache.cxf.resource.ResourceManager in project ddf by codice.

the class StaticStsProperties method configureProperties.

/**
     * Load the CallbackHandler, Crypto objects, if necessary.
     */
public void configureProperties() throws STSException {
    if (signatureCrypto == null && signatureCryptoProperties != null) {
        Properties sigProperties = null;
        if (signatureCryptoProperties instanceof Properties) {
            sigProperties = (Properties) signatureCryptoProperties;
        } else {
            ResourceManager resourceManager = getResourceManager();
            URL url = SecurityUtils.loadResource(resourceManager, signatureCryptoProperties);
            sigProperties = SecurityUtils.loadProperties(url);
        }
        if (sigProperties == null) {
            LOG.fine("Cannot load signature properties using: " + signatureCryptoProperties);
            throw new STSException("Configuration error: cannot load signature properties");
        }
        try {
            signatureCrypto = CryptoFactory.getInstance(sigProperties);
        } catch (WSSecurityException ex) {
            LOG.fine("Error in loading the signature Crypto object: " + ex.getMessage());
            throw new STSException(ex.getMessage());
        }
    }
    if (encryptionCrypto == null && encryptionCryptoProperties != null) {
        Properties encrProperties = null;
        if (encryptionCryptoProperties instanceof Properties) {
            encrProperties = (Properties) encryptionCryptoProperties;
        } else {
            ResourceManager resourceManager = getResourceManager();
            URL url = SecurityUtils.loadResource(resourceManager, encryptionCryptoProperties);
            encrProperties = SecurityUtils.loadProperties(url);
        }
        if (encrProperties == null) {
            LOG.fine("Cannot load encryption properties using: " + encryptionCryptoProperties);
            throw new STSException("Configuration error: cannot load encryption properties");
        }
        try {
            encryptionCrypto = CryptoFactory.getInstance(encrProperties);
        } catch (WSSecurityException ex) {
            LOG.fine("Error in loading the encryption Crypto object: " + ex.getMessage());
            throw new STSException(ex.getMessage());
        }
    }
    if (callbackHandler == null && callbackHandlerClass != null) {
        try {
            callbackHandler = SecurityUtils.getCallbackHandler(callbackHandlerClass);
            if (callbackHandler == null) {
                LOG.fine("Cannot load CallbackHandler using: " + callbackHandlerClass);
                throw new STSException("Configuration error: cannot load callback handler");
            }
        } catch (Exception ex) {
            LOG.fine("Error in loading the callback handler: " + ex.getMessage());
            throw new STSException(ex.getMessage());
        }
    }
    WSSConfig.init();
}
Also used : STSException(org.apache.cxf.ws.security.sts.provider.STSException) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) ResourceManager(org.apache.cxf.resource.ResourceManager) StaticSTSProperties(org.apache.cxf.sts.StaticSTSProperties) Properties(java.util.Properties) EncryptionProperties(org.apache.cxf.sts.service.EncryptionProperties) SignatureProperties(org.apache.cxf.sts.SignatureProperties) URL(java.net.URL) STSException(org.apache.cxf.ws.security.sts.provider.STSException) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException)

Aggregations

ResourceManager (org.apache.cxf.resource.ResourceManager)3 ResourceInjector (org.apache.cxf.common.injection.ResourceInjector)2 WebServiceContextResourceResolver (org.apache.cxf.jaxws.context.WebServiceContextResourceResolver)2 DefaultResourceManager (org.apache.cxf.resource.DefaultResourceManager)2 ResourceResolver (org.apache.cxf.resource.ResourceResolver)2 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Handler (javax.xml.ws.handler.Handler)1 CookieHandler (org.apache.camel.http.common.cookie.CookieHandler)1 ModCountCopyOnWriteArrayList (org.apache.cxf.common.util.ModCountCopyOnWriteArrayList)1 JaxWsClientFactoryBean (org.apache.cxf.jaxws.JaxWsClientFactoryBean)1 AnnotationHandlerChainBuilder (org.apache.cxf.jaxws.handler.AnnotationHandlerChainBuilder)1 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)1 SignatureProperties (org.apache.cxf.sts.SignatureProperties)1 StaticSTSProperties (org.apache.cxf.sts.StaticSTSProperties)1 EncryptionProperties (org.apache.cxf.sts.service.EncryptionProperties)1 STSException (org.apache.cxf.ws.security.sts.provider.STSException)1 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)1