code: protected void addAcl(@Nonnull final Session session, @Nonnull final String path,
                            @Nonnull final String principalName, boolean allow,
                            @Nonnull final String[] privilegeKeys,
                            @Nonnull final Map restrictionKeys)
              throws RepositoryException {
          try {
              final AccessControlManager acManager = session.getAccessControlManager();
              final PrincipalManager principalManager = ((JackrabbitSession) session).getPrincipalManager();
              final JackrabbitAccessControlList policies = AccessControlUtils.getAccessControlList(acManager, path);
              final Principal principal = principalManager.getPrincipal(principalName);
              final Privilege[] privileges = AccessControlUtils.privilegesFromNames(acManager, privilegeKeys);
              final Map<String, Value> restrictions = new HashMap<>();
              for (final Object key : restrictionKeys.keySet()) {
                  restrictions.put((String) key, new StringValue((String) restrictionKeys.get(key)));
              }
              policies.addEntry(principal, privileges, allow, restrictions);
              LOG.info("addAcl({},{})", principalName, Arrays.toString(privilegeKeys));
              acManager.setPolicy(path, policies);
          } catch (RepositoryException e) {
              LOG.error("Error in addAcl({},{},{},{}, {}) : {}", new Object[]{path, principalName, allow, Arrays.asList(privilegeKeys), restrictionKeys, e.toString()});
              throw e;
          }
      }
docs: ACL