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);
}
}
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;
}
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();
}
}
}
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);
}
}
}
}
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);
}
}
Aggregations