User: user57
Date: 02/02/14 22:15:56
Modified: src/main/org/jboss/test/security/ejb EntityBeanImpl.java
IOStatefulSessionBean.java
IOStatelessSessionBean.java RunAsMDB.java
StatelessSessionBean.java
StatelessSessionBean2.java
StatelessSessionBean3.java
Log:
o replaced most System.out usage with Log4j. should really introduce
some base classes to make this mess more maintainable...
Revision Changes Path
1.6 +15 -13
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EntityBeanImpl.java 26 Jul 2001 02:55:35 -0000 1.5
+++ EntityBeanImpl.java 15 Feb 2002 06:15:55 -0000 1.6
@@ -17,35 +17,37 @@
using the echo method.
@author [EMAIL PROTECTED]
-@version $Revision: 1.5 $
+@version $Revision: 1.6 $
*/
public class EntityBeanImpl implements EntityBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private String key;
private EntityContext context;
public void ejbActivate()
{
- System.out.println("EntityBean.ejbActivate() called");
+ log.debug("EntityBean.ejbActivate() called");
}
public void ejbPassivate()
{
- System.out.println("EntityBean.ejbPassivate() called");
+ log.debug("EntityBean.ejbPassivate() called");
}
public void ejbRemove()
{
- System.out.println("EntityBean.ejbRemove() called");
+ log.debug("EntityBean.ejbRemove() called");
}
public void ejbLoad()
{
- System.out.println("EntityBean.ejbLoad() called");
+ log.debug("EntityBean.ejbLoad() called");
key = (String) context.getPrimaryKey();
}
public void ejbStore()
{
- System.out.println("EntityBean.ejbStore() called");
+ log.debug("EntityBean.ejbStore() called");
}
public void setEntityContext(EntityContext context)
@@ -59,22 +61,22 @@
public String echo(String arg)
{
- System.out.println("EntityBean.echo, arg="+arg);
+ log.debug("EntityBean.echo, arg="+arg);
Principal p = context.getCallerPrincipal();
boolean isInternalRole = context.isCallerInRole("InternalRole");
- System.out.println("EntityBean.echo, callerPrincipal="+p);
- System.out.println("EntityBean.echo,
isCallerInRole('InternalRole')="+isInternalRole);
+ log.debug("EntityBean.echo, callerPrincipal="+p);
+ log.debug("EntityBean.echo,
isCallerInRole('InternalRole')="+isInternalRole);
// Check the java:comp/env/security/security-domain
try
{
InitialContext ctx = new InitialContext();
Object securityMgr =
ctx.lookup("java:comp/env/security/security-domain");
- System.out.println("Checking java:comp/env/security/security-domain");
+ log.debug("Checking java:comp/env/security/security-domain");
if( securityMgr == null )
throw new EJBException("Failed to find security mgr under:
java:comp/env/security/security-domain");
- System.out.println("Found SecurityManager: "+securityMgr);
+ log.debug("Found SecurityManager: "+securityMgr);
Subject activeSubject = (Subject)
ctx.lookup("java:comp/env/security/subject");
- System.out.println("ActiveSubject: "+activeSubject);
+ log.debug("ActiveSubject: "+activeSubject);
if( activeSubject == null )
throw new EJBException("No ActiveSubject found");
}
@@ -88,7 +90,7 @@
public String ejbFindByPrimaryKey(String key)
{
- System.out.println("EntityBean.ejbFindByPrimaryKey, key="+key);
+ log.debug("EntityBean.ejbFindByPrimaryKey, key="+key);
return key;
}
}
1.2 +11 -9
jbosstest/src/main/org/jboss/test/security/ejb/IOStatefulSessionBean.java
Index: IOStatefulSessionBean.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/IOStatefulSessionBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IOStatefulSessionBean.java 13 Jun 2001 04:55:50 -0000 1.1
+++ IOStatefulSessionBean.java 15 Feb 2002 06:15:55 -0000 1.2
@@ -10,30 +10,32 @@
/** A simple session bean for testing custom security.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
+@version $Revision: 1.2 $
*/
public class IOStatefulSessionBean implements SessionBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private SessionContext sessionContext;
public void ejbCreate() throws CreateException
{
- System.out.println("IOStatefulSessionBean.ejbCreate() called");
+ log.debug("IOStatefulSessionBean.ejbCreate() called");
}
public void ejbActivate()
{
- System.out.println("IOStatefulSessionBean.ejbActivate() called");
+ log.debug("IOStatefulSessionBean.ejbActivate() called");
}
public void ejbPassivate()
{
- System.out.println("IOStatefulSessionBean.ejbPassivate() called");
+ log.debug("IOStatefulSessionBean.ejbPassivate() called");
}
public void ejbRemove()
{
- System.out.println("IOStatefulSessionBean.ejbRemove() called");
+ log.debug("IOStatefulSessionBean.ejbRemove() called");
}
public void setSessionContext(SessionContext context)
@@ -43,16 +45,16 @@
public String read(String path) throws IOException
{
- System.out.println("IOStatefulSessionBean.read, path="+path);
+ log.debug("IOStatefulSessionBean.read, path="+path);
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("IOStatefulSessionBean.read, callerPrincipal="+p);
+ log.debug("IOStatefulSessionBean.read, callerPrincipal="+p);
return path;
}
public void write(String path) throws IOException
{
- System.out.println("IOStatefulSessionBean.write, path="+path);
+ log.debug("IOStatefulSessionBean.write, path="+path);
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("IOStatefulSessionBean.write, callerPrincipal="+p);
+ log.debug("IOStatefulSessionBean.write, callerPrincipal="+p);
}
}
1.2 +11 -9
jbosstest/src/main/org/jboss/test/security/ejb/IOStatelessSessionBean.java
Index: IOStatelessSessionBean.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/IOStatelessSessionBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- IOStatelessSessionBean.java 13 Jun 2001 04:55:50 -0000 1.1
+++ IOStatelessSessionBean.java 15 Feb 2002 06:15:55 -0000 1.2
@@ -10,30 +10,32 @@
/** A simple session bean for testing custom security.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
+@version $Revision: 1.2 $
*/
public class IOStatelessSessionBean implements SessionBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private SessionContext sessionContext;
public void ejbCreate() throws CreateException
{
- System.out.println("IOStatelessSessionBean.ejbCreate() called");
+ log.debug("IOStatelessSessionBean.ejbCreate() called");
}
public void ejbActivate()
{
- System.out.println("IOStatelessSessionBean.ejbActivate() called");
+ log.debug("IOStatelessSessionBean.ejbActivate() called");
}
public void ejbPassivate()
{
- System.out.println("IOStatelessSessionBean.ejbPassivate() called");
+ log.debug("IOStatelessSessionBean.ejbPassivate() called");
}
public void ejbRemove()
{
- System.out.println("IOStatelessSessionBean.ejbRemove() called");
+ log.debug("IOStatelessSessionBean.ejbRemove() called");
}
public void setSessionContext(SessionContext context)
@@ -43,16 +45,16 @@
public String read(String path) throws IOException
{
- System.out.println("IOStatelessSessionBean.read, path="+path);
+ log.debug("IOStatelessSessionBean.read, path="+path);
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("IOStatelessSessionBean.read, callerPrincipal="+p);
+ log.debug("IOStatelessSessionBean.read, callerPrincipal="+p);
return path;
}
public void write(String path) throws IOException
{
- System.out.println("IOStatelessSessionBean.write, path="+path);
+ log.debug("IOStatelessSessionBean.write, path="+path);
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("IOStatelessSessionBean.write, callerPrincipal="+p);
+ log.debug("IOStatelessSessionBean.write, callerPrincipal="+p);
}
}
1.4 +4 -2 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RunAsMDB.java 26 Jul 2001 02:55:35 -0000 1.3
+++ RunAsMDB.java 15 Feb 2002 06:15:55 -0000 1.4
@@ -23,10 +23,12 @@
the InternalRole assigned in the MDB descriptor run-as element.
@author [EMAIL PROTECTED]
- @version $Revision: 1.3 $
+ @version $Revision: 1.4 $
*/
public class RunAsMDB implements MessageDrivenBean, MessageListener
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private MessageDrivenContext ctx = null;
private InitialContext iniCtx;
@@ -65,7 +67,7 @@
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);
+ log.debug("RunAsMDB echo("+arg+") -> "+echo);
Destination replyTo = message.getJMSReplyTo();
// Need to send a reply...
}
1.6 +14 -12
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StatelessSessionBean.java 12 Jun 2001 07:58:40 -0000 1.5
+++ StatelessSessionBean.java 15 Feb 2002 06:15:55 -0000 1.6
@@ -10,30 +10,32 @@
/** A simple session bean for testing declarative security.
@author [EMAIL PROTECTED]
-@version $Revision: 1.5 $
+@version $Revision: 1.6 $
*/
public class StatelessSessionBean implements SessionBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private SessionContext sessionContext;
public void ejbCreate() throws CreateException
{
- System.out.println("StatelessSessionBean.ejbCreate() called");
+ log.debug("StatelessSessionBean.ejbCreate() called");
}
public void ejbActivate()
{
- System.out.println("StatelessSessionBean.ejbActivate() called");
+ log.debug("StatelessSessionBean.ejbActivate() called");
}
public void ejbPassivate()
{
- System.out.println("StatelessSessionBean.ejbPassivate() called");
+ log.debug("StatelessSessionBean.ejbPassivate() called");
}
public void ejbRemove()
{
- System.out.println("StatelessSessionBean.ejbRemove() called");
+ log.debug("StatelessSessionBean.ejbRemove() called");
}
public void setSessionContext(SessionContext context)
@@ -43,28 +45,28 @@
public String echo(String arg)
{
- System.out.println("StatelessSessionBean.echo, arg="+arg);
+ log.debug("StatelessSessionBean.echo, arg="+arg);
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean.echo, callerPrincipal="+p);
+ log.debug("StatelessSessionBean.echo, callerPrincipal="+p);
boolean isCaller = sessionContext.isCallerInRole("EchoCaller");
- System.out.println("StatelessSessionBean.echo,
isCallerInRole('EchoCaller')="+isCaller);
+ log.debug("StatelessSessionBean.echo,
isCallerInRole('EchoCaller')="+isCaller);
if( isCaller == false )
throw new SecurityException("Caller does not have EchoCaller role");
return arg;
}
public String forward(String echoArg)
{
- System.out.println("StatelessSessionBean.forward, echoArg="+echoArg);
+ log.debug("StatelessSessionBean.forward, echoArg="+echoArg);
return echo(echoArg);
}
public void noop()
{
- System.out.println("StatelessSessionBean.noop");
+ log.debug("StatelessSessionBean.noop");
}
public void npeError()
{
- System.out.println("StatelessSessionBean.npeError");
+ log.debug("StatelessSessionBean.npeError");
Object obj = null;
obj.toString();
}
@@ -72,7 +74,7 @@
public void unchecked()
{
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean.unchecked, callerPrincipal="+p);
+ log.debug("StatelessSessionBean.unchecked, callerPrincipal="+p);
}
public void excluded()
1.4 +13 -11
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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StatelessSessionBean2.java 12 Jun 2001 07:58:40 -0000 1.3
+++ StatelessSessionBean2.java 15 Feb 2002 06:15:55 -0000 1.4
@@ -17,30 +17,32 @@
identity propagation.
@author [EMAIL PROTECTED]
-@version $Revision: 1.3 $
+@version $Revision: 1.4 $
*/
public class StatelessSessionBean2 implements SessionBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private SessionContext sessionContext;
public void ejbCreate() throws RemoteException, CreateException
{
- System.out.println("StatelessSessionBean2.ejbCreate() called");
+ log.debug("StatelessSessionBean2.ejbCreate() called");
}
public void ejbActivate() throws RemoteException
{
- System.out.println("StatelessSessionBean2.ejbActivate() called");
+ log.debug("StatelessSessionBean2.ejbActivate() called");
}
public void ejbPassivate() throws RemoteException
{
- System.out.println("StatelessSessionBean2.ejbPassivate() called");
+ log.debug("StatelessSessionBean2.ejbPassivate() called");
}
public void ejbRemove() throws RemoteException
{
- System.out.println("StatelessSessionBean2.ejbRemove() called");
+ log.debug("StatelessSessionBean2.ejbRemove() called");
}
public void setSessionContext(SessionContext context) throws RemoteException
@@ -50,10 +52,10 @@
public String echo(String arg)
{
- System.out.println("StatelessSessionBean2.echo, arg="+arg);
+ log.debug("StatelessSessionBean2.echo, arg="+arg);
// This call should fail if the bean is not secured
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean2.echo, callerPrincipal="+p);
+ log.debug("StatelessSessionBean2.echo, callerPrincipal="+p);
String echo = null;
try
{
@@ -73,7 +75,7 @@
public String forward(String echoArg)
{
- System.out.println("StatelessSessionBean2.forward, echoArg="+echoArg);
+ log.debug("StatelessSessionBean2.forward, echoArg="+echoArg);
String echo = null;
try
{
@@ -93,19 +95,19 @@
public void noop()
{
- System.out.println("StatelessSessionBean2.noop");
+ log.debug("StatelessSessionBean2.noop");
}
public void npeError()
{
- System.out.println("StatelessSessionBean2.npeError");
+ log.debug("StatelessSessionBean2.npeError");
Object obj = null;
obj.toString();
}
public void unchecked()
{
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean.unchecked, callerPrincipal="+p);
+ log.debug("StatelessSessionBean.unchecked, callerPrincipal="+p);
}
public void excluded()
1.2 +15 -13
jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean3.java
Index: StatelessSessionBean3.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/security/ejb/StatelessSessionBean3.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StatelessSessionBean3.java 15 Jun 2001 08:48:25 -0000 1.1
+++ StatelessSessionBean3.java 15 Feb 2002 06:15:55 -0000 1.2
@@ -19,30 +19,32 @@
remote interface.
@author [EMAIL PROTECTED]
-@version $Revision: 1.1 $
+@version $Revision: 1.2 $
*/
public class StatelessSessionBean3 implements SessionBean
{
+ org.apache.log4j.Category log =
org.apache.log4j.Category.getInstance(getClass());
+
private SessionContext sessionContext;
public void ejbCreate() throws RemoteException, CreateException
{
- System.out.println("StatelessSessionBean3.ejbCreate() called");
+ log.debug("StatelessSessionBean3.ejbCreate() called");
}
public void ejbActivate() throws RemoteException
{
- System.out.println("StatelessSessionBean3.ejbActivate() called");
+ log.debug("StatelessSessionBean3.ejbActivate() called");
}
public void ejbPassivate() throws RemoteException
{
- System.out.println("StatelessSessionBean3.ejbPassivate() called");
+ log.debug("StatelessSessionBean3.ejbPassivate() called");
}
public void ejbRemove() throws RemoteException
{
- System.out.println("StatelessSessionBean3.ejbRemove() called");
+ log.debug("StatelessSessionBean3.ejbRemove() called");
}
public void setSessionContext(SessionContext context) throws RemoteException
@@ -57,10 +59,10 @@
*/
public String echo(String arg)
{
- System.out.println("StatelessSessionBean3.echo, arg="+arg);
+ log.debug("StatelessSessionBean3.echo, arg="+arg);
// This call should fail if the bean is not secured
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean3.echo, callerPrincipal="+p);
+ log.debug("StatelessSessionBean3.echo, callerPrincipal="+p);
String echo = null;
try
{
@@ -80,7 +82,7 @@
public String forward(String echoArg)
{
- System.out.println("StatelessSessionBean3.forward, echoArg="+echoArg);
+ log.debug("StatelessSessionBean3.forward, echoArg="+echoArg);
String echo = null;
try
{
@@ -104,7 +106,7 @@
*/
public void noop()
{
- System.out.println("StatelessSessionBean3.noop calling excluded...");
+ log.debug("StatelessSessionBean3.noop calling excluded...");
StatelessSession myEJB = (StatelessSession) sessionContext.getEJBObject();
try
{
@@ -118,14 +120,14 @@
public void npeError()
{
- System.out.println("StatelessSessionBean3.npeError");
+ log.debug("StatelessSessionBean3.npeError");
Object obj = null;
obj.toString();
}
public void unchecked()
{
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean.unchecked, callerPrincipal="+p);
+ log.debug("StatelessSessionBean.unchecked, callerPrincipal="+p);
}
/** This method should be assigned access to the runAs role and no user
@@ -133,9 +135,9 @@
*/
public void excluded()
{
- System.out.println("StatelessSessionBean3.excluded, accessed");
+ log.debug("StatelessSessionBean3.excluded, accessed");
// This call should fail if the bean is not secured
Principal p = sessionContext.getCallerPrincipal();
- System.out.println("StatelessSessionBean3.excluded, callerPrincipal="+p);
+ log.debug("StatelessSessionBean3.excluded, callerPrincipal="+p);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development