com.evermind.sql
Class DataSourceUserManager

java.lang.Object
  extended by com.evermind.security.AbstractUserManager
      extended by com.evermind.sql.DataSourceUserManager
All Implemented Interfaces:
UserManager, Config

public class DataSourceUserManager
extends AbstractUserManager

UserManager that retrieves the userdata from a DataSource (database).

init-params are:
dataSource - the installed DataSource to use
table - the name of the table
usernameField - the name of the username field in the table
passwordField - the name of the password field in the table
descriptionField - the name of the optional description field in the table
certificateIssuerField - the certificate issuer identifier if any
certificateSerialField - the certificate serial ID if any
localeField - the locale field if any
defaultGroups - Comma-separated list of groups that these users are members of
groupMembershipTableName - The (optional) tablename if group-membership support besides defaultGroups is to be used.
groupMembershipUsernameFieldName - The username field in the membership table.
groupMembershipGroupFieldName - The group field in the membership table.
staleness - time in milliseconds that a fetched set of user info is valid (how long until it has to be refetched), the default is -1 (forever).
casing - how to case usernames, the modes are "sensitive", "toupper" and "tolower" where "sensitive" is the default. The other two modes are case insensitive.
debug - outputs some debug info, useful when setting the manager up.


Constructor Summary
DataSourceUserManager()
           
 
Method Summary
 User createUser(java.lang.String username, java.lang.String password)
          Creates a user and adds the new row to the DataSource table.
 Group getGroup(java.lang.String name)
          Delegates to parent manager if present, otherwise returns null.
 User getUser(java.lang.String username)
          Retrieves a user either from the local cache or if not found in the cache from the DataSource table.
 User getUser(java.lang.String issuerDN, java.math.BigInteger serial)
          Returns null or delegates to the parent since certificates arent supported by default.
 int getUserCount()
          Return the number of users contained in this manager.
 java.util.List getUsers(int start, int length)
          Returns a list of Users (between the specified indexes) contained in this manager.
 void init(java.util.Properties properties)
          Retrieves the specified datasource from the JNDI-context.
 boolean remove(User user)
          Removes the user (and the accompanying field in the database) from this UserManager.
 java.lang.String toCase(java.lang.String name)
           
 void updateDescription(java.lang.String username, java.lang.String description)
           
 void updatePassword(java.lang.String username, java.lang.String password)
           
 void updateUserInfo(java.lang.String username, java.lang.String issuer, java.math.BigInteger serial, java.util.Locale locale)
           
 
Methods inherited from class com.evermind.security.AbstractUserManager
addDefaultGroup, containsDefaultGroup, create, createGroup, getAdminUser, getAnonymousUser, getDefaultGroups, getGroupCount, getGroups, getParent, getUser, invalidate, isUpdated, remove, setParent, store, update
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceUserManager

public DataSourceUserManager()
Method Detail

init

public void init(java.util.Properties properties)
          throws java.lang.InstantiationException
Retrieves the specified datasource from the JNDI-context.

Specified by:
init in interface UserManager
Overrides:
init in class AbstractUserManager
Throws:
java.lang.InstantiationException - if the init() fails.

getGroup

public Group getGroup(java.lang.String name)
Description copied from class: AbstractUserManager
Delegates to parent manager if present, otherwise returns null.

Specified by:
getGroup in interface UserManager
Overrides:
getGroup in class AbstractUserManager

createUser

public User createUser(java.lang.String username,
                       java.lang.String password)
                throws java.lang.InstantiationException
Creates a user and adds the new row to the DataSource table.

Specified by:
createUser in interface UserManager
Overrides:
createUser in class AbstractUserManager
Throws:
java.lang.InstantiationException - if the user exists.

getUser

public User getUser(java.lang.String username)
Retrieves a user either from the local cache or if not found in the cache from the DataSource table.

Specified by:
getUser in interface UserManager
Overrides:
getUser in class AbstractUserManager

remove

public boolean remove(User user)
Removes the user (and the accompanying field in the database) from this UserManager.

Specified by:
remove in interface UserManager
Overrides:
remove in class AbstractUserManager

updatePassword

public void updatePassword(java.lang.String username,
                           java.lang.String password)

updateDescription

public void updateDescription(java.lang.String username,
                              java.lang.String description)

updateUserInfo

public void updateUserInfo(java.lang.String username,
                           java.lang.String issuer,
                           java.math.BigInteger serial,
                           java.util.Locale locale)

getUser

public User getUser(java.lang.String issuerDN,
                    java.math.BigInteger serial)
Description copied from class: AbstractUserManager
Returns null or delegates to the parent since certificates arent supported by default.

Specified by:
getUser in interface UserManager
Overrides:
getUser in class AbstractUserManager

getUserCount

public int getUserCount()
Description copied from interface: UserManager
Return the number of users contained in this manager. Throws UnsupportedOperationException if not supported.

Specified by:
getUserCount in interface UserManager
Overrides:
getUserCount in class AbstractUserManager

getUsers

public java.util.List getUsers(int start,
                               int length)
Description copied from interface: UserManager
Returns a list of Users (between the specified indexes) contained in this manager. Throws UnsupportedOperationException if not supported.

Specified by:
getUsers in interface UserManager
Overrides:
getUsers in class AbstractUserManager

toCase

public java.lang.String toCase(java.lang.String name)