View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.jetspeed.services.security;
18  
19  import java.util.Iterator;
20  
21  import org.apache.turbine.services.Service;
22  import org.apache.jetspeed.om.security.Role;
23  
24  /***
25   * <p> The <code>RoleManagement</code> interface describes contract between
26   * the portal and security provider required for Jetspeed Role Management.
27   * This interface enables an application to be independent of the underlying
28   * role management technology.
29   *
30   * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
31   * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>
32   * @version $Id: RoleManagement.java,v 1.4 2004/02/23 03:58:11 jford Exp $
33   */
34  
35  public interface RoleManagement extends Service
36  {
37      public String SERVICE_NAME = "RoleManagement";
38      
39      public String DEFAULT_ROLE_NAME = "user";
40  
41      /***
42       * Retrieves all <code>Role</code>s for a given username principal.
43       *
44       * The security service may optionally check the current user context
45       * to determine if the requestor has permission to perform this action.
46       *
47       * @param username a user principal identity to be retrieved.
48       * @return Iterator over all roles associated to the user principal.
49       * @exception RoleException when the security provider has a general failure.
50       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
51       */
52      Iterator getRoles(String username)
53          throws JetspeedSecurityException;
54  
55      /***
56       * Retrieves all <code>Role</code>s.
57       *
58       * The security service may optionally check the current user context
59       * to determine if the requestor has permission to perform this action.
60       *
61       * @return Iterator over all roles.
62       * @exception RoleException when the security provider has a general failure.
63       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
64       */
65      Iterator getRoles()
66          throws JetspeedSecurityException;
67  
68      /***
69       * Adds a <code>Role</code> into permanent storage.
70       *
71       * The security service may optionally check the current user context
72       * to determine if the requestor has permission to perform this action.
73       *
74       * @exception RoleException when the security provider has a general failure.
75       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
76       */
77      void addRole(Role role)
78          throws JetspeedSecurityException;
79  
80      /***
81       * Saves a <code>Role</code> into permanent storage.
82       *
83       * The security service may optionally check the current user context
84       * to determine if the requestor has permission to perform this action.
85       *
86       * @exception RoleException when the security provider has a general failure.
87       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
88       */
89      void saveRole(Role role)
90          throws JetspeedSecurityException;
91  
92      /***
93       * Removes a <code>Role</code> from the permanent store.
94       *
95       * The security service may optionally check the current user context
96       * to determine if the requestor has permission to perform this action.
97       *
98       * @param rolename the principal identity of the role to be retrieved.
99       * @exception RoleException when the security provider has a general failure.
100      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
101      */
102     void removeRole(String rolename)
103         throws JetspeedSecurityException;
104 
105     /***
106      * Grants a role to a user.
107      *
108      * The security service may optionally check the current user context
109      * to determine if the requestor has permission to perform this action.
110      *
111      * @exception RoleException when the security provider has a general failure retrieving roles.
112      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
113      */
114     void grantRole(String username, String rolename)
115         throws JetspeedSecurityException;
116         
117 	void grantRole(String username, String rolename, String groupName)
118 		throws JetspeedSecurityException;
119 
120     /***
121      * Revokes a role from a user.
122      *
123      * The security service may optionally check the current user context
124      * to determine if the requestor has permission to perform this action.
125      *
126      * @exception RoleException when the security provider has a general failure retrieving roles.
127      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
128      */
129     void revokeRole(String username, String rolename)
130         throws JetspeedSecurityException;
131 
132 	void revokeRole(String username, String rolename, String groupname)
133 		throws JetspeedSecurityException;
134 
135     /***
136      * Checks for the relationship of user has a role. Returns true when the user has the given role.
137      *
138      * The security service may optionally check the current user context
139      * to determine if the requestor has permission to perform this action.
140      *
141      * @exception RoleException when the security provider has a general failure retrieving roles.
142      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
143      */
144     boolean hasRole(String username, String rolename)
145         throws JetspeedSecurityException;
146 
147 	boolean hasRole(String username, String rolename, String groupname)
148 		throws JetspeedSecurityException;
149 
150     /***
151      * Retrieves a single <code>Role</code> for a given rolename principal.
152      *
153      * The security service may optionally check the current user context
154      * to determine if the requestor has permission to perform this action.
155      *
156      * @param rolename a role principal identity to be retrieved.
157      * @return Role the role record retrieved.
158      * @exception RoleException when the security provider has a general failure.
159      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
160      */
161     Role getRole(String rolename)
162         throws JetspeedSecurityException;
163 
164 }
165 
166 
167 
168 
169 
170 
171 
172 
173