@Override
  public void onResource(final RestrictedType resource, final String action) {
    EuarePolicyContext.clearContext();

    if (resource != null) {
      if (accepted.contains(resource.getClass())
          || (!rejected.contains(resource.getClass())
              && Account.class.isAssignableFrom(resource.getClass())))
        try {
          EuarePolicyContext.setEuarePolicyContextResource(
              TypeMappers.transform(resource, EuarePolicyContextResource.class));
          accepted.add(resource.getClass());
        } catch (IllegalArgumentException e) {
          rejected.add(resource.getClass());
          Logs.exhaust()
              .info(
                  "Policy context not set for resource type: "
                      + resource.getClass().getSimpleName());
        }
    }
  }
  @SuppressWarnings("unchecked")
  @Override
  public void onResource(final PolicyResourceInfo resource, final String action) {
    EuarePolicyContext.clearContext();

    if (resource != null && RestrictedType.class.isAssignableFrom(resource.getResourceClass())) {
      if (accepted.contains(resource.getResourceClass())
          || (!rejected.contains(resource.getResourceClass())
              && EuareAccount.class.isAssignableFrom(resource.getResourceClass())))
        try {
          EuarePolicyContext.setEuarePolicyContextResource(
              TypeMappers.transform(
                  resource.getResourceObject(), EuarePolicyContextResource.class));
          accepted.add((Class<? extends RestrictedType>) resource.getResourceClass());
        } catch (IllegalArgumentException e) {
          rejected.add((Class<? extends RestrictedType>) resource.getResourceClass());
          Logs.exhaust()
              .info(
                  "Policy context not set for resource type: "
                      + resource.getResourceClass().getSimpleName());
        }
    }
  }