[jboss-cvs] JBossAS SVN: r65667 - in branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer: unit and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 27 19:31:54 EDT 2007
Author: bdecoste
Date: 2007-09-27 19:31:53 -0400 (Thu, 27 Sep 2007)
New Revision: 65667
Added:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/UnauthenticatedTimerTesterBean.java
Modified:
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
Log:
[EJBTHREE-1027] [JBAS-4572]added test for SecurityDomain(unauthenticatedPrincipal="..")
Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/UnauthenticatedTimerTesterBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/UnauthenticatedTimerTesterBean.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/UnauthenticatedTimerTesterBean.java 2007-09-27 23:31:53 UTC (rev 65667)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.timer;
+
+import javax.annotation.security.PermitAll;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import javax.ejb.Timer;
+
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+
+/**
+ * NOTE: We use a security domain without an unauthenticatedIdentity set.
+ *
+ * @author carlo
+ *
+ */
+ at Stateless
+ at Remote(SecuredTimerTester.class)
+ at SecurityDomain(value="fire", unauthenticatedPrincipal="dummy")
+public class UnauthenticatedTimerTesterBean extends BaseTimerTesterBean implements SecuredTimerTester
+{
+ private static final Logger log = Logger.getLogger(UnauthenticatedTimerTesterBean.class);
+
+ protected static boolean getCallerPrincipalCalled = false;
+
+ @Timeout
+ @PermitAll
+ public void timeoutHandler(Timer timer)
+ {
+ log.info("EJB TIMEOUT!!!!");
+ timerCalled = true;
+
+ try
+ {
+ log.info("caller principal = " + ctx.getCallerPrincipal());
+ getCallerPrincipalCalled = true;
+ }
+ catch (Exception e){}
+
+ //timer.cancel();
+ }
+
+ public boolean getCallerPrincipalCalled()
+ {
+ return getCallerPrincipalCalled;
+ }
+
+ protected void reset()
+ {
+ getCallerPrincipalCalled = false;
+ }
+}
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java 2007-09-27 23:20:46 UTC (rev 65666)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/timer/unit/RemoteUnitTestCase.java 2007-09-27 23:31:53 UTC (rev 65667)
@@ -118,6 +118,43 @@
assertFalse("EJBTHREE-1027: timer getCallerPrincipal should have failed", test.getCallerPrincipalCalled());
}
+// EJBTHREE-1027
+ public void testUnauthenticatedSecurity() throws Exception
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal("somebody"));
+ SecurityAssociation.setCredential("password".toCharArray());
+
+ SecuredTimerTester test = (SecuredTimerTester) getInitialContext().lookup("UnauthenticatedTimerTesterBean/remote");
+ test.startTimer(5000);
+ test.accessTimer();
+ Thread.sleep(6000);
+ assertTrue("EJBTHREE-1027: timer should be called", test.isTimerCalled());
+ assertTrue("EJBTHREE-1027: timer getCallerPrincipal should succeed", test.getCallerPrincipalCalled());
+ test.startTimerViaEJBContext(3000);
+ test.accessTimer();
+ Thread.sleep(6000);
+ assertTrue("EJBTHREE-1027: timer should be called", test.isTimerCalled());
+ assertTrue("EJBTHREE-1027: timer getCallerPrincipal should succeed", test.getCallerPrincipalCalled());
+ }
+
+ // EJBTHREE-1027
+ public void testUnauthenticatedSecurityWithPersistence() throws Exception
+ {
+ SecuredTimerTester test = (SecuredTimerTester) getInitialContext().lookup("UnauthenticatedTimerTesterBean/remote");
+ long when = System.currentTimeMillis() + 5000;
+ test.setTimer(new Date(when));
+
+ redeploy("timer-test.jar");
+
+ test = (SecuredTimerTester) getInitialContext().lookup("UnauthenticatedTimerTesterBean/remote");
+ long wait = 1000 + (when - System.currentTimeMillis());
+ if(wait > 0)
+ Thread.sleep(wait);
+
+ assertTrue("EJBTHREE-1027: timer should be called", test.isTimerCalled());
+ assertTrue("EJBTHREE-1027: timer getCallerPrincipal should succeed", test.getCallerPrincipalCalled());
+ }
+
public void testService() throws Exception
{
TimerTester test = (TimerTester) getInitialContext().lookup("TimerTesterService/remote");
More information about the jboss-cvs-commits
mailing list