[exo-jcr-commits] exo-jcr SVN: r2543 - in jcr/trunk/exo.jcr.component.core: src/main/java/org/exoplatform/services/jcr/impl/core/value and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jun 11 03:04:46 EDT 2010


Author: tolusha
Date: 2010-06-11 03:04:44 -0400 (Fri, 11 Jun 2010)
New Revision: 2543

Modified:
   jcr/trunk/exo.jcr.component.core/pom.xml
   jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
   jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
   jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/BaseSecurityTest.java
   jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java
   jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy
Log:
EXOJCR-756: set policy

Modified: jcr/trunk/exo.jcr.component.core/pom.xml
===================================================================
--- jcr/trunk/exo.jcr.component.core/pom.xml	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/pom.xml	2010-06-11 07:04:44 UTC (rev 2543)
@@ -374,7 +374,7 @@
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
-               <argLine>-Djava.security.manager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
+               <argLine>${env.MAVEN_OPTS}</argLine>
                <systemProperties>
                   <property>
                      <name>jcr.test.configuration.file</name>
@@ -544,7 +544,7 @@
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-plugin</artifactId>
                   <configuration>
-                     <!-- TAKE CARE TO UPDATE ALSO run-all PROFILE -->
+                  <!-- TAKE CARE TO UPDATE ALSO run-all PROFILE -->
                      <argLine>${env.MAVEN_OPTS}</argLine>
                      <systemProperties>
                         <property>

Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/value/ValueFactoryImpl.java	2010-06-11 07:04:44 UTC (rev 2543)
@@ -40,6 +40,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Calendar;
 
 import javax.jcr.Node;
@@ -77,7 +79,15 @@
       this.locationFactory = locationFactory;
       this.fileCleaner = cleanerHolder.getFileCleaner();
 
-      this.tempDirectory = new File(System.getProperty("java.io.tmpdir"));
+      PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            tempDirectory = new File(System.getProperty("java.io.tmpdir"));
+            return null;
+         }
+      };
+      AccessController.doPrivileged(action);
 
       // TODO we use WorkspaceDataContainer constants but is it ok?
       this.maxBufferSize =
@@ -88,8 +98,17 @@
    public ValueFactoryImpl(LocationFactory locationFactory)
    {
       this.locationFactory = locationFactory;
-      this.tempDirectory = new File(System.getProperty("java.io.tmpdir"));
       this.maxBufferSize = WorkspaceDataContainer.DEF_MAXBUFFERSIZE;
+
+      PrivilegedAction<Object> action = new PrivilegedAction<Object>()
+      {
+         public Object run()
+         {
+            tempDirectory = new File(System.getProperty("java.io.tmpdir"));
+            return null;
+         }
+      };
+      AccessController.doPrivileged(action);
    }
 
    /**

Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/BaseStandaloneTest.java	2010-06-11 07:04:44 UTC (rev 2543)
@@ -19,6 +19,7 @@
 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;
@@ -41,6 +42,7 @@
 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;
@@ -101,8 +103,11 @@
       }
    }
 
+   @Override
    public void setUp() throws Exception
    {
+      System.setSecurityManager(null);
+
       String configPath = System.getProperty("jcr.test.configuration.file");
       if (configPath == null)
       {
@@ -157,8 +162,14 @@
          (WorkspaceFileCleanerHolder)wsc.getComponent(WorkspaceFileCleanerHolder.class);
       fileCleaner = wfcleaner.getFileCleaner();
       holder = new ReaderSpoolFileHolder();
+
+      URL url = Thread.currentThread().getContextClassLoader().getResource("test.policy");
+      Policy.setPolicy(new PolicyFile(url));
+
+      System.setSecurityManager(new SecurityManager());
    }
 
+   @Override
    protected void tearDown() throws Exception
    {
       if (session != null)

Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/BaseSecurityTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/BaseSecurityTest.java	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/BaseSecurityTest.java	2010-06-11 07:04:44 UTC (rev 2543)
@@ -42,13 +42,16 @@
 public abstract class BaseSecurityTest extends BaseStandaloneTest
 {
 
+   @Override
    public void setUp() throws Exception
    {
       super.setUp();
+
       SecurityManager security = System.getSecurityManager();
       assertNotNull("SecurityManager must be ON.", security);
    }
 
+   @Override
    public String getRepositoryName()
    {
       return "db1";
@@ -141,11 +144,13 @@
    protected static final PermissionCollection ALL = new PermissionCollection()
    {
 
+      @Override
       public boolean implies(Permission permission)
       {
          return true;
       }
 
+      @Override
       public Enumeration<Permission> elements()
       {
          return new Enumeration<Permission>()
@@ -165,6 +170,7 @@
          };
       }
 
+      @Override
       public void add(Permission permission)
       {
       }

Modified: jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/src/test/java/org/exoplatform/services/jcr/impl/core/security/TestSecurityRepositoryManagment.java	2010-06-11 07:04:44 UTC (rev 2543)
@@ -43,7 +43,6 @@
             repository.getSystemSession();
             return null;
          }
-
       };
       try
       {
@@ -51,6 +50,7 @@
       }
       catch (AccessControlException ace)
       {
+         ace.printStackTrace();
          fail("Must be able get system session. We are under static permissions");
       }
       catch (Throwable t)
@@ -168,6 +168,7 @@
       }
       catch (AccessControlException ace)
       {
+         ace.printStackTrace();
          fail("Must be able config workspace. We are under static permissions");
       }
       catch (Throwable t)
@@ -232,6 +233,7 @@
       }
       catch (AccessControlException ace)
       {
+         ace.printStackTrace();
          fail("Must be able create workspace. We are under static permissions");
       }
       catch (Throwable t)

Modified: jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy	2010-06-10 13:39:04 UTC (rev 2542)
+++ jcr/trunk/exo.jcr.component.core/src/test/resources/test.policy	2010-06-11 07:04:44 UTC (rev 2543)
@@ -1,5 +1,13 @@
-// configure static permissions here
-grant {                                                                                                          
-    permission java.security.AllPermission;                                                                                                    
+grant codeBase "file:/home/tolusha/java/exo-jcr/jcr/trunk/exo.jcr.component.core/target/classes/-"{                                                                                                                                                       
+    permission java.security.AllPermission;
 };
- 
\ No newline at end of file
+
+grant codeBase "file:/home/tolusha/java/exo-dependencies/repository/-"{
+	permission java.security.AllPermission;      
+};
+
+grant codeBase "file:/home/tolusha/java/exo-jcr/jcr/trunk/exo.jcr.component.core/target/test-classes/-"{
+	permission java.lang.RuntimePermission "setSecurityManager";
+	permission java.lang.RuntimePermission "getJCRSystemSession";
+	permission java.lang.RuntimePermission "manageRepository";
+};



More information about the exo-jcr-commits mailing list