Package edu.ucsb.nceas.metacat.util
Class AuthUtil
java.lang.Object
edu.ucsb.nceas.metacat.util.AuthUtil
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
authenticateUserWithCN
(javax.servlet.http.HttpServletRequest request) Authenticate the user against the CN server and/or any locally-configured certificates.static boolean
canInsertOrUpdate
(String username, String[] groups) Check if the specified user can insert the documentGet the administrators from metacat.propertiesGet the allowed submitters from metacat.propertiesGet the denied submitters from metacat.propertiesGet the moderators from metacat.propertiesstatic boolean
isAdministrator
(String username, String[] groups) Check if the specified user is part of the administrators liststatic boolean
isAllowedSubmitter
(String username, String[] groups) Check if the specified user is part of the moderators liststatic boolean
Reports whether LDAP is fully configured.static boolean
isDeniedSubmitter
(String username, String[] groups) Check if the specified user is part of the moderators liststatic boolean
isModerator
(String username, String[] groups) Check if the specified user is part of the moderators liststatic 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 void
Get the vector of allowed submitter credentials from metacat.properties and put into global allowedSubmitters listConvert a delimited string to a Vector by splitting on a particular character
-
Field Details
-
logMetacat
public static org.apache.commons.logging.Log logMetacat -
DELIMITER
-
ESCAPECHAR
-
-
Method Details
-
getAdministrators
Get the administrators from metacat.properties- Returns:
- a Vector of Strings holding the administrators
- Throws:
MetacatUtilException
-
getAllowedSubmitters
Get the allowed submitters from metacat.properties- Returns:
- a Vector of Strings holding the submitters
- Throws:
MetacatUtilException
-
getDeniedSubmitters
Get the denied submitters from metacat.properties- Returns:
- a Vector of Strings holding the denied submitters
- Throws:
MetacatUtilException
-
getModerators
Get the moderators from metacat.properties- Returns:
- a Vector of Strings holding the moderators
- Throws:
MetacatUtilException
-
populateAllowedSubmitters
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
Reports whether LDAP is fully configured.- Returns:
- a boolean that is true if all sections are configured and false otherwise
- Throws:
MetacatUtilException
-
isAdministrator
Check if the specified user is part of the administrators list- Parameters:
username
- the username or subjectgroups
- an optional list of the user's groups- Throws:
MetacatUtilException
-
isModerator
Check if the specified user is part of the moderators list- Parameters:
username
- the user login credentialsgroups
- 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 credentialsgroups
- 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 credentialsgroups
- 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 credentialsgroups
- a list of the user's groups- Throws:
MetacatUtilException
-
split
Convert a delimited string to a Vector by splitting on a particular character- Parameters:
text
- the text to be split into componentsdelimiter
- the string to specify the delimiterescapeChar
- 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.
-