1 22 package org.jboss.test.security.ejb; 23 24 import java.security.Principal ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.EJBException ; 27 import javax.ejb.SessionBean ; 28 import javax.ejb.SessionContext ; 29 30 import org.jboss.logging.Logger; 31 32 37 public class UncheckedSessionBean implements SessionBean 38 { 39 Logger log = Logger.getLogger(getClass()); 40 41 private SessionContext sessionContext; 42 43 public void ejbCreate() throws CreateException 44 { 45 log.debug("ejbCreate() called"); 46 } 47 48 public void ejbActivate() 49 { 50 log.debug("ejbActivate() called"); 51 } 52 53 public void ejbPassivate() 54 { 55 log.debug("ejbPassivate() called"); 56 } 57 58 public void ejbRemove() 59 { 60 log.debug("ejbRemove() called"); 61 } 62 63 public void setSessionContext(SessionContext context) 64 { 65 sessionContext = context; 66 } 67 68 public String echo(String arg) 69 { 70 log.debug("echo, arg=" + arg); 71 Principal p = sessionContext.getCallerPrincipal(); 72 log.debug("echo, callerPrincipal=" + p); 73 boolean isCaller = sessionContext.isCallerInRole("EchoCaller"); 74 log.debug("echo, isCallerInRole('EchoCaller')=" + isCaller); 75 return arg; 76 } 77 78 public String forward(String echoArg) 79 { 80 log.debug("forward, echoArg=" + echoArg); 81 return echo(echoArg); 82 } 83 84 public void noop() 85 { 86 log.debug("noop"); 87 } 88 89 public void npeError() 90 { 91 log.debug("npeError"); 92 Object obj = null; 93 obj.toString(); 94 } 95 96 public void unchecked() 97 { 98 Principal p = sessionContext.getCallerPrincipal(); 99 log.debug("unchecked, callerPrincipal=" + p); 100 } 101 102 public void excluded() 103 { 104 throw new EJBException ("excluded, no access should be allowed"); 105 } 106 107 } 108 | Popular Tags |