Author: tolusha
Date: 2010-06-16 10:34:33 -0400 (Wed, 16 Jun 2010)
New Revision: 2639
Added:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
Removed:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/TestSecurityManager.java
Log:
EXOJCR-756: fix
Deleted:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/TestSecurityManager.java
===================================================================
---
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/TestSecurityManager.java 2010-06-16
14:20:41 UTC (rev 2638)
+++
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/TestSecurityManager.java 2010-06-16
14:34:33 UTC (rev 2639)
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2010 eXo Platform SAS.
- *
- * 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.exoplatform.commons;
-
-import java.security.Permission;
-
-/**
- * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
- * @version $Id$
- *
- */
-public class TestSecurityManager extends SecurityManager
-{
- /**
- * {@inheritDoc}
- */
- @Override
- public void checkPermission(Permission perm)
- {
- try
- {
- super.checkPermission(perm);
- }
- catch (SecurityException se)
- {
- Throwable e = se;
-
- boolean srcCode = false;
- boolean testCode = false;
-
- while (e != null)
- {
- StackTraceElement[] traceElements = e.getStackTrace();
- for (int i = 0; i < traceElements.length; i++)
- {
- String className = traceElements[i].getClassName();
- String fileName = traceElements[i].getFileName();
-
- if (className.startsWith("org.exoplatform"))
- {
- // hide Exception during JCR initialization
- if (fileName.equals("BaseStandaloneTest.java"))
- {
- return;
- }
-
- if (fileName.startsWith("Test") ||
fileName.endsWith("Test.java")
- || fileName.endsWith("TestBase.java") ||
fileName.equals("Probe.java")
- || fileName.equals("ExportBase.java"))
- {
- testCode = true;
- }
- else
- {
- srcCode = true;
- }
- }
- else if (className.startsWith("org.apache.jackrabbit.test"))
- {
- // Allow access to instances
- if (fileName.equals("RepositoryHelper.java"))
- {
- return;
- }
-
- if (fileName.endsWith("Test.java") ||
fileName.equals("JCRTestResult.java"))
- {
- testCode = true;
- }
- }
- else if
(className.startsWith("org.slf4j.impl.Log4jLoggerFactory"))
- {
- return;
- }
- }
-
- e = e.getCause();
- }
-
- // hide Exception if only test code exists
- if (!srcCode && testCode)
- {
- return;
- }
-
- throw se;
- }
- }
-}
Added:
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
===================================================================
---
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java
(rev 0)
+++
kernel/trunk/exo.kernel.commons.test/src/main/java/org/exoplatform/commons/test/TestSecurityManager.java 2010-06-16
14:34:33 UTC (rev 2639)
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * 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.exoplatform.commons.test;
+
+import java.security.Permission;
+
+/**
+ * @author <a href="anatoliy.bazko(a)exoplatform.org">Anatoliy
Bazko</a>
+ * @version $Id: TestSecurityManager.java 2636 2010-06-16 14:18:23Z tolusha $
+ *
+ */
+public class TestSecurityManager extends SecurityManager
+{
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkPermission(Permission perm)
+ {
+ try
+ {
+ super.checkPermission(perm);
+ }
+ catch (SecurityException se)
+ {
+ Throwable e = se;
+
+ boolean srcCode = false;
+ boolean testCode = false;
+
+ while (e != null)
+ {
+ StackTraceElement[] traceElements = e.getStackTrace();
+ for (int i = 0; i < traceElements.length; i++)
+ {
+ String className = traceElements[i].getClassName();
+ String fileName = traceElements[i].getFileName();
+
+ if (className.startsWith("org.exoplatform"))
+ {
+ // hide Exception during JCR initialization
+ if (fileName.equals("BaseStandaloneTest.java"))
+ {
+ return;
+ }
+
+ if (fileName.startsWith("Test") ||
fileName.endsWith("Test.java")
+ || fileName.endsWith("TestBase.java") ||
fileName.equals("Probe.java")
+ || fileName.equals("ExportBase.java"))
+ {
+ testCode = true;
+ }
+ else
+ {
+ srcCode = true;
+ }
+ }
+ else if (className.startsWith("org.apache.jackrabbit.test"))
+ {
+ // Allow access to instances
+ if (fileName.equals("RepositoryHelper.java"))
+ {
+ return;
+ }
+
+ if (fileName.endsWith("Test.java") ||
fileName.equals("JCRTestResult.java"))
+ {
+ testCode = true;
+ }
+ }
+ else if
(className.startsWith("org.slf4j.impl.Log4jLoggerFactory"))
+ {
+ return;
+ }
+ }
+
+ e = e.getCause();
+ }
+
+ // hide Exception if only test code exists
+ if (!srcCode && testCode)
+ {
+ return;
+ }
+
+ throw se;
+ }
+ }
+}