1 22 package org.jboss.ejb3.test.security; 23 24 import java.security.Principal ; 25 26 import javax.annotation.Resource; 27 import javax.ejb.CreateException ; 28 import javax.ejb.EJBException ; 29 import javax.ejb.Remote ; 30 import javax.ejb.SessionBean ; 31 import javax.ejb.SessionContext ; 32 import javax.ejb.Stateless ; 33 34 import org.jboss.logging.Logger; 35 import org.jboss.annotation.ejb.RemoteBinding; 36 import org.jboss.annotation.security.SecurityDomain; 37 import javax.annotation.security.PermitAll; 38 import javax.annotation.security.RolesAllowed; 39 40 45 @Stateless (name="UncheckedSessionRemoteLast") 46 @Remote (org.jboss.ejb3.test.security.StatelessSession.class) 47 @RemoteBinding(jndiBinding = "spec.UncheckedSessionRemoteLast") 48 @SecurityDomain("spec-test") 49 @PermitAll 50 public class UncheckedSessionBeanLast 51 { 52 Logger log = Logger.getLogger(getClass()); 53 54 @Resource SessionContext sessionContext; 55 56 @RolesAllowed({"Echo"}) 57 public String echo(String arg) 58 { 59 log.debug("echo, arg=" + arg); 60 Principal p = sessionContext.getCallerPrincipal(); 61 log.debug("echo, callerPrincipal=" + p); 62 boolean isCaller = sessionContext.isCallerInRole("EchoCaller"); 63 log.debug("echo, isCallerInRole('EchoCaller')=" + isCaller); 64 return arg; 65 } 66 67 public String forward(String echoArg) 68 { 69 log.debug("forward, echoArg=" + echoArg); 70 return echo(echoArg); 71 } 72 73 public void noop() 74 { 75 log.debug("noop"); 76 } 77 78 public void npeError() 79 { 80 log.debug("npeError"); 81 Object obj = null; 82 obj.toString(); 83 } 84 85 public void unchecked() 86 { 87 Principal p = sessionContext.getCallerPrincipal(); 88 log.debug("unchecked, callerPrincipal=" + p); 89 } 90 91 @RolesAllowed({"InternalRole"}) 92 public void excluded() 93 { 94 throw new EJBException ("excluded, no access should be allowed"); 95 } 96 97 } 98 | Popular Tags |