class JavaBeanAccessorMethodAuthorizer implements MethodInvocationAuthorizer {

  @Override
  public boolean authorize(Method method, Object target) {

    // Return false for known dangerous methods.
    if (restrictedMethodAuthorizer.isPermanentlyForbiddenMethod(method, target)) {
      return false;
    }

    String packageName = target.getClass().getPackage().getName();

    // If the target object belongs to the 'org.apache.geode' package, delegate to the default
    // authorizer.
    if (packageName.startsWith(GEODE_BASE_PACKAGE)) {
      return restrictedMethodAuthorizer.isAllowedGeodeMethod(method, target);
    }

    String methodName = method.getName();

    // Return true if the the object belongs to an allowed package and the method starts with
    // exactly 'get' or 'is' followed by a non-lowercase character (to prevent matching with
    // methods that might have names like 'getawayDate' or 'islandName' etc.)
    if (pattern.matcher(methodName).matches()) {
      if (allowedPackages.stream().anyMatch(packageName::startsWith)) {
        return true;
      }
    }

    // Delegate to the default authorizer if none of the above criteria are met.
    return restrictedMethodAuthorizer.authorize(method, target);
  }

  public  JavaBeanAccessorMethodAuthorizer(Cache cache, Set<String> allowedPackages);
  public  JavaBeanAccessorMethodAuthorizer(RestrictedMethodAuthorizer restrictedMethodAuthorizer,
      Set<String> allowedPackages);

}