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.turbine.services.Service;
22import org.apache.jetspeed.om.security.Role;
2324/***25 * <p> The <code>RoleManagement</code> interface describes contract between26 * the portal and security provider required for Jetspeed Role Management.27 * This interface enables an application to be independent of the underlying28 * role management technology.29 *30 * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>31 * @author <a href="mailto:morciuch@apache.org">Mark Orciuch</a>32 * @version $Id: RoleManagement.java,v 1.4 2004/02/23 03:58:11 jford Exp $33 */3435publicinterfaceRoleManagementextends Service
36 {
37public String SERVICE_NAME = "RoleManagement";
3839public String DEFAULT_ROLE_NAME = "user";
4041/***42 * Retrieves all <code>Role</code>s for a given username principal.43 *44 * The security service may optionally check the current user context45 * to determine if the requestor has permission to perform this action.46 *47 * @param username a user principal identity to be retrieved.48 * @return Iterator over all roles associated to the user principal.49 * @exception RoleException when the security provider has a general failure.50 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege51 */52 Iterator getRoles(String username)
53 throws JetspeedSecurityException;
5455/***56 * Retrieves all <code>Role</code>s.57 *58 * The security service may optionally check the current user context59 * to determine if the requestor has permission to perform this action.60 *61 * @return Iterator over all roles.62 * @exception RoleException when the security provider has a general failure.63 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege64 */65 Iterator getRoles()
66 throws JetspeedSecurityException;
6768/***69 * Adds a <code>Role</code> into permanent storage.70 *71 * The security service may optionally check the current user context72 * to determine if the requestor has permission to perform this action.73 *74 * @exception RoleException when the security provider has a general failure.75 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege76 */77void addRole(Role role)
78 throws JetspeedSecurityException;
7980/***81 * Saves a <code>Role</code> into permanent storage.82 *83 * The security service may optionally check the current user context84 * to determine if the requestor has permission to perform this action.85 *86 * @exception RoleException when the security provider has a general failure.87 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege88 */89void saveRole(Role role)
90 throws JetspeedSecurityException;
9192/***93 * Removes a <code>Role</code> from the permanent store.94 *95 * The security service may optionally check the current user context96 * to determine if the requestor has permission to perform this action.97 *98 * @param rolename the principal identity of the role to be retrieved.99 * @exception RoleException when the security provider has a general failure.100 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege101 */102void removeRole(String rolename)
103 throws JetspeedSecurityException;
104105/***106 * Grants a role to a user.107 *108 * The security service may optionally check the current user context109 * to determine if the requestor has permission to perform this action.110 *111 * @exception RoleException when the security provider has a general failure retrieving roles.112 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege113 */114void grantRole(String username, String rolename)
115 throws JetspeedSecurityException;
116117void grantRole(String username, String rolename, String groupName)
118 throws JetspeedSecurityException;
119120/***121 * Revokes a role from a user.122 *123 * The security service may optionally check the current user context124 * to determine if the requestor has permission to perform this action.125 *126 * @exception RoleException when the security provider has a general failure retrieving roles.127 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege128 */129void revokeRole(String username, String rolename)
130 throws JetspeedSecurityException;
131132void revokeRole(String username, String rolename, String groupname)
133 throws JetspeedSecurityException;
134135/***136 * Checks for the relationship of user has a role. Returns true when the user has the given role.137 *138 * The security service may optionally check the current user context139 * to determine if the requestor has permission to perform this action.140 *141 * @exception RoleException when the security provider has a general failure retrieving roles.142 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege143 */144boolean hasRole(String username, String rolename)
145 throws JetspeedSecurityException;
146147boolean hasRole(String username, String rolename, String groupname)
148 throws JetspeedSecurityException;
149150/***151 * Retrieves a single <code>Role</code> for a given rolename principal.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 a role principal identity to be retrieved.157 * @return Role the role record retrieved.158 * @exception RoleException when the security provider has a general failure.159 * @exception InsufficientPrivilegeException when the requestor is denied due to insufficient privilege160 */161Role getRole(String rolename)
162 throws JetspeedSecurityException;
163164 }
165166167168169170171172173