%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.security.om.impl.InternalCredentialImpl |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.jetspeed.security.om.impl; |
|
18 | ||
19 | import java.sql.Date; |
|
20 | import java.sql.Timestamp; |
|
21 | ||
22 | import org.apache.jetspeed.security.om.InternalCredential; |
|
23 | ||
24 | /** |
|
25 | * <p>{@link InternalCredential} interface implementation.</p> |
|
26 | * |
|
27 | * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a> |
|
28 | * @version $Id: InternalCredentialImpl.java 516448 2007-03-09 16:25:47Z ate $ |
|
29 | */ |
|
30 | public class InternalCredentialImpl implements InternalCredential |
|
31 | { |
|
32 | /** The serial version uid. */ |
|
33 | private static final long serialVersionUID = -8064404995292602590L; |
|
34 | ||
35 | /** |
|
36 | * <p>InternalCredential implementation default constructor.</p> |
|
37 | */ |
|
38 | public InternalCredentialImpl() |
|
39 | 0 | { |
40 | 0 | } |
41 | ||
42 | /** |
|
43 | * <p>InternalCredentialImpl constructor given a value, type and classname.</p> |
|
44 | * @param principalId The principal id. |
|
45 | * @param value The value. |
|
46 | * @param type The type. |
|
47 | * @param classname The classname. |
|
48 | */ |
|
49 | public InternalCredentialImpl(long principalId, String value, int type, String classname) |
|
50 | 0 | { |
51 | 0 | this.principalId = principalId; |
52 | 0 | this.value = value; |
53 | 0 | this.type = type; |
54 | 0 | this.classname = classname; |
55 | 0 | this.creationDate = new Timestamp(class="keyword">new java.util.Date().getTime()); |
56 | 0 | this.modifiedDate = class="keyword">this.creationDate; |
57 | 0 | } |
58 | ||
59 | /** |
|
60 | * <p>InternalCredentialImpl copy constructor given another InternalCredential and overriding classname</p> |
|
61 | * @param credential The credential to copy from |
|
62 | * @param classname The classname for the new credential |
|
63 | */ |
|
64 | public InternalCredentialImpl(InternalCredential credential, String classname) |
|
65 | 0 | { |
66 | 0 | this.authenticationFailures = credential.getAuthenticationFailures(); |
67 | 0 | this.classname = classname; |
68 | 0 | this.creationDate = credential.getCreationDate(); |
69 | 0 | this.enabled = credential.isEnabled(); |
70 | 0 | this.encoded = credential.isEncoded(); |
71 | 0 | this.expirationDate = credential.getExpirationDate(); |
72 | 0 | this.expired = credential.isExpired(); |
73 | 0 | this.previousAuthenticationDate = credential.getPreviousAuthenticationDate(); |
74 | 0 | this.lastAuthenticationDate = credential.getLastAuthenticationDate(); |
75 | 0 | this.modifiedDate = credential.getModifiedDate(); |
76 | 0 | this.principalId = credential.getPrincipalId(); |
77 | 0 | this.type = credential.getType(); |
78 | 0 | this.updateRequired = credential.isUpdateRequired(); |
79 | 0 | this.value = credential.getValue(); |
80 | 0 | } |
81 | ||
82 | private long credentialId; |
|
83 | ||
84 | /** |
|
85 | * @see org.apache.jetspeed.security.om.InternalCredential#getCredentialId() |
|
86 | */ |
|
87 | public long getCredentialId() |
|
88 | { |
|
89 | 0 | return this.credentialId; |
90 | } |
|
91 | ||
92 | /** |
|
93 | * @see org.apache.jetspeed.security.om.InternalCredential#setCredentialId(long) |
|
94 | */ |
|
95 | public void setCredentialId(long credentialId) |
|
96 | { |
|
97 | 0 | this.credentialId = credentialId; |
98 | 0 | } |
99 | ||
100 | private long principalId; |
|
101 | ||
102 | /** |
|
103 | * @see org.apache.jetspeed.security.om.InternalCredential#getPrincipalId() |
|
104 | */ |
|
105 | public long getPrincipalId() |
|
106 | { |
|
107 | 0 | return this.principalId; |
108 | } |
|
109 | ||
110 | /** |
|
111 | * @see org.apache.jetspeed.security.om.InternalCredential#setPrincipalId(long) |
|
112 | */ |
|
113 | public void setPrincipalId(long principalId) |
|
114 | { |
|
115 | 0 | this.principalId = principalId; |
116 | 0 | } |
117 | ||
118 | private String value; |
|
119 | ||
120 | /** |
|
121 | * @see org.apache.jetspeed.security.om.InternalCredential#getValue() |
|
122 | */ |
|
123 | public String getValue() |
|
124 | { |
|
125 | 0 | return this.value; |
126 | } |
|
127 | ||
128 | /** |
|
129 | * @see org.apache.jetspeed.security.om.InternalCredential#setValue(java.lang.String) |
|
130 | */ |
|
131 | public void setValue(String value) |
|
132 | { |
|
133 | 0 | this.value = value; |
134 | 0 | } |
135 | ||
136 | private boolean updateRequired; |
|
137 | ||
138 | /** |
|
139 | * @see org.apache.jetspeed.security.om.InternalCredential#isUpdateRequired() |
|
140 | */ |
|
141 | public boolean isUpdateRequired() |
|
142 | { |
|
143 | 0 | return updateRequired; |
144 | } |
|
145 | ||
146 | /* |
|
147 | * @see org.apache.jetspeed.security.om.InternalCredential#setUpdateRequired(boolean) |
|
148 | */ |
|
149 | public void setUpdateRequired(boolean updateRequired) |
|
150 | { |
|
151 | 0 | this.updateRequired = updateRequired; |
152 | 0 | } |
153 | ||
154 | private boolean encoded; |
|
155 | ||
156 | /** |
|
157 | * @see org.apache.jetspeed.security.om.InternalCredential#isEncoded() |
|
158 | */ |
|
159 | public boolean isEncoded() |
|
160 | { |
|
161 | 0 | return encoded; |
162 | } |
|
163 | ||
164 | /** |
|
165 | * @see org.apache.jetspeed.security.om.InternalCredential#setEncoded(boolean) |
|
166 | */ |
|
167 | public void setEncoded(boolean encoded) |
|
168 | { |
|
169 | 0 | this.encoded = encoded; |
170 | 0 | } |
171 | ||
172 | 0 | private boolean enabled = true; |
173 | ||
174 | /** |
|
175 | * @see org.apache.jetspeed.security.om.InternalCredential#isEnabled() |
|
176 | */ |
|
177 | public boolean isEnabled() |
|
178 | { |
|
179 | 0 | return enabled; |
180 | } |
|
181 | ||
182 | /** |
|
183 | * @see org.apache.jetspeed.security.om.InternalCredential#setEnabled(boolean) |
|
184 | */ |
|
185 | public void setEnabled(boolean enabled) |
|
186 | { |
|
187 | 0 | this.enabled = enabled; |
188 | 0 | } |
189 | ||
190 | private int authenticationFailures; |
|
191 | ||
192 | /** |
|
193 | * @see org.apache.jetspeed.security.om.InternalCredential#getAuthenticationFailures() |
|
194 | */ |
|
195 | public int getAuthenticationFailures() |
|
196 | { |
|
197 | 0 | return authenticationFailures; |
198 | } |
|
199 | ||
200 | /** |
|
201 | * @see org.apache.jetspeed.security.om.InternalCredential#setAuthenticationFailures(int) |
|
202 | */ |
|
203 | public void setAuthenticationFailures(int authenticationFailures) |
|
204 | { |
|
205 | 0 | this.authenticationFailures = authenticationFailures; |
206 | 0 | } |
207 | ||
208 | private boolean expired; |
|
209 | ||
210 | /** |
|
211 | * @see org.apache.jetspeed.security.om.InternalCredential#isExpired() |
|
212 | */ |
|
213 | public boolean isExpired() |
|
214 | { |
|
215 | 0 | return expired; |
216 | } |
|
217 | ||
218 | /** |
|
219 | * @see org.apache.jetspeed.security.om.InternalCredential#setExpired(boolean) |
|
220 | */ |
|
221 | public void setExpired(boolean expired) |
|
222 | { |
|
223 | 0 | this.expired = expired; |
224 | 0 | } |
225 | ||
226 | private Date expirationDate; |
|
227 | ||
228 | /** |
|
229 | * @see org.apache.jetspeed.security.om.InternalCredential#getExpirationDate() |
|
230 | */ |
|
231 | public Date getExpirationDate() |
|
232 | { |
|
233 | 0 | return expirationDate; |
234 | } |
|
235 | ||
236 | /** |
|
237 | * @see org.apache.jetspeed.security.om.InternalCredential#setExpirationDate(java.sql.Date) |
|
238 | */ |
|
239 | public void setExpirationDate(Date expirationDate) |
|
240 | { |
|
241 | 0 | this.expirationDate = expirationDate; |
242 | 0 | } |
243 | ||
244 | private int type; |
|
245 | ||
246 | /** |
|
247 | * @see org.apache.jetspeed.security.om.InternalCredential#getType() |
|
248 | */ |
|
249 | public int getType() |
|
250 | { |
|
251 | 0 | return this.type; |
252 | } |
|
253 | ||
254 | /** |
|
255 | * @see org.apache.jetspeed.security.om.InternalCredential#setType(int) |
|
256 | */ |
|
257 | public void setType(int type) |
|
258 | { |
|
259 | 0 | this.type = type; |
260 | 0 | } |
261 | ||
262 | private String classname; |
|
263 | ||
264 | /** |
|
265 | * @see org.apache.jetspeed.security.om.InternalCredential#getClassname() |
|
266 | */ |
|
267 | public String getClassname() |
|
268 | { |
|
269 | 0 | return this.classname; |
270 | } |
|
271 | ||
272 | /** |
|
273 | * @see org.apache.jetspeed.security.om.InternalCredential#setClassname(java.lang.String) |
|
274 | */ |
|
275 | public void setClassname(String classname) |
|
276 | { |
|
277 | 0 | this.classname = classname; |
278 | 0 | } |
279 | ||
280 | private Timestamp creationDate; |
|
281 | ||
282 | /** |
|
283 | * @see org.apache.jetspeed.security.om.InternalCredential#getCreationDate() |
|
284 | */ |
|
285 | public Timestamp getCreationDate() |
|
286 | { |
|
287 | 0 | return this.creationDate; |
288 | } |
|
289 | ||
290 | /** |
|
291 | * @see org.apache.jetspeed.security.om.InternalCredential#setCreationDate(java.sql.Timestamp) |
|
292 | */ |
|
293 | public void setCreationDate(Timestamp creationDate) |
|
294 | { |
|
295 | 0 | this.creationDate = creationDate; |
296 | 0 | } |
297 | ||
298 | private Timestamp modifiedDate; |
|
299 | ||
300 | /** |
|
301 | * @see org.apache.jetspeed.security.om.InternalCredential#getModifiedDate() |
|
302 | */ |
|
303 | public Timestamp getModifiedDate() |
|
304 | { |
|
305 | 0 | return this.modifiedDate; |
306 | } |
|
307 | ||
308 | /** |
|
309 | * @see org.apache.jetspeed.security.om.InternalCredential#setModifiedDate(java.sql.Timestamp) |
|
310 | */ |
|
311 | public void setModifiedDate(Timestamp modifiedDate) |
|
312 | { |
|
313 | 0 | this.modifiedDate = modifiedDate; |
314 | 0 | } |
315 | ||
316 | private Timestamp previousAuthenticationDate; |
|
317 | ||
318 | /** |
|
319 | * @see org.apache.jetspeed.security.om.InternalCredential#getPreviousAuthenticationDate() |
|
320 | */ |
|
321 | public Timestamp getPreviousAuthenticationDate() |
|
322 | { |
|
323 | 0 | return previousAuthenticationDate; |
324 | } |
|
325 | ||
326 | /** |
|
327 | * @see org.apache.jetspeed.security.om.InternalCredential#setPreviousAuthenticationDate(java.sql.Timestamp) |
|
328 | */ |
|
329 | public void setPreviousAuthenticationDate(Timestamp previousAuthenticationDate) |
|
330 | { |
|
331 | 0 | this.previousAuthenticationDate = previousAuthenticationDate; |
332 | 0 | } |
333 | ||
334 | private Timestamp lastAuthenticationDate; |
|
335 | ||
336 | /** |
|
337 | * @see org.apache.jetspeed.security.om.InternalCredential#getLastAuthenticationDate() |
|
338 | */ |
|
339 | public Timestamp getLastAuthenticationDate() |
|
340 | { |
|
341 | 0 | return lastAuthenticationDate; |
342 | } |
|
343 | ||
344 | /** |
|
345 | * @see org.apache.jetspeed.security.om.InternalCredential#setLastAuthenticationDate(java.sql.Timestamp) |
|
346 | */ |
|
347 | public void setLastAuthenticationDate(Timestamp lastAuthenticationDate) |
|
348 | { |
|
349 | 0 | this.lastAuthenticationDate = lastAuthenticationDate; |
350 | 0 | } |
351 | ||
352 | /** |
|
353 | * <p>Compares this {@link InternalCredential} to the provided credential |
|
354 | * and check if they are equal.</p> |
|
355 | * return Whether the {@link InternalCredential} are equal. |
|
356 | */ |
|
357 | public boolean equals(Object object) |
|
358 | { |
|
359 | 0 | if (!(object instanceof InternalCredential)) |
360 | 0 | return false; |
361 | ||
362 | 0 | InternalCredential c = (InternalCredential) object; |
363 | 0 | boolean isEqual = (((null == c.getClassname()) || (c.getClassname().equals(this.getClassname()))) && |
364 | (c.getValue().equals(this.getValue())) && |
|
365 | (c.getType() == this.getType())); |
|
366 | 0 | return isEqual; |
367 | } |
|
368 | ||
369 | /** |
|
370 | * <p>Convert <code>Node</code> to string.</p> |
|
371 | * @return The Node string value. |
|
372 | */ |
|
373 | public String toString() |
|
374 | { |
|
375 | 0 | String toStringCredential = "[[principalId, " + this.principalId + "], " |
376 | + "[value, " + this.value + "], " |
|
377 | + "[updateRequired, " + this.updateRequired + "], " |
|
378 | + "[encoded, " + this.encoded + "], " |
|
379 | + "[enabled, " + this.enabled + "], " |
|
380 | + "[authenticationFailures, "+ this.authenticationFailures + "], " |
|
381 | + "[expired, "+ this.expired + "], " |
|
382 | + "[type, " + this.type + "], " |
|
383 | + "[classname, " + this.classname + "], " |
|
384 | + "[creationDate, " + this.creationDate + "], " |
|
385 | + "[modifiedDate, " + this.modifiedDate + "], " |
|
386 | + "[previousAuthenticationDate, " + this.previousAuthenticationDate + "]" |
|
387 | + "[lastAuthenticationDate, " + this.lastAuthenticationDate + "]" |
|
388 | + (expirationDate != null ? (", [expirationDate, "+ this.expirationDate + "]]") : "]"); |
|
389 | 0 | return toStringCredential; |
390 | } |
|
391 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |