public abstract class User
extends java.lang.Object
A basis for users. This sets some very basic features all users objects should have. The three main things are: a user name, a set of roles and a set of other options and properties. The user name identifies the user and should be unique. The set of roles are used to specify what types of actions the user is allowed to perform. Everything else is stored in the generic options map, which is a collection of key value pairs.
Note that a password would be stored in the options map. This class does not specify how or with what key it would be stored. That's up to whatever performs user authentication. Some might store it in plain text (usually not a good idea) while some others could use different hashing methods to store it and authenticate a user.
You typically get users from a UserStore. Any changes to the user object can also be saved to the store where the user originally came from with the saveUser method.
Constructor and Description |
---|
User() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addRole(java.lang.String role)
Adds a role to this user.
|
abstract java.lang.String |
getOption(java.lang.String optionKey)
Gets one of the stored options.
|
abstract java.util.Collection<java.lang.String> |
getOptionKeys()
Gets all stored option keys.
|
abstract java.util.Collection<java.lang.String> |
getRoles()
Gets all the roles this user belongs to.
|
abstract java.lang.String |
getUserName()
Gets the user name.
|
boolean |
isOfRole(java.lang.String role)
Checks if this user is of a specified role.
|
abstract void |
removeOption(java.lang.String optionKey)
Removes a stored option from the options map.
|
abstract void |
removeRole(java.lang.String role)
Removes a role from this user.
|
abstract boolean |
saveUser()
Saves any changes made to the user into the persistent user
store where this user object originally came from.
|
abstract void |
setOption(java.lang.String optionKey,
java.lang.String value)
Sets a stored option.
|
public abstract java.lang.String getUserName()
public abstract java.lang.String getOption(java.lang.String optionKey)
optionKey
- The key of the property.public abstract java.util.Collection<java.lang.String> getOptionKeys()
public abstract void setOption(java.lang.String optionKey, java.lang.String value)
optionKey
- The option key.value
- The value of the option.public abstract void removeOption(java.lang.String optionKey)
optionKey
- The key of the stored option to remove.public abstract java.util.Collection<java.lang.String> getRoles()
public abstract void removeRole(java.lang.String role)
role
- The role to remove.public abstract void addRole(java.lang.String role)
role
- The role to add.public abstract boolean saveUser() throws UserStoreException
UserStoreException
public boolean isOfRole(java.lang.String role)
role
- The role identifier to check against.Copyright 2004-2015 Wandora Team