本文整理汇总了Java中org.apache.http.config.Lookup.lookup方法的典型用法代码示例。如果您正苦于以下问题:Java Lookup.lookup方法的具体用法?Java Lookup.lookup怎么用?Java Lookup.lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.http.config.Lookup
的用法示例。
在下文中一共展示了Lookup.lookup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: upgrade
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
public void upgrade(
final ManagedHttpClientConnection conn,
final HttpHost host,
final HttpContext context) throws IOException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
if (sf == null) {
throw new UnsupportedSchemeException(host.getSchemeName() +
" protocol is not supported");
}
if (!(sf instanceof LayeredConnectionSocketFactory)) {
throw new UnsupportedSchemeException(host.getSchemeName() +
" protocol does not support connection upgrade");
}
final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
Socket sock = conn.getSocket();
final int port = this.schemePortResolver.resolve(host);
sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
conn.bind(sock);
}
示例2: upgrade
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
@Override
public void upgrade(
final ManagedHttpClientConnection conn,
final HttpHost host,
final HttpContext context) throws IOException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(clientContext);
final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName());
if (sf == null) {
throw new UnsupportedSchemeException(host.getSchemeName() +
" protocol is not supported");
}
if (!(sf instanceof LayeredConnectionSocketFactory)) {
throw new UnsupportedSchemeException(host.getSchemeName() +
" protocol does not support connection upgrade");
}
final LayeredConnectionSocketFactory lsf = (LayeredConnectionSocketFactory) sf;
Socket sock = conn.getSocket();
final int port = this.schemePortResolver.resolve(host);
sock = lsf.createLayeredSocket(sock, host.getHostName(), port, context);
conn.bind(sock);
}
示例3: select
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
@Override
public Queue<AuthOption> select(final Map<String, Header> challenges, final HttpHost authhost, final HttpResponse response, final HttpContext context) throws MalformedChallengeException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if(registry == null) {
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
Collection<String> authPrefs = config.getProxyPreferredAuthSchemes();
if(authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if(log.isDebugEnabled()) {
log.debug("Authentication schemes in the order of preference: " + authPrefs);
}
for(final String id : authPrefs) {
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
if(challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if(authSchemeProvider == null) {
continue;
}
final AuthScheme authScheme = authSchemeProvider.create(context);
authScheme.processChallenge(challenge);
final Credentials saved = keychain.getCredentials(authhost.getHostName());
if(StringUtils.isEmpty(saved.getPassword())) {
try {
final Credentials input = prompt.prompt(bookmark,
StringUtils.EMPTY,
String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), authhost.getHostName()),
authScheme.getRealm(),
new LoginOptions()
.icon(bookmark.getProtocol().disk())
.usernamePlaceholder(LocaleFactory.localizedString("Username", "Credentials"))
.passwordPlaceholder(LocaleFactory.localizedString("Password", "Credentials"))
.user(true).password(true)
);
if(input.isSaved()) {
context.setAttribute(PROXY_CREDENTIALS_INPUT_ID, input);
}
options.add(new AuthOption(authScheme, new NTCredentials(input.getUsername(), input.getPassword(),
preferences.getProperty("webdav.ntlm.workstation"), preferences.getProperty("webdav.ntlm.domain"))));
}
catch(LoginCanceledException ignored) {
// Ignore dismiss of prompt
throw new MalformedChallengeException(ignored.getMessage(), ignored);
}
}
else {
options.add(new AuthOption(authScheme, new NTCredentials(saved.getUsername(), saved.getPassword(),
preferences.getProperty("webdav.ntlm.workstation"), preferences.getProperty("webdav.ntlm.domain"))));
}
}
else {
if(log.isDebugEnabled()) {
log.debug("Challenge for " + id + " authentication scheme not available");
// Try again
}
}
}
return options;
}
示例4: select
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
public Queue<AuthOption> select(
final Map<String, Header> challenges,
final HttpHost authhost,
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
Args.notNull(challenges, "Map of auth challenges");
Args.notNull(authhost, "Host");
Args.notNull(response, "HTTP response");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if (registry == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Auth scheme registry not set in the context");
}
return options;
}
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Credentials provider not set in the context");
}
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
Collection<String> authPrefs = getPreferredAuthSchemes(config);
if (authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Authentication schemes in the order of preference: " + authPrefs);
}
for (final String id: authPrefs) {
final Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if (authSchemeProvider == null) {
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "Authentication scheme " + id + " not supported");
// Try again
}
continue;
}
final AuthScheme authScheme = authSchemeProvider.create(context);
authScheme.processChallenge(challenge);
final AuthScope authScope = new AuthScope(
authhost.getHostName(),
authhost.getPort(),
authScheme.getRealm(),
authScheme.getSchemeName());
final Credentials credentials = credsProvider.getCredentials(authScope);
if (credentials != null) {
options.add(new AuthOption(authScheme, credentials));
}
} else {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Challenge for " + id + " authentication scheme not available");
// Try again
}
}
}
return options;
}
示例5: select
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
@Override
public Queue<AuthOption> select(
final Map<String, Header> challenges,
final HttpHost authhost,
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
Args.notNull(challenges, "Map of auth challenges");
Args.notNull(authhost, "Host");
Args.notNull(response, "HTTP response");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if (registry == null) {
this.log.debug("Auth scheme registry not set in the context");
return options;
}
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
this.log.debug("Credentials provider not set in the context");
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
Collection<String> authPrefs = getPreferredAuthSchemes(config);
if (authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if (this.log.isDebugEnabled()) {
this.log.debug("Authentication schemes in the order of preference: " + authPrefs);
}
for (final String id: authPrefs) {
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
if (challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if (authSchemeProvider == null) {
if (this.log.isWarnEnabled()) {
this.log.warn("Authentication scheme " + id + " not supported");
// Try again
}
continue;
}
final AuthScheme authScheme = authSchemeProvider.create(context);
authScheme.processChallenge(challenge);
final AuthScope authScope = new AuthScope(
authhost.getHostName(),
authhost.getPort(),
authScheme.getRealm(),
authScheme.getSchemeName());
final Credentials credentials = credsProvider.getCredentials(authScope);
if (credentials != null) {
options.add(new AuthOption(authScheme, credentials));
}
} else {
if (this.log.isDebugEnabled()) {
this.log.debug("Challenge for " + id + " authentication scheme not available");
// Try again
}
}
}
return options;
}
示例6: getX509TrustManager
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
private X509TrustManager getX509TrustManager(
Lookup<ConnectionSocketFactory> socketFactoryRegistry) {
ConnectionSocketFactory connectionSocketFactory = socketFactoryRegistry
.lookup("https");
SSLSocketFactory sslSocketFactory = getField(connectionSocketFactory,
"socketfactory");
SSLContextSpi sslContext = getField(sslSocketFactory, "context");
return getField(sslContext, "trustManager");
}
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:10,代码来源:DefaultApacheHttpClientConnectionManagerFactoryTests.java
示例7: getAuthSchemeProvider
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
private AuthSchemeProvider getAuthSchemeProvider(String authType) {
AuthTypes authTypes = new AuthTypes(authType);
Lookup<AuthSchemeProvider> lookup = new AuthSchemeProviderLookupBuilder()
.setHeaders(new ArrayList<Header>())
.setAuthTypes(authTypes)
.buildAuthSchemeProviderLookup();
return lookup.lookup(authType);
}
示例8: getX509TrustManager
import org.apache.http.config.Lookup; //导入方法依赖的package包/类
private X509TrustManager getX509TrustManager(Lookup<ConnectionSocketFactory> socketFactoryRegistry) {
ConnectionSocketFactory connectionSocketFactory = (ConnectionSocketFactory)socketFactoryRegistry.lookup("https");
SSLSocketFactory sslSocketFactory = (SSLSocketFactory)this.getField(connectionSocketFactory, "socketfactory");
SSLContextSpi sslContext = (SSLContextSpi)this.getField(sslSocketFactory, "context");
return (X509TrustManager)this.getField(sslContext, "trustManager");
}