Search in sources :

Example 1 with EndpointException

use of org.apache.cxf.endpoint.EndpointException in project OpenAM by OpenRock.

the class SoapSTSConsumer method handleSTSServerCertCNDNSMismatch.

/**
     * This method must be called in case the CN in the Certificate presented by the container hosting the published sts
     * instance does not match the DNS name of this server. This check should not be relied-upon in production, and is
     * only present to facilitate testing.
     * @param stsClient The stsClient which will make the sts invocations
     */
private void handleSTSServerCertCNDNSMismatch(STSClient stsClient) throws SoapSTSConsumerException {
    javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {

        public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
            return true;
        }
    });
    /*
        CXF client also needs to have disabled the CN check in server-presented cert for TLS cases, if cert CN
        does not match DNS
         */
    TLSClientParameters tlsClientParameters = new TLSClientParameters();
    tlsClientParameters.setDisableCNCheck(true);
    try {
        ((HTTPConduit) stsClient.getClient().getConduit()).setTlsClientParameters(tlsClientParameters);
    } catch (BusException | EndpointException e) {
        throw new SoapSTSConsumerException(e.getMessage(), e);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) EndpointException(org.apache.cxf.endpoint.EndpointException) BusException(org.apache.cxf.BusException)

Example 2 with EndpointException

use of org.apache.cxf.endpoint.EndpointException in project cxf by apache.

the class ClientFactoryBean method create.

public Client create() {
    getServiceFactory().reset();
    if (getServiceFactory().getProperties() == null) {
        getServiceFactory().setProperties(properties);
    } else if (properties != null) {
        getServiceFactory().getProperties().putAll(properties);
    }
    final Client client;
    final Endpoint ep;
    try {
        ep = createEndpoint();
        this.getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_CLIENT_CREATE, ep);
        applyProperties(ep);
        client = createClient(ep);
        initializeAnnotationInterceptors(ep, getServiceClass());
    } catch (EndpointException | BusException e) {
        throw new ServiceConstructionException(e);
    }
    applyFeatures(client);
    this.getServiceFactory().sendEvent(FactoryBeanListener.Event.CLIENT_CREATED, client, ep);
    return client;
}
Also used : Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointException(org.apache.cxf.endpoint.EndpointException) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) Client(org.apache.cxf.endpoint.Client) BusException(org.apache.cxf.BusException)

Example 3 with EndpointException

use of org.apache.cxf.endpoint.EndpointException in project cxf by apache.

the class ServerFactoryBean method create.

public Server create() {
    ClassLoaderHolder orig = null;
    try {
        Server server = null;
        try {
            if (bus != null) {
                ClassLoader loader = bus.getExtension(ClassLoader.class);
                if (loader != null) {
                    orig = ClassLoaderUtils.setThreadContextClassloader(loader);
                }
            }
            if (getServiceFactory().getProperties() == null) {
                getServiceFactory().setProperties(getProperties());
            } else if (getProperties() != null) {
                getServiceFactory().getProperties().putAll(getProperties());
            }
            if (serviceBean != null && getServiceClass() == null) {
                setServiceClass(ClassHelper.getRealClass(bus, serviceBean));
            }
            if (invoker != null) {
                getServiceFactory().setInvoker(invoker);
            } else if (serviceBean != null) {
                invoker = createInvoker();
                getServiceFactory().setInvoker(invoker);
            }
            Endpoint ep = createEndpoint();
            getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_SERVER_CREATE, server, serviceBean, serviceBean == null ? getServiceClass() == null ? getServiceFactory().getServiceClass() : getServiceClass() : getServiceClass() == null ? ClassHelper.getRealClass(getBus(), getServiceBean()) : getServiceClass());
            server = new ServerImpl(getBus(), ep, getDestinationFactory(), getBindingFactory());
            if (ep.getService().getInvoker() == null) {
                if (invoker == null) {
                    ep.getService().setInvoker(createInvoker());
                } else {
                    ep.getService().setInvoker(invoker);
                }
            }
        } catch (EndpointException | BusException | IOException e) {
            throw new ServiceConstructionException(e);
        }
        if (serviceBean != null) {
            Class<?> cls = ClassHelper.getRealClass(getServiceBean());
            if (getServiceClass() == null || cls.equals(getServiceClass())) {
                initializeAnnotationInterceptors(server.getEndpoint(), cls);
            } else {
                initializeAnnotationInterceptors(server.getEndpoint(), cls, getServiceClass());
            }
        } else if (getServiceClass() != null) {
            initializeAnnotationInterceptors(server.getEndpoint(), getServiceClass());
        }
        applyFeatures(server);
        getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED, server, serviceBean, serviceBean == null ? getServiceClass() == null ? getServiceFactory().getServiceClass() : getServiceClass() : getServiceClass() == null ? ClassHelper.getRealClass(getServiceBean()) : getServiceClass());
        if (start) {
            try {
                server.start();
            } catch (RuntimeException re) {
                // prevent resource leak
                server.destroy();
                throw re;
            }
        }
        getServiceFactory().reset();
        return server;
    } finally {
        if (orig != null) {
            orig.reset();
        }
    }
}
Also used : Server(org.apache.cxf.endpoint.Server) Endpoint(org.apache.cxf.endpoint.Endpoint) ServerImpl(org.apache.cxf.endpoint.ServerImpl) EndpointException(org.apache.cxf.endpoint.EndpointException) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder) IOException(java.io.IOException) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Example 4 with EndpointException

use of org.apache.cxf.endpoint.EndpointException in project cxf by apache.

the class ReflectionServiceFactoryBean method createEndpoints.

protected void createEndpoints() {
    Service service = getService();
    BindingFactoryManager bfm = getBus().getExtension(BindingFactoryManager.class);
    for (ServiceInfo inf : service.getServiceInfos()) {
        for (EndpointInfo ei : inf.getEndpoints()) {
            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
                updateBindingOperation(boi);
            }
            try {
                bfm.getBindingFactory(ei.getBinding().getBindingId());
            } catch (BusException e1) {
                continue;
            }
            try {
                Endpoint ep = createEndpoint(ei);
                service.getEndpoints().put(ei.getName(), ep);
            } catch (EndpointException e) {
                throw new ServiceConstructionException(e);
            }
        }
    }
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointException(org.apache.cxf.endpoint.EndpointException) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) BusException(org.apache.cxf.BusException)

Example 5 with EndpointException

use of org.apache.cxf.endpoint.EndpointException in project cxf by apache.

the class ServiceImpl method getJaxwsEndpoint.

private JaxWsClientEndpointImpl getJaxwsEndpoint(QName portName, AbstractServiceFactoryBean sf, WebServiceFeature... features) {
    Service service = sf.getService();
    EndpointInfo ei;
    if (portName == null) {
        ei = service.getServiceInfos().get(0).getEndpoints().iterator().next();
    } else {
        ei = service.getEndpointInfo(portName);
        if (ei == null) {
            PortInfoImpl portInfo = getPortInfo(portName);
            if (null != portInfo) {
                try {
                    ei = createEndpointInfo(sf, portName, portInfo);
                } catch (BusException e) {
                    throw new WebServiceException(e);
                }
            }
        }
    }
    if (ei == null) {
        Message msg = new Message("INVALID_PORT", BUNDLE, portName);
        throw new WebServiceException(msg.toString());
    }
    // When the dispatch is created from EPR, the EPR's address will be set in portInfo
    PortInfoImpl portInfo = getPortInfo(portName);
    if (portInfo != null && portInfo.getAddress() != null && !portInfo.getAddress().equals(ei.getAddress())) {
        ei.setAddress(portInfo.getAddress());
    }
    try {
        return new JaxWsClientEndpointImpl(bus, service, ei, this, getAllFeatures(features));
    } catch (EndpointException e) {
        throw new WebServiceException(e);
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.common.i18n.Message) JaxWsClientEndpointImpl(org.apache.cxf.jaxws.support.JaxWsClientEndpointImpl) EndpointException(org.apache.cxf.endpoint.EndpointException) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) PortInfoImpl(org.apache.cxf.jaxws.handler.PortInfoImpl) BusException(org.apache.cxf.BusException)

Aggregations

BusException (org.apache.cxf.BusException)5 EndpointException (org.apache.cxf.endpoint.EndpointException)5 Endpoint (org.apache.cxf.endpoint.Endpoint)3 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)3 Service (org.apache.cxf.service.Service)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 IOException (java.io.IOException)1 WebService (javax.jws.WebService)1 WebServiceException (javax.xml.ws.WebServiceException)1 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)1 ClassLoaderHolder (org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder)1 Message (org.apache.cxf.common.i18n.Message)1 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)1 Client (org.apache.cxf.endpoint.Client)1 Server (org.apache.cxf.endpoint.Server)1 ServerImpl (org.apache.cxf.endpoint.ServerImpl)1 PortInfoImpl (org.apache.cxf.jaxws.handler.PortInfoImpl)1 JaxWsClientEndpointImpl (org.apache.cxf.jaxws.support.JaxWsClientEndpointImpl)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1