org.apache.commons.httpclient.auth.AuthScheme类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.apache.commons.httpclient.auth.AuthScheme类的一些代码示例,展示了AuthScheme类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthScheme类的具体详情如下:
包路径:org.apache.commons.httpclient.auth.AuthScheme
类名称:AuthScheme

AuthScheme介绍

[英]This interface represents an abstract challenge-response oriented authentication scheme.

An authentication scheme should be able to support the following functions:

  • Parse and process the challenge sent by the targer server in response to request for a protected resource
  • Provide its textual designation
  • Provide its parameters, if available
  • Provide the realm this authentication scheme is applicable to, if available
  • Generate authorization string for the given set of credentials, request method and URI as specificed in the HTTP request line in response to the actual authorization challenge

Authentication schemes may ignore method name and URI parameters if they are not relevant for the given authentication mechanism

Authentication schemes may be stateful involving a series of challenge-response exchanges
[中]此接口表示一个抽象的面向质询-响应的身份验证方案。
身份验证方案应能够支持以下功能:
*解析并处理Targetr服务器响应受保护资源请求而发送的质询
*提供其文本名称
*提供其参数(如果可用)
*提供此身份验证方案适用的领域(如果可用)
*为HTTP请求行中指定的给定凭据集、请求方法和URI生成授权字符串,以响应实际的授权质询
如果方法名和URI参数与给定的身份验证机制不相关,则身份验证方案可能会忽略它们
身份验证方案可能是有状态的,涉及一系列质询-响应交换

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

return;
if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
  AuthScope authscope = new AuthScope(
    conn.getProxyHost(), conn.getProxyPort(), 
    authscheme.getRealm(), 
    authscheme.getSchemeName());  
  if (LOG.isDebugEnabled()) {
    LOG.debug("Authenticating with " + authscope);
    String authstring = authscheme.authenticate(credentials, method);
    if (authstring != null) {
      method.addRequestHeader(new Header(PROXY_AUTH_RESP, authstring, true));

代码示例来源:origin: commons-httpclient/commons-httpclient

authscheme.getRealm(), 
  authscheme.getSchemeName());  
if (authstate.isAuthAttempted() && authscheme.isComplete()) {

代码示例来源:origin: commons-httpclient/commons-httpclient

String id = authscheme.getSchemeName();
if (LOG.isDebugEnabled()) {
  LOG.debug("Using authentication scheme: " + id);
    " authorization challenge expected, but not found");
authscheme.processChallenge(challenge);
LOG.debug("Authorization challenge processed");
return authscheme;

代码示例来源:origin: commons-httpclient/commons-httpclient

public String toString() {
    StringBuffer buffer = new StringBuffer();
    buffer.append("Auth state: auth requested [");
    buffer.append(this.authRequested);
    buffer.append("]; auth attempted [");
    buffer.append(this.authAttempted);
    if (this.authScheme != null) {
      buffer.append("]; auth scheme [");
      buffer.append(this.authScheme.getSchemeName());
      buffer.append("]; realm [");
      buffer.append(this.authScheme.getRealm());            
    }
    buffer.append("] preemptive [");
    buffer.append(this.preemptive);
    buffer.append("]");
    return buffer.toString();
  }
}

代码示例来源:origin: commons-httpclient/commons-httpclient

String realm = authscheme.getRealm();
if (LOG.isDebugEnabled()) {
  StringBuffer buffer = new StringBuffer();
  throw new CredentialsNotAvailableException(buffer.toString());
String auth = authscheme.authenticate(credentials, method);
if (auth != null) {
  String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Returns the authentication realm.
 * 
 * @return the name of the authentication realm
 */
public String getRealm() {
  if (this.authScheme != null) {
    return this.authScheme.getRealm();
  } else {
    return null;
  }
}

代码示例来源:origin: edu.ucar/netcdf

if(retryCount == 0 && authstate.isAuthAttempted() && authscheme.isComplete()) {
  return null; // Stop the retry.
Credentials credentials = null;
scheme = HTTPAuthScheme.schemeForName(authscheme.getSchemeName());
  LOG.error("HTTPAuthProvider: unsupported scheme: "+authscheme.getSchemeName());

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * @param scheme the request scheme for which Credentials are asked
 * @param scope the configured authorization scope
 * @return <code>true</code> if the scope's scheme matches the provided one
 */
protected boolean matchScheme(final AuthScope scope, final AuthScheme scheme) {
  return scope.getScheme() == AuthScope.ANY_SCHEME || scope.getScheme().equals(scheme.getSchemeName());
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Builds a key with the specified data.
 * @param scheme the scheme
 * @param host the server name
 * @param port the server port
 * @param proxy is proxy
 * @return the new key
 */
protected Object buildKey(final AuthScheme scheme, final String host, final int port, final boolean proxy) {
  return scheme.getSchemeName() + " " + scheme.getRealm() + " " + host + ":" + port + " " + proxy;
}

代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient

String realm = authscheme.getRealm();
if (LOG.isDebugEnabled()) {
  StringBuffer buffer = new StringBuffer();
  throw new CredentialsNotAvailableException(buffer.toString());
String auth = authscheme.authenticate(credentials, method);
if (auth != null) {
  String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Returns the authentication realm.
 * 
 * @return the name of the authentication realm
 */
public String getRealm() {
  if (this.authScheme != null) {
    return this.authScheme.getRealm();
  } else {
    return null;
  }
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * @param scheme the request scheme for which Credentials are asked
 * @param scope the configured authorization scope
 * @return <code>true</code> if the scope's scheme matches the provided one
 */
protected boolean matchScheme(final AuthScope scope, final AuthScheme scheme) {
  return scope.getScheme() == AuthScope.ANY_SCHEME || scope.getScheme().equals(scheme.getSchemeName());
}

代码示例来源:origin: commons-httpclient/commons-httpclient

return;
if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
  String host = method.getParams().getVirtualHost();
  if (host == null) {
  AuthScope authscope = new AuthScope(
    host, port, 
    authscheme.getRealm(), 
    authscheme.getSchemeName());  
  if (LOG.isDebugEnabled()) {
    LOG.debug("Authenticating with " + authscope);
    String authstring = authscheme.authenticate(credentials, method);
    if (authstring != null) {
      method.addRequestHeader(new Header(WWW_AUTH_RESP, authstring, true));

代码示例来源:origin: commons-httpclient/commons-httpclient

AuthScope authscope = new AuthScope(
  host, port, 
  authscheme.getRealm(), 
  authscheme.getSchemeName());
if (authstate.isAuthAttempted() && authscheme.isComplete()) {

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Builds a key with the specified data.
 * @param scheme the scheme
 * @param host the server name
 * @param port the server port
 * @param proxy is proxy
 * @return the new key
 */
protected Object buildKey(final AuthScheme scheme, final String host, final int port, final boolean proxy) {
  return scheme.getSchemeName() + " " + scheme.getRealm() + " " + host + ":" + port + " " + proxy;
}

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

String realm = authscheme.getRealm();
if (LOG.isDebugEnabled()) {
  StringBuffer buffer = new StringBuffer();
  throw new CredentialsNotAvailableException(buffer.toString());
String auth = authscheme.authenticate(credentials, method);
if (auth != null) {
  String s = proxy ? PROXY_AUTH_RESP : WWW_AUTH_RESP;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

String id = authscheme.getSchemeName();
if (LOG.isDebugEnabled()) {
  LOG.debug("Using authentication scheme: " + id);
    " authorization challenge expected, but not found");
authscheme.processChallenge(challenge);
LOG.debug("Authorization challenge processed");
return authscheme;

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Returns the authentication realm.
 * 
 * @return the name of the authentication realm
 */
public String getRealm() {
  if (this.authScheme != null) {
    return this.authScheme.getRealm();
  } else {
    return null;
  }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * @param scheme the request scheme for which Credentials are asked
 * @param scope the configured authorization scope
 * @return <code>true</code> if the scope's scheme matches the provided one
 */
protected boolean matchScheme(final AuthScope scope, final AuthScheme scheme) {
  return scope.getScheme() == AuthScope.ANY_SCHEME || scope.getScheme().equals(scheme.getSchemeName());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

return;
if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
  AuthScope authscope = new AuthScope(
    conn.getProxyHost(), conn.getProxyPort(), 
    authscheme.getRealm(), 
    authscheme.getSchemeName());  
  if (LOG.isDebugEnabled()) {
    LOG.debug("Authenticating with " + authscope);
    String authstring = authscheme.authenticate(credentials, method);
    if (authstring != null) {
      method.addRequestHeader(new Header(PROXY_AUTH_RESP, authstring, true));

相关文章