View Javadoc

1   package org.apache.turbine.om.security;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.Serializable;
23  
24  import org.apache.turbine.util.security.PermissionSet;
25  import org.apache.turbine.util.security.TurbineSecurityException;
26  
27  /***
28   * This class represents a role played by the User associated with the
29   * current Session.
30   *
31   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
32   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
33   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
34   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
35   * @version $Id: Role.java 534527 2007-05-02 16:10:59Z tv $
36   */
37  public interface Role extends SecurityEntity, Serializable
38  {
39      /***
40       * Returns the set of Permissions associated with this Role.
41       *
42       * @return A PermissionSet.
43       * @exception Exception A generic exception.
44       */
45      PermissionSet getPermissions()
46          throws Exception;
47  
48      /***
49       * Sets the Permissions associated with this Role.
50       *
51       * @param permissionSet A PermissionSet.
52       */
53      void setPermissions(PermissionSet permissionSet);
54  
55      // These following methods are wrappers around TurbineSecurity
56  
57      /***
58       * Creates a new Role in the system.
59       *
60       * @param name The name of the new Role.
61       * @return An object representing the new Role.
62       * @throws TurbineSecurityException if the Role could not be created.
63       */
64      Role create(String name)
65          throws TurbineSecurityException;
66  
67      /***
68       * Makes changes made to the Role attributes permanent.
69       *
70       * @throws TurbineSecurityException if there is a problem while
71       *  saving data.
72       */
73      void save()
74          throws TurbineSecurityException;
75  
76      /***
77       * Removes a role from the system.
78       *
79       * @throws TurbineSecurityException if the Role could not be removed.
80       */
81      void remove()
82          throws TurbineSecurityException;
83  
84      /***
85       * Renames the role.
86       *
87       * @param name The new Role name.
88       * @throws TurbineSecurityException if the Role could not be renamed.
89       */
90      void rename(String name)
91          throws TurbineSecurityException;
92  
93      /***
94       * Grants a Permission to this Role.
95       *
96       * @param permission A Permission.
97       * @throws TurbineSecurityException if there is a problem while assigning
98       * the Permission.
99       */
100     void grant(Permission permission)
101         throws TurbineSecurityException;
102 
103     /***
104      * Grants Permissions from a PermissionSet to this Role.
105      *
106      * @param permissionSet A PermissionSet.
107      * @throws TurbineSecurityException if there is a problem while assigning
108      * the Permissions.
109      */
110     void grant(PermissionSet permissionSet)
111         throws TurbineSecurityException;
112 
113     /***
114      * Revokes a Permission from this Role.
115      *
116      * @param permission A Permission.
117      * @throws TurbineSecurityException if there is a problem while unassigning
118      * the Permission.
119      */
120     void revoke(Permission permission)
121         throws TurbineSecurityException;
122 
123     /***
124      * Revokes Permissions from a PermissionSet from this Role.
125      *
126      * @param permissionSet A PermissionSet.
127      * @throws TurbineSecurityException if there is a problem while unassigning
128      * the Permissions.
129      */
130     void revoke(PermissionSet permissionSet)
131         throws TurbineSecurityException;
132 }