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

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

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

AuthScheme.processChallenge介绍

[英]Processes the given challenge token. Some authentication schemes may involve multiple challenge-response exchanges. Such schemes must be able to maintain the state information when dealing with sequential challenges
[中]处理给定的质询令牌。一些认证方案可能涉及多个质询-响应交换。此类方案必须能够在处理连续挑战时维护状态信息

代码示例

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

private void processChallenges(
  final Map<String, Header> challenges,
  final AuthState authState,
  final AuthenticationHandler authHandler,
  final HttpResponse response,
  final HttpContext context)
   throws MalformedChallengeException, AuthenticationException {
 AuthScheme authScheme = authState.getAuthScheme();
 if (authScheme == null) {
  // Authentication not attempted before
  authScheme = authHandler.selectScheme(challenges, response, context);
  authState.setAuthScheme(authScheme);
 }
 String id = authScheme.getSchemeName();
 Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
 if (challenge == null) {
  throw new AuthenticationException(id +
   " authorization challenge expected, but not found");
 }
 authScheme.processChallenge(challenge);
 this.log.debug("Authorization challenge processed");
}

代码示例来源: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 void processChallenges(
    final Map<String, Header> challenges, 
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response, 
    final HttpContext context) 
      throws MalformedChallengeException, AuthenticationException {
  
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id + 
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

代码示例来源: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: MobiVM/robovm

private void processChallenges(
    final Map<String, Header> challenges, 
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response, 
    final HttpContext context) 
      throws MalformedChallengeException, AuthenticationException {
  
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id + 
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

代码示例来源:origin: com.github.japgolly.android.test/robolectric

private void processChallenges(
    final Map<String, Header> challenges,
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response,
    final HttpContext context)
      throws MalformedChallengeException, AuthenticationException {
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id +
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

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

private void processChallenges(
    final Map<String, Header> challenges, 
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response, 
    final HttpContext context) 
      throws MalformedChallengeException, AuthenticationException {
  
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id + 
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

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

private void processChallenges(
    final Map<String, Header> challenges, 
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response, 
    final HttpContext context) 
      throws MalformedChallengeException, AuthenticationException {
  
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id + 
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

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

private void processChallenges(
    final Map<String, Header> challenges, 
    final AuthState authState,
    final AuthenticationHandler authHandler,
    final HttpResponse response, 
    final HttpContext context) 
      throws MalformedChallengeException, AuthenticationException {
  
  AuthScheme authScheme = authState.getAuthScheme();
  if (authScheme == null) {
    // Authentication not attempted before
    authScheme = authHandler.selectScheme(challenges, response, context);
    authState.setAuthScheme(authScheme);
  }
  String id = authScheme.getSchemeName();
  Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
  if (challenge == null) {
    throw new AuthenticationException(id + 
      " authorization challenge expected, but not found");
  }
  authScheme.processChallenge(challenge);
  this.log.debug("Authorization challenge processed");
}

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

authScheme.processChallenge(challenge);

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

if (challenge != null) {
  this.log.debug("Authorization challenge processed");
  authScheme.processChallenge(challenge);
  if (authScheme.isComplete()) {
    this.log.debug("Authentication failed");

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

if (challenge != null) {
  this.log.debug("Authorization challenge processed");
  authScheme.processChallenge(challenge);
  if (authScheme.isComplete()) {
    this.log.debug("Authentication failed");

相关文章