當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。