KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > interop > security > Role


1 /**
2  *
3  * Copyright 2004-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.geronimo.interop.security;
19
20 import java.util.HashMap JavaDoc;
21
22 import org.apache.geronimo.interop.properties.StringProperty;
23
24
25 public class Role {
26     public static Role getInstance(String JavaDoc rolename) {
27         Role role = (Role) _roleMap.get(rolename);
28         if (role == null) {
29             synchronized (_roleMap) {
30                 role = (Role) _roleMap.get(rolename);
31                 if (role == null) {
32                     role = new Role();
33                     role.init(rolename);
34                     _roleMap.put(rolename, role);
35                 }
36             }
37         }
38         return role;
39     }
40
41     public static Role getExistingInstance(String JavaDoc rolename) {
42         return (Role) _roleMap.get(rolename);
43     }
44
45     // properties
46

47     public static final StringProperty assignedRolesProperty =
48             new StringProperty(Role.class, "assignedRoles")
49             .displayName("Assigned Roles")
50             .consoleHelp("Names of roles which have been explicitly assigned to this role.")
51             .list()
52             .sortOrder(1);
53
54     public static final StringProperty excludedRolesProperty =
55             new StringProperty(Role.class, "excludedRoles")
56             .displayName("Excluded Roles")
57             .consoleHelp("Names of roles which must be excluded from this role.")
58             .list()
59             .sortOrder(2);
60
61     public static final StringProperty excludedUsersProperty =
62             new StringProperty(Role.class, "excludedUsers")
63             .displayName("Excluded Users")
64             .consoleHelp("Names of users who must be excluded from this role.")
65             .list()
66             .sortOrder(3);
67
68     public static final StringProperty inheritedRolesProperty =
69             new StringProperty(Role.class, "inheritedRoles")
70             .displayName("Inherited Roles")
71             .consoleHelp("Names of roles which have been inherited from this role's assigned roles. This list is read only. It is derived from the assigned roles.")
72             .list()
73             .readOnly()
74             .sortOrder(4);
75
76     public static final StringProperty roleMembersProperty =
77             new StringProperty(Role.class, "roleMembers")
78             .displayName("Role Members")
79             .consoleHelp("Names of users who have been assigned this role, or who have inherited it from an assigned role. This list is read only. To add a user to a role, please edit the user's properties")
80             .list()
81             .readOnly()
82             .sortOrder(5);
83
84     // public constants
85

86     public static final String JavaDoc CLIENT = "[client]";
87
88     public static final String JavaDoc SYSTEM = "[system]";
89
90     // private data
91

92     private static HashMap JavaDoc _roleMap = new HashMap JavaDoc();
93
94     private String JavaDoc _name;
95
96     // internal methods
97

98     protected void init(String JavaDoc rolename) {
99         _name = rolename;
100     }
101
102     // public methods
103

104     public String JavaDoc getName() {
105         return _name;
106     }
107
108     public String JavaDoc toString() {
109         return super.toString() + ":" + _name;
110     }
111 }
112
Popular Tags