Java Reference
In-Depth Information
Table 9-3 Class and Instance Variables of the Password Class
VARIABLE SCOPE
DATA TYPE
VARIABLE NAME
PURPOSE
Class
int (final)
MIN_SIZE
Indicates the minimum size
(length) of a password
Class
int (final)
MAX_SIZE
Indicates the maximum size
(length) of a password
Class
int
maxHistory
Indicates the maximum
number of entries in
password history list
Class
int
expiresNotifyLimit
Indicates the number of
remaining uses when
password nears expiration
Instance
int
maxUses
Indicates the maximum
number of uses for an auto-
expiring password
Instance
int
remainingUses
Indicates the number of
remaining uses for an auto-
expiring password
Instance
boolean
autoExpires
Indicates whether password
should automatically expire
Instance
boolean
expired
Indicates whether password
has expired
Instance
ArrayList
pswdHistory
Contains a list of current and
recently used passwords
The following steps enter the code to declare class and instance variables,
including the final variables, for the Password class.
1 /*
2
Chapter 9: The Password Class
3
Programmer: Michael Mick
4
Date:
November 28, 2007
5
Filename:
Password.java
6
Purpose:
To provide a reusable Password class
7 */
8
9 import java.util.*;
10
11 public class Password
12 {
13
final static int MIN_SIZE = 6;
14
final static int MAX_SIZE = 15;
15
static int maxHistory = 4;
16
static int expiresNotifyLimit = 3;
17
18
private int maxUses = 120;
19
private int remainingUses = maxUses;
20
private boolean autoExpires = true ;
21
private boolean expired = false ;
22
23
private ArrayList pswdHistory;
24
FIGURE 9-5
 
Search WWH ::




Custom Search