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.UserConfigUserConfig.ContactType
 
- 
 - 
Field SummaryFields 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 SummaryConstructors Modifier Constructor Description protectedUserManager(GroupManager groupManager)Constructor for UserManager.
 - 
Method SummaryAll 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_PROPERTYpublic static final String ALLOW_UNSALTED_PROPERTY - See Also:
- Constant Field Values
 
 - 
m_groupManagerprotected GroupManager m_groupManager 
 - 
m_dutySchedulesprotected Map<String,List<DutySchedule>> m_dutySchedules The duty schedules for each user
 
- 
 - 
Constructor Detail- 
UserManagerprotected UserManager(GroupManager groupManager) Constructor for UserManager. - Parameters:
- groupManager- a- GroupManagerobject.
 
 
- 
 - 
Method Detail- 
parseXMLpublic void parseXML(InputStream in) parseXML - Specified by:
- parseXMLin interface- UserConfig
- Parameters:
- in- a- InputStreamobject.
 
 - 
saveUserpublic void saveUser(String name, User details) throws Exception Adds a new user and overwrites the "users.xml"- Specified by:
- saveUserin interface- UserConfig
- Parameters:
- name- a- Stringobject.
- details- a- Userobject.
- Throws:
- Exception- if any.
 
 - 
savepublic void save(OnmsUser onmsUser) throws Exception Description copied from interface:UserConfigsave - Specified by:
- savein interface- UserConfig
- Throws:
- Exception
 
 - 
isUserOnDutypublic 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 interface- UserConfig
- Parameters:
- user- the user id
- time- the time to check for a duty schedule
- Returns:
- boolean, true if the user is on duty, false otherwise.
- Throws:
- IOException- if any.
 
 - 
getUserspublic Map<String,User> getUsers() throws IOException Return aMapof usernames to user instances.- Specified by:
- getUsersin interface- UserConfig
- Returns:
- a Mapobject.
- Throws:
- IOException- if any.
 
 - 
getOnmsUserListpublic OnmsUserList getOnmsUserList() throws IOException Description copied from interface:UserConfiggetOnmsUserList - Specified by:
- getOnmsUserListin interface- UserConfig
- Returns:
- an OnmsUserList
- Throws:
- IOException
 
 - 
getOnmsUserpublic OnmsUser getOnmsUser(String username) throws IOException Description copied from interface:UserConfiggetOnmsUser - Specified by:
- getOnmsUserin interface- UserConfig
- Returns:
- an OnmsUser
- Throws:
- IOException
 
 - 
hasUserpublic boolean hasUser(String userName) throws IOException Returns a boolean indicating if the user name appears in the XML file- Specified by:
- hasUserin interface- UserConfig
- Parameters:
- userName- a- Stringobject.
- Returns:
- true if the user exists in the XML file, false otherwise
- Throws:
- IOException- if any.
 
 - 
getUserNamespublic List<String> getUserNames() throws IOException getUserNames - Specified by:
- getUserNamesin interface- UserConfig
- Returns:
- a Listobject.
- Throws:
- IOException- if any.
 
 - 
getUserpublic User getUser(String name) throws IOException Get a user by name- Specified by:
- getUserin interface- UserConfig
- Parameters:
- name- the name of the user to return
- Returns:
- the user specified by name
- Throws:
- IOException- if any.
 
 - 
getTuiPinpublic String getTuiPin(String name) throws IOException Get a user's telephone PIN by name- Specified by:
- getTuiPinin interface- UserConfig
- Parameters:
- name- the name of the user to return
- Returns:
- the telephone PIN of the user specified by name
- Throws:
- IOException- if any.
 
 - 
getTuiPinpublic String getTuiPin(User user) throws IOException Get a user's telephone PIN by User object- Specified by:
- getTuiPinin interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- the telephone PIN of the user specified by user
- Throws:
- IOException- if any.
 
 - 
getMicroblogNamepublic String getMicroblogName(String name) throws FileNotFoundException, IOException Get a user's microblog username by username- Specified by:
- getMicroblogNamein interface- UserConfig
- 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.
 
 - 
getMicroblogNamepublic 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.
 
 - 
setContactInfopublic void setContactInfo(String userId, UserConfig.ContactType contactType, String contactValue) throws Exception Description copied from interface:UserConfigsetContactInfo - Specified by:
- setContactInfoin interface- UserConfig
- Throws:
- Exception
 
 - 
getContactInfopublic String getContactInfo(String userId, UserConfig.ContactType contactType) throws IOException Description copied from interface:UserConfiggetContactInfo - Specified by:
- getContactInfoin interface- UserConfig
- Returns:
- a String
- Throws:
- IOException
 
 - 
getContactInfopublic String getContactInfo(String userID, String command) throws IOException Get the contact info given a command string- Specified by:
- getContactInfoin interface- UserConfig
- Parameters:
- userID- the name of the user
- command- the command to look up the contact info for
- Returns:
- the contact information
- Throws:
- IOException- if any.
 
 - 
getContactInfopublic String getContactInfo(User user, String command) throws IOException getContactInfo - Specified by:
- getContactInfoin interface- UserConfig
- Parameters:
- user- a- Userobject.
- command- a- Stringobject.
- Returns:
- a Stringobject.
- Throws:
- IOException- if any.
 
 - 
getContactServiceProviderpublic String getContactServiceProvider(String userID, String command) throws IOException Get the contact service provider, given a command string- Specified by:
- getContactServiceProviderin interface- UserConfig
- Parameters:
- userID- the name of the user
- command- the command to look up the contact info for
- Returns:
- the contact information
- Throws:
- IOException- if any.
 
 - 
getContactServiceProviderpublic String getContactServiceProvider(User user, String command) throws IOException getContactServiceProvider - Specified by:
- getContactServiceProviderin interface- UserConfig
- Parameters:
- user- a- Userobject.
- command- a- Stringobject.
- Returns:
- a Stringobject.
- Throws:
- IOException- if any.
 
 - 
getEmailpublic String getEmail(String userID) throws IOException Get a email by name- Specified by:
- getEmailin interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the email specified by name
- Throws:
- IOException- if any.
 
 - 
getEmailpublic String getEmail(User user) throws IOException Get a email by user- Specified by:
- getEmailin interface- UserConfig
- Parameters:
- user- the user to find the email for
- Returns:
- String the email specified by name
- Throws:
- IOException- if any.
 
 - 
getPagerEmailpublic String getPagerEmail(String userID) throws IOException Get a pager email by name- Specified by:
- getPagerEmailin interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the pager email
- Throws:
- IOException- if any.
 
 - 
getPagerEmailpublic String getPagerEmail(User user) throws IOException Get a pager email by user- Specified by:
- getPagerEmailin interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the pager email
- Throws:
- IOException- if any.
 
 - 
getNumericPinpublic String getNumericPin(String userID) throws IOException Get a numeric pin- Specified by:
- getNumericPinin interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the numeric pin
- Throws:
- IOException- if any.
 
 - 
getNumericPinpublic String getNumericPin(User user) throws IOException Get a numeric pin- Specified by:
- getNumericPinin interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the numeric pin
- Throws:
- IOException- if any.
 
 - 
getXMPPAddresspublic String getXMPPAddress(String userID) throws IOException Get an XMPP address by name- Specified by:
- getXMPPAddressin interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the XMPP address
- Throws:
- IOException- if any.
 
 - 
getXMPPAddresspublic String getXMPPAddress(User user) throws IOException Get an XMPP address by name- Specified by:
- getXMPPAddressin interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the XMPP address
- Throws:
- IOException- if any.
 
 - 
getNumericPagepublic String getNumericPage(String userID) throws IOException Get a numeric service provider- Specified by:
- getNumericPagein interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the service provider
- Throws:
- IOException- if any.
 
 - 
getNumericPagepublic String getNumericPage(User user) throws IOException Get a numeric service provider- Specified by:
- getNumericPagein interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the service provider
- Throws:
- IOException- if any.
 
 - 
getTextPinpublic String getTextPin(String userID) throws IOException Get a text pin- Specified by:
- getTextPinin interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the text pin
- Throws:
- IOException- if any.
 
 - 
getTextPinpublic String getTextPin(User user) throws IOException Get a text pin- Specified by:
- getTextPinin interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the text pin
- Throws:
- IOException- if any.
 
 - 
getTextPagepublic String getTextPage(String userID) throws IOException Get a Text Page Service Provider- Specified by:
- getTextPagein interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the text page service provider.
- Throws:
- IOException- if any.
 
 - 
getTextPagepublic String getTextPage(User user) throws IOException Get a Text Page Service Provider- Specified by:
- getTextPagein interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the text page service provider.
- Throws:
- IOException- if any.
 
 - 
getWorkPhonepublic String getWorkPhone(String userID) throws IOException Get a work phone number- Specified by:
- getWorkPhonein interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the work phone number
- Throws:
- IOException- if any.
 
 - 
getWorkPhonepublic String getWorkPhone(User user) throws IOException Get a work phone number- Specified by:
- getWorkPhonein interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the work phone number
- Throws:
- IOException- if any.
 
 - 
getMobilePhonepublic String getMobilePhone(String userID) throws IOException Get a mobile phone number- Specified by:
- getMobilePhonein interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the mobile phone number
- Throws:
- IOException- if any.
 
 - 
getMobilePhonepublic String getMobilePhone(User user) throws IOException Get a mobile phone number- Specified by:
- getMobilePhonein interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the mobile phone number
- Throws:
- IOException- if any.
 
 - 
getHomePhonepublic String getHomePhone(String userID) throws IOException Get a home phone number- Specified by:
- getHomePhonein interface- UserConfig
- Parameters:
- userID- the user ID of the user to return
- Returns:
- String the home phone number
- Throws:
- IOException- if any.
 
 - 
getHomePhonepublic String getHomePhone(User user) throws IOException Get a home phone number- Specified by:
- getHomePhonein interface- UserConfig
- Parameters:
- user- a- Userobject.
- Returns:
- String the home phone number
- Throws:
- IOException- if any.
 
 - 
saveUserspublic void saveUsers(Collection<User> usersList) throws Exception saveUsers - Specified by:
- saveUsersin interface- UserConfig
- Parameters:
- usersList- a- Collectionobject.
- Throws:
- Exception- if any.
 
 - 
deleteUserpublic void deleteUser(String name) throws Exception Removes the user from the list of users. Then overwrites to the "users.xml"- Specified by:
- deleteUserin interface- UserConfig
- Parameters:
- name- a- Stringobject.
- Throws:
- Exception- if any.
 
 - 
saveXMLprotected abstract void saveXML(String writerString) throws IOException saveXML - Parameters:
- writerString- a- Stringobject.
- Throws:
- IOException- if any.
 
 - 
renameUserpublic 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 interface- UserConfig
- Parameters:
- oldName- a- Stringobject.
- newName- a- Stringobject.
- Throws:
- Exception- if any.
 
 - 
setEncryptedPasswordpublic 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 interface- UserConfig
- Parameters:
- userID- the user ID to change the password for
- aPassword- the encrypted password
- Throws:
- Exception- if any.
 
 - 
setUnencryptedPasswordpublic void setUnencryptedPassword(String userID, String aPassword) throws Exception Sets the password for this user, first encrypting it- Specified by:
- setUnencryptedPasswordin interface- UserConfig
- Parameters:
- userID- the user ID to change the password for
- aPassword- the password
- Throws:
- Exception- if any.
 
 - 
encryptedPasswordpublic String encryptedPassword(String aPassword, boolean useSalt) encryptedPassword - Specified by:
- encryptedPasswordin interface- UserConfig
- Parameters:
- aPassword- a- Stringobject.
- useSalt- TODO
- Returns:
- a Stringobject.
 
 - 
comparePasswordspublic boolean comparePasswords(String userID, String aPassword) This method compares two encrypted strings for equality.- Specified by:
- comparePasswordsin interface- UserConfig
- 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
 
 - 
checkSaltedPasswordpublic boolean checkSaltedPassword(String raw, String encrypted) Description copied from interface:UserConfigcheckSaltedPassword - Specified by:
- checkSaltedPasswordin interface- UserConfig
- Returns:
- a boolean
 
 - 
doUpdateprotected abstract void doUpdate() throws IOException, FileNotFoundExceptionupdate - Throws:
- IOException- if any.
- FileNotFoundException- if any.
 
 - 
updatepublic final void update() throws IOExceptionDescription copied from interface:UserConfigupdate - Specified by:
- updatein interface- UserConfig
- Throws:
- IOException
- FileNotFoundException
 
 - 
getUsersWithRolepublic String[] getUsersWithRole(String roleid) throws IOException getUsersWithRole - Specified by:
- getUsersWithRolein interface- UserConfig
- Parameters:
- roleid- a- Stringobject.
- Returns:
- an array of Stringobjects.
- Throws:
- IOException- if any.
 
 - 
userHasRolepublic boolean userHasRole(User user, String roleid) throws FileNotFoundException, IOException userHasRole - Specified by:
- userHasRolein interface- UserConfig
- Parameters:
- user- a- Userobject.
- roleid- a- Stringobject.
- Returns:
- a boolean.
- Throws:
- FileNotFoundException- if any.
- IOException- if any.
 
 - 
isUserScheduledForRolepublic boolean isUserScheduledForRole(User user, String roleid, Date time) throws FileNotFoundException, IOException isUserScheduledForRole - Specified by:
- isUserScheduledForRolein interface- UserConfig
- Parameters:
- user- a- Userobject.
- roleid- a- Stringobject.
- time- a- Dateobject.
- Returns:
- a boolean.
- Throws:
- FileNotFoundException- if any.
- IOException- if any.
 
 - 
getUsersScheduledForRolepublic String[] getUsersScheduledForRole(String roleid, Date time) throws IOException getUsersScheduledForRole - Specified by:
- getUsersScheduledForRolein interface- UserConfig
- Parameters:
- roleid- a- Stringobject.
- time- a- Dateobject.
- Returns:
- an array of Stringobjects.
- Throws:
- IOException- if any.
 
 - 
hasOnCallRolepublic boolean hasOnCallRole(String roleid) throws IOException hasOnCallRole - Specified by:
- hasOnCallRolein interface- UserConfig
- Parameters:
- roleid- a- Stringobject.
- Returns:
- a boolean.
- Throws:
- IOException- if any.
 
 - 
countUsersWithRolepublic int countUsersWithRole(String roleid) throws IOException countUsersWithRole - Specified by:
- countUsersWithRolein interface- UserConfig
- Parameters:
- roleid- a- Stringobject.
- Returns:
- a int.
- Throws:
- IOException- if any.
 
 - 
isUpdateNeededpublic abstract boolean isUpdateNeeded() 
 - 
getLastModifiedpublic abstract long getLastModified() 
 - 
getFileSizepublic abstract long getFileSize() 
 - 
reloadpublic abstract void reload() throws IOException, FileNotFoundException- Throws:
- IOException
- FileNotFoundException
 
 
- 
 
-