code: public boolean grantResourcePermission(String subjectid, String resourcePath,
  			EnumSet<AllowedMethods> permission, boolean allowGuestAccess) {
  		// urlDecode resource path & strip slashes at both ends
  		resourcePath = Utils.urlDecode(resourcePath);
  		resourcePath = StringUtils.removeEnd(resourcePath, "/");
  		resourcePath = StringUtils.removeStart(resourcePath, "/");
  		resourcePath = StringUtils.remove(resourcePath, ".");	// Elasticsearch 2.0+ restriction
  		if (!StringUtils.isBlank(subjectid) && !StringUtils.isBlank(resourcePath) &&
  				permission != null && !permission.isEmpty()) {
  
  			allowGuestAccess = permission.remove(GUEST) || allowGuestAccess;
  			EnumSet<AllowedMethods> methods = getAllowedMethodsSet(permission);
  			if (!getResourcePermissions().containsKey(subjectid)) {
  				Map<String, List<String>> perm = new LinkedHashMap<>();
  				perm.put(resourcePath, new ArrayList<>(permission.size()));
  				getResourcePermissions().put(subjectid, perm);
  			}
  			if (allowGuestAccess && ALLOW_ALL.equals(subjectid)) {
  				methods.add(GUEST);
  			}
  			if (permission.contains(OWN)) {
  				methods.add(OWN); // limits access to objects created by the user
  			}
  			List<String> perm = new ArrayList<>(methods.size());
  			for (AllowedMethods allowedMethod : methods) {
  				perm.add(allowedMethod.toString());
  			}
  			getResourcePermissions().get(subjectid).put(resourcePath, perm);
  			return true;
  		}
  		return false;
  	}
docs: Grants a new permission for a given subject and resource.
  @param subjectid the subject to give permissions to
  @param resourcePath the resource name/type
  @param permission the set or HTTP methods allowed
  @param allowGuestAccess if true - all unauthenticated requests will go through, 'false' by default.
  @return true if successful