/** * Return my mapping of rolename to users and groups on a particular * server. */ public SecurityRoleMapper getRoleMapper() { if (this.roleMapper == null) { SecurityRoleMapperFactory factory = habitat.getComponent(SecurityRoleMapperFactory.class); if (factory == null) { _logger.log(Level.FINE, "SecurityRoleMapperFactory NOT set."); } else { this.roleMapper = factory.getRoleMapper(this.getName()); } } return this.roleMapper; }
private String getRoleName(Principal callerPrincipal) { String roleName = null; WebBundleDescriptor wbd = (WebBundleDescriptor) getComponentEnvManager().getCurrentJndiNameEnvironment(); SecurityRoleMapperFactory securityRoleMapperFactory = getSecurityRoleMapperFactory(); SecurityRoleMapper securityRoleMapper = securityRoleMapperFactory.getRoleMapper(wbd.getModuleID()); Map<String, Subject> map = securityRoleMapper.getRoleToSubjectMapping(); for (Map.Entry<String, Subject> entry : map.entrySet()) { roleName = entry.getKey(); Subject subject = entry.getValue(); Set principalSet = subject.getPrincipals(); if (principalSet.contains(callerPrincipal)) { return roleName; } } return ""; }
private SecurityRoleMapper getRoleMapper(){ Habitat habitat = Globals.getDefaultHabitat(); SecurityRoleMapper srm = null; if(habitat != null){ SecurityRoleMapperFactory srmf = habitat.getComponent(SecurityRoleMapperFactory.class); if(srmf != null){ srm = srmf.getRoleMapper(descriptor.getModuleDescriptor().getModuleName()); } } return srm; } public void addDescriptor(Object newDescriptor) {
SecurityRoleMapper srm = factory.getRoleMapper(CONTEXT_ID); if (srm != null) { roleToSubjectMap = srm.getRoleToSubjectMapping(); String contextId = (String)it.next(); if (!CONTEXT_ID.equals(contextId)) { SecurityRoleMapper otherSrm = factory.getRoleMapper(contextId); Map otherRoleToSubjectMap = null;