org.opennms.netmgt.config
Class UserManager

java.lang.Object
  extended by org.opennms.netmgt.config.UserManager
Direct Known Subclasses:
UserFactory

public abstract class UserManager
extends java.lang.Object

Author:
david hustace

Field Summary
protected  java.util.HashMap<java.lang.String,java.util.List<DutySchedule>> m_dutySchedules
          The duty schedules for each user
protected  GroupManager m_groupManager
           
protected  java.util.HashMap<java.lang.String,org.opennms.netmgt.config.users.User> m_users
          A mapping of user ids to the User objects
 
Constructor Summary
protected UserManager(GroupManager groupManager)
           
 
Method Summary
 boolean comparePasswords(java.lang.String userID, java.lang.String aPassword)
          This method compares two encrypted strings for equality.
 int countUsersWithRole(java.lang.String roleid)
           
 void deleteUser(java.lang.String name)
          Removes the user from the list of users.
 java.lang.String encryptedPassword(java.lang.String aPassword)
           
 java.lang.String getContactInfo(java.lang.String userID, java.lang.String command)
          Get the contact info given a command string
 java.lang.String getContactInfo(org.opennms.netmgt.config.users.User user, java.lang.String command)
           
 java.lang.String getContactServiceProvider(java.lang.String userID, java.lang.String command)
          Get the contact service provider, given a command string
 java.lang.String getContactServiceProvider(org.opennms.netmgt.config.users.User user, java.lang.String command)
           
 java.lang.String getEmail(java.lang.String userid)
          Get a email by name
 java.lang.String getNumericPage(java.lang.String userid)
          Get a numeric service provider
 java.lang.String getNumericPin(java.lang.String userid)
          Get a numeric pin
 java.lang.String getPagerEmail(java.lang.String userid)
          Get a pager email by name
 java.lang.String getTextPage(java.lang.String userid)
          Get a Text Page Service Provider
 java.lang.String getTextPin(java.lang.String userid)
          Get a text pin
 org.opennms.netmgt.config.users.User getUser(java.lang.String name)
          Get a user by name
 java.util.List<java.lang.String> getUserNames()
           
 java.util.Map<java.lang.String,org.opennms.netmgt.config.users.User> getUsers()
          Return a Map of usernames to user instances.
 java.lang.String[] getUsersScheduledForRole(java.lang.String roleid, java.util.Date time)
           
 java.lang.String[] getUsersWithRole(java.lang.String roleid)
           
 java.lang.String getXMPPAddress(java.lang.String userid)
          Get an XMPP address by name
 boolean hasRole(java.lang.String roleid)
           
 boolean hasUser(java.lang.String userName)
          Returns a boolean indicating if the user name appears in the xml file
abstract  boolean isUpdateNeeded()
           
 boolean isUserOnDuty(java.lang.String user, java.util.Calendar time)
          Determines if a user is on duty at a given time.
 boolean isUserScheduledForRole(org.opennms.netmgt.config.users.User user, java.lang.String roleid, java.util.Date time)
           
 void parseXML(java.io.Reader reader)
           
 void renameUser(java.lang.String oldName, java.lang.String newName)
          When this method is called users name is changed, so also is the username belonging to the group and the view.
 void saveUser(java.lang.String name, org.opennms.netmgt.config.users.User details)
          Adds a new user and overwrites the "users.xml"
 void saveUsers(java.util.Collection usersList)
           
protected abstract  void saveXML(java.lang.String writerString)
           
 void setEncryptedPassword(java.lang.String userID, java.lang.String aPassword)
          Sets the password for this user, assuming that the value passed in is already encrypted properly
 void setUnencryptedPassword(java.lang.String userID, java.lang.String aPassword)
          Sets the password for this user, first encrypting it
protected abstract  void update()
           
 boolean userHasRole(org.opennms.netmgt.config.users.User user, java.lang.String roleid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_groupManager

protected GroupManager m_groupManager

m_users

protected java.util.HashMap<java.lang.String,org.opennms.netmgt.config.users.User> m_users
A mapping of user ids to the User objects


m_dutySchedules

protected java.util.HashMap<java.lang.String,java.util.List<DutySchedule>> m_dutySchedules
The duty schedules for each user

Constructor Detail

UserManager

protected UserManager(GroupManager groupManager)
Method Detail

parseXML

public void parseXML(java.io.Reader reader)
              throws org.exolab.castor.xml.MarshalException,
                     org.exolab.castor.xml.ValidationException
Parameters:
reader -
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveUser

public void saveUser(java.lang.String name,
                     org.opennms.netmgt.config.users.User details)
              throws java.lang.Exception
Adds a new user and overwrites the "users.xml"

Throws:
java.lang.Exception

isUserOnDuty

public boolean isUserOnDuty(java.lang.String user,
                            java.util.Calendar time)
                     throws java.io.IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException
Determines if a user is on duty at a given time. If a user has no duty schedules listed in the config file, that user is assumed to always be on duty.

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:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUsers

public java.util.Map<java.lang.String,org.opennms.netmgt.config.users.User> getUsers()
                                                                              throws java.io.IOException,
                                                                                     org.exolab.castor.xml.MarshalException,
                                                                                     org.exolab.castor.xml.ValidationException
Return a Map of usernames to user instances.

Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

hasUser

public boolean hasUser(java.lang.String userName)
                throws java.io.IOException,
                       org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException
Returns a boolean indicating if the user name appears in the xml file

Returns:
true if the user exists in the xml file, false otherwise
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUserNames

public java.util.List<java.lang.String> getUserNames()
                                              throws java.io.IOException,
                                                     org.exolab.castor.xml.MarshalException,
                                                     org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUser

public org.opennms.netmgt.config.users.User getUser(java.lang.String name)
                                             throws java.io.IOException,
                                                    org.exolab.castor.xml.MarshalException,
                                                    org.exolab.castor.xml.ValidationException
Get a user by name

Parameters:
name - the name of the user to return
Returns:
the user specified by name
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getContactInfo

public java.lang.String getContactInfo(java.lang.String userID,
                                       java.lang.String command)
                                throws java.io.IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException
Get the contact info given a command string

Parameters:
userID - the name of the user
command - the command to look up the contact info for
Returns:
the contact information
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getContactInfo

public java.lang.String getContactInfo(org.opennms.netmgt.config.users.User user,
                                       java.lang.String command)
                                throws java.io.IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getContactServiceProvider

public java.lang.String getContactServiceProvider(java.lang.String userID,
                                                  java.lang.String command)
                                           throws java.io.IOException,
                                                  org.exolab.castor.xml.MarshalException,
                                                  org.exolab.castor.xml.ValidationException
Get the contact service provider, given a command string

Parameters:
userID - the name of the user
command - the command to look up the contact info for
Returns:
the contact information
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getContactServiceProvider

public java.lang.String getContactServiceProvider(org.opennms.netmgt.config.users.User user,
                                                  java.lang.String command)
                                           throws java.io.IOException,
                                                  org.exolab.castor.xml.MarshalException,
                                                  org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getEmail

public java.lang.String getEmail(java.lang.String userid)
                          throws java.io.IOException,
                                 org.exolab.castor.xml.MarshalException,
                                 org.exolab.castor.xml.ValidationException
Get a email by name

Parameters:
userid - the userid of the user to return
Returns:
String the email specified by name
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getPagerEmail

public java.lang.String getPagerEmail(java.lang.String userid)
                               throws java.io.IOException,
                                      org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException
Get a pager email by name

Parameters:
userid - the userid of the user to return
Returns:
String the pager email
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getNumericPin

public java.lang.String getNumericPin(java.lang.String userid)
                               throws java.io.IOException,
                                      org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException
Get a numeric pin

Parameters:
userid - the userid of the user to return
Returns:
String the numeric pin
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getXMPPAddress

public java.lang.String getXMPPAddress(java.lang.String userid)
                                throws java.io.IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException
Get an XMPP address by name

Parameters:
userid - the userid of the user to return
Returns:
String the XMPP address
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getNumericPage

public java.lang.String getNumericPage(java.lang.String userid)
                                throws java.io.IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException
Get a numeric service provider

Parameters:
userid - the userid of the user to return
Returns:
String the service provider
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getTextPin

public java.lang.String getTextPin(java.lang.String userid)
                            throws java.io.IOException,
                                   org.exolab.castor.xml.MarshalException,
                                   org.exolab.castor.xml.ValidationException
Get a text pin

Parameters:
userid - the userid of the user to return
Returns:
String the text pin
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getTextPage

public java.lang.String getTextPage(java.lang.String userid)
                             throws java.io.IOException,
                                    org.exolab.castor.xml.MarshalException,
                                    org.exolab.castor.xml.ValidationException
Get a Text Page Service Provider

Parameters:
userid - the userid of the user to return
Returns:
String the text page service provider.
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

saveUsers

public void saveUsers(java.util.Collection usersList)
               throws java.lang.Exception
Throws:
java.lang.Exception

deleteUser

public void deleteUser(java.lang.String name)
                throws java.lang.Exception
Removes the user from the list of users. Then overwrites to the "users.xml"

Throws:
java.lang.Exception

saveXML

protected abstract void saveXML(java.lang.String writerString)
                         throws java.io.IOException
Parameters:
writerString -
Throws:
java.io.IOException

renameUser

public void renameUser(java.lang.String oldName,
                       java.lang.String newName)
                throws java.lang.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

Throws:
java.lang.Exception

setEncryptedPassword

public void setEncryptedPassword(java.lang.String userID,
                                 java.lang.String aPassword)
                          throws java.lang.Exception
Sets the password for this user, assuming that the value passed in is already encrypted properly

Parameters:
userID - the user ID to change the pasword for
aPassword - the encrypted password
Throws:
java.lang.Exception

setUnencryptedPassword

public void setUnencryptedPassword(java.lang.String userID,
                                   java.lang.String aPassword)
                            throws java.lang.Exception
Sets the password for this user, first encrypting it

Parameters:
userID - the user ID to change the pasword for
aPassword - the password
Throws:
java.lang.Exception

encryptedPassword

public java.lang.String encryptedPassword(java.lang.String aPassword)
Parameters:
aPassword -
Returns:

comparePasswords

public boolean comparePasswords(java.lang.String userID,
                                java.lang.String aPassword)
This method compares two encrypted strings for equality.

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

update

protected abstract void update()
                        throws java.io.IOException,
                               java.io.FileNotFoundException,
                               org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
java.io.FileNotFoundException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUsersWithRole

public java.lang.String[] getUsersWithRole(java.lang.String roleid)
                                    throws java.io.IOException,
                                           org.exolab.castor.xml.MarshalException,
                                           org.exolab.castor.xml.ValidationException
Throws:
java.io.IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

userHasRole

public boolean userHasRole(org.opennms.netmgt.config.users.User user,
                           java.lang.String roleid)
                    throws java.io.FileNotFoundException,
                           org.exolab.castor.xml.MarshalException,
                           org.exolab.castor.xml.ValidationException,
                           java.io.IOException
Throws:
java.io.FileNotFoundException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

isUserScheduledForRole

public boolean isUserScheduledForRole(org.opennms.netmgt.config.users.User user,
                                      java.lang.String roleid,
                                      java.util.Date time)
                               throws java.io.FileNotFoundException,
                                      org.exolab.castor.xml.MarshalException,
                                      org.exolab.castor.xml.ValidationException,
                                      java.io.IOException
Throws:
java.io.FileNotFoundException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

getUsersScheduledForRole

public java.lang.String[] getUsersScheduledForRole(java.lang.String roleid,
                                                   java.util.Date time)
                                            throws org.exolab.castor.xml.MarshalException,
                                                   org.exolab.castor.xml.ValidationException,
                                                   java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

hasRole

public boolean hasRole(java.lang.String roleid)
                throws org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException,
                       java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

countUsersWithRole

public int countUsersWithRole(java.lang.String roleid)
                       throws org.exolab.castor.xml.MarshalException,
                              org.exolab.castor.xml.ValidationException,
                              java.io.IOException
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
java.io.IOException

isUpdateNeeded

public abstract boolean isUpdateNeeded()


Copyright © 2007. All Rights Reserved.