KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > security > JetspeedGroupManagement


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 JavaDoc;
20
21 import org.apache.jetspeed.om.security.Group;
22 import org.apache.turbine.services.TurbineServices;
23
24 /**
25  * <p> The <code>GroupManagement</code> interface describes contract between
26  * the portal and security provider required for Jetspeed Group Management.
27  * This interface enables an application to be independent of the underlying
28  * group management technology.
29  *
30  * @author <a HREF="mailto:david@bluesunrise.com">David Sean Taylor</a>
31  * @version $Id: JetspeedGroupManagement.java,v 1.5 2004/02/23 03:58:11 jford Exp $
32  */

33
34 public abstract class JetspeedGroupManagement
35 {
36     public String JavaDoc SERVICE_NAME = "GroupManagement";
37
38     /*
39      * Utility method for accessing the service
40      * implementation
41      *
42      * @return a GroupManagement implementation instance
43      */

44     protected static GroupManagement getService()
45     {
46         return (GroupManagement)TurbineServices
47         .getInstance().getService(GroupManagement.SERVICE_NAME);
48     }
49
50     /**
51      * Retrieves all <code>Group</code>s for a given username principal.
52      *
53      * The security service may optionally check the current user context
54      * to determine if the requestor has permission to perform this action.
55      *
56      * @param username a user principal identity to be retrieved.
57      * @return Iterator over all groups associated to the user principal.
58      * @exception GroupException when the security provider has a general failure.
59      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
60      */

61     public static Iterator JavaDoc getGroups(String JavaDoc username)
62         throws JetspeedSecurityException
63     {
64         return getService().getGroups(username);
65     }
66
67     /**
68      * Retrieves all <code>Group</code>s.
69      *
70      * The security service may optionally check the current user context
71      * to determine if the requestor has permission to perform this action.
72      *
73      * @return Iterator over all groups.
74      * @exception GroupException when the security provider has a general failure.
75      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
76      */

77     public static Iterator JavaDoc getGroups()
78         throws JetspeedSecurityException
79     {
80         return getService().getGroups();
81     }
82
83     /**
84      * Adds a <code>Group</code> into permanent storage.
85      *
86      *
87      * @exception GroupException when the security provider has a general failure.
88      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
89      */

90     public static void addGroup(Group group)
91         throws JetspeedSecurityException
92     {
93         getService().addGroup(group);
94     }
95
96     /**
97      * Saves a <code>Group</code> into permanent storage.
98      *
99      *
100      * @exception GroupException when the security provider has a general failure.
101      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
102      */

103     public static void saveGroup(Group group)
104         throws JetspeedSecurityException
105     {
106         getService().saveGroup(group);
107     }
108
109     /**
110      * Removes a <code>Group</code> from the permanent store.
111      *
112      * The security service may optionally check the current user context
113      * to determine if the requestor has permission to perform this action.
114      *
115      * @param groupname the principal identity of the group to be retrieved.
116      * @exception GroupException when the security provider has a general failure.
117      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
118      */

119     public static void removeGroup(String JavaDoc groupname)
120         throws JetspeedSecurityException
121     {
122         getService().removeGroup(groupname);
123     }
124
125     /**
126      * Join a user to a group.
127      *
128      * The security service may optionally check the current user context
129      * to determine if the requestor has permission to perform this action.
130      *
131      * @exception GroupException when the security provider has a general failure retrieving users.
132      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
133      */

134     public static void joinGroup(String JavaDoc username, String JavaDoc groupname)
135         throws JetspeedSecurityException
136     {
137         getService().joinGroup(username,groupname);
138     }
139
140     /**
141      * Join a user to a group - specific role.
142      *
143      * The security service may optionally check the current user context
144      * to determine if the requestor has permission to perform this action.
145      *
146      * @exception GroupException when the security provider has a general failure retrieving groups.
147      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
148      */

149     public static void joinGroup(String JavaDoc username, String JavaDoc groupname, String JavaDoc rolename)
150         throws JetspeedSecurityException
151     {
152         getService().joinGroup(username,groupname, rolename);
153     }
154
155
156     /**
157      * Unjoin a user from a group.
158      *
159      * The security service may optionally check the current user context
160      * to determine if the requestor has permission to perform this action.
161      *
162      * @exception GroupException when the security provider has a general failure retrieving users.
163      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
164      */

165     public static void unjoinGroup(String JavaDoc username, String JavaDoc groupname)
166         throws JetspeedSecurityException
167     {
168         getService().unjoinGroup(username,groupname);
169     }
170
171     /**
172      * Unjoin a user from a group - specific role.
173      *
174      * The security service may optionally check the current user context
175      * to determine if the requestor has permission to perform this action.
176      *
177      * @exception GroupException when the security provider has a general failure retrieving users.
178      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
179      */

180     public static void unjoinGroup(String JavaDoc username, String JavaDoc groupname, String JavaDoc rolename)
181         throws JetspeedSecurityException
182     {
183         getService().unjoinGroup(username,groupname,rolename);
184     }
185
186
187     /**
188      * Checks for the relationship of user has a group. Returns true when the user has the given group.
189      *
190      * The security service may optionally check the current user context
191      * to determine if the requestor has permission to perform this action.
192      *
193      * @exception GroupException when the security provider has a general failure retrieving users.
194      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
195      */

196     public static boolean inGroup(String JavaDoc username, String JavaDoc groupname)
197         throws JetspeedSecurityException
198     {
199         return getService().inGroup(username,groupname);
200     }
201
202     /**
203      * Retrieves a single <code>Group</code> for a given groupname principal.
204      *
205      * The security service may optionally check the current user context
206      * to determine if the requestor has permission to perform this action.
207      *
208      * @param groupname a group principal identity to be retrieved.
209      * @return Group the group record retrieved.
210      * @exception GroupException when the security provider has a general failure.
211      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
212      */

213     public static Group getGroup(String JavaDoc groupname)
214         throws JetspeedSecurityException
215     {
216         return getService().getGroup(groupname);
217     }
218 }
219
220
221
222
223
224
225
226
227
228
229
230
Popular Tags