User.java
01 package com.bea.medrec.value;
02 
03 import com.bea.medrec.utils.MedRecUtils;
04 import java.io.Serializable;
05 
06 /**
07  <p>Represents information about a user including
08  * username and password.</p>
09  *
10  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
11  */
12 public class User implements Serializable {
13   private String username;
14   private String password;
15   private String status;
16 
17   // Constructors
18   public User() {
19   }
20 
21   public User(String pUsername,
22               String pPassword,
23               String pStatus) {
24     this.username = pUsername;
25     this.password = pPassword;
26     this.status = pStatus;
27   }
28 
29   public User(String pUsername) {
30     this.username = pUsername;
31   }
32 
33   // Getters
34   public String getUsername() {
35     return this.username;
36   }
37 
38   public String getPassword() {
39     return this.password;
40   }
41 
42   public String getEncodedPassword() {
43     return MedRecUtils.encodePassword(this.password);
44   }
45 
46   public String getStatus() {
47     return this.status;
48   }
49 
50   // Setters
51   public void setUsername(String pUsername) {
52     this.username = pUsername;
53   }
54 
55   public void setPassword(String pPassword) {
56     this.password = pPassword;
57   }
58 
59   public void setStatus(String pStatus) {
60     this.status = pStatus;
61   }
62 
63   public String toString() {
64     StringBuffer str = new StringBuffer();
65     str.append("User[Username: "+username);
66     str.append(" | Password: "+printPassword());
67     str.append(" | Status: "+status);
68     str.append("]");
69     return str.toString();
70   }
71 
72   // Utility
73   private String printPassword() {
74     String pwd = "";
75     if (password != nullfor (int i = 0; i < password.length(); i++pwd += "*";
76     return pwd;
77   }
78 }