View Javadoc

1   package org.apache.turbine.om.security;
2   
3   /* ====================================================================
4    * The Apache Software License, Version 1.1
5    *
6    * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
7    * reserved.
8    *
9    * Redistribution and use in source and binary forms, with or without
10   * modification, are permitted provided that the following conditions
11   * are met:
12   *
13   * 1. Redistributions of source code must retain the above copyright
14   *    notice, this list of conditions and the following disclaimer.
15   *
16   * 2. Redistributions in binary form must reproduce the above copyright
17   *    notice, this list of conditions and the following disclaimer in
18   *    the documentation and/or other materials provided with the
19   *    distribution.
20   *
21   * 3. The end-user documentation included with the redistribution,
22   *    if any, must include the following acknowledgment:
23   *       "This product includes software developed by the
24   *        Apache Software Foundation (http://www.apache.org/)."
25   *    Alternately, this acknowledgment may appear in the software itself,
26   *    if and wherever such third-party acknowledgments normally appear.
27   *
28   * 4. The names "Apache" and "Apache Software Foundation" and
29   *    "Apache Turbine" must not be used to endorse or promote products
30   *    derived from this software without prior written permission. For
31   *    written permission, please contact apache@apache.org.
32   *
33   * 5. Products derived from this software may not be called "Apache",
34   *    "Apache Turbine", nor may "Apache" appear in their name, without
35   *    prior written permission of the Apache Software Foundation.
36   *
37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48   * SUCH DAMAGE.
49   * ====================================================================
50   *
51   * This software consists of voluntary contributions made by many
52   * individuals on behalf of the Apache Software Foundation.  For more
53   * information on the Apache Software Foundation, please see
54   * <http://www.apache.org/>.
55   */
56  
57  import org.apache.turbine.util.security.PermissionSet;
58  import org.apache.turbine.util.security.TurbineSecurityException;
59  
60  /***
61   * This class represents a role played by the User associated with the
62   * current Session.
63   *
64   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
65   * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
66   * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
67   * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
68   * @version $Id: Role.java,v 1.4 2003/03/09 02:45:15 quintonm Exp $
69   */
70  public interface Role extends SecurityEntity
71  {
72      /***
73       * Returns the set of Permissions associated with this Role.
74       *
75       * @return A PermissionSet.
76       * @exception Exception A generic exception.
77       */
78      PermissionSet getPermissions()
79          throws Exception;
80  
81      /***
82       * Sets the Permissions associated with this Role.
83       *
84       * @param permissionSet A PermissionSet.
85       */
86      void setPermissions(PermissionSet permissionSet);
87  
88      // These following methods are wrappers around TurbineSecurity
89  
90      /***
91       * Creates a new Role in the system.
92       *
93       * @param name The name of the new Role.
94       * @return An object representing the new Role.
95       * @throws TurbineSecurityException if the Role could not be created.
96       */
97      Role create(String name)
98          throws TurbineSecurityException;
99  
100     /***
101      * Makes changes made to the Role attributes permanent.
102      *
103      * @throws TurbineSecurityException if there is a problem while
104      *  saving data.
105      */
106     void save()
107         throws TurbineSecurityException;
108 
109     /***
110      * Removes a role from the system.
111      *
112      * @throws TurbineSecurityException if the Role could not be removed.
113      */
114     void remove()
115         throws TurbineSecurityException;
116 
117     /***
118      * Renames the role.
119      *
120      * @param name The new Role name.
121      * @throws TurbineSecurityException if the Role could not be renamed.
122      */
123     void rename(String name)
124         throws TurbineSecurityException;
125 
126     /***
127      * Grants a Permission to this Role.
128      *
129      * @param permission A Permission.
130      * @throws TurbineSecurityException if there is a problem while assigning
131      * the Permission.
132      */
133     void grant(Permission permission)
134         throws TurbineSecurityException;
135 
136     /***
137      * Grants Permissions from a PermissionSet to this Role.
138      *
139      * @param permissionSet A PermissionSet.
140      * @throws TurbineSecurityException if there is a problem while assigning
141      * the Permissions.
142      */
143     void grant(PermissionSet permissionSet)
144         throws TurbineSecurityException;
145 
146     /***
147      * Revokes a Permission from this Role.
148      *
149      * @param permission A Permission.
150      * @throws TurbineSecurityException if there is a problem while unassigning
151      * the Permission.
152      */
153     void revoke(Permission permission)
154         throws TurbineSecurityException;
155 
156     /***
157      * Revokes Permissions from a PermissionSet from this Role.
158      *
159      * @param permissionSet A PermissionSet.
160      * @throws TurbineSecurityException if there is a problem while unassigning
161      * the Permissions.
162      */
163     void revoke(PermissionSet permissionSet)
164         throws TurbineSecurityException;
165 }