本文整理汇总了Java中org.apache.http.auth.AuthScheme类的典型用法代码示例。如果您正苦于以下问题:Java AuthScheme类的具体用法?Java AuthScheme怎么用?Java AuthScheme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthScheme类属于org.apache.http.auth包,在下文中一共展示了AuthScheme类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authSucceeded
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void authSucceeded(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
Args.notNull(authhost, "Host");
Args.notNull(authScheme, "Auth scheme");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
if (isCachable(authScheme)) {
AuthCache authCache = clientContext.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
clientContext.setAuthCache(authCache);
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Caching '" + authScheme.getSchemeName() +
"' auth scheme for " + authhost);
}
authCache.put(authhost, authScheme);
}
}
示例2: doPreemptiveAuth
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
private void doPreemptiveAuth(
final HttpHost host,
final AuthScheme authScheme,
final AuthState authState,
final CredentialsProvider credsProvider) {
String schemeName = authScheme.getSchemeName();
if (this.log.isDebugEnabled()) {
this.log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host);
}
AuthScope authScope = new AuthScope(host, AuthScope.ANY_REALM, schemeName);
Credentials creds = credsProvider.getCredentials(authScope);
if (creds != null) {
authState.setState(AuthProtocolState.SUCCESS);
authState.update(authScheme, creds);
} else {
this.log.debug("No credentials for preemptive authentication");
}
}
示例3: authSucceeded
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void authSucceeded(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
if (authhost == null) {
throw new IllegalArgumentException("Host may not be null");
}
if (authScheme == null) {
throw new IllegalArgumentException("Auth scheme may not be null");
}
if (context == null) {
throw new IllegalArgumentException("HTTP context may not be null");
}
if (isCachable(authScheme)) {
AuthCache authCache = (AuthCache) context.getAttribute(ClientContext.AUTH_CACHE);
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
}
if (this.log.isDebugEnabled()) {
this.log.debug("Caching '" + authScheme.getSchemeName() +
"' auth scheme for " + authhost);
}
authCache.put(authhost, authScheme);
}
}
示例4: authFailed
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void authFailed(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
if (authhost == null) {
throw new IllegalArgumentException("Host may not be null");
}
if (context == null) {
throw new IllegalArgumentException("HTTP context may not be null");
}
AuthCache authCache = (AuthCache) context.getAttribute(ClientContext.AUTH_CACHE);
if (authCache != null) {
if (this.log.isDebugEnabled()) {
this.log.debug("Clearing cached auth scheme for " + authhost);
}
authCache.remove(authhost);
}
}
示例5: authSucceeded
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void authSucceeded(final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Credentials credentials = clientContext.getAttribute(PROXY_CREDENTIALS_INPUT_ID, Credentials.class);
if(null != credentials) {
clientContext.removeAttribute(PROXY_CREDENTIALS_INPUT_ID);
if(log.isInfoEnabled()) {
log.info(String.format("Save passphrase for proxy %s", authhost));
}
keychain.addCredentials(authhost.getHostName(), credentials.getUsername(), credentials.getPassword());
}
super.authSucceeded(authhost, authScheme, context);
}
示例6: process
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
// If no auth scheme avaialble yet, try to initialize it preemptively
if (authState.getAuthScheme() == null) {
AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
if (authScheme != null) {
Credentials creds = credsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
if (creds == null) {
throw new HttpException("No credentials for preemptive authentication");
}
authState.setAuthScheme(authScheme);
authState.setCredentials(creds);
}
}
}
示例7: doPreemptiveAuth
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
private void doPreemptiveAuth(
final HttpHost host,
final AuthScheme authScheme,
final AuthStateHC4 authState,
final CredentialsProvider credsProvider) {
final String schemeName = authScheme.getSchemeName();
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Re-using cached '" + schemeName + "' auth scheme for " + host);
}
final AuthScope authScope = new AuthScope(host.getHostName(), host.getPort(), AuthScope.ANY_REALM, schemeName);
final Credentials creds = credsProvider.getCredentials(authScope);
if (creds != null) {
if ("BASIC".equalsIgnoreCase(authScheme.getSchemeName())) {
authState.setState(AuthProtocolState.CHALLENGED);
} else {
authState.setState(AuthProtocolState.SUCCESS);
}
authState.update(authScheme, creds);
} else {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "No credentials for preemptive authentication");
}
}
}
示例8: authFailed
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void authFailed(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
Args.notNull(authhost, "Host");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final AuthCache authCache = clientContext.getAuthCache();
if (authCache != null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Clearing cached auth scheme for " + authhost);
}
authCache.remove(authhost);
}
}
示例9: process
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void process(HttpRequest httpRequest, HttpContext httpContext) throws HttpException, IOException {
AuthState authState = (AuthState) httpContext.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
if (authState.getAuthScheme() == null) {
AuthScheme authScheme = (AuthScheme) httpContext.getAttribute("preemptive-auth");
CredentialsProvider credsProvider = (CredentialsProvider) httpContext
.getAttribute(HttpClientContext.CREDS_PROVIDER);
HttpHost targetHost = (HttpHost) httpContext.getAttribute(HttpClientContext.HTTP_TARGET_HOST);
if (authScheme != null) {
Credentials creds = credsProvider
.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
if (creds == null) {
throw new HttpException("No credentials for preemptive authentication");
}
authState.update(authScheme, creds);
}
}
}
示例10: process
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
// If no auth scheme avaialble yet, try to initialize it preemptively
if (authState.getAuthScheme() == null) {
AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
if (authScheme != null) {
Credentials creds = credsProvider.getCredentials(AuthScope.ANY);
if (creds == null) {
throw new HttpException("No credentials for preemptive authentication");
}
authState.update(authScheme, creds);
}
}
}
示例11: authSucceeded
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void authSucceeded(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
AuthCache authCache = (AuthCache) context.getAttribute(ClientContext.AUTH_CACHE);
if (isCachable(authScheme)) {
if (authCache == null) {
authCache = new BasicAuthCache();
context.setAttribute(ClientContext.AUTH_CACHE, authCache);
}
if (this.log.isDebugEnabled()) {
this.log.debug("Caching '" + authScheme.getSchemeName() +
"' auth scheme for " + authhost);
}
authCache.put(authhost, authScheme);
}
}
示例12: doPreemptiveAuth
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
private void doPreemptiveAuth(
final HttpHost host,
final AuthScheme authScheme,
final AuthState authState,
final CredentialsProvider credsProvider) {
final String schemeName = authScheme.getSchemeName();
if (this.log.isDebugEnabled()) {
this.log.debug("Re-using cached '" + schemeName + "' auth scheme for " + host);
}
final AuthScope authScope = new AuthScope(host, AuthScope.ANY_REALM, schemeName);
final Credentials creds = credsProvider.getCredentials(authScope);
if (creds != null) {
if ("BASIC".equalsIgnoreCase(authScheme.getSchemeName())) {
authState.setState(AuthProtocolState.CHALLENGED);
} else {
authState.setState(AuthProtocolState.SUCCESS);
}
authState.update(authScheme, creds);
} else {
this.log.debug("No credentials for preemptive authentication");
}
}
示例13: authSucceeded
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void authSucceeded(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
Args.notNull(authhost, "Host");
Args.notNull(authScheme, "Auth scheme");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
if (isCachable(authScheme)) {
AuthCache authCache = clientContext.getAuthCache();
if (authCache == null) {
authCache = new BasicAuthCache();
clientContext.setAuthCache(authCache);
}
if (this.log.isDebugEnabled()) {
this.log.debug("Caching '" + authScheme.getSchemeName() +
"' auth scheme for " + authhost);
}
authCache.put(authhost, authScheme);
}
}
示例14: authFailed
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void authFailed(
final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
Args.notNull(authhost, "Host");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final AuthCache authCache = clientContext.getAuthCache();
if (authCache != null) {
if (this.log.isDebugEnabled()) {
this.log.debug("Clearing cached auth scheme for " + authhost);
}
authCache.remove(authhost);
}
}
示例15: put
import org.apache.http.auth.AuthScheme; //导入依赖的package包/类
@Override
public void put(final HttpHost host, final AuthScheme authScheme) {
Args.notNull(host, "HTTP host");
if (authScheme == null) {
return;
}
if (authScheme instanceof Serializable) {
try {
final ByteArrayOutputStream buf = new ByteArrayOutputStream();
final ObjectOutputStream out = new ObjectOutputStream(buf);
out.writeObject(authScheme);
out.close();
this.map.put(getKey(host), buf.toByteArray());
} catch (final IOException ex) {
if (log.isWarnEnabled()) {
log.warn("Unexpected I/O error while serializing auth scheme", ex);
}
}
} else {
if (log.isDebugEnabled()) {
log.debug("Auth scheme " + authScheme.getClass() + " is not serializable");
}
}
}