Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / usermanager / api / src / main / java / org / opendaylight / controller / usermanager / IUserManager.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.usermanager;
10
11 import java.util.List;
12 import java.util.Map;
13 import java.util.Set;
14
15 import org.opendaylight.controller.sal.authorization.AuthResultEnum;
16 import org.opendaylight.controller.sal.authorization.UserLevel;
17 import org.opendaylight.controller.sal.utils.Status;
18 import org.springframework.security.core.userdetails.UserDetailsService;
19 import org.springframework.security.web.context.SecurityContextRepository;
20
21 /**
22  * The Interface which describes the methods exposed by User Manager.
23  */
24 public interface IUserManager extends UserDetailsService {
25
26     /**
27      * Returns the list of roles associated to the passed user name
28      *
29      * @param userName
30      * @return the role associated to the user name
31      */
32     public List<String> getUserRoles(String userName);
33
34     /**
35      * Authenticate user with AAA server and return authentication and
36      * authorization info
37      *
38      * @param username
39      *            the username
40      * @param password
41      *            the password
42      * @return {@link org.opendaylight.controller.sal.authorization.AuthResultEnum}
43      *         authentication result
44      */
45     public AuthResultEnum authenticate(String username, String password);
46
47     /**
48      * Add/remove AAA server
49      *
50      * @param configObject
51      *            {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
52      *            Server Configuration
53      * @return {@link org.opendaylight.controller.sal.utils.Status}
54      *         status of this action
55      */
56     public Status addAAAServer(ServerConfig configObject);
57
58     /**
59      * Remove AAA server
60      *
61      * @param configObject
62      *            refer to
63      *            {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
64      *            Server Configuration
65      * @return {@link org.opendaylight.controller.sal.utils.Status}
66      *         status of this action
67      */
68     public Status removeAAAServer(ServerConfig configObject);
69
70     /**
71      * Add a local user
72      *
73      * @param configObject
74      *            {@link org.opendaylight.controller.usermanager.internal.UserConfig}
75      *            User Configuration
76      * @return refer to {@link org.opendaylight.controller.sal.utils.Status}
77      *         status code
78      */
79     public Status addLocalUser(UserConfig configObject);
80
81     /**
82      * Modify a local user
83      *
84      * @param configObject
85      *            {@link org.opendaylight.controller.usermanager.internal.UserConfig}
86      *            The new User Configuration
87      * @return refer to {@link org.opendaylight.controller.sal.utils.Status}
88      *         status code
89      */
90     public Status modifyLocalUser(UserConfig configObject);
91
92     /**
93      * Remove a local user
94      *
95      * @param configObject
96      *            {@link org.opendaylight.controller.usermanager.internal.UserConfig}
97      *            UserConfig
98      * @return {@link org.opendaylight.controller.sal.utils.Status}
99      *         status of this action
100      */
101     public Status removeLocalUser(UserConfig configObject);
102
103     /**
104      * Remove a local user
105      *
106      * @param userName
107      *            the user name
108      * @return {@link org.opendaylight.controller.sal.utils.Status}
109      *         status of this action
110      */
111     public Status removeLocalUser(String userName);
112
113     /**
114      * Add the authorization information for a user that gets authenticated
115      * remotely
116      *
117      * @param AAAconf
118      *            {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
119      *            Authorization Resources
120      * @return {@link org.opendaylight.controller.sal.utils.Status}
121      *         status of this action
122      */
123     public Status addAuthInfo(AuthorizationConfig AAAconf);
124
125     /**
126      * Remove the authorization information for a user that gets authenticated
127      * remotely
128      *
129      * @param AAAconf
130      *            {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
131      *            Authorization Resource
132      * @return {@link org.opendaylight.controller.sal.utils.Status}
133      *         status of this action
134      */
135     public Status removeAuthInfo(AuthorizationConfig AAAconf);
136
137     /**
138      * Return the list of authorization resources
139      *
140      * @return {@link org.opendaylight.controller.usermanager.internal.AuthorizationConfig}
141      *         List of Authorization Resource
142      */
143     public List<AuthorizationConfig> getAuthorizationList();
144
145     /**
146      * Returns a list of AAA Providers.
147      *
148      * @return Set of provider names.
149      */
150     public Set<String> getAAAProviderNames();
151
152     /**
153      * Change the current password for a locally configured user
154      *
155      * @param user
156      *            the username
157      * @param curPasssword
158      *            the current password
159      * @param newPassword
160      *            the new password
161      * @return {@link org.opendaylight.controller.sal.utils.Status}
162      *         status of this action
163      */
164     public Status changeLocalUserPassword(String user, String curPassword,
165             String newPassword);
166
167     /**
168      * Return a list of AAA servers currently configured
169      *
170      * @return {@link org.opendaylight.controller.usermanager.internal.ServerConfig}
171      *         List of ServerConfig
172      */
173     public List<ServerConfig> getAAAServerList();
174
175     /**
176      * Return a list of local users
177      *
178      * @return {@link org.opendaylight.controller.usermanager.internal.UserConfig}
179      *         List of UserConfig
180      */
181     public List<UserConfig> getLocalUserList();
182
183     /**
184      * Save the local users to disk
185      *
186      * @return {@link org.opendaylight.controller.sal.utils.Status}
187      *         status of this action
188      */
189     public Status saveLocalUserList();
190
191     /**
192      * Save the AAA server configurations to disk
193      *
194      * @return {@link org.opendaylight.controller.sal.utils.Status}
195      *         status of this action
196      */
197     public Status saveAAAServerList();
198
199     /**
200      * Save the Authorization configurations to disk
201      *
202      * @return {@link org.opendaylight.controller.sal.utils.Status}
203      *         status code
204      */
205     public Status saveAuthorizationList();
206
207     /**
208      * Remove user profile when user logs out
209      *
210      * @param username
211      *            the user name
212      */
213     public void userLogout(String username);
214
215     /**
216      * Remove user profile when user times out
217      *
218      * @param username
219      *            the user name
220      */
221     public void userTimedOut(String username);
222
223     /**
224      * Get the list of users currently logged in
225      *
226      * @return the list of users along with their administrative roles
227      */
228     public Map<String, List<String>> getUserLoggedIn();
229
230     /**
231      * Get date and time user was successfully authenticated
232      *
233      * @param user
234      * @return Date in String format
235      */
236     public String getAccessDate(String user);
237
238     /**
239      * Returns the highest user level for the passed user name. It checks the roles
240      * assigned to this user and checks against the well known Controller user
241      * roles to determines the highest user level associated with the user
242      *
243      * @param userName
244      *            the user name
245      * @return {@link org.opendaylight.controller.sal.authorization.UserLevel}
246      *         the highest user level for this user
247      */
248     public UserLevel getUserLevel(String userName);
249
250     /**
251      * Returns the list of user level for the passed user name. It checks the roles
252      * assigned to this user and checks against the well known Controller user
253      * roles to determines the corresponding list of user level associated with the user
254      *
255      * @param userName
256      *            the user name
257      * @return
258      *          the list of user level for this user
259      */
260     public List<UserLevel> getUserLevels(String userName);
261
262     /**
263      * Returns the Security Context
264      *
265      * @returns {@link org.springframework.security.web.context.SecurityContextRepository}
266      *          Security Context
267      */
268     public SecurityContextRepository getSecurityContextRepo();
269
270     /**
271      * Returns the Session Manager Interface Handler
272      *
273      * @return {@link org.opendaylight.controller.usermanager.ISessionManager}
274      *         session manager interface handler
275      */
276     public ISessionManager getSessionManager();
277
278     /**
279      * Checks if the specified role belongs to any application. Usually an
280      * application will call this function when configuring a role, to check if
281      * that role is already being used by another application.
282      *
283      * @param role
284      *            The role to check
285      * @return true if the specified role belongs to any application or if the
286      *         role is a well-known controller role, false otherwise.
287      */
288     public boolean isRoleInUse(String role);
289
290     /* non-Javadoc
291      * Returns the password for a given user
292      *
293      * @param username
294      *            the user name
295      * @return password for the username
296      */
297     public String getPassword(String username);
298
299 }