1 22 package org.jboss.test.security.ejb; 23 24 import java.security.Principal ; 25 import javax.ejb.CreateException ; 26 import javax.ejb.SessionBean ; 27 import javax.ejb.SessionContext ; 28 29 import org.jboss.logging.Logger; 30 31 37 public class CalleeBean implements SessionBean 38 { 39 private static Logger log = Logger.getLogger(CalleeBean.class); 40 private SessionContext sessionContext; 41 42 public void ejbCreate() throws CreateException 43 { 44 log.debug("ejbCreate() called"); 45 } 46 47 public void ejbActivate() 48 { 49 log.debug("ejbActivate() called"); 50 } 51 52 public void ejbPassivate() 53 { 54 log.debug("ejbPassivate() called"); 55 } 56 57 public void ejbRemove() 58 { 59 log.debug("ejbRemove() called"); 60 } 61 62 public void setSessionContext(SessionContext context) 63 { 64 sessionContext = context; 65 } 66 67 public String echo(String arg) 68 { 69 log.debug("echo, arg="+arg); 70 Principal p = sessionContext.getCallerPrincipal(); 71 log.debug("echo, callerPrincipal="+p); 72 boolean isCaller = sessionContext.isCallerInRole("EchoCaller"); 73 log.debug("echo, isCallerInRole('EchoCaller')="+isCaller); 74 isCaller = sessionContext.isCallerInRole("InternalRole"); 75 log.debug("echo, isCallerInRole('InternalRole')="+isCaller); 76 return arg; 77 } 78 79 public void noop() 80 { 81 log.debug("noop"); 82 } 83 } 84 | Popular Tags |