Package org.opennms.netmgt.config
Class UserManager
- java.lang.Object
-
- org.opennms.netmgt.config.UserManager
-
- All Implemented Interfaces:
UserConfig
- Direct Known Subclasses:
MockUserManager,UserFactory
public abstract class UserManager extends Object implements UserConfig
Abstract UserManager class.
- Author:
- David Hustace, Matt Brozowski, Benjamin Reed, Jeff Gehlbach
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.opennms.netmgt.config.api.UserConfig
UserConfig.ContactType
-
-
Field Summary
Fields Modifier and Type Field Description static StringALLOW_UNSALTED_PROPERTYprotected Map<String,List<DutySchedule>>m_dutySchedulesThe duty schedules for each userprotected GroupManagerm_groupManagerprotected Map<String,User>m_usersA mapping of user IDs to the User objects
-
Constructor Summary
Constructors Modifier Constructor Description protectedUserManager(GroupManager groupManager)Constructor for UserManager.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancheckSaltedPassword(String raw, String encrypted)checkSaltedPasswordbooleancomparePasswords(String userID, String aPassword)This method compares two encrypted strings for equality.intcountUsersWithRole(String roleid)countUsersWithRolevoiddeleteUser(String name)Removes the user from the list of users.protected abstract voiddoUpdate()updateStringencryptedPassword(String aPassword, boolean useSalt)encryptedPasswordStringgetContactInfo(String userID, String command)Get the contact info given a command stringStringgetContactInfo(String userId, UserConfig.ContactType contactType)getContactInfoStringgetContactInfo(User user, String command)getContactInfoStringgetContactServiceProvider(String userID, String command)Get the contact service provider, given a command stringStringgetContactServiceProvider(User user, String command)getContactServiceProviderStringgetEmail(String userID)Get a email by nameStringgetEmail(User user)Get a email by userabstract longgetFileSize()StringgetHomePhone(String userID)Get a home phone numberStringgetHomePhone(User user)Get a home phone numberabstract longgetLastModified()StringgetMicroblogName(String name)Get a user's microblog username by usernameStringgetMicroblogName(User user)Get a user's microblog username by UserStringgetMobilePhone(String userID)Get a mobile phone numberStringgetMobilePhone(User user)Get a mobile phone numberStringgetNumericPage(String userID)Get a numeric service providerStringgetNumericPage(User user)Get a numeric service providerStringgetNumericPin(String userID)Get a numeric pinStringgetNumericPin(User user)Get a numeric pinOnmsUsergetOnmsUser(String username)getOnmsUserOnmsUserListgetOnmsUserList()getOnmsUserListStringgetPagerEmail(String userID)Get a pager email by nameStringgetPagerEmail(User user)Get a pager email by userStringgetTextPage(String userID)Get a Text Page Service ProviderStringgetTextPage(User user)Get a Text Page Service ProviderStringgetTextPin(String userID)Get a text pinStringgetTextPin(User user)Get a text pinStringgetTuiPin(String name)Get a user's telephone PIN by nameStringgetTuiPin(User user)Get a user's telephone PIN by User objectUsergetUser(String name)Get a user by nameList<String>getUserNames()getUserNamesMap<String,User>getUsers()Return aMapof usernames to user instances.String[]getUsersScheduledForRole(String roleid, Date time)getUsersScheduledForRoleString[]getUsersWithRole(String roleid)getUsersWithRoleStringgetWorkPhone(String userID)Get a work phone numberStringgetWorkPhone(User user)Get a work phone numberStringgetXMPPAddress(String userID)Get an XMPP address by nameStringgetXMPPAddress(User user)Get an XMPP address by namebooleanhasOnCallRole(String roleid)hasOnCallRolebooleanhasUser(String userName)Returns a boolean indicating if the user name appears in the XML fileabstract booleanisUpdateNeeded()booleanisUserOnDuty(String user, Calendar time)Determines if a user is on duty at a given time.booleanisUserScheduledForRole(User user, String roleid, Date time)isUserScheduledForRolevoidparseXML(InputStream in)parseXMLabstract voidreload()voidrenameUser(String oldName, String newName)When this method is called users name is changed, so also is the username belonging to the group and the view.voidsave(OnmsUser onmsUser)savevoidsaveUser(String name, User details)Adds a new user and overwrites the "users.xml"voidsaveUsers(Collection<User> usersList)saveUsersprotected abstract voidsaveXML(String writerString)saveXMLvoidsetContactInfo(String userId, UserConfig.ContactType contactType, String contactValue)setContactInfovoidsetEncryptedPassword(String userID, String aPassword, boolean salted)Sets the password for this user, assuming that the value passed in is already encrypted properlyvoidsetUnencryptedPassword(String userID, String aPassword)Sets the password for this user, first encrypting itvoidupdate()updatebooleanuserHasRole(User user, String roleid)userHasRole
-
-
-
Field Detail
-
ALLOW_UNSALTED_PROPERTY
public static final String ALLOW_UNSALTED_PROPERTY
- See Also:
- Constant Field Values
-
m_groupManager
protected GroupManager m_groupManager
-
m_dutySchedules
protected Map<String,List<DutySchedule>> m_dutySchedules
The duty schedules for each user
-
-
Constructor Detail
-
UserManager
protected UserManager(GroupManager groupManager)
Constructor for UserManager.
- Parameters:
groupManager- aGroupManagerobject.
-
-
Method Detail
-
parseXML
public void parseXML(InputStream in)
parseXML
- Specified by:
parseXMLin interfaceUserConfig- Parameters:
in- aInputStreamobject.
-
saveUser
public void saveUser(String name, User details) throws Exception
Adds a new user and overwrites the "users.xml"- Specified by:
saveUserin interfaceUserConfig- Parameters:
name- aStringobject.details- aUserobject.- Throws:
Exception- if any.
-
save
public void save(OnmsUser onmsUser) throws Exception
Description copied from interface:UserConfigsave
- Specified by:
savein interfaceUserConfig- Throws:
Exception
-
isUserOnDuty
public boolean isUserOnDuty(String user, Calendar time) throws IOException
Determines if a user is on duty at a given time. If a user has no duty schedules listed in the configuration file, that user is assumed to always be on duty.- Specified by:
isUserOnDutyin interfaceUserConfig- Parameters:
user- the user idtime- the time to check for a duty schedule- Returns:
- boolean, true if the user is on duty, false otherwise.
- Throws:
IOException- if any.
-
getUsers
public Map<String,User> getUsers() throws IOException
Return aMapof usernames to user instances.- Specified by:
getUsersin interfaceUserConfig- Returns:
- a
Mapobject. - Throws:
IOException- if any.
-
getOnmsUserList
public OnmsUserList getOnmsUserList() throws IOException
Description copied from interface:UserConfiggetOnmsUserList
- Specified by:
getOnmsUserListin interfaceUserConfig- Returns:
- an OnmsUserList
- Throws:
IOException
-
getOnmsUser
public OnmsUser getOnmsUser(String username) throws IOException
Description copied from interface:UserConfiggetOnmsUser
- Specified by:
getOnmsUserin interfaceUserConfig- Returns:
- an OnmsUser
- Throws:
IOException
-
hasUser
public boolean hasUser(String userName) throws IOException
Returns a boolean indicating if the user name appears in the XML file- Specified by:
hasUserin interfaceUserConfig- Parameters:
userName- aStringobject.- Returns:
- true if the user exists in the XML file, false otherwise
- Throws:
IOException- if any.
-
getUserNames
public List<String> getUserNames() throws IOException
getUserNames
- Specified by:
getUserNamesin interfaceUserConfig- Returns:
- a
Listobject. - Throws:
IOException- if any.
-
getUser
public User getUser(String name) throws IOException
Get a user by name- Specified by:
getUserin interfaceUserConfig- Parameters:
name- the name of the user to return- Returns:
- the user specified by name
- Throws:
IOException- if any.
-
getTuiPin
public String getTuiPin(String name) throws IOException
Get a user's telephone PIN by name- Specified by:
getTuiPinin interfaceUserConfig- Parameters:
name- the name of the user to return- Returns:
- the telephone PIN of the user specified by name
- Throws:
IOException- if any.
-
getTuiPin
public String getTuiPin(User user) throws IOException
Get a user's telephone PIN by User object- Specified by:
getTuiPinin interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- the telephone PIN of the user specified by user
- Throws:
IOException- if any.
-
getMicroblogName
public String getMicroblogName(String name) throws FileNotFoundException, IOException
Get a user's microblog username by username- Specified by:
getMicroblogNamein interfaceUserConfig- Parameters:
name- the username of the user whose microblog username should be returned- Returns:
- the microblog username of the specified user
- Throws:
IOException- if any.FileNotFoundException- if any.
-
getMicroblogName
public String getMicroblogName(User user) throws FileNotFoundException, IOException
Get a user's microblog username by User- Parameters:
user- the user object of the user whose microblog username should be returned- Returns:
- the microblog username of the specified user
- Throws:
IOException- if any.FileNotFoundException- if any.
-
setContactInfo
public void setContactInfo(String userId, UserConfig.ContactType contactType, String contactValue) throws Exception
Description copied from interface:UserConfigsetContactInfo
- Specified by:
setContactInfoin interfaceUserConfig- Throws:
Exception
-
getContactInfo
public String getContactInfo(String userId, UserConfig.ContactType contactType) throws IOException
Description copied from interface:UserConfiggetContactInfo
- Specified by:
getContactInfoin interfaceUserConfig- Returns:
- a String
- Throws:
IOException
-
getContactInfo
public String getContactInfo(String userID, String command) throws IOException
Get the contact info given a command string- Specified by:
getContactInfoin interfaceUserConfig- Parameters:
userID- the name of the usercommand- the command to look up the contact info for- Returns:
- the contact information
- Throws:
IOException- if any.
-
getContactInfo
public String getContactInfo(User user, String command) throws IOException
getContactInfo
- Specified by:
getContactInfoin interfaceUserConfig- Parameters:
user- aUserobject.command- aStringobject.- Returns:
- a
Stringobject. - Throws:
IOException- if any.
-
getContactServiceProvider
public String getContactServiceProvider(String userID, String command) throws IOException
Get the contact service provider, given a command string- Specified by:
getContactServiceProviderin interfaceUserConfig- Parameters:
userID- the name of the usercommand- the command to look up the contact info for- Returns:
- the contact information
- Throws:
IOException- if any.
-
getContactServiceProvider
public String getContactServiceProvider(User user, String command) throws IOException
getContactServiceProvider
- Specified by:
getContactServiceProviderin interfaceUserConfig- Parameters:
user- aUserobject.command- aStringobject.- Returns:
- a
Stringobject. - Throws:
IOException- if any.
-
getEmail
public String getEmail(String userID) throws IOException
Get a email by name- Specified by:
getEmailin interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the email specified by name
- Throws:
IOException- if any.
-
getEmail
public String getEmail(User user) throws IOException
Get a email by user- Specified by:
getEmailin interfaceUserConfig- Parameters:
user- the user to find the email for- Returns:
- String the email specified by name
- Throws:
IOException- if any.
-
getPagerEmail
public String getPagerEmail(String userID) throws IOException
Get a pager email by name- Specified by:
getPagerEmailin interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the pager email
- Throws:
IOException- if any.
-
getPagerEmail
public String getPagerEmail(User user) throws IOException
Get a pager email by user- Specified by:
getPagerEmailin interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the pager email
- Throws:
IOException- if any.
-
getNumericPin
public String getNumericPin(String userID) throws IOException
Get a numeric pin- Specified by:
getNumericPinin interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the numeric pin
- Throws:
IOException- if any.
-
getNumericPin
public String getNumericPin(User user) throws IOException
Get a numeric pin- Specified by:
getNumericPinin interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the numeric pin
- Throws:
IOException- if any.
-
getXMPPAddress
public String getXMPPAddress(String userID) throws IOException
Get an XMPP address by name- Specified by:
getXMPPAddressin interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the XMPP address
- Throws:
IOException- if any.
-
getXMPPAddress
public String getXMPPAddress(User user) throws IOException
Get an XMPP address by name- Specified by:
getXMPPAddressin interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the XMPP address
- Throws:
IOException- if any.
-
getNumericPage
public String getNumericPage(String userID) throws IOException
Get a numeric service provider- Specified by:
getNumericPagein interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the service provider
- Throws:
IOException- if any.
-
getNumericPage
public String getNumericPage(User user) throws IOException
Get a numeric service provider- Specified by:
getNumericPagein interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the service provider
- Throws:
IOException- if any.
-
getTextPin
public String getTextPin(String userID) throws IOException
Get a text pin- Specified by:
getTextPinin interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the text pin
- Throws:
IOException- if any.
-
getTextPin
public String getTextPin(User user) throws IOException
Get a text pin- Specified by:
getTextPinin interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the text pin
- Throws:
IOException- if any.
-
getTextPage
public String getTextPage(String userID) throws IOException
Get a Text Page Service Provider- Specified by:
getTextPagein interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the text page service provider.
- Throws:
IOException- if any.
-
getTextPage
public String getTextPage(User user) throws IOException
Get a Text Page Service Provider- Specified by:
getTextPagein interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the text page service provider.
- Throws:
IOException- if any.
-
getWorkPhone
public String getWorkPhone(String userID) throws IOException
Get a work phone number- Specified by:
getWorkPhonein interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the work phone number
- Throws:
IOException- if any.
-
getWorkPhone
public String getWorkPhone(User user) throws IOException
Get a work phone number- Specified by:
getWorkPhonein interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the work phone number
- Throws:
IOException- if any.
-
getMobilePhone
public String getMobilePhone(String userID) throws IOException
Get a mobile phone number- Specified by:
getMobilePhonein interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the mobile phone number
- Throws:
IOException- if any.
-
getMobilePhone
public String getMobilePhone(User user) throws IOException
Get a mobile phone number- Specified by:
getMobilePhonein interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the mobile phone number
- Throws:
IOException- if any.
-
getHomePhone
public String getHomePhone(String userID) throws IOException
Get a home phone number- Specified by:
getHomePhonein interfaceUserConfig- Parameters:
userID- the user ID of the user to return- Returns:
- String the home phone number
- Throws:
IOException- if any.
-
getHomePhone
public String getHomePhone(User user) throws IOException
Get a home phone number- Specified by:
getHomePhonein interfaceUserConfig- Parameters:
user- aUserobject.- Returns:
- String the home phone number
- Throws:
IOException- if any.
-
saveUsers
public void saveUsers(Collection<User> usersList) throws Exception
saveUsers
- Specified by:
saveUsersin interfaceUserConfig- Parameters:
usersList- aCollectionobject.- Throws:
Exception- if any.
-
deleteUser
public void deleteUser(String name) throws Exception
Removes the user from the list of users. Then overwrites to the "users.xml"- Specified by:
deleteUserin interfaceUserConfig- Parameters:
name- aStringobject.- Throws:
Exception- if any.
-
saveXML
protected abstract void saveXML(String writerString) throws IOException
saveXML
- Parameters:
writerString- aStringobject.- Throws:
IOException- if any.
-
renameUser
public void renameUser(String oldName, String newName) throws Exception
When this method is called users name is changed, so also is the username belonging to the group and the view. Also overwrites the "users.xml" file- Specified by:
renameUserin interfaceUserConfig- Parameters:
oldName- aStringobject.newName- aStringobject.- Throws:
Exception- if any.
-
setEncryptedPassword
public void setEncryptedPassword(String userID, String aPassword, boolean salted) throws Exception
Sets the password for this user, assuming that the value passed in is already encrypted properly- Specified by:
setEncryptedPasswordin interfaceUserConfig- Parameters:
userID- the user ID to change the password foraPassword- the encrypted password- Throws:
Exception- if any.
-
setUnencryptedPassword
public void setUnencryptedPassword(String userID, String aPassword) throws Exception
Sets the password for this user, first encrypting it- Specified by:
setUnencryptedPasswordin interfaceUserConfig- Parameters:
userID- the user ID to change the password foraPassword- the password- Throws:
Exception- if any.
-
encryptedPassword
public String encryptedPassword(String aPassword, boolean useSalt)
encryptedPassword
- Specified by:
encryptedPasswordin interfaceUserConfig- Parameters:
aPassword- aStringobject.useSalt- TODO- Returns:
- a
Stringobject.
-
comparePasswords
public boolean comparePasswords(String userID, String aPassword)
This method compares two encrypted strings for equality.- Specified by:
comparePasswordsin interfaceUserConfig- Parameters:
userID- the user ID to check against.aPassword- the password to check for equality- Returns:
- true if the two passwords are equal (after encryption), false otherwise
-
checkSaltedPassword
public boolean checkSaltedPassword(String raw, String encrypted)
Description copied from interface:UserConfigcheckSaltedPassword
- Specified by:
checkSaltedPasswordin interfaceUserConfig- Returns:
- a boolean
-
doUpdate
protected abstract void doUpdate() throws IOException, FileNotFoundExceptionupdate
- Throws:
IOException- if any.FileNotFoundException- if any.
-
update
public final void update() throws IOExceptionDescription copied from interface:UserConfigupdate
- Specified by:
updatein interfaceUserConfig- Throws:
IOExceptionFileNotFoundException
-
getUsersWithRole
public String[] getUsersWithRole(String roleid) throws IOException
getUsersWithRole
- Specified by:
getUsersWithRolein interfaceUserConfig- Parameters:
roleid- aStringobject.- Returns:
- an array of
Stringobjects. - Throws:
IOException- if any.
-
userHasRole
public boolean userHasRole(User user, String roleid) throws FileNotFoundException, IOException
userHasRole
- Specified by:
userHasRolein interfaceUserConfig- Parameters:
user- aUserobject.roleid- aStringobject.- Returns:
- a boolean.
- Throws:
FileNotFoundException- if any.IOException- if any.
-
isUserScheduledForRole
public boolean isUserScheduledForRole(User user, String roleid, Date time) throws FileNotFoundException, IOException
isUserScheduledForRole
- Specified by:
isUserScheduledForRolein interfaceUserConfig- Parameters:
user- aUserobject.roleid- aStringobject.time- aDateobject.- Returns:
- a boolean.
- Throws:
FileNotFoundException- if any.IOException- if any.
-
getUsersScheduledForRole
public String[] getUsersScheduledForRole(String roleid, Date time) throws IOException
getUsersScheduledForRole
- Specified by:
getUsersScheduledForRolein interfaceUserConfig- Parameters:
roleid- aStringobject.time- aDateobject.- Returns:
- an array of
Stringobjects. - Throws:
IOException- if any.
-
hasOnCallRole
public boolean hasOnCallRole(String roleid) throws IOException
hasOnCallRole
- Specified by:
hasOnCallRolein interfaceUserConfig- Parameters:
roleid- aStringobject.- Returns:
- a boolean.
- Throws:
IOException- if any.
-
countUsersWithRole
public int countUsersWithRole(String roleid) throws IOException
countUsersWithRole
- Specified by:
countUsersWithRolein interfaceUserConfig- Parameters:
roleid- aStringobject.- Returns:
- a int.
- Throws:
IOException- if any.
-
isUpdateNeeded
public abstract boolean isUpdateNeeded()
-
getLastModified
public abstract long getLastModified()
-
getFileSize
public abstract long getFileSize()
-
reload
public abstract void reload() throws IOException, FileNotFoundException- Throws:
IOExceptionFileNotFoundException
-
-