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 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;
202122// Turbine23import org.apache.turbine.services.TurbineServices;
242526import org.apache.jetspeed.om.security.Permission;
2728/***29 * <p> The <code>PermissionManagement</code> interface describes contract between 30 * the portal and security provider required for Jetspeed Permission Management.31 * This interface enables an application to be independent of the underlying 32 * permission management technology.33 *34 * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>35 * @version $Id: JetspeedPermissionManagement.java,v 1.4 2004/02/23 03:58:11 jford Exp $36 */3738publicabstractclassJetspeedPermissionManagement39 {
40public String SERVICE_NAME = "PermissionManagement";
4142/*43 * Utility method for accessing the service44 * implementation45 *46 * @return a PermissionManagement implementation instance47 */48protectedstaticPermissionManagement getService()
49 {
50return (PermissionManagement)TurbineServices
51 .getInstance().getService(PermissionManagement.SERVICE_NAME);
52 }
5354/***55 * Retrieves all <code>Permission</code>s for a given rolename principal.56 * 57 * The security service may optionally check the current user context58 * to determine if the requestor has permission to perform this action.59 *60 * @param rolename a role name identity to be retrieved.61 * @return Iterator over all permissions associated to the role principal.62 * @exception PermissionException when the security provider has a general failure.63 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 64 */65publicstatic Iterator getPermissions(String rolename)
66 throws JetspeedSecurityException67 {
68return getService().getPermissions(rolename);
69 }
7071/***72 * Retrieves all <code>Permission</code>s.73 * 74 * The security service may optionally check the current user context75 * to determine if the requestor has permission to perform this action.76 *77 * @return Iterator over all permissions.78 * @exception PermissionException when the security provider has a general failure.79 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 80 */81publicstatic Iterator getPermissions()
82 throws JetspeedSecurityException83 {
84return getService().getPermissions();
85 }
8687/***88 * Adds a <code>Permission</code> into permanent storage. 89 *90 * The security service may optionally check the current user context91 * to determine if the requestor has permission to perform this action.92 *93 * @exception PermissionException when the security provider has a general failure.94 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 95 */96publicstaticvoid addPermission(Permission permission)
97 throws JetspeedSecurityException98 {
99 getService().addPermission(permission);
100 }
101102/***103 * Saves a <code>Permission</code> into permanent storage. 104 *105 * The security service may optionally check the current user context106 * to determine if the requestor has permission to perform this action.107 *108 * @exception PermissionException when the security provider has a general failure.109 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 110 */111publicstaticvoid savePermission(Permission permission)
112 throws JetspeedSecurityException113 {
114 getService().savePermission(permission);
115 }
116117/***118 * Removes a <code>Permission</code> from the permanent store.119 *120 * The security service may optionally check the current user context121 * to determine if the requestor has permission to perform this action.122 *123 * @param permissionName the principal identity of the permission to be retrieved.124 * @exception PermissionException when the security provider has a general failure.125 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 126 */127publicstaticvoid removePermission(String permissionName)
128 throws JetspeedSecurityException129 {
130 getService().removePermission(permissionName);
131 }
132133/***134 * Grants a permission to a role. 135 *136 * The security service may optionally check the current user context137 * to determine if the requestor has permission to perform this action.138 *139 * @param roleName grant a permission to this role.140 * @param permissionName the permission to grant to the role.141 * @exception PermissionException when the security provider has a general failure retrieving permissions.142 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 143 */144publicstaticvoid grantPermission(String roleName, String permissionName)
145 throws JetspeedSecurityException146 {
147 getService().grantPermission(roleName, permissionName);
148 }
149150/***151 * Revokes a permission from a role. 152 *153 * The security service may optionally check the current user context154 * to determine if the requestor has permission to perform this action.155 *156 * @param roleName grant a permission to this role.157 * @param permissionName the permission to grant to the role. 158 * @exception PermissionException when the security provider has a general failure retrieving permissions.159 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 160 */161publicstaticvoid revokePermission(String roleName, String permissionName)
162 throws JetspeedSecurityException163 {
164 getService().revokePermission(roleName,permissionName);
165 }
166167/***168 * Checks for the relationship of role has a permission. Returns true when the role has the given permission.169 *170 * The security service may optionally check the current user context171 * to determine if the requestor has permission to perform this action.172 *173 * @param roleName grant a permission to this role.174 * @param permissionName the permission to grant to the role. 175 * @exception PermissionException when the security provider has a general failure retrieving permissions.176 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 177 */178publicstaticboolean hasPermission(String roleName, String permissionName)
179 throws JetspeedSecurityException180 {
181return getService().hasPermission(roleName,permissionName);
182 }
183184/***185 * Retrieves a single <code>Permission</code> for a given permissionName principal.186 * 187 * The security service may optionally check the current user context188 * to determine if the requestor has permission to perform this action.189 *190 * @param permissionName a permission principal identity to be retrieved.191 * @return Permission the permission record retrieved.192 * @exception PermissionException when the security provider has a general failure.193 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege 194 */195publicstaticPermission getPermission(String permissionName)
196 throws JetspeedSecurityException197 {
198return getService().getPermission(permissionName);
199 }
200201 }
202203204205206207208209210211212