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  
22  // Jetspeed Security
23  import org.apache.jetspeed.services.security.PermissionManagement;
24  
25  import org.apache.jetspeed.om.security.Permission;
26  
27  import org.apache.jetspeed.om.security.BaseJetspeedPermission;
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>NoPermissionManagement</code> class is a Jetspeed
37   * security provider, implementing the <code>PermissionManagement</code> interface.
38   * It provides no permission management - no roles have permissions, no permissions are
39   * saved, and requests for any permission is satisfied with a temp. Permission object.
40   *
41   * @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>
42   * @version $Id: NoPermissionManagement.java,v 1.3 2004/02/23 03:53:24 jford Exp $
43   */
44  public class NoPermissionManagement
45      extends TurbineBaseService
46     implements PermissionManagement
47  {
48     /***
49       * Retrieves all <code>Permission</code>s for a given rolename 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 rolename a role name identity to be retrieved.
55       * @return Iterator over all permissions associated to the role principal.
56       * @exception PermissionException when the security provider has a general failure.
57       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
58       */
59      public Iterator getPermissions(String rolename)
60          throws JetspeedSecurityException
61      {
62          return new Vector().iterator();
63      }
64  
65      /***
66       * Retrieves all <code>Permission</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 permissions.
72       * @exception PermissionException when the security provider has a general failure.
73       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
74       */
75      public Iterator getPermissions()
76          throws JetspeedSecurityException
77      {
78          return new Vector().iterator();
79      }
80  
81      /***
82       * Adds a <code>Permission</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 PermissionException when the security provider has a general failure.
88       * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
89       */
90      public void addPermission(Permission permission)
91          throws JetspeedSecurityException
92      {
93      }
94  
95      /***
96       * Saves a <code>Permission</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 PermissionException when the security provider has a general failure.
102      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
103      */
104     public void savePermission(Permission permission)
105         throws JetspeedSecurityException
106     {
107     }
108 
109     /***
110      * Removes a <code>Permission</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 permissionName the principal identity of the permission to be retrieved.
116      * @exception PermissionException when the security provider has a general failure.
117      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
118      */
119     public void removePermission(String permissionName)
120         throws JetspeedSecurityException
121     {
122     }
123 
124     /***
125      * Grants a permission to a role. 
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      * @param roleName grant a permission to this role.
131      * @param permissionName the permission to grant to the role.
132      * @exception PermissionException when the security provider has a general failure retrieving permissions.
133      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
134      */
135     public void grantPermission(String roleName, String permissionName)
136         throws JetspeedSecurityException
137     {
138     }
139 
140     /***
141      * Revokes a permission from a 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      * @param roleName grant a permission to this role.
147      * @param permissionName the permission to grant to the role.     
148      * @exception PermissionException when the security provider has a general failure retrieving permissions.
149      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
150      */
151     public void revokePermission(String roleName, String permissionName)
152         throws JetspeedSecurityException
153     {
154     }
155 
156     /***
157      * Checks for the relationship of role has a permission. Returns true when the role has the given permission.
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      * @param roleName grant a permission to this role.
163      * @param permissionName the permission to grant to the role.    
164      * @exception PermissionException when the security provider has a general failure retrieving permissions.
165      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
166      */
167     public boolean hasPermission(String roleName, String permissionName)
168         throws JetspeedSecurityException
169     {
170         return false;
171     }
172 
173     /***
174      * Retrieves a single <code>Permission</code> for a given permissionName principal.
175      *   
176      * The security service may optionally check the current user context
177      * to determine if the requestor has permission to perform this action.
178      *
179      * @param permissionName a permission principal identity to be retrieved.
180      * @return Permission the permission record retrieved.
181      * @exception PermissionException when the security provider has a general failure.
182      * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 
183      */
184     public Permission getPermission(String permissionName)
185         throws JetspeedSecurityException
186     {
187         BaseJetspeedPermission r = new BaseJetspeedPermission();
188         //r.setNew(false);
189         r.setName(permissionName);
190         r.setId(permissionName);
191         return r;
192     }
193 }
194