|
SalesPoint v3.3 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object users.UserManager
public class UserManager
Manages users, their capabilities and their associations to other objects.
The UserManager provides possibilities to manage any number of users. Users can be added, retrieved using their name to identify them, and removed from the system. Additionally, users can be associated to, and disassociated from, any object. Their can be a maximum of one user associated to any given object at any given time.
You can provide a set of default capabilities, that every new user will be provided with.
User
,
setDefaultCaps(java.util.Map)
,
SalesPoint
,
logOn(java.lang.Object, users.User)
,
Serialized FormField Summary | |
---|---|
protected ListenerHelper |
m_lhListeners
The list of listeners registered with this UserManager. |
Constructor Summary | |
---|---|
UserManager()
Create a new UserManager with an empty set of default capabilities, managing direct instances of the User class. |
|
UserManager(Map<String,Capability> mpDefaultCaps)
Create a new UserManager, using a specific set of default capabilities. |
|
UserManager(Map<String,Capability> mpDefaultCaps,
UserCreator ucCreator)
Create a new UserManager providing both a set of default capabilities and a User creation factory. |
|
UserManager(UserCreator ucCreator)
Create a new UserManager with an empty set of default capabilities. |
Method Summary | |
---|---|
void |
addUser(User usr)
Add a user to the UserManager. |
void |
addUserDataListener(UserDataListener udl)
Add a UserDataListener. |
User |
createUser(String sName)
Create a new user to be managed by this UserManager. |
User |
deleteUser(String sName)
Delete a user from this UserManager. |
protected void |
fireUserAdded(User usr)
Fire a userAdded event to all interested listeners. |
protected void |
fireUserDeleted(User usr)
Fire a userDeleted event to all interested listeners. |
User |
getCurrentUser(Object o)
Retrieve the user currently associated with some Object. |
static UserManager |
getGlobalUM()
Get the global UserManager. |
User |
getUser(String sName)
Retrieve a user by name. |
Set<String> |
getUserNames()
Return all user names registered with this UserManager. |
Collection<User> |
getUsers()
Return all users registered with this UserManager. |
User |
logOff(Object o)
Disassociate the current user from an Object. |
User |
logOn(Object o,
User u)
Associate a user with an object. |
void |
removeUserDataListener(UserDataListener udl)
Remove a UserDataListener. |
void |
setDefaultCapability(Capability cap)
Set a capability to be used as a default capability henceforward. |
void |
setDefaultCaps(Map<String,Capability> mpDefaultCaps)
Specify the set of default capabilities to be used when creating new User objects. |
static UserManager |
setGlobalUM(UserManager umNew)
Set a new UserManager to be the global UserManager from now on. |
void |
setUserCreator(UserCreator ucCreator)
Set the factory to be used when creating new User objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ListenerHelper m_lhListeners
Constructor Detail |
---|
public UserManager()
setDefaultCaps(java.util.Map)
,
createUser(java.lang.String)
public UserManager(Map<String,Capability> mpDefaultCaps)
mpDefaultCaps
- a map describing the default capabilities any new user should
have. The keys of this map should be the name of their associated capability. Specifying
null
will result in there being no default capabilities.setDefaultCaps(java.util.Map)
,
createUser(java.lang.String)
,
Capability
public UserManager(UserCreator ucCreator)
ucCreator
- the factory to be used to create new User objects. Specifying
null
will result in a default implementation being used, which will
create direct instances of the User class.setDefaultCaps(java.util.Map)
,
createUser(java.lang.String)
public UserManager(Map<String,Capability> mpDefaultCaps, UserCreator ucCreator)
mpDefaultCaps
- a map describing the default capabilities any new user should
have. The keys of this map should be the name of their associated capability. Specifying
null
will result in there being no default capabilities.ucCreator
- the factory to be used to create new User objects. Specifying
null
will result in a default implementation being used, which will
create direct instances of the User class.setDefaultCaps(java.util.Map)
,
Capability
,
createUser(java.lang.String)
,
User
Method Detail |
---|
public void setUserCreator(UserCreator ucCreator)
ucCreator
- the factory to be used to create new User objects. Specifying
null
will result in a default implementation being used, which will
create direct instances of the User class.createUser(java.lang.String)
,
User
public void setDefaultCaps(Map<String,Capability> mpDefaultCaps)
Calling this method will not influence the capabilities of users already created.
mpDefaultCaps
- a map describing the default capabilities any new user should
have. The keys of this map should be the name of their associated capability. Specifying
null
will result in there being no default capabilities.createUser(java.lang.String)
,
Capability
public void setDefaultCapability(Capability cap)
Calling this method will not influence the capabilities of users already created.
If a default capability of the same name as the one given did already exist, it will be replaced by the new capability.
cap
- the capability to be set as a default capability.createUser(java.lang.String)
public User createUser(String sName)
This method uses the defined UserCreator
(see setUserCreator(users.UserCreator)
) to create the
new User
object. The new user will later be accessible using its name.
The newly created user will get all the default capabilities defined at the time this method is called.
A userAdded
event will be received by any UserDataListener
that
registered an interest in this UserManager
.
sName
- the name of the new user. This must be unique, i.e. there must not be
a user with the same name already managed by this UserManager.
DuplicateUserException
- if there already was a user with the given name.setDefaultCaps(java.util.Map)
,
setUserCreator(users.UserCreator)
,
User
,
UserCreator.createUser(java.lang.String)
,
UserDataListener.userAdded(users.events.UserDataEvent)
UserCreator
.public void addUser(User usr)
A userAdded
event will be received by any UserDataListener
that
registered an interest in this UserManager.
usr
- the user to be added.
DuplicateUserException
- if there already is a user of the same name.UserDataListener.userAdded(users.events.UserDataEvent)
public User getUser(String sName)
If no user with the given name exists, this method will return null
.
sName
- the name of the user looked for.
null
will
be returned if no such user can be found.createUser(java.lang.String)
public Set<String> getUserNames()
The returned set is backed by the UserManager, i.e. it will reflect changes
made through createUser()
or removeUser()
. The set itself
is unmodifiable and ordered alphabetically.
createUser(java.lang.String)
,
deleteUser(java.lang.String)
public Collection<User> getUsers()
The returned collection is backed by the UserManager, i.e. it will reflect
changes made through createUser()
or removeUser()
. The
collection itself is unmodifiable and ordered alphabetically by the users' names.
createUser(java.lang.String)
,
deleteUser(java.lang.String)
public User deleteUser(String sName)
The user will be removed from the UserManager and will no longer be available
via getUser(java.lang.String)
. A userDeleted
event will be received by all
UserDataListeners
registered with this UserManager if a user was removed. If no user
with the given name existed no exception will be thrown and no event will be fired.
If the user is currently associated to some object, it will stay so until it is disassociated explicitly. It will not have the possibility to log in again, though.
sName
- the name of the user to be removed
null
if none.UserDataListener.userDeleted(users.events.UserDataEvent)
public void addUserDataListener(UserDataListener udl)
udl
- the UserDataListener to add.public void removeUserDataListener(UserDataListener udl)
udl
- the UserDataListener to remove.protected void fireUserAdded(User usr)
userAdded
event to all interested listeners.
usr
- the user that was added.protected void fireUserDeleted(User usr)
userDeleted
event to all interested listeners.
usr
- the user that was deleted.public User logOn(Object o, User u)
Only one user at a time can be associated with one Object. If there is already another user associated with the given Object, its association is undone and the user is returned.
Only users that are actually managed by this UserManager can be logged in. An
exception will be thrown if you try to log in a user that is unknown to this
UserManager. Especially, this can happen if you try to log in a user that was
previously removed using deleteUser(java.lang.String)
.
o
- the Object with which to associate the user.u
- the user to associate with the Object
null
if none.
UnknownUserException
- if the user to log in is not known at this
UserManager. A user is known at a UserManager, if the User object is registered,
i.e. no equals()
method of any kind is called.User.loggedOn(java.lang.Object)
public User logOff(Object o)
o
- the Object from which to disassociate a user.
null
if none.User.loggedOff(java.lang.Object)
public User getCurrentUser(Object o)
o
- the Object with which the searched user must be associated.
null
if none.public static UserManager getGlobalUM()
The global UserManager can be used as a centralized instance to manage all the users in an application.
public static UserManager setGlobalUM(UserManager umNew)
umNew
- the new global UserManager.
|
SalesPoint v3.3 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |