当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationStrategy类代码示例

本文整理汇总了Java中org.apache.http.client.AuthenticationStrategy的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationStrategy类的具体用法?Java AuthenticationStrategy怎么用?Java AuthenticationStrategy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AuthenticationStrategy类属于org.apache.http.client包,在下文中一共展示了AuthenticationStrategy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isAuthenticationRequested

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public boolean isAuthenticationRequested(
        final HttpHost host,
        final HttpResponse response,
        final AuthenticationStrategy authStrategy,
        final AuthState authState,
        final HttpContext context) {
    if (authStrategy.isAuthenticationRequested(host, response, context)) {
        return true;
    } else {
        switch (authState.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            authState.setState(AuthProtocolState.SUCCESS);
            authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
            break;
        case SUCCESS:
            break;
        default:
            authState.setState(AuthProtocolState.UNCHALLENGED);
        }
        return false;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:HttpAuthenticator.java

示例2: createMainExec

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
/**
 * Produces an instance of {@link ClientExecChain} to be used as a main exec.
 * <p>
 * Default implementation produces an instance of {@link MainClientExec}
 * </p>
 * <p>
 * For internal use.
 * </p>
 *
 * @since 4.4
 */
protected ClientExecChain createMainExec(
        final HttpRequestExecutor requestExec,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy,
        final HttpProcessor proxyHttpProcessor,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler)
{
    return new MainClientExec(
            requestExec,
            connManager,
            reuseStrategy,
            keepAliveStrategy,
            proxyHttpProcessor,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:32,代码来源:HttpClientBuilder.java

示例3: setUp

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.defltAuthStrategy = Mockito.mock(AuthenticationStrategy.class);
    this.authState = new AuthState();
    this.authScheme = Mockito.mock(ContextAwareAuthScheme.class);
    Mockito.when(this.authScheme.getSchemeName()).thenReturn("Basic");
    Mockito.when(this.authScheme.isComplete()).thenReturn(Boolean.TRUE);
    this.context = new BasicHttpContext();
    this.defaultHost = new HttpHost("localhost", 80);
    this.context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.defaultHost);
    this.credentials = Mockito.mock(Credentials.class);
    this.credentialsProvider = new BasicCredentialsProvider();
    this.credentialsProvider.setCredentials(AuthScope.ANY, this.credentials);
    this.context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider);
    this.authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
        .register("basic", new BasicSchemeFactory())
        .register("digest", new DigestSchemeFactory())
        .register("ntlm", new NTLMSchemeFactory()).build();
    this.context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
    this.authCache = Mockito.mock(AuthCache.class);
    this.context.setAttribute(HttpClientContext.AUTH_CACHE, this.authCache);
    this.httpAuthenticator = new HttpAuthenticator();
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestHttpAuthenticator.java

示例4: getTargetAuthenticationStrategy

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
/**
 * @since 4.2
 */
public synchronized final AuthenticationStrategy getTargetAuthenticationStrategy() {
    if (targetAuthStrategy == null) {
        targetAuthStrategy = createTargetAuthenticationStrategy();
    }
    return targetAuthStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractHttpClient.java

示例5: getProxyAuthenticationStrategy

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
/**
 * @since 4.2
 */
public synchronized final AuthenticationStrategy getProxyAuthenticationStrategy() {
    if (proxyAuthStrategy == null) {
        proxyAuthStrategy = createProxyAuthenticationStrategy();
    }
    return proxyAuthStrategy;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:AbstractHttpClient.java

示例6: createClientRequestDirector

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
/**
 * @since 4.2
 */
protected RequestDirector createClientRequestDirector(
        final HttpRequestExecutor requestExec,
        final ClientConnectionManager conman,
        final ConnectionReuseStrategy reustrat,
        final ConnectionKeepAliveStrategy kastrat,
        final HttpRoutePlanner rouplan,
        final HttpProcessor httpProcessor,
        final HttpRequestRetryHandler retryHandler,
        final RedirectStrategy redirectStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler,
        final HttpParams params) {
    return new DefaultRequestDirector(
            log,
            requestExec,
            conman,
            reustrat,
            kastrat,
            rouplan,
            httpProcessor,
            retryHandler,
            redirectStrategy,
            targetAuthStrategy,
            proxyAuthStrategy,
            userTokenHandler,
            params);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:AbstractHttpClient.java

示例7: isAuthenticationRequested

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public boolean isAuthenticationRequested(
        final HttpHost host,
        final HttpResponse response,
        final AuthenticationStrategy authStrategy,
        final AuthStateHC4 authState,
        final HttpContext context) {
    if (authStrategy.isAuthenticationRequested(host, response, context)) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "Authentication required");
        }
        if (authState.getState() == AuthProtocolState.SUCCESS) {
            authStrategy.authFailed(host, authState.getAuthScheme(), context);
        }
        return true;
    } else {
        switch (authState.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                Log.d(TAG, "Authentication succeeded");
            }
            authState.setState(AuthProtocolState.SUCCESS);
            authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
            break;
        case SUCCESS:
            break;
        default:
            authState.setState(AuthProtocolState.UNCHALLENGED);
        }
        return false;
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:33,代码来源:HttpAuthenticator.java

示例8: MainClientExec

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public MainClientExec(
        final HttpRequestExecutor requestExecutor,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler) {
    Args.notNull(requestExecutor, "HTTP request executor");
    Args.notNull(connManager, "Client connection manager");
    Args.notNull(reuseStrategy, "Connection reuse strategy");
    Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
    Args.notNull(targetAuthStrategy, "Target authentication strategy");
    Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
    Args.notNull(userTokenHandler, "User token handler");
    this.authenticator      = new HttpAuthenticator();
    this.proxyHttpProcessor = new ImmutableHttpProcessor(
            new RequestTargetHostHC4(), new RequestClientConnControl());
    this.routeDirector      = new BasicRouteDirector();
    this.requestExecutor    = requestExecutor;
    this.connManager        = connManager;
    this.reuseStrategy      = reuseStrategy;
    this.keepAliveStrategy  = keepAliveStrategy;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy  = proxyAuthStrategy;
    this.userTokenHandler   = userTokenHandler;
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:28,代码来源:MainClientExec.java

示例9: authenticate

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public boolean authenticate (
        final HttpHost host,
        final HttpResponse response,
        final AuthenticationStrategy authStrategy,
        final AuthState authState,
        final HttpContext context) {
    return handleAuthChallenge(host, response, authStrategy, authState, context);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:HttpAuthenticator.java

示例10: isAuthenticationRequested

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public boolean isAuthenticationRequested(
        final HttpHost host,
        final HttpResponse response,
        final AuthenticationStrategy authStrategy,
        final AuthState authState,
        final HttpContext context) {
    if (authStrategy.isAuthenticationRequested(host, response, context)) {
        this.log.debug("Authentication required");
        if (authState.getState() == AuthProtocolState.SUCCESS) {
            authStrategy.authFailed(host, authState.getAuthScheme(), context);
        }
        return true;
    } else {
        switch (authState.getState()) {
        case CHALLENGED:
        case HANDSHAKE:
            this.log.debug("Authentication succeeded");
            authState.setState(AuthProtocolState.SUCCESS);
            authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
            break;
        case SUCCESS:
            break;
        default:
            authState.setState(AuthProtocolState.UNCHALLENGED);
        }
        return false;
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:29,代码来源:HttpAuthenticator.java

示例11: MainClientExec

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
/**
 * @since 4.4
 */
public MainClientExec(
        final HttpRequestExecutor requestExecutor,
        final HttpClientConnectionManager connManager,
        final ConnectionReuseStrategy reuseStrategy,
        final ConnectionKeepAliveStrategy keepAliveStrategy,
        final HttpProcessor proxyHttpProcessor,
        final AuthenticationStrategy targetAuthStrategy,
        final AuthenticationStrategy proxyAuthStrategy,
        final UserTokenHandler userTokenHandler) {
    Args.notNull(requestExecutor, "HTTP request executor");
    Args.notNull(connManager, "Client connection manager");
    Args.notNull(reuseStrategy, "Connection reuse strategy");
    Args.notNull(keepAliveStrategy, "Connection keep alive strategy");
    Args.notNull(proxyHttpProcessor, "Proxy HTTP processor");
    Args.notNull(targetAuthStrategy, "Target authentication strategy");
    Args.notNull(proxyAuthStrategy, "Proxy authentication strategy");
    Args.notNull(userTokenHandler, "User token handler");
    this.authenticator      = new HttpAuthenticator();
    this.routeDirector      = new BasicRouteDirector();
    this.requestExecutor    = requestExecutor;
    this.connManager        = connManager;
    this.reuseStrategy      = reuseStrategy;
    this.keepAliveStrategy  = keepAliveStrategy;
    this.proxyHttpProcessor = proxyHttpProcessor;
    this.targetAuthStrategy = targetAuthStrategy;
    this.proxyAuthStrategy  = proxyAuthStrategy;
    this.userTokenHandler   = userTokenHandler;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:32,代码来源:MainClientExec.java

示例12: initializeHttpClient

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
private void initializeHttpClient() {
  Registry<ConnectionSocketFactory> registry = createConnectionSocketFactoryRegistry();
  HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry);
  AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy();

  httpClient = HttpClients.custom()
    .setConnectionManager(httpConnectionManager)
    .setTargetAuthenticationStrategy(authStrategy)
    .build();
}
 
开发者ID:OfficeDev,项目名称:ews-java-api,代码行数:11,代码来源:ExchangeServiceBase.java

示例13: initializeHttpPoolingClient

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
private void initializeHttpPoolingClient() {
  Registry<ConnectionSocketFactory> registry = createConnectionSocketFactoryRegistry();
  PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry);
  httpConnectionManager.setMaxTotal(maximumPoolingConnections);
  httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections);
  AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy();

  httpPoolingClient = HttpClients.custom()
      .setConnectionManager(httpConnectionManager)
      .setTargetAuthenticationStrategy(authStrategy)
      .build();
}
 
开发者ID:OfficeDev,项目名称:ews-java-api,代码行数:13,代码来源:ExchangeServiceBase.java

示例14: createClientRequestDirector

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
@Override
protected RequestDirector createClientRequestDirector(HttpRequestExecutor requestExec,
                                                      ClientConnectionManager conman,
                                                      ConnectionReuseStrategy reustrat,
                                                      ConnectionKeepAliveStrategy kastrat,
                                                      HttpRoutePlanner rouplan,
                                                      HttpProcessor httpProcessor,
                                                      HttpRequestRetryHandler retryHandler,
                                                      RedirectStrategy redirectStrategy,
                                                      AuthenticationStrategy targetAuthStrategy,
                                                      AuthenticationStrategy proxyAuthStrategy,
                                                      UserTokenHandler userTokenHandler,
                                                      HttpParams params)
{
  return new RedirectRequestDirector(log,
                                     requestExec,
                                     conman,
                                     reustrat,
                                     kastrat,
                                     rouplan,
                                     httpProcessor,
                                     retryHandler,
                                     redirectStrategy,
                                     targetAuthStrategy,
                                     proxyAuthStrategy,
                                     userTokenHandler,
                                     params);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:29,代码来源:RedirectHttpClient.java

示例15: RedirectRequestDirector

import org.apache.http.client.AuthenticationStrategy; //导入依赖的package包/类
public RedirectRequestDirector(Log log,
                               HttpRequestExecutor requestExec,
                               ClientConnectionManager conman,
                               ConnectionReuseStrategy reustrat,
                               ConnectionKeepAliveStrategy kastrat,
                               HttpRoutePlanner rouplan,
                               HttpProcessor httpProcessor,
                               HttpRequestRetryHandler retryHandler,
                               RedirectStrategy redirectStrategy,
                               AuthenticationStrategy targetAuthStrategy,
                               AuthenticationStrategy proxyAuthStrategy,
                               UserTokenHandler userTokenHandler,
                               HttpParams params)
{
  super(log,
        requestExec,
        conman,
        reustrat,
        kastrat,
        rouplan,
        httpProcessor,
        retryHandler,
        redirectStrategy,
        targetAuthStrategy,
        proxyAuthStrategy,
        userTokenHandler,
        params);
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:29,代码来源:RedirectRequestDirector.java


注:本文中的org.apache.http.client.AuthenticationStrategy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。