User: starksm Date: 01/07/19 03:20:26 Modified: src/main/org/jboss/test/security/ejb Tag: Branch_2_4 EntityBeanImpl.java RunAsMDB.java Log: Update active subject access test Revision Changes Path No revision No revision 1.2.2.2 +2 -24 jbosstest/src/main/org/jboss/test/security/ejb/EntityBeanImpl.java Index: EntityBeanImpl.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/EntityBeanImpl.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- EntityBeanImpl.java 2001/07/14 17:10:52 1.2.2.1 +++ EntityBeanImpl.java 2001/07/19 10:20:26 1.2.2.2 @@ -17,7 +17,7 @@ using the echo method. @author [EMAIL PROTECTED] -@version $Revision: 1.2.2.1 $ +@version $Revision: 1.2.2.2 $ */ public class EntityBeanImpl implements EntityBean { @@ -73,32 +73,10 @@ if( securityMgr == null ) throw new EJBException("Failed to find security mgr under: java:comp/env/security/security-domain"); System.out.println("Found SecurityManager: "+securityMgr); - /* I'm using this runtime introspection to determin if the security - manager supports a getActiveSubject() method because the - org.jboss.security.SubjectSecurityManager interface is not part of - the standard client jars which are used to build the jbosstest suite. - Not legal EJB code, but this is test code. - */ - Class securityMgrClass = securityMgr.getClass(); - Class[] parameterTypes = {}; - Method getActiveSubject = securityMgrClass.getDeclaredMethod("getActiveSubject", parameterTypes); - Object[] args = {}; - Subject activeSubject = (Subject) getActiveSubject.invoke(securityMgr, args); + Subject activeSubject = (Subject) ctx.lookup("java:comp/env/security/subject"); System.out.println("ActiveSubject: "+activeSubject); if( activeSubject == null ) throw new EJBException("No ActiveSubject found"); - } - catch(NoSuchMethodException e) - { - // Ok, not a SubjectSecurityManager - } - catch(InvocationTargetException e) - { - // Ok, not a SubjectSecurityManager - } - catch(IllegalAccessException e) - { - // Ok, not a SubjectSecurityManager } catch(NamingException e) { 1.1.2.3 +77 -77 jbosstest/src/main/org/jboss/test/security/ejb/RunAsMDB.java Index: RunAsMDB.java =================================================================== RCS file: /cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/RunAsMDB.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- RunAsMDB.java 2001/07/14 17:10:52 1.1.2.2 +++ RunAsMDB.java 2001/07/19 10:20:26 1.1.2.3 @@ -1,77 +1,77 @@ -/* - * jBoss, the OpenSource EJB server - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ -package org.jboss.test.security.ejb; - -import javax.ejb.MessageDrivenBean; -import javax.ejb.MessageDrivenContext; -import javax.ejb.EJBException; -import javax.jms.Destination; -import javax.jms.MessageListener; -import javax.jms.Message; -import javax.naming.InitialContext; -import javax.naming.NamingException; - -import org.jboss.test.security.interfaces.Entity; -import org.jboss.test.security.interfaces.EntityHome; - -/** An MDB that takes the string from the msg passed to onMessage - and invokes the echo(String) method on an internal Entity using - the InternalRole assigned in the MDB descriptor run-as element. - - @author [EMAIL PROTECTED] - @version $Revision: 1.1.2.2 $ - */ -public class RunAsMDB implements MessageDrivenBean, MessageListener -{ - private MessageDrivenContext ctx = null; - private InitialContext iniCtx; - - public RunAsMDB() - { - } - - public void setMessageDrivenContext(MessageDrivenContext ctx) - throws EJBException - { - this.ctx = ctx; - try - { - iniCtx = new InitialContext(); - } - catch(NamingException e) - { - throw new EJBException(e); - } - } - - public void ejbCreate() - { - } - - public void ejbRemove() - { - ctx = null; - } - - public void onMessage(Message message) - { - try - { - String arg = message.getStringProperty("arg"); - EntityHome home = (EntityHome) iniCtx.lookup("java:comp/env/ejb/Entity"); - Entity bean = home.findByPrimaryKey(arg); - String echo = bean.echo(arg); - System.out.println("RunAsMDB echo("+arg+") -> "+echo); - Destination replyTo = message.getJMSReplyTo(); - // Need to send a reply... - } - catch(Exception e) - { - e.printStackTrace(); - } - } -} +/* + * jBoss, the OpenSource EJB server + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.test.security.ejb; + +import javax.ejb.MessageDrivenBean; +import javax.ejb.MessageDrivenContext; +import javax.ejb.EJBException; +import javax.jms.Destination; +import javax.jms.MessageListener; +import javax.jms.Message; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +import org.jboss.test.security.interfaces.Entity; +import org.jboss.test.security.interfaces.EntityHome; + +/** An MDB that takes the string from the msg passed to onMessage + and invokes the echo(String) method on an internal Entity using + the InternalRole assigned in the MDB descriptor run-as element. + + @author [EMAIL PROTECTED] + @version $Revision: 1.1.2.3 $ + */ +public class RunAsMDB implements MessageDrivenBean, MessageListener +{ + private MessageDrivenContext ctx = null; + private InitialContext iniCtx; + + public RunAsMDB() + { + } + + public void setMessageDrivenContext(MessageDrivenContext ctx) + throws EJBException + { + this.ctx = ctx; + try + { + iniCtx = new InitialContext(); + } + catch(NamingException e) + { + throw new EJBException(e); + } + } + + public void ejbCreate() + { + } + + public void ejbRemove() + { + ctx = null; + } + + public void onMessage(Message message) + { + try + { + String arg = message.getStringProperty("arg"); + EntityHome home = (EntityHome) iniCtx.lookup("java:comp/env/ejb/Entity"); + Entity bean = home.findByPrimaryKey(arg); + String echo = bean.echo(arg); + System.out.println("RunAsMDB echo("+arg+") -> "+echo); + Destination replyTo = message.getJMSReplyTo(); + // Need to send a reply... + } + catch(Throwable e) + { + e.printStackTrace(); + } + } +} _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development