1 22 package org.jboss.aspects.security; 23 24 import org.jboss.aop.Advisor; 25 import org.jboss.aop.InstanceAdvisor; 26 import org.jboss.aop.advice.AspectFactory; 27 import org.jboss.aop.joinpoint.Joinpoint; 28 import org.jboss.security.AuthenticationManager; 29 30 import javax.naming.InitialContext ; 31 import javax.naming.NamingException ; 32 33 39 public class AuthenticationInterceptorFactory implements AspectFactory 40 { 41 public Object createPerVM() 42 { 43 throw new RuntimeException ("PER_VM not supported for this interceptor factory, only PER_CLASS"); 44 } 45 46 public Object createPerClass(Advisor advisor) 47 { 48 AuthenticationManager manager = (AuthenticationManager) advisor.getDefaultMetaData().getMetaData("security", "authentication-manager"); 49 if (manager == null) 50 { 51 SecurityDomain domain = (SecurityDomain) advisor.resolveAnnotation(SecurityDomain.class); 52 if (domain == null) throw new RuntimeException ("Unable to determine security domain"); 53 try 54 { 55 manager = (AuthenticationManager) new InitialContext ().lookup("java:/jaas/" + domain.value()); 56 } 57 catch (NamingException e) 58 { 59 throw new RuntimeException (e); } 61 } 62 if (manager == null) throw new RuntimeException ("Unable to find Security Domain"); 63 return new AuthenticationInterceptor(manager); 64 } 65 66 public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor) 67 { 68 throw new RuntimeException ("PER_VM not supported for this interceptor factory, only PER_CLASS"); 69 } 70 71 public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) 72 { 73 throw new RuntimeException ("PER_VM not supported for this interceptor factory, only PER_CLASS"); 74 } 75 76 public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp) 77 { 78 throw new RuntimeException ("PER_VM not supported for this interceptor factory, only PER_CLASS"); 79 } 80 81 public String getName() 82 { 83 return getClass().getName(); 84 } 85 } 86 | Popular Tags |