org.apache.http.auth.AuthScheme.isConnectionBased()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(75)

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

AuthScheme.isConnectionBased介绍

[英]Tests if the authentication scheme is provides authorization on a per connection basis instead of usual per request basis
[中]测试验证方案是否基于每个连接而不是通常的每个请求提供授权

代码示例

代码示例来源:origin: internetarchive/heritrix3

protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) {
  HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet());
  for (String authSchemeName: new String[]{"digest","basic"}) {
    if (authSchemesLeftToTry.remove(authSchemeName)) {
      AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);;
      BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName));
      try {
        authScheme.processChallenge(challenge);
      } catch (MalformedChallengeException e) {
        logger.fine(e.getMessage() + " " + challenge);
        continue;
      }
      if (authScheme.isConnectionBased()) {
        logger.fine("Connection based " + authScheme);
        continue;
      }
      if (authScheme.getRealm() == null
          || authScheme.getRealm().length() <= 0) {
        logger.fine("Empty realm " + authScheme);
        continue;
      }
      return authScheme;
    }
  }
  for (String unsupportedSchemeName: authSchemesLeftToTry) {
    logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName);
  }
  
  return null;
}

代码示例来源:origin: robovm/robovm

private static Principal getAuthPrincipal(final AuthState authState) {
  AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal(); 
    }
  }
  return null;
}

代码示例来源:origin: robovm/robovm

return;
if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
  try {
    request.addHeader(authScheme.authenticate(creds, request));

代码示例来源:origin: robovm/robovm

if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
  try {
    request.addHeader(authScheme.authenticate(creds, request));

代码示例来源:origin: robovm/robovm

Credentials creds = this.proxyAuthState.getCredentials();
if (creds != null) {
  if (authScope != null || !authScheme.isConnectionBased()) {
    try {
      connect.addHeader(authScheme.authenticate(creds, connect));

代码示例来源:origin: robolectric/robolectric

targetAuthState.invalidate();
AuthScheme authScheme = proxyAuthState.getAuthScheme();
if (authScheme != null && authScheme.isConnectionBased()) {
 proxyAuthState.invalidate();

代码示例来源:origin: soundcloud/java-api-wrapper

@Override public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    if (request == null) throw new IllegalArgumentException("HTTP request may not be null");
    if (context == null) throw new IllegalArgumentException("HTTP context may not be null");

    if (!request.getRequestLine().getMethod().equalsIgnoreCase("CONNECT")) {
      AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
      if (authState != null) {
        AuthScheme authScheme = authState.getAuthScheme();
        if (authScheme != null && !authScheme.isConnectionBased()) {
          try {
            request.setHeader(authScheme.authenticate(null, request));
          } catch (AuthenticationException ignored) {
            // ignored
          }
        }
      }
    }
  }
}

代码示例来源:origin: org.archive.heritrix/heritrix-modules

protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) {
  HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet());
  for (String authSchemeName: new String[]{"digest","basic"}) {
    if (authSchemesLeftToTry.remove(authSchemeName)) {
      AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);;
      BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName));
      try {
        authScheme.processChallenge(challenge);
      } catch (MalformedChallengeException e) {
        logger.fine(e.getMessage() + " " + challenge);
        continue;
      }
      if (authScheme.isConnectionBased()) {
        logger.fine("Connection based " + authScheme);
        continue;
      }
      if (authScheme.getRealm() == null
          || authScheme.getRealm().length() <= 0) {
        logger.fine("Empty realm " + authScheme);
        continue;
      }
      return authScheme;
    }
  }
  for (String unsupportedSchemeName: authSchemesLeftToTry) {
    logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName);
  }
  
  return null;
}

代码示例来源:origin: com.bugvm/bugvm-rt

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: org.apache.httpcomponents/httpclient-android

private static Principal getAuthPrincipal(final AuthStateHC4 authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: MobiVM/robovm

private static Principal getAuthPrincipal(final AuthState authState) {
  AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal(); 
    }
  }
  return null;
}

代码示例来源:origin: com.gluonhq/robovm-rt

private static Principal getAuthPrincipal(final AuthState authState) {
  AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal(); 
    }
  }
  return null;
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: ibinti/bugvm

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: FlexoVM/flexovm

private static Principal getAuthPrincipal(final AuthState authState) {
  AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal(); 
    }
  }
  return null;
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

private static Principal getAuthPrincipal(final AuthState authState) {
  AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal(); 
    }
  }
  return null;
}

代码示例来源:origin: com.hynnet/httpclient

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

代码示例来源:origin: MobiVM/robovm

if (authState.getAuthScope() != null || !authScheme.isConnectionBased()) {
  try {
    request.addHeader(authScheme.authenticate(creds, request));

代码示例来源:origin: Nextdoor/bender

private static Principal getAuthPrincipal(final AuthState authState) {
  final AuthScheme scheme = authState.getAuthScheme();
  if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
    final Credentials creds = authState.getCredentials();
    if (creds != null) {
      return creds.getUserPrincipal();
    }
  }
  return null;
}

相关文章