private Set<Principal> getPrincipalsInRole(SecurityRoleMapper srm, String roleName) throws SecurityException, UnsupportedOperationException { Map<String, Subject> roleMap = (Map) srm.getRoleToSubjectMapping(); if (roleMap == null) { return null; } Subject s = roleMap.get(roleName); if (s == null) { return null; } return s.getPrincipals(); }
/** * Reset the display name of this application. * * @param name the display name of the application. */ public void setName(String name) { name = name.replace('/', '-'); name = name.replace('\\', '-'); // for deploying from NT to solaris & vice versa. This will // need to be cleaned when we clean up the backend for registering apps super.setName(name); if (this.getRoleMapper() != null) { this.getRoleMapper().setName(name); } }
@Override public void addDescriptor(Object newDescriptor) { if (newDescriptor instanceof SecurityRoleMapping) { SecurityRoleMapping roleMap = (SecurityRoleMapping)newDescriptor; descriptor.addSecurityRoleMapping(roleMap); Application app = descriptor.getApplication(); if (app!=null) { Role role = new Role(roleMap.getRoleName()); SecurityRoleMapper rm = app.getRoleMapper(); if (rm != null) { List<PrincipalNameDescriptor> principals = roleMap.getPrincipalNames(); for (int i = 0; i < principals.size(); i++) { rm.assignRole(principals.get(i).getPrincipal(), role, descriptor); } List<String> groups = roleMap.getGroupNames(); for (int i = 0; i < groups.size(); i++) { rm.assignRole(new Group(groups.get(i)), role, descriptor); } } } } }
Enumeration grps = rmap.getGroupsAssignedTo(r); while (grps.hasMoreElements()) { sb.append(grps.nextElement()); Enumeration users = rmap.getUsersAssignedTo(r); while (users.hasMoreElements()) { sb.append(users.nextElement());
/** * Adds a new DOL descriptor instance to the descriptor instance associated with * this XMLNode * * @param newDescriptor the new descriptor */ public void addDescriptor(Object newDescriptor) { if (newDescriptor instanceof SecurityRoleMapping) { SecurityRoleMapping roleMap = (SecurityRoleMapping) newDescriptor; if (descriptor!=null && !descriptor.isVirtual()) { descriptor.addSecurityRoleMapping(roleMap); Role role = new Role(roleMap.getRoleName()); SecurityRoleMapper rm = descriptor.getRoleMapper(); if (rm != null) { List<PrincipalNameDescriptor> principals = roleMap.getPrincipalNames(); for (int i = 0; i < principals.size(); i++) { rm.assignRole(principals.get(i).getPrincipal(), role, descriptor); } List<String> groups = roleMap.getGroupNames(); for (int i = 0; i < groups.size(); i++) { rm.assignRole(new Group(groups.get(i)), role, descriptor); } } } } }
String roleName = runAs.getRoleName(); final Subject fs = (Subject)application.getRoleMapper().getRoleToSubjectMapping().get(roleName); if (fs != null) { principalName = (String)AccessController.doPrivileged(new PrivilegedAction() {
/** * Sets the registration name for this application. This name is used * while deploying the application. The deployment process gurantees * that this name is unique. * * @param appId the registration name used for this application */ public void setRegistrationName(String appId) { // at his point we need to swap our RoleMapper, if we have one... SecurityRoleMapper roleMapper = null; try { roleMapper = getRoleMapper(); } catch (IllegalArgumentException ignore) { } if (roleMapper != null) { if (securityRoleMapperFactory == null) { throw new IllegalArgumentException(localStrings.getLocalString( "enterprise.deployment.norolemapperfactorydefine", "This application has no role mapper factory defined")); } securityRoleMapperFactory.removeRoleMapper(getName()); roleMapper.setName(appId); securityRoleMapperFactory.setRoleMapper(appId, roleMapper); } this.registrationName = appId; }
roleToSubjectMap = srm.getRoleToSubjectMapping(); otherRoleToSubjectMap = otherSrm.getRoleToSubjectMapping();