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


Java AuthState.update方法代码示例

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


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

示例1: doPreemptiveAuth

import org.apache.http.auth.AuthState; //导入方法依赖的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

示例2: buildHttpContext

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
/**
 * Builds a configured HTTP context object that is pre-configured for
 * using HTTP Signature authentication.
 *
 * @param configurator HTTP Signatures configuration helper to pull properties from
 * @return configured HTTP context object
 */
protected HttpContext buildHttpContext(final HttpSignatureConfigurator configurator) {
    final HttpClientContext context = HttpClientContext.create();

    if (configurator != null) {
        AuthCache authCache = new BasicAuthCache();
        context.setAuthCache(authCache);

        AuthState authState = new AuthState();
        authState.update(configurator.getAuthScheme(), configurator.getCredentials());

        context.setAttribute(HttpClientContext.TARGET_AUTH_STATE,
                authState);
        context.getTargetAuthState().setState(AuthProtocolState.UNCHALLENGED);

    }

    return context;
}
 
开发者ID:joyent,项目名称:java-triton,代码行数:26,代码来源:CloudApiApacheHttpClientContext.java

示例3: process

import org.apache.http.auth.AuthState; //导入方法依赖的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

示例4: process

import org.apache.http.auth.AuthState; //导入方法依赖的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

示例5: doPreemptiveAuth

import org.apache.http.auth.AuthState; //导入方法依赖的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

示例6: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    final AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);
    // If no auth scheme available yet, try to initialize it
    // preemptively
    if (authState.getAuthScheme() == null) {
        final CredentialsProvider credsProvider = (CredentialsProvider)
                context.getAttribute(HttpClientContext.CREDS_PROVIDER);
        final HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
        final AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        final Credentials creds = credsProvider.getCredentials(authScope);
        if (creds == null) {
            LOGGER.debug("Cannot initiate preemtive authentication, Credentials not found!");
        }
        authState.update(new BasicScheme(), creds);
    }
}
 
开发者ID:fcrepo4-exts,项目名称:fcrepo-java-client,代码行数:17,代码来源:FcrepoHttpClientBuilder.java

示例7: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    HttpClientContext clientContext = HttpClientContext.adapt(context);
    AuthState authState = clientContext.getTargetAuthState();

    // If there's no auth scheme available yet, try to initialize it preemptively
    if (authState.getAuthScheme() == null) {
        CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
        HttpHost targetHost = clientContext.getTargetHost();
        Credentials creds = credsProvider.getCredentials(
                new AuthScope(targetHost.getHostName(), targetHost.getPort()));
        if (creds == null) {
            log.debug("No credentials found for host " + targetHost);
        } else {
            log.debug("Updating credentials for host " + targetHost);
            authState.update(new BasicScheme(), creds);
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:20,代码来源:PreemptiveAuthInterceptor.java

示例8: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context)
        throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

    if (authState.getAuthScheme() == null) {
        CredentialsProvider credsProvider = (CredentialsProvider) context
                .getAttribute(HttpClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(HttpClientContext.HTTP_TARGET_HOST);
        Credentials creds = credsProvider
                .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
        if (creds == null) {
            throw new HttpException("No credentials given for preemptive authentication");
        }
        authState.update(authScheme, creds);
    }
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:17,代码来源:JolokiaClientFactory.java

示例9: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
@Override
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 available 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);
      HttpHost targetHost = (HttpHost) context.getAttribute(HttpCoreContext.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:apache,项目名称:activemq-artemis,代码行数:19,代码来源:UriStrategy.java

示例10: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    Credentials creds;
    
    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) {
            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:Verigreen,项目名称:verigreen,代码行数:24,代码来源:PreemptiveAuth.java

示例11: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
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) {
        CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext
                .CREDS_PROVIDER);
        HttpHost host = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
        Credentials creds = credsProvider.getCredentials(new AuthScope(host.getHostName(), host.getPort()));
        if (creds == null) {
            throw new HttpException("No credentials for preemptive authentication");
        }
        authState.update(new BasicScheme(), creds);
    }
}
 
开发者ID:integram,项目名称:cleverbus,代码行数:19,代码来源:CloseableHttpComponentsMessageSender.java

示例12: setAuthPreemtive

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
public void setAuthPreemtive(boolean authPreemtive) {
    /**
     * Add an HttpRequestInterceptor that will perform preemptive authentication
     * @see http://hc.apache.org/httpcomponents-client-4.0.1/tutorial/html/authentication.html
     */
    HttpRequestInterceptor preemptiveAuth = new HttpRequestInterceptor() {
        public void process(final HttpRequest request, final HttpContext context) throws IOException {
            AuthState authState = (AuthState)context.getAttribute(ClientContext.TARGET_AUTH_STATE);
            CredentialsProvider credsProvider = (CredentialsProvider)context.getAttribute(ClientContext.CREDS_PROVIDER);
            HttpHost targetHost = (HttpHost)context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
            // If not authentication scheme has been initialized yet
            if (authState.getAuthScheme() == null) {
                AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
                // Obtain credentials matching the target host
                Credentials creds = credsProvider.getCredentials(authScope);
                // If found, generate BasicScheme preemptively
                if (creds != null) {
                    authState.update(new BasicScheme(), creds);
                }
            }
        }

    };
    m_httpClient.addRequestInterceptor(preemptiveAuth, 0);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:WebClient.java

示例13: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException
{
	final AuthState state = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

	// Try to initialise an auth scheme if one is not already set
	if (state.getAuthScheme() == null)
	{
		CredentialsProvider credentialsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
		HttpHost host = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);

		final Credentials credentials = credentialsProvider.getCredentials(new AuthScope(host));

		if (credentials == null)
			throw new HttpException("No credentials for preemptive authentication against: " + host);
		else
			state.update(new BearerAuthSchemeProvider().create(context), credentials);
	}
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:19,代码来源:PreemptiveBearerAuthInterceptor.java

示例14: process

import org.apache.http.auth.AuthState; //导入方法依赖的package包/类
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException
{
	final AuthState state = (AuthState) context.getAttribute(HttpClientContext.TARGET_AUTH_STATE);

	// Try to initialise an auth scheme if one is not already set
	if (state.getAuthScheme() == null)
	{
		CredentialsProvider credentialsProvider = (CredentialsProvider) context.getAttribute(HttpClientContext.CREDS_PROVIDER);
		HttpHost host = (HttpHost) context.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);

		final Credentials credentials = credentialsProvider.getCredentials(new AuthScope(host));

		if (credentials == null)
			throw new HttpException("No credentials for preemptive authentication against: " + host);
		else
			state.update(new BasicScheme(), credentials);
	}
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:19,代码来源:PreemptiveBasicAuthInterceptor.java

示例15: convertHttpClientContext

import org.apache.http.auth.AuthState; //导入方法依赖的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;
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:19,代码来源:HttpUriRequestConverter.java


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