User: starksm
Date: 01/05/21 20:21:00
Modified: src/main/org/jboss/test/security/ejb
StatelessSessionBean.java
StatelessSessionBean2.java
Log:
Add test of principal propagation from unsecure bean to secure bean
Revision Changes Path
1.3 +6 -1
jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean.java
Index: StatelessSessionBean.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StatelessSessionBean.java 2001/03/13 20:33:11 1.2
+++ StatelessSessionBean.java 2001/05/22 03:21:00 1.3
@@ -9,7 +9,7 @@
/** A simple session bean for testing declarative security.
@author [EMAIL PROTECTED]
-@version $Revision: 1.2 $
+@version $Revision: 1.3 $
*/
public class StatelessSessionBean implements SessionBean
{
@@ -51,6 +51,11 @@
throw new SecurityException("Caller does not have EchoCaller role");
return arg;
}
+ public String forward(String echoArg)
+ {
+ return echo(echoArg);
+ }
+
public void noop()
{
System.out.println("StatelessSessionBean.noop");
1.2 +32 -5
jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean2.java
Index: StatelessSessionBean2.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean2.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StatelessSessionBean2.java 2001/03/05 10:11:00 1.1
+++ StatelessSessionBean2.java 2001/05/22 03:21:00 1.2
@@ -2,17 +2,22 @@
import java.rmi.RemoteException;
import java.security.Principal;
-import javax.ejb.*;
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
import javax.naming.InitialContext;
import org.jboss.test.security.interfaces.Entity;
import org.jboss.test.security.interfaces.EntityHome;
+import org.jboss.test.security.interfaces.StatelessSession;
+import org.jboss.test.security.interfaces.StatelessSessionHome;
/** A SessionBean that access the Entity bean to test Principal
identity propagation.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
+@version $Revision: 1.2 $
*/
public class StatelessSessionBean2 implements SessionBean
{
@@ -53,13 +58,35 @@
try
{
InitialContext ctx = new InitialContext();
- EntityHome home = (EntityHome) ctx.lookup("java:comp/env/Entity");
- Entity entity = home.findByPrimaryKey(arg);
- echo = entity.echo(arg);
+ EntityHome home = (EntityHome) ctx.lookup("java:comp/env/ejb/Entity");
+ Entity bean = home.findByPrimaryKey(arg);
+ echo = bean.echo(arg);
}
catch(Exception e)
{
e.printStackTrace();
+ e.fillInStackTrace();
+ throw new EJBException(e);
+ }
+ return echo;
+ }
+
+ public String forward(String echoArg)
+ {
+ System.out.println("StatelessSessionBean2.forward, echoArg="+echoArg);
+ String echo = null;
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ StatelessSessionHome home = (StatelessSessionHome)
ctx.lookup("java:comp/env/ejb/Session");
+ StatelessSession bean = home.create();
+ echo = bean.echo(echoArg);
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ e.fillInStackTrace();
+ throw new EJBException(e);
}
return echo;
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development