Ejemplo n.º 1
0
  /**
   * Processes the given collection of challenges and updates the {@link AuthState state} of the
   * authentication process.
   *
   * @param challenges the collection of authentication challenges
   * @return the {@link AuthScheme authentication scheme} used to process the challenge
   * @throws AuthChallengeException if authentication challenges cannot be successfully processed or
   *     the preferred authentication scheme cannot be determined
   */
  public AuthScheme processChallenge(final AuthState state, final Map challenges)
      throws MalformedChallengeException, AuthenticationException {
    if (state == null) {
      throw new IllegalArgumentException("Authentication state may not be null");
    }
    if (challenges == null) {
      throw new IllegalArgumentException("Challenge map may not be null");
    }

    if (state.isPreemptive() || state.getAuthScheme() == null) {
      // Authentication not attempted before
      state.setAuthScheme(selectAuthScheme(challenges));
    }
    AuthScheme authscheme = state.getAuthScheme();
    String id = authscheme.getSchemeName();
    //       //  if (LOG.isDebugEnabled()) {
    //           //   LOG.debug("Using authentication scheme: " + id);
    //        }
    String challenge = (String) challenges.get(id.toLowerCase());
    if (challenge == null) {
      throw new AuthenticationException(id + " authorization challenge expected, but not found");
    }
    authscheme.processChallenge(challenge);
    // LOG.debug("Authorization challenge processed");
    return authscheme;
  }
 public AuthScheme processChallenge(AuthState paramAuthState, Map paramMap)
     throws MalformedChallengeException, AuthenticationException {
   if (paramAuthState == null)
     throw new IllegalArgumentException("Authentication state may not be null");
   if (paramMap == null) throw new IllegalArgumentException("Challenge map may not be null");
   if ((paramAuthState.isPreemptive()) || (paramAuthState.getAuthScheme() == null))
     paramAuthState.setAuthScheme(selectAuthScheme(paramMap));
   AuthScheme localAuthScheme = paramAuthState.getAuthScheme();
   String str1 = localAuthScheme.getSchemeName();
   if (LOG.isDebugEnabled()) LOG.debug("Using authentication scheme: " + str1);
   String str2 = (String) paramMap.get(str1.toLowerCase());
   if (str2 == null)
     throw new AuthenticationException(str1 + " authorization challenge expected, but not found");
   localAuthScheme.processChallenge(str2);
   LOG.debug("Authorization challenge processed");
   return localAuthScheme;
 }