001package co.codewizards.cloudstore.ls.core.invoke.filter; 002 003import static co.codewizards.cloudstore.core.util.ReflectionUtil.*; 004 005import java.lang.reflect.Proxy; 006 007import co.codewizards.cloudstore.core.util.ReflectionUtil; 008 009public class AllowCloudStoreInvocationFilter extends AbstractInvocationFilter { 010 011 @Override 012 public int getPriority() { 013 return 100; 014 } 015 016 @Override 017 public Boolean canInvoke(final ExtMethodInvocationRequest extMethodInvocationRequest) { 018 final Class<?> targetClass = extMethodInvocationRequest.getTargetClass(); 019 if (isBlackListed(targetClass)) 020 return false; 021 022 if (isWhiteListed(targetClass)) 023 return true; 024 025 if (Proxy.isProxyClass(targetClass)) { 026 for (final Class<?> iface : getAllInterfaces(targetClass)) { 027 if (isWhiteListed(iface)) 028 return true; 029 } 030 } 031 032 return null; 033 } 034 035 private boolean isBlackListed(Class<?> classOrInterface) { 036 return ReflectionUtil.class.equals(classOrInterface); 037 } 038 039 private boolean isWhiteListed(Class<?> classOrInterface) { 040 return classOrInterface.getName().startsWith("co.codewizards.cloudstore."); 041 } 042}