001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.jetspeed.security.om;
018:
019: import java.io.Serializable;
020: import java.sql.Date;
021: import java.sql.Timestamp;
022:
023: /**
024: * <p>Interface representing a security credential.</p>
025: * <p>The credential value represents the value of the credential
026: * such as a password.</p>
027: * <p>For now, we do not have custom credentials classes and
028: * credentials support only 1 credential (i.e. 1 password).<p>
029: * <p>The credential type represents whether a credential is private or
030: * public:</p>
031: * <ul>
032: * <li>Private credential: type == 0</li>
033: * <li>Public credential: type == 1</li>
034: * </ul>
035: * <p>The credential classname represent the class of credential.
036: * </p>
037: * TODO Add multiple credentials support.
038: * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
039: * @version $Id: InternalCredential.java 516448 2007-03-09 16:25:47Z ate $
040: */
041: public interface InternalCredential extends Serializable, Cloneable {
042: /** Private credentials type. */
043: public static final int PRIVATE = 0;
044: /** Public credentials type. */
045: public static final int PUBLIC = 1;
046:
047: /**
048: * Maximum allowed java.sql.Date value (according to the specs).
049: * <em>Note:</em><br>
050: * The concrete value is default time zone dependent and should <em>only</em>
051: * be used for setting Date fields, not to <em>compare<em> against.
052: */
053: public static final Date MAX_DATE = Date.valueOf("8099-01-01");
054:
055: /**
056: * <p>Getter for the credential id.</p>
057: * @return The credential id.
058: */
059: long getCredentialId();
060:
061: /**
062: * <p>Setter for the credential id.</p>
063: * @param credentialId The credential id.
064: */
065: void setCredentialId(long credentialId);
066:
067: /**
068: * <p>Getter for the principal id.</p>
069: * @return The principal id.
070: */
071: long getPrincipalId();
072:
073: /**
074: * <p>Setter for the principal id.</p>
075: * @param principalId The principal id.
076: */
077: void setPrincipalId(long principalId);
078:
079: /**
080: * <p>Getter for the credential value.</p>
081: * @return The credential value.
082: */
083: String getValue();
084:
085: /**
086: * <p>Setter for the credential value.</p>
087: * @param value The credential value.
088: */
089: void setValue(String value);
090:
091: /**
092: * <p>Getter for the update required state</p>
093: * @return true if required
094: */
095: boolean isUpdateRequired();
096:
097: /**
098: * <p>Setter for the update required state</p>
099: * @param updateRequired the update required state
100: */
101: void setUpdateRequired(boolean updateRequired);
102:
103: /**
104: * <p>Getter for the encoded state</p>
105: * @return true if encoded
106: */
107: boolean isEncoded();
108:
109: /**
110: * Setter for the encoded state</p>
111: * @param encoded The encoded state
112: */
113: void setEncoded(boolean encoded);
114:
115: /**
116: * <p>Getter for the enabled state</p>
117: * @return true if enabled
118: */
119: boolean isEnabled();
120:
121: /**
122: * Setter for the enabled state</p>
123: * @param enabled The enabled state
124: */
125: void setEnabled(boolean enabled);
126:
127: /**
128: * <p>Getter for the current number of authentication failures in a row.</p>
129: * <ul>
130: * <li>-1: never tried yet</li>
131: * <li> 0: none, or last attempt was successful</li>
132: * <li>>0: number of failures</li>
133: * </ul>
134: * @return The number of authentication failures
135: */
136: int getAuthenticationFailures();
137:
138: /**
139: * <p>Setter for the number of authentication failures</p>
140: * @param authenticationFailures The number of authentication failures
141: */
142: void setAuthenticationFailures(int authenticationFailures);
143:
144: /**
145: * Getter for the expired state.</p>
146: * @return true if expired
147: */
148: boolean isExpired();
149:
150: /**
151: * Setter for the expired state.</p>
152: * @param expired The expired state
153: */
154: void setExpired(boolean expired);
155:
156: /**
157: * <p>Getter for the expiration date.</p>
158: * @return The expiration date.
159: */
160: Date getExpirationDate();
161:
162: /**
163: * <p>Setter for the expiration date.</p>
164: * @param expirationDate The expiration date.
165: */
166: void setExpirationDate(Date expirationDate);
167:
168: /**
169: * <p>Getter for the credential type.</p>
170: * <ul>
171: * <li>Private credential: type == 0</li>
172: * <li>Public credential: type == 1</li>
173: * </ul>
174: * @return The credential type.
175: */
176: int getType();
177:
178: /**
179: * <p>Setter for the credential type.</p>
180: * <ul>
181: * <li>Private credential: type == 0</li>
182: * <li>Public credential: type == 1</li>
183: * </ul>
184: * @param type The credential type.
185: */
186: void setType(int type);
187:
188: /**
189: * <p>Getter for the principal classname.</p>
190: * @return The principal classname.
191: */
192: String getClassname();
193:
194: /**
195: * <p>Setter for the principal classname.</p>
196: * @param classname The principal classname.
197: */
198: void setClassname(String classname);
199:
200: /**
201: * <p>Getter for creation date.</p>
202: * @return The creation date.
203: */
204: Timestamp getCreationDate();
205:
206: /**
207: * <p>Setter for the creation date.</p>
208: * @param creationDate The creation date.
209: */
210: void setCreationDate(Timestamp creationDate);
211:
212: /**
213: * <p>Getter for the modified date.</p>
214: * @return The modified date.
215: */
216: Timestamp getModifiedDate();
217:
218: /**
219: * <p>Setter for the modified date.</p>
220: * @param modifiedDate The modified date.
221: */
222: void setModifiedDate(Timestamp modifiedDate);
223:
224: /**
225: * <p>Getter for the previous authentication date</p>
226: * @return The previous authentication date.
227: */
228: Timestamp getPreviousAuthenticationDate();
229:
230: /**
231: * <p>Setter for the previous authentication date</p>
232: * @param previousAuthenticationDate The previous authentication date.
233: */
234: void setPreviousAuthenticationDate(
235: 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: }
|