1 22 package org.jboss.ejb3.test.stateless; 23 24 import javax.annotation.Resource; 25 import javax.annotation.security.RunAs; 26 import javax.ejb.SessionContext ; 27 import javax.ejb.Stateless ; 28 import javax.annotation.security.PermitAll; 29 import javax.ejb.Local ; 30 import javax.ejb.Remote ; 31 import javax.naming.InitialContext ; 32 import javax.naming.NamingException ; 33 import org.jboss.annotation.security.SecurityDomain; 34 import org.jboss.logging.Logger; 35 36 40 @Stateless (name="RunAsStatelessEjbName") 41 @RunAs("allowed") 42 @SecurityDomain("other") 43 @Remote ({RunAsStateless.class, RunAsStateless2.class}) 44 @Local (RunAsStatelessLocal.class) 45 public class RunAsStatelessBean implements RunAsStateless, RunAsStateless2 46 { 47 private static final Logger log = Logger.getLogger(RunAsStatelessBean.class); 48 49 @Resource 50 SessionContext sessionContext; 51 52 @PermitAll 53 public int method(int i) throws NamingException 54 { 55 InitialContext jndiContext = new InitialContext (); 56 57 CheckedStateless tester = 58 (CheckedStateless) jndiContext.lookup("CheckedStatelessBean/remote"); 59 60 return tester.method(i); 61 } 62 63 @PermitAll 64 public int method2(int i) throws NamingException 65 { 66 return i; 67 } 68 69 @PermitAll 70 public String getCallerPrincipal() 71 { 72 return sessionContext.getCallerPrincipal().getName(); 73 } 74 75 @PermitAll 76 public String getCheckedCallerPrincipal() throws NamingException 77 { 78 InitialContext jndiContext = new InitialContext (); 79 80 CheckedStateless tester = 81 (CheckedStateless) jndiContext.lookup("CheckedStatelessBean/remote"); 82 83 return tester.getCallerPrincipal(); 84 } 85 } 86 | Popular Tags |