本文整理汇总了Java中org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier类的典型用法代码示例。如果您正苦于以下问题:Java DefaultBasicAuthSupplier类的具体用法?Java DefaultBasicAuthSupplier怎么用?Java DefaultBasicAuthSupplier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultBasicAuthSupplier类属于org.apache.cxf.transport.http.auth包,在下文中一共展示了DefaultBasicAuthSupplier类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: proxyFor
点赞 2
import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier; //导入依赖的package包/类
/**
* Creates a proxy for the given interface without
* @param <T> The type bound to the service interface
* @param serviceInterface The service interface
* @return The proxy for the given interface
*/
@SuppressWarnings("unchecked")
public synchronized <T> T proxyFor(final Class<T> serviceInterface) {
// Check for a cached instance
final Object cached = cachedProxies.get(serviceInterface);
if (cached != null) {
return (T) cached;
}
// Cache miss. Create the proxy
final String url = resolveUrlFor(serviceInterface);
if (url == null) {
throw new IllegalStateException("Cannot resolve url for service " + serviceInterface.getName() + " for server root url " + serverRootUrl);
}
// Create a proxy factory
final JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(serviceInterface);
factory.setAddress(url);
// Create the proxy
final Object proxy = factory.create();
final Client client = ClientProxy.getClient(proxy);
final HTTPConduit http = (HTTPConduit) client.getConduit();
// If the username / password are set, use them
if (username != null || password != null) {
final AuthorizationPolicy authorization = new AuthorizationPolicy();
authorization.setUserName(username);
authorization.setPassword(password);
http.setAuthorization(authorization);
http.setAuthSupplier(new DefaultBasicAuthSupplier());
}
http.setTlsClientParameters(getTLSClientParameters());
http.getClient().setConnectionTimeout(connectionTimeout);
http.getClient().setReceiveTimeout(readTimeout);
// The proxy is ready. Store it on the cache
cachedProxies.put(serviceInterface, proxy);
return (T) proxy;
}
开发者ID:mateli,
项目名称:OpenCyclos,
代码行数:50,
代码来源:CyclosWebServicesClientFactory.java