1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.astrogrid.community.server.security.data ;
19
20 public class PasswordData
21 {
22 /***
23 * No encryption, clear text password.
24 * This is the default at the moment.
25 *
26 */
27 public static final String NO_ENCRYPTION = "CLEAR_TEXT" ;
28
29 /***
30 * Public constructor.
31 *
32 */
33 public PasswordData()
34 {
35 this(null, null) ;
36 }
37
38 /***
39 * Public constructor.
40 *
41 */
42 public PasswordData(String account, String password)
43 {
44 this.setAccount(account) ;
45 this.setPassword(password) ;
46 this.setEncryption(NO_ENCRYPTION) ;
47 }
48
49 /***
50 * Our Account identifier.
51 *
52 */
53 private String account ;
54
55 /***
56 * Access to our Account identifier.
57 *
58 */
59 public String getAccount()
60 {
61 return this.account ;
62 }
63
64 /***
65 * Access to our Account identifier.
66 *
67 */
68 public void setAccount(String value)
69 {
70 this.account = value ;
71 }
72
73 /***
74 * Our Account password.
75 *
76 */
77 private String password ;
78
79 /***
80 * Access to our Account password.
81 *
82 */
83 public String getPassword()
84 {
85 return this.password ;
86 }
87
88 /***
89 * Access to our Account password.
90 *
91 */
92 public void setPassword(String value)
93 {
94 this.password = value ;
95 }
96
97 /***
98 * Our Account encryption.
99 *
100 */
101 private String encryption ;
102
103 /***
104 * Access to our Account encryption.
105 *
106 */
107 public String getEncryption()
108 {
109 return this.encryption ;
110 }
111
112 /***
113 * Access to our Account encryption.
114 *
115 */
116 public void setEncryption(String value)
117 {
118 this.encryption = value ;
119 }
120
121
122
123
124
125
126 public synchronized boolean equals(Object object)
127 {
128
129
130 if (null == object)
131 {
132 return false ;
133 }
134
135
136 else {
137
138
139 if (object instanceof PasswordData)
140 {
141 PasswordData that = (PasswordData) object ;
142
143
144 if (null == this.getAccount())
145 {
146
147
148 return (null == that.getAccount()) ;
149 }
150
151
152 else {
153
154
155 return (
156 this.getAccount().equals(that.getAccount())
157 &&
158 this.getPassword().equals(that.getPassword())
159 ) ;
160 }
161 }
162
163
164 else {
165 return false ;
166 }
167 }
168 }
169
170 /***
171 * Generate a hash code for comparison tests.
172 * This combines the hash code for both identifier and password.
173 *
174 */
175 public synchronized int hashCode()
176 {
177 int result = 0 ;
178
179
180 if (null != this.getAccount())
181 {
182 result += this.getAccount().hashCode() ;
183 }
184
185
186 if (null != this.getPassword())
187 {
188 result += this.getPassword().hashCode() ;
189 }
190 return result ;
191 }
192 }