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


Java AuthScheme类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:22,代码来源:AuthenticationStrategyImpl.java

示例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");
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:RequestAuthCache.java

示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AuthenticationStrategyImpl.java

示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:AuthenticationStrategyImpl.java

示例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);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:CallbackProxyAuthenticationStrategy.java

示例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);
        }
    }
    
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:HttpSender.java

示例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");
        }
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:27,代码来源:RequestAuthCache.java

示例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);
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:16,代码来源:AuthenticationStrategyImpl.java

示例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);
        }
    }
}
 
开发者ID:sabre1041,项目名称:jenkinsfile-maven-plugin,代码行数:20,代码来源:PreemptiveAuth.java

示例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);
        }
    }

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:PreemptiveAuthInterceptor.java

示例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);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:AuthenticationStrategyAdaptor.java

示例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");
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:RequestAuthCache.java

示例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);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:23,代码来源:AuthenticationStrategyImpl.java

示例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);
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:AuthenticationStrategyImpl.java

示例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");
        }
    }
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:BasicAuthCache.java


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