User: stark
Date: 01/03/13 12:33:11
Modified: src/main/org/jboss/test/security/ejb
StatelessSessionBean.java
Log:
Add test of isCallerInRole() using a role name that requires a proper
role-link.
Revision Changes Path
1.2 +18 -7
jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean.java
Index: StatelessSessionBean.java
===================================================================
RCS file:
/products/cvs/ejboss/jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StatelessSessionBean.java 2001/03/05 10:10:59 1.1
+++ StatelessSessionBean.java 2001/03/13 20:33:11 1.2
@@ -2,33 +2,40 @@
import java.rmi.RemoteException;
import java.security.Principal;
-import javax.ejb.*;
-
+import javax.ejb.CreateException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+/** A simple session bean for testing declarative security.
+
+@author [EMAIL PROTECTED]
+@version $Revision: 1.2 $
+*/
public class StatelessSessionBean implements SessionBean
{
private SessionContext sessionContext;
- public void ejbCreate() throws RemoteException, CreateException
+ public void ejbCreate() throws CreateException
{
System.out.println("StatelessSessionBean.ejbCreate() called");
}
- public void ejbActivate() throws RemoteException
+ public void ejbActivate()
{
System.out.println("StatelessSessionBean.ejbActivate() called");
}
- public void ejbPassivate() throws RemoteException
+ public void ejbPassivate()
{
System.out.println("StatelessSessionBean.ejbPassivate() called");
}
- public void ejbRemove() throws RemoteException
+ public void ejbRemove()
{
System.out.println("StatelessSessionBean.ejbRemove() called");
}
- public void setSessionContext(SessionContext context) throws RemoteException
+ public void setSessionContext(SessionContext context)
{
sessionContext = context;
}
@@ -38,6 +45,10 @@
System.out.println("StatelessSessionBean.echo, arg="+arg);
Principal p = sessionContext.getCallerPrincipal();
System.out.println("StatelessSessionBean.echo, callerPrincipal="+p);
+ boolean isCaller = sessionContext.isCallerInRole("EchoCaller");
+ System.out.println("StatelessSessionBean.echo,
isCallerInRole('EchoCaller')="+isCaller);
+ if( isCaller == false )
+ throw new SecurityException("Caller does not have EchoCaller role");
return arg;
}
public void noop()