This project has retired. For details please refer to its Attic page.
Role xref
View Javadoc

1   package org.apache.archiva.redback.rbac;
2   
3   /*
4    * Copyright 2001-2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.util.List;
20  
21  /**
22   * Role
23   * <p/>
24   * A role is assignable to a user and effectively grants that user all of the
25   * permissions that are present in that role.  A role can also contain other roles
26   * which add the permissions in those roles to the available permissions for authorization.
27   * <p/>
28   * A role can contain any number of permissions
29   * A role can contain any number of other roles
30   * A role can be assigned to any number of users
31   *
32   * @author Jesse McConnell <jmcconnell@apache.org>
33   * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
34   *
35   */
36  public interface Role
37  {
38  
39      /**
40       * Method addPermission
41       *
42       * @param permission
43       */
44      void addPermission( Permission permission );
45  
46      /**
47       * Method addChildRoleName
48       *
49       * @param name the name of the child role.
50       */
51      void addChildRoleName( String name );
52  
53      /**
54       * Method getChildRoleNames
55       */
56      List<String> getChildRoleNames();
57  
58      /**
59       * Convienence method to see if Role has Child Roles.
60       *
61       * @return true if child roles exists and has any roles being tracked.
62       */
63      boolean hasChildRoles();
64  
65      /**
66       * Long description of the role.
67       */
68      String getDescription();
69  
70      /**
71       * Get the name.
72       * <p/>
73       * NOTE: This field is considered the Primary Key for this object.
74       */
75      String getName();
76  
77      /**
78       * Method getPermissions
79       */
80      List<Permission> getPermissions();
81  
82      /**
83       * true if this role is available to be assigned to a user
84       */
85      boolean isAssignable();
86  
87      /**
88       * Method removePermission
89       *
90       * @param permission
91       */
92      void removePermission( Permission permission );
93  
94      /**
95       * true if this role is available to be assigned to a user
96       *
97       * @param assignable
98       */
99      void setAssignable( boolean assignable );
100 
101     /**
102      * The names of the roles that will inherit the permissions of this role
103      *
104      * @param names the list of names of other roles.
105      */
106     void setChildRoleNames( List<String> names );
107 
108     /**
109      * Set the Description
110      *
111      * @param description
112      */
113     void setDescription( String description );
114 
115     /**
116      * Set Name
117      * <p/>
118      * NOTE: This field is considered the Primary Key for this object.
119      *
120      * @param name
121      */
122     void setName( String name );
123 
124     /**
125      * Set Permissions
126      *
127      * @param permissions
128      */
129     void setPermissions( List<Permission> permissions );
130 
131     /**
132      * Test to see if the object is a permanent object or not.
133      *
134      * @return true if the object is permanent.
135      */
136     boolean isPermanent();
137 
138     /**
139      * Set flag indicating if the object is a permanent object or not.
140      *
141      * @param permanent true if the object is permanent.
142      */
143     void setPermanent( boolean permanent );
144 }