KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jcr > Credentials


1 /*
2  * $Id: Credentials.java,v 1.2 2004/07/24 00:16:21 benjmestrallet Exp $
3  *
4  * Copyright 2002-2004 Day Management AG, Switzerland.
5  *
6  * Licensed under the Day RI License, Version 2.0 (the "License"),
7  * as a reference implementation of the following specification:
8  *
9  * Content Repository API for Java Technology, revision 0.12
10  * <http://www.jcp.org/en/jsr/detail?id=170>
11  *
12  * You may not use this file except in compliance with the License.
13  * You may obtain a copy of the License files at
14  *
15  * http://www.day.com/content/en/licenses/day-ri-license-2.0
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */

24 package javax.jcr;
25
26 import java.io.Serializable JavaDoc;
27
28 /**
29  * Base interface for all credentials that may be passed to the
30  * {@link Repository#login(Credentials, String)
31  * Repository.login(Credentials credentials, String workspaceName)} method.
32  * Provides a minimal standard method for authenticating against a
33  * repository (i.e., using a user ID and password). Additional attributes may
34  * be used by the repository to, for example, set a token that can then be
35  * passed back and forth once authentication has been completed (thus enabling
36  * later authorization without re-authentication). In addition, any class that
37  * implements this interface can also, of course, add its own methods to deal
38  * with more advanced authentication/authorization mechanisms.
39  *
40  * @author Peeter Piegaze
41  * @author Stefan Guggisberg
42  */

43 public interface Credentials extends Serializable JavaDoc {
44
45   /**
46    * Returns the user ID.
47    *
48    * @return the user ID.
49    */

50   public String JavaDoc getUserId();
51
52   /**
53    * Returns the password.
54    * <p/>
55    * Note that this method returns a reference to the password.
56    * It is the caller's responsibility to zero out the password information
57    * after it is no longer needed.
58    *
59    * @return the password.
60    */

61   public char[] getPassword();
62
63   /**
64    * Stores an attribute in this credentials instance.
65    *
66    * @param name a <code>String</code> specifying the name of the attribute
67    * @param value the <code>Object</code> to be stored
68    */

69   public void setAttribute(String JavaDoc name, Object JavaDoc value);
70
71   /**
72    * Removes an attribute from this credentials instance.
73    *
74    * @param name a <code>String</code> specifying the name of the attribute
75    * to remove
76    */

77   public void removeAttribute(String JavaDoc name);
78
79   /**
80    * Returns the value of the named attribute as an <code>Object</code>,
81    * or <code>null</code> if no attribute of the given name exists.
82    *
83    * @param name a <code>String</code> specifying the name of
84    * the attribute
85    * @return an <code>Object</code> containing the value of the attribute,
86    * or <code>null</code> if the attribute does not exist
87    */

88   public Object JavaDoc getAttribute(String JavaDoc name);
89
90   /**
91    * Returns the names of the attributes available to this
92    * credentials instance. This method returns an empty array
93    * if the credentials instance has no attributes available to it.
94    *
95    * @return a string array containing the names of the stored attributes
96    */

97   public String JavaDoc[] getAttributeNames();
98 }
Popular Tags