From do-not-reply at jboss.org Tue Jun 15 04:26:28 2010
Content-Type: multipart/mixed; boundary="===============0270267419659259418=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: exo-jcr-commits at lists.jboss.org
Subject: [exo-jcr-commits] exo-jcr SVN: r2592 - in
jcr/trunk/exo.jcr.component.core:
src/main/java/org/exoplatform/services/jcr/impl/util and 1 other directories.
Date: Tue, 15 Jun 2010 04:26:28 -0400
Message-ID: <201006150826.o5F8QS0H017827@svn01.web.mwc.hst.phx2.redhat.com>
--===============0270267419659259418==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: tolusha
Date: 2010-06-15 04:26:28 -0400 (Tue, 15 Jun 2010)
New Revision: 2592
Added:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/=
jcr/impl/util/TesterSecurityManager.java
Modified:
jcr/trunk/exo.jcr.component.core/pom.xml
jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/=
jcr/BaseStandaloneTest.java
Log:
EXOJCR-756: add TesterSecurityManager
Modified: jcr/trunk/exo.jcr.component.core/pom.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-15 08:25:16 UTC (rev 2=
591)
+++ jcr/trunk/exo.jcr.component.core/pom.xml 2010-06-15 08:26:28 UTC (rev 2=
592)
@@ -374,7 +374,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- ${env.MAVEN_OPTS}
+ ${env.MAVEN_OPTS} -Djava.security.manager=3Dorg.ex=
oplatform.services.jcr.impl.util.TesterSecurityManager -Djava.security.poli=
cy=3D${project.build.directory}/test-classes/test.policy
jcr.test.configuration.file
Added: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/servi=
ces/jcr/impl/util/TesterSecurityManager.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/util/TesterSecurityManager.java (rev 0)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services=
/jcr/impl/util/TesterSecurityManager.java 2010-06-15 08:26:28 UTC (rev 2592)
@@ -0,0 +1,99 @@
+/*
+ * 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.services.jcr.impl.util;
+
+import java.security.Permission;
+
+/**
+ * @author Anatoliy Bazko
+ * @version $Id: TesterSecurityManager.java 111 2010-11-11 11:11:11Z tolus=
ha $
+ *
+ */
+public class TesterSecurityManager extends SecurityManager
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void checkPermission(Permission perm)
+ {
+ try
+ {
+ super.checkPermission(perm);
+ }
+ catch (SecurityException se)
+ {
+ Throwable e =3D se;
+
+ boolean srcCode =3D false;
+ boolean testCode =3D false;
+
+ while (e !=3D null)
+ {
+ StackTraceElement[] traceElements =3D e.getStackTrace();
+ for (int i =3D 0; i < traceElements.length; i++)
+ {
+ StackTraceElement el =3D traceElements[i];
+ String cl =3D el.getClassName();
+
+ if (cl.startsWith("org.exoplatform"))
+ {
+ int p =3D cl.lastIndexOf('.');
+ if (p !=3D -1)
+ {
+ cl =3D cl.substring(p + 1);
+ }
+
+ // TesterSecurityManager is not a part of source code
+ if (cl.equals("TesterSecurityManager"))
+ {
+ continue;
+ }
+
+ // hide Exception
+ if (cl.equals("BaseStandaloneTest"))
+ {
+ return;
+ }
+
+ if (cl.startsWith("Test") || cl.endsWith("Test") || cl.e=
ndsWith("TestBase"))
+ {
+ testCode =3D true;
+ }
+ else
+ {
+ srcCode =3D true;
+ }
+ }
+ }
+
+ e =3D e.getCause();
+ }
+
+ // hide Exception if only test code exists
+ if (!srcCode && testCode)
+ {
+ return;
+ }
+
+ throw se;
+ }
+ }
+}
Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/se=
rvices/jcr/BaseStandaloneTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/BaseStandaloneTest.java 2010-06-15 08:25:16 UTC (rev 2591)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services=
/jcr/BaseStandaloneTest.java 2010-06-15 08:26:28 UTC (rev 2592)
@@ -19,7 +19,6 @@
package org.exoplatform.services.jcr;
=
import junit.framework.TestCase;
-import sun.security.provider.PolicyFile;
=
import org.exoplatform.container.StandaloneContainer;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
@@ -43,7 +42,6 @@
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URL;
-import java.security.Policy;
import java.util.Random;
=
import javax.jcr.Node;
@@ -107,8 +105,6 @@
@Override
public void setUp() throws Exception
{
- System.setSecurityManager(null);
-
String configPath =3D System.getProperty("jcr.test.configuration.fil=
e");
if (configPath =3D=3D null)
{
@@ -164,17 +160,15 @@
fileCleaner =3D wfcleaner.getFileCleaner();
holder =3D new ReaderSpoolFileHolder();
=
- URL url =3D Thread.currentThread().getContextClassLoader().getResour=
ce("./test.policy");
- Policy.setPolicy(new PolicyFile(url));
-
- System.setSecurityManager(new SecurityManager());
+ // URL url =3D Thread.currentThread().getContextClassLoader().g=
etResource("./test.policy");
+ // Policy.setPolicy(new PolicyFile(url));
+ //
+ // System.setSecurityManager(new TesterSecurityManager());
}
=
@Override
protected void tearDown() throws Exception
{
- System.setSecurityManager(null);
-
if (session !=3D null)
{
try
--===============0270267419659259418==--