/* ===================================================================
 * AuthorizationException.java
 * 
 * Created Sep 29, 2004 11:04:35 AM
 * 
 * Copyright (c) 2004 Matt Magoffin (spamsqr@msqr.us)
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 
 * 02111-1307 USA
 * ===================================================================
 * $Id: AuthorizationException.java 23 2009-05-03 22:59:25Z msqr $
 * ===================================================================
 */

package magoffin.matt.ieat;

/**
 * Exception thrown when authorization fails.
 * 
 * @author Matt Magoffin (spamsqr@msqr.us)
 * @version $Revision: 23 $ $Date: 2009-05-04 10:59:25 +1200 (Mon, 04 May 2009) $
 */

public class AuthorizationException extends EatException {

	private static final long serialVersionUID = 3256437027812489016L;

	/** Reason code for a bad password. */
	public static final int BAD_PASSWORD = 1;

	/** Reason code for an unknown login. */
	public static final int UNKNOWN_LOGIN = 2;

	/** Reason code for a duplicate login. */
	public static final int DUPLICATE_LOGIN = 3;

	/** Reason code for a duplicate email. */
	public static final int DUPLICATE_EMAIL = 4;

	/** Reason code for a bad registration confirmation. */
	public static final int REGISTRATION_NOT_CONFIRMED = 5;

	/** Reason code for when a registration is already confirmed. */
	public static final int REGISTRATION_ALREADY_CONFIRMED = 6;

	/** Reason code for a bad forgotten password confirmation. */
	public static final int FORGOTTEN_PASSWORD_NOT_CONFIRMED = 7;
	
	private int reason;
	private String login;
	
	/**
	 * Constructor.
	 * 
	 * @param login the login in use
	 * @param reason the reason code
	 */
	public AuthorizationException(String login, int reason) {
		this.reason = reason;
		this.login = login;
	}

	/**
	 * Get the attempted login.
	 * 
	 * @return the login
	 */
	public String getLogin() {
		return login;
	}
	
	/**
	 * Get the reason code.
	 * 
	 * @return the reason code
	 */
	public int getReason() {
		return reason;
	}
}
