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 String
ALLOW_UNSALTED_PROPERTY
protected Map<String,List<DutySchedule>>
m_dutySchedules
The duty schedules for each userprotected GroupManager
m_groupManager
protected Map<String,User>
m_users
A mapping of user IDs to the User objects
-
Constructor Summary
Constructors Modifier Constructor Description protected
UserManager(GroupManager groupManager)
Constructor for UserManager.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
checkSaltedPassword(String raw, String encrypted)
checkSaltedPasswordboolean
comparePasswords(String userID, String aPassword)
This method compares two encrypted strings for equality.int
countUsersWithRole(String roleid)
countUsersWithRolevoid
deleteUser(String name)
Removes the user from the list of users.protected abstract void
doUpdate()
updateString
encryptedPassword(String aPassword, boolean useSalt)
encryptedPasswordString
getContactInfo(String userID, String command)
Get the contact info given a command stringString
getContactInfo(String userId, UserConfig.ContactType contactType)
getContactInfoString
getContactInfo(User user, String command)
getContactInfoString
getContactServiceProvider(String userID, String command)
Get the contact service provider, given a command stringString
getContactServiceProvider(User user, String command)
getContactServiceProviderString
getEmail(String userID)
Get a email by nameString
getEmail(User user)
Get a email by userabstract long
getFileSize()
String
getHomePhone(String userID)
Get a home phone numberString
getHomePhone(User user)
Get a home phone numberabstract long
getLastModified()
String
getMicroblogName(String name)
Get a user's microblog username by usernameString
getMicroblogName(User user)
Get a user's microblog username by UserString
getMobilePhone(String userID)
Get a mobile phone numberString
getMobilePhone(User user)
Get a mobile phone numberString
getNumericPage(String userID)
Get a numeric service providerString
getNumericPage(User user)
Get a numeric service providerString
getNumericPin(String userID)
Get a numeric pinString
getNumericPin(User user)
Get a numeric pinOnmsUser
getOnmsUser(String username)
getOnmsUserOnmsUserList
getOnmsUserList()
getOnmsUserListString
getPagerEmail(String userID)
Get a pager email by nameString
getPagerEmail(User user)
Get a pager email by userString
getTextPage(String userID)
Get a Text Page Service ProviderString
getTextPage(User user)
Get a Text Page Service ProviderString
getTextPin(String userID)
Get a text pinString
getTextPin(User user)
Get a text pinString
getTuiPin(String name)
Get a user's telephone PIN by nameString
getTuiPin(User user)
Get a user's telephone PIN by User objectUser
getUser(String name)
Get a user by nameList<String>
getUserNames()
getUserNamesMap<String,User>
getUsers()
Return aMap
of usernames to user instances.String[]
getUsersScheduledForRole(String roleid, Date time)
getUsersScheduledForRoleString[]
getUsersWithRole(String roleid)
getUsersWithRoleString
getWorkPhone(String userID)
Get a work phone numberString
getWorkPhone(User user)
Get a work phone numberString
getXMPPAddress(String userID)
Get an XMPP address by nameString
getXMPPAddress(User user)
Get an XMPP address by nameboolean
hasOnCallRole(String roleid)
hasOnCallRoleboolean
hasUser(String userName)
Returns a boolean indicating if the user name appears in the XML fileabstract boolean
isUpdateNeeded()
boolean
isUserOnDuty(String user, Calendar time)
Determines if a user is on duty at a given time.boolean
isUserScheduledForRole(User user, String roleid, Date time)
isUserScheduledForRolevoid
parseXML(InputStream in)
parseXMLabstract void
reload()
void
renameUser(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.void
save(OnmsUser onmsUser)
savevoid
saveUser(String name, User details)
Adds a new user and overwrites the "users.xml"void
saveUsers(Collection<User> usersList)
saveUsersprotected abstract void
saveXML(String writerString)
saveXMLvoid
setContactInfo(String userId, UserConfig.ContactType contactType, String contactValue)
setContactInfovoid
setEncryptedPassword(String userID, String aPassword, boolean salted)
Sets the password for this user, assuming that the value passed in is already encrypted properlyvoid
setUnencryptedPassword(String userID, String aPassword)
Sets the password for this user, first encrypting itvoid
update()
updateboolean
userHasRole(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
- aGroupManager
object.
-
-
Method Detail
-
parseXML
public void parseXML(InputStream in)
parseXML
- Specified by:
parseXML
in interfaceUserConfig
- Parameters:
in
- aInputStream
object.
-
saveUser
public void saveUser(String name, User details) throws Exception
Adds a new user and overwrites the "users.xml"- Specified by:
saveUser
in interfaceUserConfig
- Parameters:
name
- aString
object.details
- aUser
object.- Throws:
Exception
- if any.
-
save
public void save(OnmsUser onmsUser) throws Exception
Description copied from interface:UserConfig
save
- Specified by:
save
in 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:
isUserOnDuty
in 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 aMap
of usernames to user instances.- Specified by:
getUsers
in interfaceUserConfig
- Returns:
- a
Map
object. - Throws:
IOException
- if any.
-
getOnmsUserList
public OnmsUserList getOnmsUserList() throws IOException
Description copied from interface:UserConfig
getOnmsUserList
- Specified by:
getOnmsUserList
in interfaceUserConfig
- Returns:
- an OnmsUserList
- Throws:
IOException
-
getOnmsUser
public OnmsUser getOnmsUser(String username) throws IOException
Description copied from interface:UserConfig
getOnmsUser
- Specified by:
getOnmsUser
in 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:
hasUser
in interfaceUserConfig
- Parameters:
userName
- aString
object.- 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:
getUserNames
in interfaceUserConfig
- Returns:
- a
List
object. - Throws:
IOException
- if any.
-
getUser
public User getUser(String name) throws IOException
Get a user by name- Specified by:
getUser
in 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:
getTuiPin
in 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:
getTuiPin
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getMicroblogName
in 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:UserConfig
setContactInfo
- Specified by:
setContactInfo
in interfaceUserConfig
- Throws:
Exception
-
getContactInfo
public String getContactInfo(String userId, UserConfig.ContactType contactType) throws IOException
Description copied from interface:UserConfig
getContactInfo
- Specified by:
getContactInfo
in 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:
getContactInfo
in 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:
getContactInfo
in interfaceUserConfig
- Parameters:
user
- aUser
object.command
- aString
object.- Returns:
- a
String
object. - 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:
getContactServiceProvider
in 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:
getContactServiceProvider
in interfaceUserConfig
- Parameters:
user
- aUser
object.command
- aString
object.- Returns:
- a
String
object. - Throws:
IOException
- if any.
-
getEmail
public String getEmail(String userID) throws IOException
Get a email by name- Specified by:
getEmail
in 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:
getEmail
in 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:
getPagerEmail
in 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:
getPagerEmail
in interfaceUserConfig
- Parameters:
user
- aUser
object.- Returns:
- String the pager email
- Throws:
IOException
- if any.
-
getNumericPin
public String getNumericPin(String userID) throws IOException
Get a numeric pin- Specified by:
getNumericPin
in 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:
getNumericPin
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getXMPPAddress
in 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:
getXMPPAddress
in interfaceUserConfig
- Parameters:
user
- aUser
object.- Returns:
- String the XMPP address
- Throws:
IOException
- if any.
-
getNumericPage
public String getNumericPage(String userID) throws IOException
Get a numeric service provider- Specified by:
getNumericPage
in 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:
getNumericPage
in interfaceUserConfig
- Parameters:
user
- aUser
object.- Returns:
- String the service provider
- Throws:
IOException
- if any.
-
getTextPin
public String getTextPin(String userID) throws IOException
Get a text pin- Specified by:
getTextPin
in 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:
getTextPin
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getTextPage
in 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:
getTextPage
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getWorkPhone
in 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:
getWorkPhone
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getMobilePhone
in 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:
getMobilePhone
in interfaceUserConfig
- Parameters:
user
- aUser
object.- 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:
getHomePhone
in 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:
getHomePhone
in interfaceUserConfig
- Parameters:
user
- aUser
object.- Returns:
- String the home phone number
- Throws:
IOException
- if any.
-
saveUsers
public void saveUsers(Collection<User> usersList) throws Exception
saveUsers
- Specified by:
saveUsers
in interfaceUserConfig
- Parameters:
usersList
- aCollection
object.- 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:
deleteUser
in interfaceUserConfig
- Parameters:
name
- aString
object.- Throws:
Exception
- if any.
-
saveXML
protected abstract void saveXML(String writerString) throws IOException
saveXML
- Parameters:
writerString
- aString
object.- 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:
renameUser
in interfaceUserConfig
- Parameters:
oldName
- aString
object.newName
- aString
object.- 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:
setEncryptedPassword
in 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:
setUnencryptedPassword
in 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:
encryptedPassword
in interfaceUserConfig
- Parameters:
aPassword
- aString
object.useSalt
- TODO- Returns:
- a
String
object.
-
comparePasswords
public boolean comparePasswords(String userID, String aPassword)
This method compares two encrypted strings for equality.- Specified by:
comparePasswords
in 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:UserConfig
checkSaltedPassword
- Specified by:
checkSaltedPassword
in interfaceUserConfig
- Returns:
- a boolean
-
doUpdate
protected abstract void doUpdate() throws IOException, FileNotFoundException
update
- Throws:
IOException
- if any.FileNotFoundException
- if any.
-
update
public final void update() throws IOException
Description copied from interface:UserConfig
update
- Specified by:
update
in interfaceUserConfig
- Throws:
IOException
FileNotFoundException
-
getUsersWithRole
public String[] getUsersWithRole(String roleid) throws IOException
getUsersWithRole
- Specified by:
getUsersWithRole
in interfaceUserConfig
- Parameters:
roleid
- aString
object.- Returns:
- an array of
String
objects. - Throws:
IOException
- if any.
-
userHasRole
public boolean userHasRole(User user, String roleid) throws FileNotFoundException, IOException
userHasRole
- Specified by:
userHasRole
in interfaceUserConfig
- Parameters:
user
- aUser
object.roleid
- aString
object.- 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:
isUserScheduledForRole
in interfaceUserConfig
- Parameters:
user
- aUser
object.roleid
- aString
object.time
- aDate
object.- Returns:
- a boolean.
- Throws:
FileNotFoundException
- if any.IOException
- if any.
-
getUsersScheduledForRole
public String[] getUsersScheduledForRole(String roleid, Date time) throws IOException
getUsersScheduledForRole
- Specified by:
getUsersScheduledForRole
in interfaceUserConfig
- Parameters:
roleid
- aString
object.time
- aDate
object.- Returns:
- an array of
String
objects. - Throws:
IOException
- if any.
-
hasOnCallRole
public boolean hasOnCallRole(String roleid) throws IOException
hasOnCallRole
- Specified by:
hasOnCallRole
in interfaceUserConfig
- Parameters:
roleid
- aString
object.- Returns:
- a boolean.
- Throws:
IOException
- if any.
-
countUsersWithRole
public int countUsersWithRole(String roleid) throws IOException
countUsersWithRole
- Specified by:
countUsersWithRole
in interfaceUserConfig
- Parameters:
roleid
- aString
object.- 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:
IOException
FileNotFoundException
-
-