KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > security > authentication > AuthenticationService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.security.authentication;
18
19 import java.util.Set JavaDoc;
20
21 import org.alfresco.service.cmr.repository.NodeRef;
22 import org.alfresco.service.cmr.repository.StoreRef;
23
24 /**
25  * The authentication service defines the API for managing authentication information
26  * against a userid.
27  *
28  * @author Andy Hind
29  *
30  */

31 public interface AuthenticationService
32 {
33     /**
34      * Create an authentication for the given user.
35      *
36      * @param userName
37      * @param password
38      * @throws AuthenticationException
39      */

40     public void createAuthentication(String JavaDoc userName, char[] password) throws AuthenticationException;
41     
42     /**
43      * Update the login information for the user (typically called by the user)
44      *
45      * @param userName
46      * @param oldPassword
47      * @param newPassword
48      * @throws AuthenticationException
49      */

50     public void updateAuthentication(String JavaDoc userName, char[] oldPassword, char[] newPassword) throws AuthenticationException;
51     
52     /**
53      * Set the login information for a user (typically called by an admin user)
54      *
55      * @param userName
56      * @param newPassword
57      * @throws AuthenticationException
58      */

59     public void setAuthentication(String JavaDoc userName, char[] newPassword) throws AuthenticationException;
60     
61
62     /**
63      * Delete an authentication entry
64      *
65      * @param userName
66      * @throws AuthenticationException
67      */

68     public void deleteAuthentication(String JavaDoc userName) throws AuthenticationException;
69     
70     /**
71      * Carry out an authentication attempt. If successful the user is set to the current user.
72      * The current user is a part of the thread context.
73      *
74      * @param userName
75      * @param password
76      * @throws AuthenticationException
77      */

78     public void authenticate(String JavaDoc userName, char[] password) throws AuthenticationException;
79     
80     /**
81      * Get the name of the currently authenticated user.
82      *
83      * @return
84      * @throws AuthenticationException
85      */

86     public String JavaDoc getCurrentUserName() throws AuthenticationException;
87     
88     /**
89      * Invlidate any tickets held by the user.
90      *
91      * @param userName
92      * @throws AuthenticationException
93      */

94     public void invalidateUserSession(String JavaDoc userName) throws AuthenticationException;
95     
96    /**
97     * Invalidate a single ticket by ID
98     *
99     * @param ticket
100     * @throws AuthenticationException
101     */

102     public void invalidateTicket(String JavaDoc ticket) throws AuthenticationException;
103     
104    /**
105     * Validate a ticket. Set the current user name accordingly.
106     *
107     * @param ticket
108     * @throws AuthenticationException
109     */

110     public void validate(String JavaDoc ticket) throws AuthenticationException;
111     
112     /**
113      * Get the current ticket as a string
114      * @return
115      */

116     public String JavaDoc getCurrentTicket();
117     
118     /**
119      * Remove the current security information
120      *
121      */

122     public void clearCurrentSecurityContext();
123     
124     
125     /**
126      * Get all the roles for the currently authenticated user.
127      *
128      * @return
129      */

130     public Set JavaDoc<String JavaDoc> getCurrentUserRoles();
131     
132     /**
133      * Get all the groups for the currently authenticated user.
134      *
135      * @return
136      */

137     public Set JavaDoc<String JavaDoc> getCurrentUserGroups();
138     
139     /**
140      * Get all the roles for the given userName.
141      *
142      * @param userName
143      * @return
144      */

145     public Set JavaDoc<String JavaDoc> getUserRoles(String JavaDoc userName);
146     
147     /**
148      * Get all the groups for the given userName.
149      *
150      * @param userName
151      * @return
152      */

153     public Set JavaDoc<String JavaDoc> getUserGroups(String JavaDoc userName);
154     
155     /**
156      * Get all the roles the authentication service knows about.
157      *
158      * @return
159      */

160     public Set JavaDoc<String JavaDoc> getAllUserRoles();
161     
162     /**
163      * Get all the groups the authentication service knows about.
164      *
165      * @return
166      */

167     public Set JavaDoc<String JavaDoc> getAllUserGroups();
168     
169     /**
170      * Get all the user names the authentication knows about.
171      *
172      * @return
173      */

174     public Set JavaDoc<String JavaDoc> getAllUserNames();
175     
176     /**
177      * Create or update a basic person entry for the given user name.
178      * Depending on the implementation this may set properties derived from the authenication store.
179      *
180      * @param storeRef
181      * @param userName
182      * @return
183      */

184     public NodeRef synchronisePerson(StoreRef storeRef, String JavaDoc userName);
185     
186     /**
187      * Get a user by userName
188      *
189      * @param storeRef
190      * @param userName
191      * @return
192      */

193     public NodeRef getPersonNodeRef(StoreRef storeRef, String JavaDoc userName);
194     
195     /**
196      * Is the current user the system user
197      *
198      * @return
199      */

200     
201     public boolean isCurrentUserTheSystemUser();
202     
203 }
204
205
Popular Tags