org.apache.wiki.auth.user
Class DefaultUserProfile

java.lang.Object
  extended by org.apache.wiki.auth.user.DefaultUserProfile
All Implemented Interfaces:
Serializable, UserProfile

public final class DefaultUserProfile
extends Object
implements UserProfile

Default implementation for representing wiki user information, such as the login name, full name, wiki name, and e-mail address.

Since:
2.3
See Also:
Serialized Form

Method Summary
 boolean equals(Object o)
          
 Map<String,Serializable> getAttributes()
          Returns the attributes associated with this profile as a Map of key/value pairs.
 Date getCreated()
          Returns the creation date
 String getEmail()
          Returns the user's e-mail address.
 String getFullname()
          Returns the user's full name.
 Date getLastModified()
          Returns the last-modified date.
 Date getLockExpiry()
          Returns the date/time of expiration of the profile's lock, if it has been previously locked via UserProfile.setLockExpiry(Date) and the lock is still active.
 String getLoginName()
          Returns the user's login name.
 String getPassword()
          Returns the user password for use with custom authentication.
 String getUid()
          Returns the unique identifier for the user profile.
 String getWikiName()
          Returns the user's wiki name.
 int hashCode()
           
 boolean isLocked()
          Returns true if the profile is currently locked (disabled); false otherwise.
 boolean isNew()
          Returns true if the user profile is new.
protected static UserProfile newProfile(UserDatabase db)
          Static factory method that creates a new DefaultUserProfile and sets a unique identifier (uid) for the supplied UserDatabase.
 void setCreated(Date date)
          Sets the created date.
 void setEmail(String email)
          Sets the user's e-mail address.
 void setFullname(String arg)
          Sets the user's full name.
 void setLastModified(Date date)
          Sets the last-modified date.
 void setLockExpiry(Date expiry)
          Locks the profile until a specified lock expiration date.
 void setLoginName(String name)
          Sets the name by which the user logs in.
 void setPassword(String arg)
          Sets the user's password for use with custom authentication.
 void setUid(String uid)
          Sets the unique identifier for the user profile.
 void setWikiName(String name)
          Deprecated. This method will be removed in a future release.
 String toString()
          Returns a string representation of this user profile.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

newProfile

protected static UserProfile newProfile(UserDatabase db)
Static factory method that creates a new DefaultUserProfile and sets a unique identifier (uid) for the supplied UserDatabase.

Parameters:
db - the UserDatabase for which the uid should be created
Returns:
the new profile

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getCreated

public Date getCreated()
Returns the creation date

Specified by:
getCreated in interface UserProfile
Returns:
the creation date
See Also:
UserProfile.getCreated()

getEmail

public String getEmail()
Returns the user's e-mail address.

Specified by:
getEmail in interface UserProfile
Returns:
the e-mail address

getFullname

public String getFullname()
Returns the user's full name.

Specified by:
getFullname in interface UserProfile
Returns:
the full name

getLastModified

public Date getLastModified()
Returns the last-modified date.

Specified by:
getLastModified in interface UserProfile
Returns:
the last-modified date
See Also:
UserProfile.getLastModified()

getLoginName

public String getLoginName()
Returns the user's login name.

Specified by:
getLoginName in interface UserProfile
Returns:
the login name

getPassword

public String getPassword()
Returns the user password for use with custom authentication. Note that the password field is not meaningful for container authentication; the user's private credentials are generally stored elsewhere. While it depends on the UserDatabaseimplementation, in most cases the value returned by this method will be a password hash, not the password itself.

Specified by:
getPassword in interface UserProfile
Returns:
the password

getWikiName

public String getWikiName()
Returns the user's wiki name.

Specified by:
getWikiName in interface UserProfile
Returns:
the wiki name.

isNew

public boolean isNew()
Returns true if the user profile is new. This implementation checks whether getLastModified() returns null to determine the status.

Specified by:
isNew in interface UserProfile
Returns:
whether the profile is new
See Also:
UserProfile.isNew()

setCreated

public void setCreated(Date date)
Description copied from interface: UserProfile
Sets the created date.

Specified by:
setCreated in interface UserProfile
Parameters:
date - the creation date
See Also:
UserProfile.setCreated(java.util.Date)

setEmail

public void setEmail(String email)
Sets the user's e-mail address.

Specified by:
setEmail in interface UserProfile
Parameters:
email - the e-mail address

setFullname

public void setFullname(String arg)
Sets the user's full name. For example, "Janne Jalkanen."

Specified by:
setFullname in interface UserProfile
Parameters:
arg - the full name

setLastModified

public void setLastModified(Date date)
Sets the last-modified date.

Specified by:
setLastModified in interface UserProfile
Parameters:
date - the last-modified date
See Also:
UserProfile.setLastModified(java.util.Date)

setLoginName

public void setLoginName(String name)
Sets the name by which the user logs in. The login name is used as the username for custom authentication (see AuthenticationManager.login(WikiSession,HttpServletRequest, String, String)). The login name is typically a short name ("jannej"). In contrast, the wiki name is typically of type FirstnameLastName ("JanneJalkanen").

Specified by:
setLoginName in interface UserProfile
Parameters:
name - the login name

setPassword

public void setPassword(String arg)
Sets the user's password for use with custom authentication. It is not the responsibility of implementing classes to hash the password; that responsibility is borne by the UserDatabase implementation during save operations (see UserDatabase.save(UserProfile)). Note that the password field is not meaningful for container authentication; the user's private credentials are generally stored elsewhere.

Specified by:
setPassword in interface UserProfile
Parameters:
arg - the password

setWikiName

public void setWikiName(String name)
Deprecated. This method will be removed in a future release.

No-op method. In previous versions of JSPWiki, the method set the user's wiki name directly. Now, the wiki name is automatically calculated based on the full name.

Specified by:
setWikiName in interface UserProfile
Parameters:
name - the wiki name

toString

public String toString()
Returns a string representation of this user profile.

Specified by:
toString in interface UserProfile
Overrides:
toString in class Object
Returns:
the string

getAttributes

public Map<String,Serializable> getAttributes()
Returns the attributes associated with this profile as a Map of key/value pairs. The Map should generally be a "live" Map; changes to the keys or values will be reflected in the UserProfile.

Specified by:
getAttributes in interface UserProfile
Returns:
the attributes

getLockExpiry

public Date getLockExpiry()
Returns the date/time of expiration of the profile's lock, if it has been previously locked via UserProfile.setLockExpiry(Date) and the lock is still active. If the profile is unlocked, this method returns null. Note that calling this method after the expiration date, even if had previously been set explicitly by UserProfile.setLockExpiry(Date), will always return null.

Specified by:
getLockExpiry in interface UserProfile
Returns:
the lock expiration date

getUid

public String getUid()
Returns the unique identifier for the user profile. If not previously set, the value will be null.

Specified by:
getUid in interface UserProfile
Returns:
the unique ID.

isLocked

public boolean isLocked()
Returns true if the profile is currently locked (disabled); false otherwise. By default, profiles are created unlocked. Strictly speaking, calling this method is equivalent to calling UserProfile.getLockExpiry() and, if it returns a non-null value, checking if the date returned is later than the current time.

Specified by:
isLocked in interface UserProfile
Returns:
the result

setLockExpiry

public void setLockExpiry(Date expiry)
Locks the profile until a specified lock expiration date.

Specified by:
setLockExpiry in interface UserProfile
Parameters:
expiry - the date the lock expires; setting this value to null will cause the lock to be cleared.

setUid

public void setUid(String uid)
Sets the unique identifier for the user profile. Note that UserDatabase implementations are required not to change the unique identifier after the initial save.

Specified by:
setUid in interface UserProfile
Parameters:
uid - the unique identifier to set


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.