1 19 package gcc.security; 20 21 import gcc.properties.*; 22 import java.util.*; 23 24 public class Role 25 { 26 public static Role getInstance(String rolename) 27 { 28 Role role = (Role)_roleMap.get(rolename); 29 if (role == null) 30 { 31 synchronized (_roleMap) 32 { 33 role = (Role)_roleMap.get(rolename); 34 if (role == null) 35 { 36 role = new Role(); 37 role.init(rolename); 38 _roleMap.put(rolename, role); 39 } 40 } 41 } 42 return role; 43 } 44 45 public static Role getExistingInstance(String rolename) 46 { 47 return (Role)_roleMap.get(rolename); 48 } 49 50 52 public static final StringProperty assignedRolesProperty = 53 new StringProperty(Role.class, "assignedRoles") 54 .displayName("Assigned Roles") 55 .consoleHelp("Names of roles which have been explicitly assigned to this role.") 56 .list() 57 .sortOrder(1); 58 59 public static final StringProperty excludedRolesProperty = 60 new StringProperty(Role.class, "excludedRoles") 61 .displayName("Excluded Roles") 62 .consoleHelp("Names of roles which must be excluded from this role.") 63 .list() 64 .sortOrder(2); 65 66 public static final StringProperty excludedUsersProperty = 67 new StringProperty(Role.class, "excludedUsers") 68 .displayName("Excluded Users") 69 .consoleHelp("Names of users who must be excluded from this role.") 70 .list() 71 .sortOrder(3); 72 73 public static final StringProperty inheritedRolesProperty = 74 new StringProperty(Role.class, "inheritedRoles") 75 .displayName("Inherited Roles") 76 .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.") 77 .list() 78 .readOnly() 79 .sortOrder(4); 80 81 public static final StringProperty roleMembersProperty = 82 new StringProperty(Role.class, "roleMembers") 83 .displayName("Role Members") 84 .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") 85 .list() 86 .readOnly() 87 .sortOrder(5); 88 89 91 public static final String CLIENT = "[client]"; 92 93 public static final String SYSTEM = "[system]"; 94 95 97 private static HashMap _roleMap = new HashMap(); 98 99 private String _name; 100 101 103 protected void init(String rolename) 104 { 105 _name = rolename; 106 } 107 108 110 public String getName() 111 { 112 return _name; 113 } 114 115 public String toString() 116 { 117 return super.toString() + ":" + _name; 118 } 119 } 120 | Popular Tags |