1 17 package org.apache.geronimo.security.jacc; 18 19 import java.security.Permission ; 20 import java.security.PermissionCollection ; 21 import java.security.Policy ; 22 import java.util.Enumeration ; 23 import java.util.HashMap ; 24 import java.util.Iterator ; 25 import java.util.Map ; 26 import java.util.Set ; 27 import javax.security.auth.Subject ; 28 import javax.security.jacc.PolicyConfiguration ; 29 import javax.security.jacc.PolicyConfigurationFactory ; 30 import javax.security.jacc.PolicyContextException ; 31 32 import org.apache.geronimo.gbean.GBeanInfo; 33 import org.apache.geronimo.gbean.GBeanInfoBuilder; 34 import org.apache.geronimo.gbean.GBeanLifecycle; 35 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 36 import org.apache.geronimo.security.ContextManager; 37 import org.apache.geronimo.security.IdentificationPrincipal; 38 import org.apache.geronimo.security.SubjectId; 39 40 43 public class ApplicationPrincipalRoleConfigurationManager implements PrincipalRoleMapper { 44 45 private final Map principalRoleMap; 46 47 public ApplicationPrincipalRoleConfigurationManager(Map principalRoleMap) throws PolicyContextException , ClassNotFoundException { 48 this.principalRoleMap = principalRoleMap; 49 } 50 51 52 public void install(Set contextIds) throws PolicyContextException { 53 GeronimoPolicyConfigurationFactory roleMapperFactory = GeronimoPolicyConfigurationFactory.getSingleton(); 54 if (roleMapperFactory == null) { 55 throw new IllegalStateException ("Inconsistent security setup. GeronimoPolicyConfigurationFactory is not being used"); 56 } 57 58 for (Iterator iterator = contextIds.iterator(); iterator.hasNext();) { 59 String contextID = (String ) iterator.next(); 60 61 GeronimoPolicyConfiguration geronimoPolicyConfiguration = roleMapperFactory.getGeronimoPolicyConfiguration(contextID); 62 geronimoPolicyConfiguration.setPrincipalRoleMapping(principalRoleMap); 63 } 64 65 } 66 67 68 public void uninstall() throws PolicyContextException { 69 } 70 71 72 public static final GBeanInfo GBEAN_INFO; 73 74 static { 75 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(ApplicationPrincipalRoleConfigurationManager.class, NameFactory.JACC_MANAGER); 76 infoBuilder.addAttribute("principalRoleMap", Map .class, true); 77 infoBuilder.addInterface(PrincipalRoleMapper.class); 78 infoBuilder.setConstructor(new String [] {"principalRoleMap"}); 79 GBEAN_INFO = infoBuilder.getBeanInfo(); 80 } 81 82 public GBeanInfo getGBeanInfo() { 83 return GBEAN_INFO; 84 } 85 } 86 | Popular Tags |