Source code: com/ciphercore/UserPasswordException.java
1 /* $Id: UserPasswordException.java,v 1.1 2001/04/02 08:44:06 cvsbob Exp $ */
2
3 /*
4 * UserPasswordException.java, signifies password authentication error.
5 * Copyright (C) 2001 Robert Bushman.
6 *
7 * I reserve the right to release this program under seperate license.
8 * If you require a special license grant contact Robert Bushman.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 * 02111-1307, USA.
24 */
25
26 package com.ciphercore;
27
28 import java.security.DigestException;
29
30 public class UserPasswordException extends DigestException {
31
32 // ----------------------------------------------------------
33 // CONSTANTS
34 // ----------------------------------------------------------
35
36 public static final int
37 TYPE_USER_UNKNOWN = 0,
38 TYPE_PASSWORD_INCORRECT = 1,
39 TYPE_DIGEST_CORRUPT = 2;
40
41 // -----------------------------------------------------------
42 // CONSTRUCTORS AND INITIALIZERS
43 // -----------------------------------------------------------
44
45 public UserPasswordException( int type ) {
46 super( setMessage( type ) );
47 setType( type );
48 }
49
50 // ---------------------------------------------------------
51 // INTERNAL API
52 // ---------------------------------------------------------
53
54 protected static String setMessage( int type ) {
55 if( type == TYPE_USER_UNKNOWN ) {
56 return( "\nUnknown User Attempted Login\n" );
57 } else if( type == TYPE_DIGEST_CORRUPT ) {
58 return( "\nSHA-1 hash for this user is corrupt.\n" );
59 } else {
60 return( "\nUser submitted password does not match hash.\n" );
61 }
62 }
63
64 // -----------------------------------------------------------
65 // INSTANCE PARAMETERS AND ACCESSORS
66 // -----------------------------------------------------------
67
68 // PARAMETERS
69 private int _type;
70
71 // SETTERS
72 protected void setType( int type ) { _type = type; }
73
74 // GETTERS
75 public int getType() { return( _type ); }
76 }
77