commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1425899 - in /commons/sandbox/privilizer/trunk: example/ modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/
Date Wed, 26 Dec 2012 13:20:05 GMT
Author: struberg
Date: Wed Dec 26 13:20:05 2012
New Revision: 1425899

URL: http://svn.apache.org/viewvc?rev=1425899&view=rev
Log:
fix AccessLevel reporting and check

Modified:
    commons/sandbox/privilizer/trunk/example/pom.xml
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FilesystemPrivilizer.java
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
    commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java

Modified: commons/sandbox/privilizer/trunk/example/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/example/pom.xml?rev=1425899&r1=1425898&r2=1425899&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/example/pom.xml (original)
+++ commons/sandbox/privilizer/trunk/example/pom.xml Wed Dec 26 13:20:05 2012
@@ -43,7 +43,7 @@
         <version>${project.version}</version>
         <configuration>
           <weaverConfig>
-            <privilizer.accessLevel>PRIVATE</privilizer.accessLevel>
+            <privilizer.accessLevel>PACKAGE</privilizer.accessLevel>
             <privilizer.policy>ON_INIT</privilizer.policy>
           </weaverConfig>
         </configuration>
@@ -83,7 +83,7 @@
                   <pluginExecutionFilter>
                     <groupId>org.apache.commons</groupId>
                     <artifactId>commons-privilizer-maven-plugin</artifactId>
-                    <versionRange>[1.0-SNAPSHOT,)</versionRange>
+                    <versionRange>[0.1-SNAPSHOT,)</versionRange>
                     <goals>
                       <goal>prepare</goal>
                       <goal>weave</goal>

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FilesystemPrivilizer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FilesystemPrivilizer.java?rev=1425899&r1=1425898&r2=1425899&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FilesystemPrivilizer.java
(original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/FilesystemPrivilizer.java
Wed Dec 26 13:20:05 2012
@@ -34,6 +34,8 @@ import org.apache.commons.lang3.Validate
  * Handles weaving of methods annotated with {@link Privileged}.
  */
 public class FilesystemPrivilizer extends Privilizer<FilesystemPrivilizer> {
+
+
     private static ClassPool createClassPool(ClassLoader classpath, File target) {
         final ClassPool result = new ClassPool();
         try {

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java?rev=1425899&r1=1425898&r2=1425899&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
(original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/Privilizer.java
Wed Dec 26 13:20:05 2012
@@ -234,6 +234,10 @@ public abstract class Privilizer<SELF ex
         log.info(String.format(message, args));
     }
 
+    protected AccessLevel getTargetAccessLevel() {
+        return AccessLevel.PRIVATE;
+    }
+
     protected boolean permitMethodWeaving(AccessLevel accessLevel) {
         return true;
     }
@@ -346,8 +350,8 @@ public abstract class Privilizer<SELF ex
         final AccessLevel accessLevel = AccessLevel.of(method.getModifiers());
         if (!permitMethodWeaving(accessLevel)) {
             throw new IllegalAccessException("Method " + type.getName() + "#" +  toString(method)
-                                             + " must have maximum access level " + accessLevel
-                                             + " but is defined wider");
+                                             + " must have maximum access level '" + getTargetAccessLevel()
+                                             + "' but is defined wider ('" + accessLevel
+ "')");
         }
         if (AccessLevel.PACKAGE.compareTo(accessLevel) > 0) {
             warn("Possible security leak: granting privileges to %s method %s.%s", accessLevel,
type.getName(),

Modified: commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
URL: http://svn.apache.org/viewvc/commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java?rev=1425899&r1=1425898&r2=1425899&view=diff
==============================================================================
--- commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
(original)
+++ commons/sandbox/privilizer/trunk/modules/privilizer/weaver/src/main/java/org/apache/commons/weaver/privilizer/PrivilizerWeaver.java
Wed Dec 26 13:20:05 2012
@@ -36,6 +36,7 @@ public class PrivilizerWeaver implements
 
     private AccessLevel targetAccessLevel;
 
+
     @Override
     public void configure(List<String> classPath, File target, Properties config)
     {
@@ -58,6 +59,12 @@ public class PrivilizerWeaver implements
             protected boolean permitMethodWeaving(final AccessLevel accessLevel) {
                 return targetAccessLevel.compareTo(accessLevel) <= 0;
             }
+
+            @Override
+            protected AccessLevel getTargetAccessLevel()
+            {
+                return targetAccessLevel;
+            }
         };
 
     }



Mime
View raw message