[jboss-cvs] JBossAS SVN: r75001 - in projects/security/security-spi/trunk/spi/src: tests/org/jboss/test/security/securitycontext and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 24 17:18:30 EDT 2008
Author: anil.saldhana at jboss.com
Date: 2008-06-24 17:18:29 -0400 (Tue, 24 Jun 2008)
New Revision: 75001
Added:
projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/securitycontext/SecurityContextAssociationUnitTestCase.java
Modified:
projects/security/security-spi/trunk/spi/src/main/org/jboss/security/SecurityContextAssociation.java
Log:
SECURITY-251: SecurityContextAssociation with a vmwide usage
Modified: projects/security/security-spi/trunk/spi/src/main/org/jboss/security/SecurityContextAssociation.java
===================================================================
--- projects/security/security-spi/trunk/spi/src/main/org/jboss/security/SecurityContextAssociation.java 2008-06-24 20:54:58 UTC (rev 75000)
+++ projects/security/security-spi/trunk/spi/src/main/org/jboss/security/SecurityContextAssociation.java 2008-06-24 21:18:29 UTC (rev 75001)
@@ -36,6 +36,13 @@
public class SecurityContextAssociation
{
/**
+ * A flag that denotes whether SCA operates in a client side vm-wide mode
+ */
+ private static boolean SERVER = true;
+
+ private static SecurityContext securityContext = null;
+
+ /**
* Flag to indicate whether threads that are spawned inherit the security context from parent
* Set this to false if you do not want inheritance. By default the context is inherited.
*/
@@ -66,19 +73,41 @@
}
}
+ public static boolean isClient()
+ {
+ return !SERVER;
+ }
+
+ /**
+ * Set the VM-wide client side usage
+ */
+ public static void setClient()
+ {
+ SERVER = false;
+ }
+
public static void setSecurityContext(SecurityContext sc)
{
- securityContextLocal.set(sc);
+ if(!SERVER)
+ securityContext = sc;
+ else
+ securityContextLocal.set(sc);
}
public static SecurityContext getSecurityContext()
{
+ if(!SERVER)
+ return securityContext;
+
return securityContextLocal.get();
}
public static void clearSecurityContext()
{
- securityContextLocal.set(null);
+ if(!SERVER)
+ securityContext = null;
+ else
+ securityContextLocal.set(null);
}
Added: projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/securitycontext/SecurityContextAssociationUnitTestCase.java
===================================================================
--- projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/securitycontext/SecurityContextAssociationUnitTestCase.java (rev 0)
+++ projects/security/security-spi/trunk/spi/src/tests/org/jboss/test/security/securitycontext/SecurityContextAssociationUnitTestCase.java 2008-06-24 21:18:29 UTC (rev 75001)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.security.securitycontext;
+
+import org.jboss.security.SecurityContextAssociation;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Test the SecurityContextAssociation
+ * @author anil.saldhana at redhat.com
+ */
+public class SecurityContextAssociationUnitTestCase extends TestCase
+{
+ public void testClientSide()
+ {
+ assertFalse("SCA is not client", SecurityContextAssociation.isClient());
+ SecurityContextAssociation.setClient();
+ assertTrue("SCA is client", SecurityContextAssociation.isClient());
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list