001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2006 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: SessionException.java,v 1.3 2008/06/25 05:47:28 qcheng Exp $
026 *
027 */
028
029package com.sun.identity.plugin.session;
030
031import com.sun.identity.shared.locale.L10NMessageImpl;
032
033/**
034 * This class is to handle Session related exceptions.
035 *
036 * @supported.all.api
037 */
038public class SessionException extends L10NMessageImpl {
039
040
041    /**
042     * Error codes.
043     */
044    public static int AUTH_ERROR_NOT_DEFINED = -1;
045    public static int AUTH_USER_INACTIVE = 1;
046    public static int AUTH_USER_LOCKED = 2;
047    public static int AUTH_ACCOUNT_EXPIRED = 3;
048
049    private int code = AUTH_ERROR_NOT_DEFINED;
050
051    /**
052     * Constructs a <code>SessionException</code> with a detailed
053     * message.
054     *
055     * @param message Detailed message for this exception.
056     */
057    public SessionException(String message) {
058        super(message);
059    }
060    
061    /**
062     * Constructs a <code>SessionException</code> with
063     * an embedded exception.
064     *
065     * @param rootCause An embedded exception
066     */
067    public SessionException(Throwable rootCause) {
068        super(rootCause);
069    }
070
071    /**
072     * Constructs a <code>SessionException</code> with an exception.
073     *
074     * @param ex an exception
075     */
076    public SessionException(Exception ex) {
077       super(ex);
078    }
079
080    /**
081     * Constructs a new <code>SessionException</code> without a nested
082     * <code>Throwable</code>.
083     * @param rbName Resource Bundle Name to be used for getting
084     *  localized error message.
085     * @param messageKey Key to resource bundle. You can use
086     * <pre>
087     * ResourceBundle rb = ResourceBunde.getBundle (rbName,locale);
088     * String localizedStr = rb.getString(messageCode);
089     * </pre>
090     * @param args arguments to message. If it is not present pass them
091     *  as null
092     *
093     */
094    public SessionException(String rbName, String messageKey, Object[] args) {
095        super(rbName, messageKey, args);
096    }
097
098    /**
099     * Returns the error code for the caller of a <code>SessionProvider</code>
100     * method.
101     * @return Error code.
102     */
103    public int getErrCode() {
104        return code;
105    }
106
107    /**
108     * Sets an error code by an implementation of the
109     * <code>SessionProvider</code> to indicate a specific error condition
110     * which could be retrieved by the caller of a SessionProvider method.
111     *
112     * @param errorCode the error code to be set.
113     */
114    public void setErrCode(int errorCode) {
115        code = errorCode;
116    }
117}