src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/security/SecurityContext.java
public synchronized void handleAuthorization(HttpServletRequest req, HttpServletResponse res)
      throws AuthorizationException {
    boolean authorizationEnabled = applicationConfiguration.getAuthorizationEnabled();
    if (!authorizationEnabled) {
      return;
    }
    String user = getUserName();
    String uri = req.getRequestURI();
    for (Endpoint unsecured : Constants.UNSECURED_ENDPOINTS) {
      if (uri.startsWith("/" + unsecured.name())) {
        return;
      }
    }
    for (Endpoint admins : Constants.ADMIN_ENDPOINTS) {
      if (uri.startsWith("/" + admins.name())) {
        if (adminUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint writers : Constants.WRITER_ENDPOINTS) {
      if (uri.startsWith("/" + writers.name())) {
        if (writeUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint readers : Constants.READER_ENDPOINTS) {
      if (uri.startsWith("/" + readers.name())) {
        if (readOnlyUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint cacheReaders : Constants.CACHE_READER_ENDPOINTS) {
      if (uri.startsWith("/" + cacheReaders.name())) {
        if (cacheReaderUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
  }
/**
   * Checks whether user has authorization to make the call they intend to.
   *
   * @param req the HTTP request
   * @param res the HTTP resopnse
   * @throws AuthorizationException user does not have authorization
   */
Checks whether user has authorization to make the call they intend to.
@param req the HTTP request
@param res the HTTP resopnse
@throws AuthorizationException user does not have authorization
Checks whether user has authorization to make the call they intend to . @param req the HTTP request @param res the HTTP resopnse @throws AuthorizationException user does not have authorization
public synchronized void handleAuthorization(HttpServletRequest req, HttpServletResponse res)
      throws AuthorizationException {
    boolean authorizationEnabled = applicationConfiguration.getAuthorizationEnabled();
    if (!authorizationEnabled) {
      return;
    }
    String user = getUserName();
    String uri = req.getRequestURI();
    for (Endpoint unsecured : Constants.UNSECURED_ENDPOINTS) {
      if (uri.startsWith("/" + unsecured.name())) {
        return;
      }
    }
    for (Endpoint admins : Constants.ADMIN_ENDPOINTS) {
      if (uri.startsWith("/" + admins.name())) {
        if (adminUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint writers : Constants.WRITER_ENDPOINTS) {
      if (uri.startsWith("/" + writers.name())) {
        if (writeUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint readers : Constants.READER_ENDPOINTS) {
      if (uri.startsWith("/" + readers.name())) {
        if (readOnlyUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    for (Endpoint cacheReaders : Constants.CACHE_READER_ENDPOINTS) {
      if (uri.startsWith("/" + cacheReaders.name())) {
        if (cacheReaderUsers.allows(user)) {
          return;
        } else {
          throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
        }
      }
    }
    throw new AuthorizationException("User: " + user + ", is not authorized for URI: " + uri);
  }
public synchronized void handleAuthorization ( HttpServletRequest req , HttpServletResponse res ) throws AuthorizationException { boolean authorizationEnabled = applicationConfiguration . getAuthorizationEnabled ( ) ; if ( ! authorizationEnabled ) { return ; } String user = getUserName ( ) ; String uri = req . getRequestURI ( ) ; for ( Endpoint unsecured : Constants . UNSECURED_ENDPOINTS ) { if ( uri . startsWith ( "/" + unsecured . name ( ) ) ) { return ; } } for ( Endpoint admins : Constants . ADMIN_ENDPOINTS ) { if ( uri . startsWith ( "/" + admins . name ( ) ) ) { if ( adminUsers . allows ( user ) ) { return ; } else { throw new AuthorizationException ( "User: " + user + ", is not authorized for URI: " + uri ) ; } } } for ( Endpoint writers : Constants . WRITER_ENDPOINTS ) { if ( uri . startsWith ( "/" + writers . name ( ) ) ) { if ( writeUsers . allows ( user ) ) { return ; } else { throw new AuthorizationException ( "User: " + user + ", is not authorized for URI: " + uri ) ; } } } for ( Endpoint readers : Constants . READER_ENDPOINTS ) { if ( uri . startsWith ( "/" + readers . name ( ) ) ) { if ( readOnlyUsers . allows ( user ) ) { return ; } else { throw new AuthorizationException ( "User: " + user + ", is not authorized for URI: " + uri ) ; } } } for ( Endpoint cacheReaders : Constants . CACHE_READER_ENDPOINTS ) { if ( uri . startsWith ( "/" + cacheReaders . name ( ) ) ) { if ( cacheReaderUsers . allows ( user ) ) { return ; } else { throw new AuthorizationException ( "User: " + user + ", is not authorized for URI: " + uri ) ; } } } throw new AuthorizationException ( "User: " + user + ", is not authorized for URI: " + uri ) ; }
Checks whether user has authorization to make the call they intend to.
Checks whether user has authorization to make the call they intend to .