1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.security.om;
18
19 import java.io.Serializable;
20 import java.sql.Date;
21 import java.sql.Timestamp;
22
23 /***
24 * <p>Interface representing a security credential.</p>
25 * <p>The credential value represents the value of the credential
26 * such as a password.</p>
27 * <p>For now, we do not have custom credentials classes and
28 * credentials support only 1 credential (i.e. 1 password).<p>
29 * <p>The credential type represents whether a credential is private or
30 * public:</p>
31 * <ul>
32 * <li>Private credential: type == 0</li>
33 * <li>Public credential: type == 1</li>
34 * </ul>
35 * <p>The credential classname represent the class of credential.
36 * </p>
37 * TODO Add multiple credentials support.
38 * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
39 * @version $Id: InternalCredential.java 516448 2007-03-09 16:25:47Z ate $
40 */
41 public interface InternalCredential extends Serializable, Cloneable
42 {
43 /*** Private credentials type. */
44 public static final int PRIVATE = 0;
45 /*** Public credentials type. */
46 public static final int PUBLIC = 1;
47
48 /***
49 * Maximum allowed java.sql.Date value (according to the specs).
50 * <em>Note:</em><br>
51 * The concrete value is default time zone dependent and should <em>only</em>
52 * be used for setting Date fields, not to <em>compare<em> against.
53 */
54 public static final Date MAX_DATE = Date.valueOf("8099-01-01");
55
56 /***
57 * <p>Getter for the credential id.</p>
58 * @return The credential id.
59 */
60 long getCredentialId();
61
62 /***
63 * <p>Setter for the credential id.</p>
64 * @param credentialId The credential id.
65 */
66 void setCredentialId(long credentialId);
67
68 /***
69 * <p>Getter for the principal id.</p>
70 * @return The principal id.
71 */
72 long getPrincipalId();
73
74 /***
75 * <p>Setter for the principal id.</p>
76 * @param principalId The principal id.
77 */
78 void setPrincipalId(long principalId);
79
80 /***
81 * <p>Getter for the credential value.</p>
82 * @return The credential value.
83 */
84 String getValue();
85
86 /***
87 * <p>Setter for the credential value.</p>
88 * @param value The credential value.
89 */
90 void setValue(String value);
91
92 /***
93 * <p>Getter for the update required state</p>
94 * @return true if required
95 */
96 boolean isUpdateRequired();
97
98 /***
99 * <p>Setter for the update required state</p>
100 * @param updateRequired the update required state
101 */
102 void setUpdateRequired(boolean updateRequired);
103
104 /***
105 * <p>Getter for the encoded state</p>
106 * @return true if encoded
107 */
108 boolean isEncoded();
109
110 /***
111 * Setter for the encoded state</p>
112 * @param encoded The encoded state
113 */
114 void setEncoded(boolean encoded);
115
116 /***
117 * <p>Getter for the enabled state</p>
118 * @return true if enabled
119 */
120 boolean isEnabled();
121
122 /***
123 * Setter for the enabled state</p>
124 * @param enabled The enabled state
125 */
126 void setEnabled(boolean enabled);
127
128 /***
129 * <p>Getter for the current number of authentication failures in a row.</p>
130 * <ul>
131 * <li>-1: never tried yet</li>
132 * <li> 0: none, or last attempt was successful</li>
133 * <li>>0: number of failures</li>
134 * </ul>
135 * @return The number of authentication failures
136 */
137 int getAuthenticationFailures();
138
139 /***
140 * <p>Setter for the number of authentication failures</p>
141 * @param authenticationFailures The number of authentication failures
142 */
143 void setAuthenticationFailures(int authenticationFailures);
144
145 /***
146 * Getter for the expired state.</p>
147 * @return true if expired
148 */
149 boolean isExpired();
150
151 /***
152 * Setter for the expired state.</p>
153 * @param expired The expired state
154 */
155 void setExpired(boolean expired);
156
157 /***
158 * <p>Getter for the expiration date.</p>
159 * @return The expiration date.
160 */
161 Date getExpirationDate();
162
163 /***
164 * <p>Setter for the expiration date.</p>
165 * @param expirationDate The expiration date.
166 */
167 void setExpirationDate(Date expirationDate);
168
169 /***
170 * <p>Getter for the credential type.</p>
171 * <ul>
172 * <li>Private credential: type == 0</li>
173 * <li>Public credential: type == 1</li>
174 * </ul>
175 * @return The credential type.
176 */
177 int getType();
178
179 /***
180 * <p>Setter for the credential type.</p>
181 * <ul>
182 * <li>Private credential: type == 0</li>
183 * <li>Public credential: type == 1</li>
184 * </ul>
185 * @param type The credential type.
186 */
187 void setType(int type);
188
189 /***
190 * <p>Getter for the principal classname.</p>
191 * @return The principal classname.
192 */
193 String getClassname();
194
195 /***
196 * <p>Setter for the principal classname.</p>
197 * @param classname The principal classname.
198 */
199 void setClassname(String classname);
200
201 /***
202 * <p>Getter for creation date.</p>
203 * @return The creation date.
204 */
205 Timestamp getCreationDate();
206
207 /***
208 * <p>Setter for the creation date.</p>
209 * @param creationDate The creation date.
210 */
211 void setCreationDate(Timestamp creationDate);
212
213 /***
214 * <p>Getter for the modified date.</p>
215 * @return The modified date.
216 */
217 Timestamp getModifiedDate();
218
219 /***
220 * <p>Setter for the modified date.</p>
221 * @param modifiedDate The modified date.
222 */
223 void setModifiedDate(Timestamp modifiedDate);
224
225 /***
226 * <p>Getter for the previous authentication date</p>
227 * @return The previous authentication date.
228 */
229 Timestamp getPreviousAuthenticationDate();
230
231 /***
232 * <p>Setter for the previous authentication date</p>
233 * @param previousAuthenticationDate The previous authentication date.
234 */
235 void setPreviousAuthenticationDate(Timestamp previousAuthenticationDate);
236
237 /***
238 * <p>Getter for the last authentication date</p>
239 * @return The last authentication date.
240 */
241 Timestamp getLastAuthenticationDate();
242
243 /***
244 * <p>Setter for the last authentication date</p>
245 * @param lastAuthenticationDate The last authentication date.
246 */
247 void setLastAuthenticationDate(Timestamp lastAuthenticationDate);
248 }