Class AuthUtil

java.lang.Object
edu.ucsb.nceas.metacat.util.AuthUtil

public class AuthUtil extends Object
  • Field Details

    • logMetacat

      public static org.apache.commons.logging.Log logMetacat
    • DELIMITER

      public static String DELIMITER
    • ESCAPECHAR

      public static String ESCAPECHAR
  • Method Details

    • getAdministrators

      public static Vector<String> getAdministrators() throws MetacatUtilException
      Get the administrators from metacat.properties
      Returns:
      a Vector of Strings holding the administrators
      Throws:
      MetacatUtilException
    • getAllowedSubmitters

      public static Vector<String> getAllowedSubmitters() throws MetacatUtilException
      Get the allowed submitters from metacat.properties
      Returns:
      a Vector of Strings holding the submitters
      Throws:
      MetacatUtilException
    • getDeniedSubmitters

      public static Vector<String> getDeniedSubmitters() throws MetacatUtilException
      Get the denied submitters from metacat.properties
      Returns:
      a Vector of Strings holding the denied submitters
      Throws:
      MetacatUtilException
    • getModerators

      public static Vector<String> getModerators() throws MetacatUtilException
      Get the moderators from metacat.properties
      Returns:
      a Vector of Strings holding the moderators
      Throws:
      MetacatUtilException
    • populateAllowedSubmitters

      public static void populateAllowedSubmitters() throws MetacatUtilException
      Get the vector of allowed submitter credentials from metacat.properties and put into global allowedSubmitters list
      Throws:
      MetacatUtilException
    • authenticateUserWithCN

      public static String authenticateUserWithCN(javax.servlet.http.HttpServletRequest request) throws MetacatUtilException
      Authenticate the user against the CN server and/or any locally-configured certificates. If the login is successful, add the session information to the session list in SessionUtil.
      Parameters:
      request - the http request.
      Returns:
      the userId if successful
      Throws:
      MetacatUtilException - if there's a problem adding the userId to the session
    • isUserLoggedInAsAdmin

      public static boolean isUserLoggedInAsAdmin(javax.servlet.http.HttpServletRequest request) throws MetacatUtilException
      Checks to see if the user is logged in as admin by first checking if the user is logged in and then seeing if the user's account is on the administrators list in metacat.properties.
      Parameters:
      request - the http request that holds the login session
      Returns:
      boolean that is true if the user is logged in as admin, false otherwise
      Throws:
      MetacatUtilException
    • isAuthConfigured

      public static boolean isAuthConfigured() throws MetacatUtilException
      Reports whether LDAP is fully configured.
      Returns:
      a boolean that is true if all sections are configured and false otherwise
      Throws:
      MetacatUtilException
    • isAdministrator

      public static boolean isAdministrator(String username, String[] groups) throws MetacatUtilException
      Check if the specified user is part of the administrators list
      Parameters:
      username - the username or subject
      groups - an optional list of the user's groups
      Throws:
      MetacatUtilException
    • isModerator

      public static boolean isModerator(String username, String[] groups) throws MetacatUtilException
      Check if the specified user is part of the moderators list
      Parameters:
      username - the user login credentials
      groups - a list of the user's groups
      Throws:
      MetacatUtilException
    • isAllowedSubmitter

      public static boolean isAllowedSubmitter(String username, String[] groups) throws MetacatUtilException
      Check if the specified user is part of the moderators list
      Parameters:
      username - the user login credentials
      groups - a list of the user's groups
      Throws:
      MetacatUtilException
    • isDeniedSubmitter

      public static boolean isDeniedSubmitter(String username, String[] groups) throws MetacatUtilException
      Check if the specified user is part of the moderators list
      Parameters:
      username - the user login credentials
      groups - a list of the user's groups
      Throws:
      MetacatUtilException
    • canInsertOrUpdate

      public static boolean canInsertOrUpdate(String username, String[] groups) throws MetacatUtilException
      Check if the specified user can insert the document
      Parameters:
      username - the user login credentials
      groups - a list of the user's groups
      Throws:
      MetacatUtilException
    • split

      public static Vector<String> split(String text, String delimiter, String escapeChar)
      Convert a delimited string to a Vector by splitting on a particular character
      Parameters:
      text - the text to be split into components
      delimiter - the string to specify the delimiter
      escapeChar - the string to escape a delimiter.
      Returns:
      a vector holding the values. An empty vector will be returned if the text is null or empty.