📄 account.java
字号:
// $Id: Account.java,v 1.2 2002/04/04 08:13:25 pmartin Exp $//// ____.// __/\ ______| |__/\. _______// __ .____| | \ | +----+ \// _______| /--| | | - \ _ | : - \_________// \\______: :---| : : | : | \________>// |__\---\_____________:______: :____|____:_____\// /_____|//// . . . i n j a h i a w e t r u s t . . .//package org.jahia.security.accounts;import java.util.Date;import java.lang.String;import org.jahia.exceptions.database.JahiaDatabaseException;import org.jahia.security.accounts.AccountExistException;/** * This class represent the user account for a specified jahia site. An account * is bounded at creation time to one specific user and cannot be change * afterwards, the same rule is applied for the site assignation. <b>An account * cannot be shared between two sites</b>.</br></br> * * An account is made of an unique identification number, which is unique among * a site. A creation date is associated to the account as well as an * expiratin date and a password expiration date. The account expiration date * is used to check if the account is still valid when a user tries to access * the server, and the password expiration date is used to force the user to * change his password after a laps of time. Another date is also stored inside * the account, it's the last date the user logged in the server</br></br> * * An Account can be created but not yet available to the related user, for * example, the account activation is waiting a billing confirmation. Therefore * an account can be disactivated for a while and enabled later.</br></br> * * No security and priviledge information is stored inside the account, this is * handled through access control lists (ACL). * * @author Fulco Houkes * @version 1.0 */public class Account { /** User unique key */ private String mUserKey = null; /** Site unique key */ private String mSiteKey = null; /** Creation date */ private Date mCreationDate; /** Expiration date */ private Date mExpirationDate; /** Password expiration date */ private Date mPasswordExpirationDate; /** Last login date */ private Date mLastLoginDate; /** Account activation flag. True if the accound is active, * otherwise false. */ private boolean mActivated; /** reference to the DB tool methods */ private static AccountDBUtils mDBUtils = null; //------------------------------------------------------------------------- /** Default constructor * * @param userKey * User unique identification key. * @param siteKey * Site unique identification key. * @param creationDate * Account creation date. * @param expirationDate * Account expiration date. Specify null in case the account never * expire. * @param lastLoginDate * Last Date the user used his account. * @param activated * True if the user is active an can be used by the user. False if the * account is not activated and not available to the user. */ protected Account (String userKey, String siteKey, Date creationDate, Date expirationDate, Date passwordExpirationDate, Date lastLoginDate, boolean activated) { initialize (userKey, siteKey, creationDate, expirationDate, passwordExpirationDate, lastLoginDate, activated); } //------------------------------------------------------------------------- /** Return the account unique identification number. * * @return * Return the account unique identification number. */ public final String getUserKey () { return new String (mUserKey); } //------------------------------------------------------------------------- /** * Return the unique identification number. * @return * Return the site unique identification number. */ public final String getSiteKey () { return new String (mSiteKey); } //------------------------------------------------------------------------- /** Return the creation date. * * @return * Retrun the creation date. */ public final Date getCreationDate () { return (Date)mCreationDate.clone(); } //------------------------------------------------------------------------- /** Return the expiration date. * * @return * Return the expiration date. */ public final Date getExpirationDate () { return mExpirationDate; } //------------------------------------------------------------------------- /** Return the password expiration date. * * @return * Return the expiration date. */ public final Date getPasswordExpirationDate () { return mPasswordExpirationDate; } //------------------------------------------------------------------------- /** Return the last login date. * * @return * Return the last login date. */ public final Date getLastLoginDate () { return mLastLoginDate; } //------------------------------------------------------------------------- /** This method is called by the constructors in order to initialize a new * object instanciation of this class. * * @param userKey * User unique identification key. * @param siteKey * Site unique identification key. * @param creationDate * Account creation date. * @param expirationDate * Account expiration date. Specify null in case the account never * expire. * @param lastLoginDate * Last Date the user used his account. * @param activated * True if the user is active an can be used by the user. False if the * account is not activated and not available to the user. * @param siteID * Site unique identification number to which the account belongs. */ private void initialize (String userKey, String siteKey, Date creationDate, Date expirationDate, Date passwordExpirationDate, Date lastLoginDate, boolean activated) { mUserKey = userKey; mSiteKey = siteKey; mCreationDate = creationDate; mExpirationDate = expirationDate; mPasswordExpirationDate = passwordExpirationDate; mLastLoginDate = lastLoginDate; mActivated = activated; mDBUtils = AccountDBUtils.getInstance(); } //------------------------------------------------------------------------- /** Return the account's activation state. * * @return * Retrun <code>true</code> if the account is activated (available), * otherwise return <code>false</code>. */ public final boolean isActivated () { return mActivated; } //------------------------------------------------------------------------- /** Test for account expiration. * * @return * Return <code>true</code> if the account has expired, otherwise * return <code>false</code>. */ public boolean isExpired () { if (mExpirationDate != null) { // get the current date Date currentDate = new Date (); return (currentDate.after (mExpirationDate)); } // if not expiration date is given, the account does not expire. return false; } //------------------------------------------------------------------------- /** Reset the expiration to a new date. * * @param value * New expiration date. A <code>null</code> value will not reset the * expiration date.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -