001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: InvalidPasswordException.java,v 1.4 2008/06/25 05:42:06 qcheng Exp $
026 *
027 */
028
029package com.sun.identity.authentication.spi;
030
031/**
032 * Exception that is thrown when the user-entered password token causes the
033 * authentication module to be authenticated to <b>fail</b>. Authentication
034 * module must throw this exception if it wishes to participate in user lock out
035 * due to too many password failure login feature. Prior to throwing this
036 * exception, the authentication module should set the <code>userTokenId</code>
037 * so that subsequent calls to <code>getUserTokenId</code> will return correct
038 * <code>userTokenId</code> that will be use to lock out the user.
039 *
040 * @supported.all.api
041 */
042public class InvalidPasswordException extends AuthLoginException {
043
044    String tokenId;
045
046    /**
047     * Constructs an <code>InvalidPasswordException</code> object.
048     * 
049     * @param rbName
050     *            Resource bundle name for the message.
051     * @param errCode
052     *            Key to the message in resource bundle.
053     * @param args
054     *            Arguments to the message.
055     */
056    public InvalidPasswordException(String rbName, 
057            String errCode, Object[] args) 
058    {
059        super(rbName, errCode, args);
060    }
061
062    /**
063     * Constructs an <code>InvalidPasswordException</code> object.
064     * 
065     * @param message
066     *            English message for the exception.
067     */
068    public InvalidPasswordException(String message) {
069        super(message);
070    }
071
072    /**
073     * Constructs an <code>InvalidPasswordException</code> object.
074     * 
075     * @param message
076     *            English message for the exception.
077     * @param tokenId
078     *            The <code>userId</code> for which the exception occurred.
079     */
080    public InvalidPasswordException(String message, String tokenId) {
081        super(message);
082        this.tokenId = tokenId;
083    }
084
085    /**
086     * Constructs an <code>InvalidPasswordException</code> object.
087     * 
088     * @param t
089     *            the root cause of the exception
090     */
091    public InvalidPasswordException(Throwable t) {
092        super(t);
093        if (t instanceof InvalidPasswordException) {
094            this.tokenId = ((InvalidPasswordException) t).tokenId;
095        }
096    }
097
098    /**
099     * Constructs an <code>InvalidPasswordException</code> object.
100     * 
101     * @param rbName
102     *            Resource bundle name for the message.
103     * @param errorCode
104     *            Key to the message in resource bundle.
105     * @param args
106     *            Arguments to the message.
107     * @param tokenId
108     *            <code>userID</code> for which the exception occurred.
109     * @param t
110     *            The root cause of the exception.
111     */
112    public InvalidPasswordException(String rbName, String errorCode,
113            Object[] args, String tokenId, Throwable t) {
114        super(rbName, errorCode, args, t);
115        this.tokenId = tokenId;
116    }
117
118    /**
119     * Returns the token ID.
120     * 
121     * @return the token ID.
122     */
123    public String getTokenId() {
124        return tokenId;
125    }
126}