public abstract class AbstractUserDatabase extends Object implements UserDatabase
| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.log4j.Logger |
log |
protected static String |
SHA_PREFIX |
protected static String |
SSHA_PREFIX |
| Constructor and Description |
|---|
AbstractUserDatabase() |
| Modifier and Type | Method and Description |
|---|---|
UserProfile |
find(String index)
Looks up and returns the first
UserProfilein the user database
that whose login name, full name, or wiki name matches the supplied
string. |
abstract 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. |
abstract UserProfile |
findByFullName(String index)
Looks up and returns the first
UserProfile in the user database
that matches a profile having a given full name. |
abstract UserProfile |
findByLoginName(String index)
Looks up and returns the first
UserProfile in the user database
that matches a profile having a given login name. |
abstract UserProfile |
findByWikiName(String index)
Looks up and returns the first
UserProfile in the user database
that matches a profile having a given wiki name. |
protected static String |
generateUid(UserDatabase db)
Generates a new random user identifier (uid) that is guaranteed to be unique.
|
protected String |
getHash(String text)
Private method that calculates the salted SHA-1 hash of a given
String. |
Principal[] |
getPrincipals(String identifier)
Looks up the Principals representing a user from the user database.
|
abstract void |
initialize(WikiEngine engine,
Properties props)
Initializes the user database based on values from a Properties object.
|
UserProfile |
newProfile()
Factory method that instantiates a new DefaultUserProfile with a new, distinct
unique identifier.
|
protected long |
parseLong(String value)
Parses a long integer from a supplied string, or returns 0 if not parsable.
|
abstract void |
save(UserProfile profile)
Saves a
UserProfileto the user database, overwriting the
existing profile if it exists. |
boolean |
validatePassword(String loginName,
String password)
Validates the password for a given user.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdeleteByLoginName, findByUid, getWikiNames, renameprotected static final org.apache.log4j.Logger log
protected static final String SHA_PREFIX
protected static final String SSHA_PREFIX
public AbstractUserDatabase()
public UserProfile find(String index) throws NoSuchPrincipalException
UserProfilein the user database
that whose login name, full name, or wiki name matches the supplied
string. This method provides a "forgiving" search algorithm for resolving
principal names when the exact profile attribute that supplied the name
is unknown.find in interface UserDatabaseindex - the login name, full name, or wiki nameNoSuchPrincipalExceptionUserDatabase.find(java.lang.String)public abstract UserProfile findByEmail(String index) throws NoSuchPrincipalException
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.findByEmail in interface UserDatabaseindex - the e-mail address of the desired user profileNoSuchPrincipalExceptionUserDatabase.findByEmail(java.lang.String)public abstract UserProfile findByFullName(String index) throws NoSuchPrincipalException
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.findByFullName in interface UserDatabaseindex - the fill name of the desired user profileNoSuchPrincipalExceptionUserDatabase.findByFullName(java.lang.String)public abstract UserProfile findByLoginName(String index) throws NoSuchPrincipalException
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.findByLoginName in interface UserDatabaseindex - the login name of the desired user profileNoSuchPrincipalExceptionUserDatabase.findByLoginName(java.lang.String)public abstract UserProfile findByWikiName(String index) throws NoSuchPrincipalException
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.findByWikiName in interface UserDatabaseindex - the wiki name of the desired user profileNoSuchPrincipalExceptionUserDatabase.findByWikiName(java.lang.String)public Principal[] getPrincipals(String identifier) throws NoSuchPrincipalException
Looks up the Principals representing a user from the user database. These
are defined as a set of WikiPrincipals manufactured from the login name,
full name, and wiki name. If the user database does not contain a user
with the supplied identifier, throws a NoSuchPrincipalException.
When this method creates WikiPrincipals, the Principal containing
the user's full name is marked as containing the common name (see
WikiPrincipal.WikiPrincipal(String, String)).
getPrincipals in interface UserDatabaseidentifier - the name of the principal to retrieve; this corresponds to
value returned by the user profile's
UserProfile.getLoginName()method.NoSuchPrincipalExceptionUserDatabase.getPrincipals(java.lang.String)public abstract void initialize(WikiEngine engine, Properties props) throws NoRequiredPropertyException, WikiSecurityException
initialize in interface UserDatabaseNoRequiredPropertyExceptionWikiSecurityExceptionUserDatabase.initialize(org.apache.wiki.WikiEngine, java.util.Properties)public UserProfile newProfile()
newProfile in interface UserDatabasepublic abstract void save(UserProfile profile) throws WikiSecurityException
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>
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.
save in interface UserDatabaseprofile - the user profile to saveWikiSecurityException - if the profile cannot be savedUserDatabase.save(org.apache.wiki.auth.user.UserProfile)public boolean validatePassword(String loginName, String password)
false. If
the user exists, the supplied password is compared to the stored
password. Note that if the stored password's value starts with
{SHA}, the supplied password is hashed prior to the
comparison.validatePassword in interface UserDatabaseloginName - the user's login namepassword - the user's password (obtained from user input, e.g., a web form)true if the supplied user password matches the
stored passwordUserDatabase.validatePassword(java.lang.String,
java.lang.String)protected static String generateUid(UserDatabase db)
db - The database for which the UID should be generated.protected String getHash(String text)
String. Note that as of JSPWiki 2.8, this method calculates
a salted hash rather than a plain hash.text - the text to hashCopyright © 2001-2019 The Apache Software Foundation. All rights reserved.