View Javadoc

1   /*
2    * Copyright 2000-2001,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.nosecurity;
18  
19  import java.util.Iterator;
20  import java.util.Vector;
21  import java.util.HashMap;
22  
23  // Jetspeed Security
24  import org.apache.jetspeed.services.security.GroupManagement;
25  
26  import org.apache.jetspeed.om.security.Group;
27  import org.apache.jetspeed.om.security.BaseJetspeedGroup;
28  
29  // Jetspeed Security Exceptions
30  import org.apache.jetspeed.services.security.JetspeedSecurityException;
31  
32  // Turbine
33  import org.apache.turbine.services.TurbineBaseService;
34  
35  /***
36   * <p> The <code>NoGroupManagement</code> class is a Jetspeed
37   * security provider, implementing the <code>GroupManagement</code> interface.
38   * It provides no group management - no groups are listed, no groups are saved,
39   * no users are in any groups, any request for a group is satisfied with a temporary Group object.
40   *
41   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
42   * @version $Id: NoGroupManagement.java,v 1.3 2004/02/23 03:53:24 jford Exp $
43   */
44  public class NoGroupManagement
45      extends TurbineBaseService
46      implements GroupManagement
47  {
48      /***
49       * Retrieves all <code>Group</code>s for a given username principal.
50       *
51       * The security service may optionally check the current user context
52       * to determine if the requestor has permission to perform this action.
53       *
54       * @param username a user principal identity to be retrieved.
55       * @return Iterator over all groups associated to the user principal.
56       * @exception GroupException when the security provider has a general failure.
57       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
58       */
59      public Iterator getGroups(String username)
60          throws JetspeedSecurityException
61      {
62          return new Vector().iterator();
63      }
64  
65      /***
66       * Retrieves all <code>Group</code>s.
67       *
68       * The security service may optionally check the current user context
69       * to determine if the requestor has permission to perform this action.
70       *
71       * @return Iterator over all groups.
72       * @exception GroupException when the security provider has a general failure.
73       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
74       */
75      public Iterator getGroups()
76          throws JetspeedSecurityException
77      {
78          return new Vector().iterator();
79      }
80  
81      /***
82       * Adds a <code>Group</code> into permanent storage.
83       *
84       * The security service may optionally check the current user context
85       * to determine if the requestor has permission to perform this action.
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 void addGroup(Group group)
91          throws JetspeedSecurityException
92      {
93      }
94  
95      /***
96       * Saves a <code>Group</code> into permanent storage.
97       *
98       * The security service may optionally check the current user context
99       * to determine if the requestor has permission to perform this action.
100      *
101      * @exception GroupException when the security provider has a general failure.
102      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
103      */
104     public void saveGroup(Group group)
105         throws JetspeedSecurityException
106     {
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 void removeGroup(String groupname)
120         throws JetspeedSecurityException
121     {
122     }
123 
124     /***
125      * Joins a user to a group.
126      *
127      * The security service may optionally check the current user context
128      * to determine if the requestor has permission to perform this action.
129      *
130      * @exception GroupException when the security provider has a general failure retrieving groups.
131      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
132      */
133     public void joinGroup(String username, String groupname)
134         throws JetspeedSecurityException
135     {
136     }
137 
138     /***
139      * Join a user to a group - specific role.
140      *
141      * The security service may optionally check the current user context
142      * to determine if the requestor has permission to perform this action.
143      *
144      * @exception GroupException when the security provider has a general failure retrieving groups.
145      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
146      */
147     public void joinGroup(String username, String groupname, String rolename)
148         throws JetspeedSecurityException
149     {
150     }
151 
152     /***
153      * Unjoins a user from a group.
154      *
155      * The security service may optionally check the current user context
156      * to determine if the requestor has permission to perform this action.
157      *
158      * @exception GroupException when the security provider has a general failure retrieving groups.
159      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
160      */
161     public void unjoinGroup(String username, String groupname)
162         throws JetspeedSecurityException
163     {
164     }
165 
166     /***
167      * Unjoin a user from a group in which the user has a specific role instead of <Code>JetspeedSecurity.getRole(defaultRole)</Code>
168      *
169      * The security service may optionally check the current user context
170      * to determine if the requestor has permission to perform this action.
171      *
172      * @exception GroupException when the security provider has a general failure retrieving groups.
173      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
174      */
175 
176     public void unjoinGroup(String username, String groupname, String rolename)
177         throws JetspeedSecurityException
178     {
179     }
180 
181 
182     /***
183      * Checks for the relationship of user in a group. Returns true when the user is in the given group.
184      *
185      * The security service may optionally check the current user context
186      * to determine if the requestor has permission to perform this action.
187      *
188      * @exception GroupException when the security provider has a general failure retrieving groups.
189      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
190      */
191     public boolean inGroup(String username, String groupname)
192         throws JetspeedSecurityException
193     {
194         return false;
195     }
196 
197     /***
198      * Retrieves a single <code>Group</code> for a given groupname principal.
199      *
200      * The security service may optionally check the current user context
201      * to determine if the requestor has permission to perform this action.
202      *
203      * @param groupname a group principal identity to be retrieved.
204      * @return Group the group record retrieved.
205      * @exception GroupException when the security provider has a general failure.
206      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege
207      */
208     public Group getGroup(String groupname)
209         throws JetspeedSecurityException
210     {
211         BaseJetspeedGroup r = new BaseJetspeedGroup();
212         //r.setNew(false);
213         r.setName(groupname);
214         r.setId(groupname);
215         return r;
216     }
217 
218     /***
219      * Retrieves a hashtable which associates Groups with Roles for a given username principal.
220      *
221      * The security service may optionally check the current user context
222      * to determine if the requestor has permission to perform this action.
223      *
224      * @param username a user principal identity to be retrieved.
225      * @return Hashtable record retrieved.
226      * @exception GroupException when the security provider has a general failure.
227      */
228     public HashMap getTurbineGroupRole(String username)
229         throws JetspeedSecurityException
230     {
231       HashMap h = new HashMap();
232       return h;
233     }
234 }
235