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