本文整理汇总了Java中org.apache.http.auth.ChallengeState类的典型用法代码示例。如果您正苦于以下问题:Java ChallengeState类的具体用法?Java ChallengeState怎么用?Java ChallengeState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChallengeState类属于org.apache.http.auth包,在下文中一共展示了ChallengeState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertHttpClientContext
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
private HttpClientContext convertHttpClientContext(Request request, Site site, Proxy proxy) {
HttpClientContext httpContext = new HttpClientContext();
if (proxy != null && proxy.getUsername() != null) {
AuthState authState = new AuthState();
authState.update(new BasicScheme(ChallengeState.PROXY), new UsernamePasswordCredentials(proxy.getUsername(), proxy.getPassword()));
httpContext.setAttribute(HttpClientContext.PROXY_AUTH_STATE, authState);
}
if (request.getCookies() != null && !request.getCookies().isEmpty()) {
CookieStore cookieStore = new BasicCookieStore();
for (Map.Entry<String, String> cookieEntry : request.getCookies().entrySet()) {
BasicClientCookie cookie1 = new BasicClientCookie(cookieEntry.getKey(), cookieEntry.getValue());
cookie1.setDomain(UrlUtils.removePort(UrlUtils.getDomain(request.getUrl())));
cookieStore.addCookie(cookie1);
}
httpContext.setCookieStore(cookieStore);
}
return httpContext;
}
示例2: readObject
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
this.credentialsCharset = CharsetUtils.get(in.readUTF());
if (this.credentialsCharset == null) {
this.credentialsCharset = Consts.ASCII;
}
this.challengeState = (ChallengeState) in.readObject();
}
示例3: process
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
HttpClientContext clientContext = HttpClientContext.adapt(context);
AuthState proxyAuthState = clientContext.getProxyAuthState();
// If there's no auth scheme available yet, try to initialize it preemptively
if (proxyAuthState.getAuthScheme() == null) {
CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
RouteInfo route = clientContext.getHttpRoute();
if (route == null) {
log.debug("No route found for {}", clientContext.getTargetHost());
return;
}
HttpHost proxyHost = route.getProxyHost();
if (proxyHost == null) {
log.warn("No proxy host found in route {} for host {}", route, clientContext.getTargetHost());
return;
}
Credentials creds = credsProvider.getCredentials(
new AuthScope(proxyHost.getHostName(), proxyHost.getPort()));
if (creds == null) {
log.info("No credentials found for proxy: " + proxyHost);
return;
}
proxyAuthState.update(new BasicScheme(ChallengeState.PROXY), creds);
}
}
示例4: RFC2617SchemeHC4
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>RFC2617Scheme</tt> with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public RFC2617SchemeHC4(final ChallengeState challengeState) {
super(challengeState);
this.params = new HashMap<String, String>();
this.credentialsCharset = Consts.ASCII;
}
示例5: RFC2617Scheme
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of {@code RFC2617Scheme} with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public RFC2617Scheme(final ChallengeState challengeState) {
super(challengeState);
this.params = new HashMap<String, String>();
this.credentialsCharset = Consts.ASCII;
}
示例6: RFC2617Scheme
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>RFC2617Scheme</tt> with the given challenge
* state.
*
* @since 4.2
*/
public RFC2617Scheme(final ChallengeState challengeState) {
super(challengeState);
this.params = new HashMap<String, String>();
}
示例7: DigestScheme
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>DigestScheme</tt> with the given challenge
* state.
*
* @since 4.2
*/
public DigestScheme(final ChallengeState challengeState) {
super(challengeState);
this.complete = false;
}
示例8: BasicScheme
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>BasicScheme</tt> with the given challenge
* state.
*
* @since 4.2
*/
public BasicScheme(final ChallengeState challengeState) {
super(challengeState);
this.complete = false;
}
示例9: AuthSchemeBase
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>AuthSchemeBase</tt> with the given challenge
* state.
*
* @since 4.2
*/
public AuthSchemeBase(final ChallengeState challengeState) {
super();
this.challengeState = challengeState;
}
示例10: isProxy
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Returns <code>true</code> if authenticating against a proxy, <code>false</code>
* otherwise.
*/
public boolean isProxy() {
return this.challengeState != null && this.challengeState == ChallengeState.PROXY;
}
示例11: getChallengeState
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Returns {@link ChallengeState} value or <code>null</code> if unchallenged.
*
* @since 4.2
*/
public ChallengeState getChallengeState() {
return this.challengeState;
}
示例12: BasicSchemeHC4
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>BasicScheme</tt> with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public BasicSchemeHC4(final ChallengeState challengeState) {
super(challengeState);
}
示例13: DigestSchemeHC4
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>DigestScheme</tt> with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public DigestSchemeHC4(final ChallengeState challengeState) {
super(challengeState);
}
示例14: AuthSchemeBaseHC4
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of <tt>AuthSchemeBase</tt> with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public AuthSchemeBaseHC4(final ChallengeState challengeState) {
super();
this.challengeState = challengeState;
}
示例15: DigestScheme
import org.apache.http.auth.ChallengeState; //导入依赖的package包/类
/**
* Creates an instance of {@code DigestScheme} with the given challenge
* state.
*
* @since 4.2
*
* @deprecated (4.3) do not use.
*/
@Deprecated
public DigestScheme(final ChallengeState challengeState) {
super(challengeState);
}