edu.ucsb.nceas.metacat.util

## Class AuthUtil

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

-     public class AuthUtil
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DELIMITER`
    `static java.lang.String` | `ESCAPECHAR`
    `static org.apache.commons.logging.Log` | `logMetacat`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `canInsertOrUpdate(java.lang.String username, java.lang.String[] groups)` Check if the specified user can insert the document
    `static java.lang.String` | `createLDAPString(java.lang.String username, java.lang.String organization, java.util.Vector<java.lang.String> dnList)` Creates an ldap credentail string from the username, organization and dn list.
    `static java.util.Vector<java.lang.String>` | `getAdministrators()` Get the administrators from metacat.properties
    `static java.util.Vector<java.lang.String>` | `getAllowedSubmitters()` Get the allowed submitters from metacat.properties
    `static java.util.Vector<java.lang.String>` | `getDeniedSubmitters()` Get the denied submitters from metacat.properties
    `static java.lang.String[]` | `getGroupNames(javax.servlet.http.HttpServletRequest request)` Gets the user group names from the login session on the http request
    `static java.util.Vector<java.lang.String>` | `getModerators()` Get the moderators from metacat.properties
    `static java.lang.String` | `getUserName(javax.servlet.http.HttpServletRequest request)` Gets the user name from the login session on the http request
    `static boolean` | `isAdministrator(java.lang.String username, java.lang.String[] groups)` Check if the specified user is part of the administrators list
    `static boolean` | `isAllowedSubmitter(java.lang.String username, java.lang.String[] groups)` Check if the specified user is part of the moderators list
    `static boolean` | `isAuthConfigured()` Reports whether LDAP is fully configured.
    `static boolean` | `isDeniedSubmitter(java.lang.String username, java.lang.String[] groups)` Check if the specified user is part of the moderators list
    `static boolean` | `isModerator(java.lang.String username, java.lang.String[] groups)` Check if the specified user is part of the moderators list
    `static boolean` | `isUserLoggedIn(javax.servlet.http.HttpServletRequest request)` Checks to see if the user is logged in by grabbing the session from the request and seeing if it exists in the global session list.
    `static boolean` | `isUserLoggedInAsAdmin(javax.servlet.http.HttpServletRequest request)` 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.
    `static boolean` | `logUserIn(javax.servlet.http.HttpServletRequest request, java.lang.String userName, java.lang.String password)` log the user in against ldap.
    `static void` | `populateAllowedSubmitters()` Get the vector of allowed submitter credentials from metacat.properties and put into global allowedSubmitters list
    `static java.util.Vector<java.lang.String>` | `split(java.lang.String text, java.lang.String delimiter, java.lang.String escapeChar)` Convert a delimited string to a Vector by splitting on a particular character

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logMetacat

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

    - #### DELIMITER

          public static java.lang.String DELIMITER

    - #### ESCAPECHAR

          public static java.lang.String ESCAPECHAR

  - ### Method Detail

    - #### getAdministrators

          public static java.util.Vector<java.lang.String> getAdministrators()
                                                                      throws MetacatUtilException

      Get the administrators from metacat.properties
      Returns:
        a Vector of Strings holding the administrators
      Throws:
        `MetacatUtilException`

    - #### getAllowedSubmitters

          public static java.util.Vector<java.lang.String> getAllowedSubmitters()
                                                                         throws MetacatUtilException

      Get the allowed submitters from metacat.properties
      Returns:
        a Vector of Strings holding the submitters
      Throws:
        `MetacatUtilException`

    - #### getDeniedSubmitters

          public static java.util.Vector<java.lang.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 java.util.Vector<java.lang.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`

    - #### logUserIn

          public static boolean logUserIn(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String userName,
                                          java.lang.String password)
                                   throws MetacatUtilException

      log the user in against ldap. If the login is successful, add the session information to the session list in SessionUtil.
      Parameters:
        `request` - the http request.
      Throws:
        `MetacatUtilException`

    - #### isUserLoggedIn

          public static boolean isUserLoggedIn(javax.servlet.http.HttpServletRequest request)
                                        throws MetacatUtilException

      Checks to see if the user is logged in by grabbing the session from the request and seeing if it exists in the global session list.
      Parameters:
        `request` - the http request that holds the login session
      Returns:
        boolean that is true if the user is logged in, false otherwise
      Throws:
        `MetacatUtilException`

    - #### 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`

    - #### getUserName

          public static java.lang.String getUserName(javax.servlet.http.HttpServletRequest request)

      Gets the user name from the login session on the http request
      Parameters:
        `request` - the http request that holds the login session
      Returns:
        String that holds the user name

    - #### getGroupNames

          public static java.lang.String[] getGroupNames(javax.servlet.http.HttpServletRequest request)

      Gets the user group names from the login session on the http request
      Parameters:
        `request` - the http request that holds the login session
      Returns:
        String array that holds the user groups

    - #### createLDAPString

          public static java.lang.String createLDAPString(java.lang.String username,
                                                          java.lang.String organization,
                                                          java.util.Vector<java.lang.String> dnList)
                                                   throws MetacatUtilException

      Creates an ldap credentail string from the username, organization and dn list.
      Parameters:
        `username` - the user name
        `organization` - the organization
        `dnList` - a list of dns
      Returns:
        String holding the ldap login string
      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(java.lang.String username,
                                                java.lang.String[] groups)
                                         throws MetacatUtilException

      Check if the specified user is part of the administrators list
      Parameters:
        `username` - the user login credentails
        `groups` - a list of the user's groups
      Throws:
        `MetacatUtilException`

    - #### isModerator

          public static boolean isModerator(java.lang.String username,
                                            java.lang.String[] groups)
                                     throws MetacatUtilException

      Check if the specified user is part of the moderators list
      Parameters:
        `username` - the user login credentails
        `groups` - a list of the user's groups
      Throws:
        `MetacatUtilException`

    - #### isAllowedSubmitter

          public static boolean isAllowedSubmitter(java.lang.String username,
                                                   java.lang.String[] groups)
                                            throws MetacatUtilException

      Check if the specified user is part of the moderators list
      Parameters:
        `username` - the user login credentails
        `groups` - a list of the user's groups
      Throws:
        `MetacatUtilException`

    - #### isDeniedSubmitter

          public static boolean isDeniedSubmitter(java.lang.String username,
                                                  java.lang.String[] groups)
                                           throws MetacatUtilException

      Check if the specified user is part of the moderators list
      Parameters:
        `username` - the user login credentails
        `groups` - a list of the user's groups
      Throws:
        `MetacatUtilException`

    - #### canInsertOrUpdate

          public static boolean canInsertOrUpdate(java.lang.String username,
                                                  java.lang.String[] groups)
                                           throws MetacatUtilException

      Check if the specified user can insert the document
      Parameters:
        `username` - the user login credentails
        `groups` - a list of the user's groups
      Throws:
        `MetacatUtilException`

    - #### split

          public static java.util.Vector<java.lang.String> split(java.lang.String text,
                                                                 java.lang.String delimiter,
                                                                 java.lang.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.

Copyright © 2023 Regents of the University of California. All Rights Reserved.