Class AuthFile
java.lang.Object
edu.ucsb.nceas.metacat.authentication.AuthFile
- All Implemented Interfaces:
AuthInterface
This an authentication class base on a username/password file.
It is an alternative authentication mechanism of the ldap authentication.
The password file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
*******
foo@foo.com
Smith
John
NCEAS
nceas-dev
developers at NCEAS
http://commons.apache.org/proper/commons-configuration/userguide/howto_xml.html
- Author:
- tao
-
Field Summary
Fields inherited from interface edu.ucsb.nceas.metacat.AuthInterface
GROUPDESINDEX, GROUPNAMEINDEX, USERCNINDEX, USERDNINDEX, USEREMAILINDEX, USERINFOCNINDEX, USERINFOEMAILINDEX, USERINFOORGANIDEX, USERORGINDEX, USERORGUNITINDEX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a group into the filevoid
addUser
(String dn, String[] groups, String plainPass, String hashedPass, String email, String surName, String givenName, String organization) Add a user to the filevoid
addUserToGroup
(String userName, String group) Add a user to a groupboolean
authenticate
(String user, String password) Determine if a user/password are valid according to the authentication service.getAttributes
(String foruser) Get attributes describing a user or groupgetAttributes
(String user, String password, String foruser) Get attributes describing a user or groupString[][]
Get all groups from the authentication serviceString[][]
Get the groups for a particular user from the authentication servicegetPrincipals
(String user, String password) Get all groups and users from authentication service.String[]
getUserInfo
(String user, String password) Get information for a user - name, organization and email address.String[][]
Get all users from the authentication serviceString[]
Get the users for a particular group from the authentication servicestatic void
A method is used to help administrator to manage users and groupsvoid
modifyPassWithHash
(String userName, String newHashPassword) Change the password of the user to the new one which is hashedvoid
modifyPassWithPlain
(String userName, String newPlainPassword) Change the password of the user to the new one which is plain.void
removeUserFromGroup
(String userName, String group) Remove a user from a group.
-
Constructor Details
-
AuthFile
Constructor- Throws:
AuthenticationException
-
AuthFile
- Parameters:
passwordFile
-- Throws:
AuthenticationException
-
-
Method Details
-
authenticate
Description copied from interface:AuthInterface
Determine if a user/password are valid according to the authentication service.- Specified by:
authenticate
in interfaceAuthInterface
- Parameters:
user
- the name of the principal to authenticatepassword
- the password to use for authentication- Throws:
AuthenticationException
-
getUsers
Description copied from interface:AuthInterface
Get all users from the authentication service- Specified by:
getUsers
in interfaceAuthInterface
- Throws:
ConnectException
-
getUserInfo
Description copied from interface:AuthInterface
Get information for a user - name, organization and email address.- Specified by:
getUserInfo
in interfaceAuthInterface
- Throws:
ConnectException
-
getUsers
Description copied from interface:AuthInterface
Get the users for a particular group from the authentication service- Specified by:
getUsers
in interfaceAuthInterface
- Throws:
ConnectException
-
getGroups
Description copied from interface:AuthInterface
Get all groups from the authentication service- Specified by:
getGroups
in interfaceAuthInterface
- Throws:
ConnectException
-
getGroups
Description copied from interface:AuthInterface
Get the groups for a particular user from the authentication service- Specified by:
getGroups
in interfaceAuthInterface
- Throws:
ConnectException
-
getAttributes
Description copied from interface:AuthInterface
Get attributes describing a user or group- Specified by:
getAttributes
in interfaceAuthInterface
- Throws:
ConnectException
-
getAttributes
public HashMap<String,Vector<String>> getAttributes(String user, String password, String foruser) throws ConnectException Description copied from interface:AuthInterface
Get attributes describing a user or group- Specified by:
getAttributes
in interfaceAuthInterface
- Parameters:
user
- the user for which the attribute list is requestedpassword
- the password for authenticating against the service- Throws:
ConnectException
-
getPrincipals
Description copied from interface:AuthInterface
Get all groups and users from authentication service. The output is formatted in XML.- Specified by:
getPrincipals
in interfaceAuthInterface
- Parameters:
user
- the user which requests the informationpassword
- the user's password- Throws:
ConnectException
-
addUser
public void addUser(String dn, String[] groups, String plainPass, String hashedPass, String email, String surName, String givenName, String organization) throws AuthenticationException Add a user to the file- Parameters:
userName
- the name of the usergroups
- the groups the user belong to. The group should exist in the filepassword
- the password of the user- Throws:
AuthenticationException
-
addGroup
Add a group into the file- Parameters:
groupName
- the name of group- Throws:
AuthenticationException
-
modifyPassWithHash
public void modifyPassWithHash(String userName, String newHashPassword) throws AuthenticationException Change the password of the user to the new one which is hashed- Parameters:
usrName
- the specified user.newPassword
- the new password which will be set- Throws:
AuthenticationException
-
modifyPassWithPlain
public void modifyPassWithPlain(String userName, String newPlainPassword) throws AuthenticationException Change the password of the user to the new one which is plain. However, only the hashed version will be serialized.- Parameters:
usrName
- the specified user.newPassword
- the new password which will be set- Throws:
AuthenticationException
-
addUserToGroup
Add a user to a group- Parameters:
userName
- the name of the user. the user should already existgroup
- the name of the group. the group should already exist- Throws:
AuthenticationException
-
removeUserFromGroup
Remove a user from a group.- Parameters:
userName
- the name of the user. the user should already exist.group
- the name of the group- Throws:
AuthenticationException
-
main
A method is used to help administrator to manage users and groups- Parameters:
argus
-- Throws:
Exception
-