com.ecyrd.jspwiki.auth
Class UserManager.DummyUserDatabase

java.lang.Object
  extended by com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
      extended by com.ecyrd.jspwiki.auth.UserManager.DummyUserDatabase
All Implemented Interfaces:
UserDatabase
Enclosing class:
UserManager

public class UserManager.DummyUserDatabase
extends AbstractUserDatabase

This is a database that gets used if nothing else is available. It does nothing of note - it just mostly thorws NoSuchPrincipalExceptions if someone tries to log in.

Author:
Janne Jalkanen

Field Summary
 
Fields inherited from class com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
log, PROP_SHARED_WITH_CONTAINER, SHA_PREFIX
 
Constructor Summary
UserManager.DummyUserDatabase()
           
 
Method Summary
 void commit()
          Persists the current state of the user database to back-end storage.
 void deleteByLoginName(String loginName)
          Looks up and deletes the first UserProfile in the user database that matches a profile having a given login name.
 UserProfile findByEmail(String index)
          Looks up and returns the first UserProfile in the user database that matches a profile having a given e-mail address.
 UserProfile findByFullName(String index)
          Looks up and returns the first UserProfile in the user database that matches a profile having a given full name.
 UserProfile findByLoginName(String index)
          Looks up and returns the first UserProfile in the user database that matches a profile having a given login name.
 UserProfile findByWikiName(String index)
          Looks up and returns the first UserProfile in the user database that matches a profile having a given wiki name.
 Principal[] getWikiNames()
          Returns all WikiNames that are stored in the UserDatabase as an array of Principal objects.
 void initialize(WikiEngine engine, Properties props)
          Initializes the user database based on values from a Properties object.
 boolean isSharedWithContainer()
          Returns true if this user database shares user/password data with the web container; false otherwise.
 void save(UserProfile profile)
           Saves a UserProfileto the user database, overwriting the existing profile if it exists.
 
Methods inherited from class com.ecyrd.jspwiki.auth.user.AbstractUserDatabase
find, getHash, getPrincipals, newProfile, validatePassword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserManager.DummyUserDatabase

public UserManager.DummyUserDatabase()
Method Detail

commit

public void commit()
            throws WikiSecurityException
Description copied from interface: UserDatabase
Persists the current state of the user database to back-end storage. This method is intended to be atomic; results cannot be partially committed. If the commit fails, it should roll back its state appropriately. Implementing classes that persist to the file system may wish to make this method synchronized.

Specified by:
commit in interface UserDatabase
Specified by:
commit in class AbstractUserDatabase
Throws:
WikiSecurityException
See Also:
UserDatabase.commit()

deleteByLoginName

public void deleteByLoginName(String loginName)
                       throws NoSuchPrincipalException,
                              WikiSecurityException
Description copied from interface: UserDatabase
Looks up and deletes the first UserProfile in the user database that matches a profile having a given login name. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException. The method does not commit the results of the delete; it only alters the database in memory.

Parameters:
loginName - the login name of the user profile that shall be deleted
Throws:
NoSuchPrincipalException
WikiSecurityException

findByEmail

public UserProfile findByEmail(String index)
                        throws NoSuchPrincipalException
Description copied from interface: UserDatabase
Looks up and returns the first UserProfile in the user database that matches a profile having a given e-mail address. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException.

Specified by:
findByEmail in interface UserDatabase
Specified by:
findByEmail in class AbstractUserDatabase
Parameters:
index - the e-mail address of the desired user profile
Returns:
the user profile
Throws:
NoSuchPrincipalException
See Also:
UserDatabase.findByEmail(java.lang.String)

findByFullName

public UserProfile findByFullName(String index)
                           throws NoSuchPrincipalException
Description copied from interface: UserDatabase
Looks up and returns the first UserProfile in the user database that matches a profile having a given full name. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException.

Specified by:
findByFullName in interface UserDatabase
Specified by:
findByFullName in class AbstractUserDatabase
Parameters:
index - the fill name of the desired user profile
Returns:
the user profile
Throws:
NoSuchPrincipalException
See Also:
UserDatabase.findByFullName(java.lang.String)

findByLoginName

public UserProfile findByLoginName(String index)
                            throws NoSuchPrincipalException
Description copied from interface: UserDatabase
Looks up and returns the first UserProfile in the user database that matches a profile having a given login name. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException.

Specified by:
findByLoginName in interface UserDatabase
Specified by:
findByLoginName in class AbstractUserDatabase
Parameters:
index - the login name of the desired user profile
Returns:
the user profile
Throws:
NoSuchPrincipalException
See Also:
UserDatabase.findByLoginName(java.lang.String)

findByWikiName

public UserProfile findByWikiName(String index)
                           throws NoSuchPrincipalException
Description copied from interface: UserDatabase
Looks up and returns the first UserProfile in the user database that matches a profile having a given wiki name. If the user database does not contain a user with a matching attribute, throws a NoSuchPrincipalException.

Specified by:
findByWikiName in interface UserDatabase
Specified by:
findByWikiName in class AbstractUserDatabase
Parameters:
index - the wiki name of the desired user profile
Returns:
the user profile
Throws:
NoSuchPrincipalException
See Also:
UserDatabase.findByWikiName(java.lang.String)

getWikiNames

public Principal[] getWikiNames()
                         throws WikiSecurityException
Description copied from interface: UserDatabase
Returns all WikiNames that are stored in the UserDatabase as an array of Principal objects. If the database does not contain any profiles, this method will return a zero-length array.

Returns:
the WikiNames
Throws:
WikiSecurityException

initialize

public void initialize(WikiEngine engine,
                       Properties props)
                throws NoRequiredPropertyException
Description copied from interface: UserDatabase
Initializes the user database based on values from a Properties object.

Specified by:
initialize in interface UserDatabase
Specified by:
initialize in class AbstractUserDatabase
Throws:
NoRequiredPropertyException
See Also:
UserDatabase.initialize(com.ecyrd.jspwiki.WikiEngine, java.util.Properties)

isSharedWithContainer

public boolean isSharedWithContainer()
Description copied from interface: UserDatabase
Returns true if this user database shares user/password data with the web container; false otherwise.

Returns:
the result

save

public void save(UserProfile profile)
          throws WikiSecurityException
Description copied from interface: UserDatabase

Saves a UserProfileto the user database, overwriting the existing profile if it exists. The user name under which the profile should be saved is returned by the supplied profile's UserProfile.getLoginName() method.

The database implementation is responsible for detecting potential duplicate user profiles; specifically, the login name, wiki name, and full name must be unique. The implementation is not required to check for validity of passwords or e-mail addresses. Special case: if the profile already exists and the password is null, it should retain its previous value, rather than being set to null.

Implementations are required to time-stamp the creation or modification fields of the UserProfile./p>

Calling classes should generally call AuthenticationManager.refreshCredentials(WikiSession) after calling this method to ensure that Principals are reloaded into the current WikiSession's Subject.

Specified by:
save in interface UserDatabase
Specified by:
save in class AbstractUserDatabase
Parameters:
profile - the user profile to save
Throws:
WikiSecurityException - if the profile cannot be saved
See Also:
UserDatabase.save(com.ecyrd.jspwiki.auth.user.UserProfile)