3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.sal.authorization;
12 import java.util.List;
15 import org.opendaylight.controller.sal.utils.Status;
18 * Interface for applications which maintain an authorization
19 * database for their resources. Respective application web bundle
20 * and User Manager make use of this interface to retrieve
21 * authorization information at user or and role level.
23 public interface IResourceAuthorization {
26 * Create a Role name for the application
28 * @param role the role name
29 * @param userLevel the user level in the application context
30 * @return the status of the request
32 public Status createRole(String role, AppRoleLevel userLevel);
37 * @param role the role name
38 * @return the status of the request
40 public Status removeRole(String role);
43 * Return the list of roles configured for the application
45 * @return the list of roles
47 public List<String> getRoles();
50 * Returns the application role level for the specified role. If the role is
51 * not known to this application NOUSER will be returned as specified in
52 * {@link AppRoleLevel}
55 * the role name to query
56 * @return the application level of the given role in the application
57 * context as specified by {@link AppRoleLevel}. If the role is not
58 * part of this application's roles, NOUSER is returned.
60 public AppRoleLevel getApplicationRoleLevel(String roleName);
63 * Returns whether the specified role is part of this application's roles
65 * @param roleName the role name to test
66 * @return true if the role belongs to this application, false otherwise
68 public boolean isApplicationRole(String roleName);
71 * Create a resource group for application.
73 * NOTE: Resource addition is "best effort", if an object is not of correct type,
77 * the name for the resource group
79 * the list of resources for the group
80 * @return the status of the request
82 public Status createResourceGroup(String groupName, List<Object> resources);
85 * Removes a resource group
87 * @param groupName the name of the group
88 * @return the status of the request
90 public Status removeResourceGroup(String groupName);
93 * Returns the list of resource groups configured for the application
95 * @return the list of resource group names
97 public List<String> getResourceGroups();
100 * Assign a resource group to a role
102 * @param groupName the name of the resource group
103 * @param privilege the access privilege role will have on the resource group
104 * @param role the role name
105 * @return the status of the request
108 public Status assignResourceGroupToRole(String groupName,
109 Privilege privilege, String role);
112 * Assign a resource group to a role. The access privilege on the resources
113 * is inferred by the AppRoleLevel associated to role.
115 * @param groupName the name of the resource group
116 * @param role the role name
117 * @return the status of the request
119 public Status assignResourceGroupToRole(String groupName, String role);
122 * Unassign the passed resource group from the specified role
124 * @param groupName the name of the resource group
125 * @param role the role name
126 * @return the status of the request
128 public Status unassignResourceGroupFromRole(String groupName, String role);
131 * Returns the list of resource groups the given Role is authorized to use
132 * The returning object expresses the resource group name and the access
133 * its privilege for the given user role
135 * @param role the role name
136 * @return list of resources
138 public List<ResourceGroup> getAuthorizedGroups(String role);
141 * Returns the list of resources contained in the given resource group
143 * @param groupName the resource group name
146 public List<Object> getResources(String groupName);
149 * Returns the list of authorized resources for the given role
150 * For each resource only the highest privilege occurrence is returned
151 * @param role the role name
152 * @return the list of Resource
154 public List<Resource> getAuthorizedResources(String role);
160 * Returns the controller user role level the passed user name is associated with
162 * @param userName the user name
163 * @return the user role level as specified in {@link UserLevel}
165 public UserLevel getUserLevel(String userName);
168 * Returns the application context user role level the passed user name is associated with
170 * @param userName the user name
171 * @return the user role level as specified in {@link AppRoleLevel}
173 public AppRoleLevel getUserApplicationLevel(String userName);
176 * Returns the list of resources (resource + privilege) associated
177 * with the passed user name for this application context
178 * For each resource only the highest privilege occurrence is returned
180 * @param userName the user name
181 * @return the list of resources associated with this user name in this application context
183 public Set<Resource> getAllResourcesforUser(String userName);
186 * Returns the highest privilege that the user has on the specified
187 * resource in this application context
189 * @param userName the user name
190 * @param resource the given resource
191 * @return the privilege the user has on the passed resource
193 public Privilege getResourcePrivilege(String userName, Object resource);
196 * Add a resource to a group
201 * the resource object
202 * @return the status of the request
204 public Status addResourceToGroup(String groupName, Object resource);
207 * Remove a resource from a group
212 * the resource object
213 * @return the status of the request
215 public Status removeResourceFromGroup(String groupName, Object resource);
218 * Return whether the specified user has access to this application. In
219 * other words if the user is associated any roles belonging to this
224 * @return true if the user has access to this application's resources,
227 boolean isApplicationUser(String userName);