src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/security/SecurityContext.java
public void login(
      HttpServletRequest request,
      HttpServletResponse response,
      MultivaluedMap<String, String> formData)
      throws AuthenticationException, HttpAction, IOException {
    boolean authenticationEnabled = isAuthenticationEnabled();
    if (!authenticationEnabled) {
      String reqUsername = request.getParameter("proxy");
      if (reqUsername != null && !reqUsername.isEmpty()) {
        currentUser.set(reqUsername);
      }
      return;
    }

    String username;
    String password;
    if (formData == null) {
      username = request.getParameter("username");
      password = request.getParameter("password");
    } else {
      username = formData.getFirst("username");
      password = formData.getFirst("password");
    }

    if (username == null || username.isEmpty() || password == null || password.isEmpty()) {
      LOG.info("Corrupt login credentials for: {}", request.getRemoteAddr());
      throw new AuthenticationException("Bad username / password provided.");
    }

    // Perform local authentication if found.
    if (localLogin(request, response, username, password)) {
      return;
    }

    // Perform LDAP authentication if found.
    if (ldapLogin(request, response, username, password)) {
      return;
    }

    LOG.info("Login failed for: {}", request.getRemoteAddr());
    throw new AuthenticationException("Authentication required.");
  }
/**
   * Begin authenticated web session; set a JWT on response if successful; 401/403 otherwise.
   *
   * @param request - The HTTP request.
   * @param response - The HTTP response.
   * @param formData - The HTTP POST form data if from Jersey.
   */
Begin authenticated web session; set a JWT on response if successful; 401/403 otherwise.
@param request - The HTTP request.
@param response - The HTTP response.
@param formData - The HTTP POST form data if from Jersey.
Begin authenticated web session ; set a JWT on response if successful ; 401 / 403 otherwise . @param request - The HTTP request . @param response - The HTTP response . @param formData - The HTTP POST form data if from Jersey .
public void login(
      HttpServletRequest request,
      HttpServletResponse response,
      MultivaluedMap<String, String> formData)
      throws AuthenticationException, HttpAction, IOException {
    boolean authenticationEnabled = isAuthenticationEnabled();
    if (!authenticationEnabled) {
      String reqUsername = request.getParameter("proxy");
      if (reqUsername != null && !reqUsername.isEmpty()) {
        currentUser.set(reqUsername);
      }
      return;
    }
    String username;
    String password;
    if (formData == null) {
      username = request.getParameter("username");
      password = request.getParameter("password");
    } else {
      username = formData.getFirst("username");
      password = formData.getFirst("password");
    }
    if (username == null || username.isEmpty() || password == null || password.isEmpty()) {
      LOG.info("Corrupt login credentials for: {}", request.getRemoteAddr());
      throw new AuthenticationException("Bad username / password provided.");
    }
    if (localLogin(request, response, username, password)) {
      return;
    }
    if (ldapLogin(request, response, username, password)) {
      return;
    }
    LOG.info("Login failed for: {}", request.getRemoteAddr());
    throw new AuthenticationException("Authentication required.");
  }
public void login ( HttpServletRequest request , HttpServletResponse response , MultivaluedMap < String , String > formData ) throws AuthenticationException , HttpAction , IOException { boolean authenticationEnabled = isAuthenticationEnabled ( ) ; if ( ! authenticationEnabled ) { String reqUsername = request . getParameter ( "proxy" ) ; if ( reqUsername != null && ! reqUsername . isEmpty ( ) ) { currentUser . set ( reqUsername ) ; } return ; } String username ; String password ; if ( formData == null ) { username = request . getParameter ( "username" ) ; password = request . getParameter ( "password" ) ; } else { username = formData . getFirst ( "username" ) ; password = formData . getFirst ( "password" ) ; } if ( username == null || username . isEmpty ( ) || password == null || password . isEmpty ( ) ) { LOG . info ( "Corrupt login credentials for: {}" , request . getRemoteAddr ( ) ) ; throw new AuthenticationException ( "Bad username / password provided." ) ; } if ( localLogin ( request , response , username , password ) ) { return ; } if ( ldapLogin ( request , response , username , password ) ) { return ; } LOG . info ( "Login failed for: {}" , request . getRemoteAddr ( ) ) ; throw new AuthenticationException ( "Authentication required." ) ; }
Begin authenticated web session; set a JWT on response if successful; 401/403 otherwise.
Begin authenticated web session ; set a JWT on response if successful ; 401 / 403 otherwise .
// Perform local authentication if found. // Perform LDAP authentication if found.