diff --git a/src/main/java/de/tudbut/security/PermissionManager.java b/src/main/java/de/tudbut/security/PermissionManager.java index 5d4748e..007f978 100644 --- a/src/main/java/de/tudbut/security/PermissionManager.java +++ b/src/main/java/de/tudbut/security/PermissionManager.java @@ -41,7 +41,7 @@ public interface PermissionManager extends Cloneable { return getClassName(clazz, null, 0); } default String getClassName(Class clazz, boolean[] cache, int idx) { - if(cache != null && cache[0]) + if(cache != null && cache[idx]) return clazz.getName(); try { // Reset the name field so that it must be cached again diff --git a/src/main/java/de/tudbut/security/permissionmanager/CallClassRestriction.java b/src/main/java/de/tudbut/security/permissionmanager/CallClassRestriction.java index 7e9049c..defbb61 100644 --- a/src/main/java/de/tudbut/security/permissionmanager/CallClassRestriction.java +++ b/src/main/java/de/tudbut/security/permissionmanager/CallClassRestriction.java @@ -55,8 +55,8 @@ public class CallClassRestriction extends Restriction { // is class, inner class of it, loaded by it, or lambda in it? Class enclosingClass = lambda.getClass().getEnclosingClass(); boolean[] cache = new boolean[2]; - b = allow.contains(getClassName(lambda.getClass(), cache, 0)) - || allow.contains(getClassName(lambda.getClass(), cache, 0).replaceAll("\\$\\$Lambda.*$", "")); + b = allow.contains(getClassName(lambda.getClass())) + || allow.contains(getClassName(lambda.getClass()).replaceAll("\\$\\$Lambda.*$", "")); if (enclosingClass != null) b = b || allow.contains(getClassName(enclosingClass)); } diff --git a/src/main/java/de/tudbut/security/permissionmanager/ClassLoaderRestriction.java b/src/main/java/de/tudbut/security/permissionmanager/ClassLoaderRestriction.java index edb1feb..5c65080 100644 --- a/src/main/java/de/tudbut/security/permissionmanager/ClassLoaderRestriction.java +++ b/src/main/java/de/tudbut/security/permissionmanager/ClassLoaderRestriction.java @@ -94,9 +94,8 @@ public class ClassLoaderRestriction extends Restriction { b = b || allow.stream().anyMatch(x -> x.getClass() == enclosingClass); // is lambda in allowed class? - boolean[] cache = new boolean[1]; - String name = getClassName(lambda.getClass(), cache, 0).replaceAll("\\$\\$Lambda.*$", ""); - b = b || allow.stream().anyMatch(x -> getClassName(x.getClass(), cache, 0).equals(name)); // is lambda in classloader + String name = getClassName(lambda.getClass()).replaceAll("\\$\\$Lambda.*$", ""); + b = b || allow.stream().anyMatch(x -> getClassName(x.getClass()).equals(name)); // is lambda in classloader try { b = b || allow.contains(getClassObject(name).getClassLoader()); // is lambda in classloader-loaded class } catch (Exception e) {