|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wiki.auth.user.AbstractUserDatabase
org.apache.wiki.auth.user.XMLUserDatabase
public class XMLUserDatabase

Manages DefaultUserProfile objects using XML files for persistence.
Passwords are hashed using SHA1. User entries are simple <user>
elements under the root. User profile properties are attributes of the
element. For example:
<users>
<user loginName="janne" fullName="Janne Jalkanen"
wikiName="JanneJalkanen" email="janne@ecyrd.com"
password="{SHA}457b08e825da547c3b77fbc1ff906a1d00a7daee"/>
</users>
In this example, the un-hashed password is myP@5sw0rd. Passwords are hashed without salt.
| Field Summary | |
|---|---|
static String |
PROP_USERDATABASE
The jspwiki.properties property specifying the file system location of the user database. |
| Fields inherited from class org.apache.wiki.auth.user.AbstractUserDatabase |
|---|
log, SHA_PREFIX, SSHA_PREFIX |
| Constructor Summary | |
|---|---|
XMLUserDatabase()
|
|
| Method Summary | |
|---|---|
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 UserProfilein the user database
that matches a profile having a given e-mail address. |
UserProfile |
findByFullName(String index)
Looks up and returns the first UserProfilein the user database
that matches a profile having a given full name. |
UserProfile |
findByLoginName(String index)
Looks up and returns the first UserProfilein the user database
that matches a profile having a given login name. |
UserProfile |
findByUid(String uid)
Looks up and returns the first UserProfile in the user database
that matches a profile having a given unique ID (uid). |
UserProfile |
findByWikiName(String index)
Looks up and returns the first UserProfilein 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 WikiPrincipal objects. |
void |
initialize(WikiEngine engine,
Properties props)
Initializes the user database based on values from a Properties object. |
void |
rename(String loginName,
String newName)
Renames a UserProfile in the user database by changing
the profile's login name. |
void |
save(UserProfile profile)
Saves a UserProfileto the user database, overwriting the
existing profile if it exists. |
| Methods inherited from class org.apache.wiki.auth.user.AbstractUserDatabase |
|---|
commit, find, generateUid, getHash, getOldHash, getPrincipals, newProfile, parseLong, validatePassword |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PROP_USERDATABASE
| Constructor Detail |
|---|
public XMLUserDatabase()
| Method Detail |
|---|
public void deleteByLoginName(String loginName)
throws NoSuchPrincipalException,
WikiSecurityException
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.
loginName - the login name of the user profile that shall be deleted
NoSuchPrincipalException
WikiSecurityException
public UserProfile findByEmail(String index)
throws NoSuchPrincipalException
UserProfilein 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 UserDatabasefindByEmail in class AbstractUserDatabaseindex - the e-mail address of the desired user profile
NoSuchPrincipalExceptionUserDatabase.findByEmail(String)
public UserProfile findByFullName(String index)
throws NoSuchPrincipalException
UserProfilein 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 UserDatabasefindByFullName in class AbstractUserDatabaseindex - the fill name of the desired user profile
NoSuchPrincipalExceptionUserDatabase.findByFullName(java.lang.String)
public UserProfile findByLoginName(String index)
throws NoSuchPrincipalException
UserProfilein 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 UserDatabasefindByLoginName in class AbstractUserDatabaseindex - the login name of the desired user profile
NoSuchPrincipalExceptionUserDatabase.findByLoginName(java.lang.String)
public UserProfile findByUid(String uid)
throws NoSuchPrincipalException
UserProfile in the user database
that matches a profile having a given unique ID (uid). If the user database
does not contain a user with a unique ID, it throws a
NoSuchPrincipalException.
uid - the unique identifier of the desired user profile
NoSuchPrincipalException
public UserProfile findByWikiName(String index)
throws NoSuchPrincipalException
UserProfilein 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 UserDatabasefindByWikiName in class AbstractUserDatabaseindex - the wiki name of the desired user profile
NoSuchPrincipalExceptionUserDatabase.findByWikiName(java.lang.String)
public Principal[] getWikiNames()
throws WikiSecurityException
WikiSecurityException - In case things fail.
public void initialize(WikiEngine engine,
Properties props)
throws NoRequiredPropertyException
PROP_USERDATABASE.
initialize in interface UserDatabaseinitialize in class AbstractUserDatabaseNoRequiredPropertyException - if the user database cannot be located, parsed, or openedUserDatabase.initialize(org.apache.wiki.WikiEngine,
java.util.Properties)
public void rename(String loginName,
String newName)
throws NoSuchPrincipalException,
DuplicateUserException,
WikiSecurityException
UserDatabaseRenames a UserProfile in the user database by changing
the profile's login name. Because the login name is the profile's unique
identifier, implementations should verify that the identifier is
"safe" to change before actually changing it. Specifically: the profile
with the supplied login name must already exist, and the proposed new
name must not be in use by another profile.
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.
loginName - the existing login name for the profilenewName - the proposed new login name
NoSuchPrincipalException - if the user profile identified by
loginName does not exist
DuplicateUserException - if another user profile with the
proposed new login name already exists
WikiSecurityException - if the profile cannot be renamed for
any reason, such as an I/O error, database connection failure
or lack of support for renames.UserDatabase.rename(String, String)
public void save(UserProfile profile)
throws WikiSecurityException
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.
save in interface UserDatabasesave in class AbstractUserDatabaseprofile - the user profile to save
WikiSecurityException - if the profile cannot be savedUserDatabase.save(org.apache.wiki.auth.user.UserProfile)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||