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


Java BasicScheme.processChallenge方法代码示例

本文整理汇总了Java中org.apache.http.impl.auth.BasicScheme.processChallenge方法的典型用法代码示例。如果您正苦于以下问题:Java BasicScheme.processChallenge方法的具体用法?Java BasicScheme.processChallenge怎么用?Java BasicScheme.processChallenge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.impl.auth.BasicScheme的用法示例。


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

示例1: testAuthSucceeded

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
@Test
public void testAuthSucceeded() throws Exception {
    final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
    final HttpHost authhost = new HttpHost("somehost", 80);
    final BasicScheme authScheme = new BasicScheme();
    authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

    final AuthCache authCache = Mockito.mock(AuthCache.class);

    final HttpClientContext context = HttpClientContext.create();
    context.setAuthCache(authCache);

    authStrategy.authSucceeded(authhost, authScheme, context);
    Mockito.verify(authCache).put(authhost, authScheme);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:TestAuthenticationStrategy.java

示例2: testAuthSucceededNoCache

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
@Test
public void testAuthSucceededNoCache() throws Exception {
    final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
    final HttpHost authhost = new HttpHost("somehost", 80);
    final BasicScheme authScheme = new BasicScheme();
    authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

    final HttpClientContext context = HttpClientContext.create();
    context.setAuthCache(null);

    authStrategy.authSucceeded(authhost, authScheme, context);
    final AuthCache authCache = context.getAuthCache();
    Assert.assertNotNull(authCache);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:TestAuthenticationStrategy.java

示例3: testAuthFailed

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
@Test
public void testAuthFailed() throws Exception {
    final TargetAuthenticationStrategy authStrategy = new TargetAuthenticationStrategy();
    final HttpHost authhost = new HttpHost("somehost", 80);
    final BasicScheme authScheme = new BasicScheme();
    authScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "Basic realm=test"));

    final AuthCache authCache = Mockito.mock(AuthCache.class);

    final HttpClientContext context = HttpClientContext.create();
    context.setAuthCache(authCache);

    authStrategy.authFailed(authhost, authScheme, context);
    Mockito.verify(authCache).remove(authhost);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:16,代码来源:TestAuthenticationStrategy.java

示例4: authPreemptive

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
public Executor authPreemptive(final HttpHost host) {
    final BasicScheme basicScheme = new BasicScheme();
    try {
        basicScheme.processChallenge(new BasicHeader(AUTH.WWW_AUTH, "BASIC "));
    } catch (final MalformedChallengeException ignore) {
    }
    this.authCache.put(host, basicScheme);
    return this;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:Executor.java

示例5: authPreemptiveProxy

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
public Executor authPreemptiveProxy(final HttpHost proxy) {
    final BasicScheme basicScheme = new BasicScheme();
    try {
        basicScheme.processChallenge(new BasicHeader(AUTH.PROXY_AUTH, "BASIC "));
    } catch (final MalformedChallengeException ignore) {
    }
    this.authCache.put(proxy, basicScheme);
    return this;
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:Executor.java

示例6: getHttpClientContext

import org.apache.http.impl.auth.BasicScheme; //导入方法依赖的package包/类
private HttpClientContext getHttpClientContext() throws Exception {
    HttpProxyConfig httpProxyConfig = configRepository.getHttpProxyConfig();
    if (httpProxyConfig.host().isEmpty() || httpProxyConfig.username().isEmpty()) {
        return HttpClientContext.create();
    }

    // perform preemptive proxy authentication

    int proxyPort = MoreObjects.firstNonNull(httpProxyConfig.port(), 80);
    HttpHost proxyHost = new HttpHost(httpProxyConfig.host(), proxyPort);

    BasicScheme basicScheme = new BasicScheme();
    basicScheme.processChallenge(new BasicHeader(AUTH.PROXY_AUTH, "BASIC realm="));
    BasicAuthCache authCache = new BasicAuthCache();
    authCache.put(proxyHost, basicScheme);

    String password = httpProxyConfig.password();
    if (!password.isEmpty()) {
        password = Encryption.decrypt(password, configRepository.getLazySecretKey());
    }
    CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
    credentialsProvider.setCredentials(new AuthScope(proxyHost),
            new UsernamePasswordCredentials(httpProxyConfig.username(), password));
    HttpClientContext context = HttpClientContext.create();
    context.setAuthCache(authCache);
    context.setCredentialsProvider(credentialsProvider);
    return context;
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:29,代码来源:SyntheticMonitorService.java


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