1 22 package org.jboss.deployment; 23 24 import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer; 25 import org.jboss.deployers.spi.deployer.DeploymentUnit; 26 import org.jboss.logging.Logger; 27 28 import javax.security.jacc.PolicyConfigurationFactory ; 29 import javax.security.jacc.PolicyConfiguration ; 30 import javax.security.jacc.PolicyContextException ; 31 import java.util.Set ; 32 33 40 public class JaccInitializationDeployer extends AbstractSimpleDeployer 41 { 42 private static final Logger log = Logger.getLogger(JaccInitializationDeployer.class); 43 44 private Set <String > acceptedAttachments; 45 46 public Set <String > getAcceptedAttachments() 47 { 48 return acceptedAttachments; 49 } 50 51 public void setAcceptedAttachments(Set <String > acceptedAttachments) 52 { 53 this.acceptedAttachments = acceptedAttachments; 54 } 55 56 public void deploy(DeploymentUnit unit) throws org.jboss.deployers.spi.DeploymentException 57 { 58 boolean accepted = false; 59 for (String accept : acceptedAttachments) 60 { 61 if (unit.getDeploymentContext().getTransientAttachments().isAttachmentPresent(accept)) 62 { 63 accepted = true; 64 break; 65 } 66 } 67 if (accepted == false) return; 68 69 String contextID = unit.getName(); 70 PolicyConfiguration pc = null; 71 try 72 { 73 PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory(); 74 pc = pcFactory.getPolicyConfiguration(contextID, true); 75 } 76 catch (Exception e) 77 { 78 throw new RuntimeException ("failed to initialize JACC for unit: " + unit.getName(), e); 79 } 80 unit.getAttachment(""); 81 unit.getDeploymentContext().getTransientAttachments().addAttachment("javax.security.jacc.PolicyConfiguration", pc); 82 } 83 84 } 85 | Popular Tags |