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 at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services.security;
1819import java.util.Iterator;
2021import org.apache.jetspeed.om.security.Group;
22import org.apache.turbine.services.TurbineServices;
2324/***25 * <p> The <code>GroupManagement</code> interface describes contract between26 * the portal and security provider required for Jetspeed Group Management.27 * This interface enables an application to be independent of the underlying28 * 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 */3334publicabstractclassJetspeedGroupManagement35 {
36public String SERVICE_NAME = "GroupManagement";
3738/*39 * Utility method for accessing the service40 * implementation41 *42 * @return a GroupManagement implementation instance43 */44protectedstaticGroupManagement getService()
45 {
46return (GroupManagement)TurbineServices
47 .getInstance().getService(GroupManagement.SERVICE_NAME);
48 }
4950/***51 * Retrieves all <code>Group</code>s for a given username principal.52 *53 * The security service may optionally check the current user context54 * 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 privilege60 */61publicstatic Iterator getGroups(String username)
62 throws JetspeedSecurityException63 {
64return getService().getGroups(username);
65 }
6667/***68 * Retrieves all <code>Group</code>s.69 *70 * The security service may optionally check the current user context71 * 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 privilege76 */77publicstatic Iterator getGroups()
78 throws JetspeedSecurityException79 {
80return getService().getGroups();
81 }
8283/***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 privilege89 */90publicstaticvoid addGroup(Group group)
91 throws JetspeedSecurityException92 {
93 getService().addGroup(group);
94 }
9596/***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 privilege102 */103publicstaticvoid saveGroup(Group group)
104 throws JetspeedSecurityException105 {
106 getService().saveGroup(group);
107 }
108109/***110 * Removes a <code>Group</code> from the permanent store.111 *112 * The security service may optionally check the current user context113 * 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 privilege118 */119publicstaticvoid removeGroup(String groupname)
120 throws JetspeedSecurityException121 {
122 getService().removeGroup(groupname);
123 }
124125/***126 * Join a user to a group.127 *128 * The security service may optionally check the current user context129 * 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 privilege133 */134publicstaticvoid joinGroup(String username, String groupname)
135 throws JetspeedSecurityException136 {
137 getService().joinGroup(username,groupname);
138 }
139140/***141 * Join a user to a group - specific role.142 *143 * The security service may optionally check the current user context144 * 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 privilege148 */149publicstaticvoid joinGroup(String username, String groupname, String rolename)
150 throws JetspeedSecurityException151 {
152 getService().joinGroup(username,groupname, rolename);
153 }
154155156/***157 * Unjoin a user from a group.158 *159 * The security service may optionally check the current user context160 * 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 privilege164 */165publicstaticvoid unjoinGroup(String username, String groupname)
166 throws JetspeedSecurityException167 {
168 getService().unjoinGroup(username,groupname);
169 }
170171/***172 * Unjoin a user from a group - specific role.173 *174 * The security service may optionally check the current user context175 * 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 privilege179 */180publicstaticvoid unjoinGroup(String username, String groupname, String rolename)
181 throws JetspeedSecurityException182 {
183 getService().unjoinGroup(username,groupname,rolename);
184 }
185186187/***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 context191 * 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 privilege195 */196publicstaticboolean inGroup(String username, String groupname)
197 throws JetspeedSecurityException198 {
199return getService().inGroup(username,groupname);
200 }
201202/***203 * Retrieves a single <code>Group</code> for a given groupname principal.204 *205 * The security service may optionally check the current user context206 * 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 privilege212 */213publicstaticGroup getGroup(String groupname)
214 throws JetspeedSecurityException215 {
216return getService().getGroup(groupname);
217 }
218 }
219220221222223224225226227228229