private static void init(final Cache cache) throws NotAuthorizedException {
    final LogWriter systemLogWriter = cache.getLogger();
    final String xmlDocumentUri =
        (String) cache.getDistributedSystem().getSecurityProperties().get(DOC_URI_PROP_NAME);

    try {
      if (xmlDocumentUri == null) {
        throw new NotAuthorizedException(
            "No ACL file defined using tag [" + DOC_URI_PROP_NAME + "] in system properties");
      }
      if (xmlDocumentUri.equals(XmlAuthorization.currentDocUri)) {
        if (XmlAuthorization.xmlLoadFailure != null) {
          throw XmlAuthorization.xmlLoadFailure;
        }
        return;
      }

      final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setIgnoringComments(true);
      factory.setIgnoringElementContentWhitespace(true);
      factory.setValidating(true);

      final DocumentBuilder builder = factory.newDocumentBuilder();
      final XmlErrorHandler errorHandler = new XmlErrorHandler(systemLogWriter, xmlDocumentUri);
      builder.setErrorHandler(errorHandler);
      builder.setEntityResolver(new AuthzDtdResolver());

      final Document xmlDocument = builder.parse(xmlDocumentUri);

      XmlAuthorization.userRoles = new HashMap<>();
      XmlAuthorization.rolePermissions =
          new HashMap<>();

      final NodeList roleUserNodes = xmlDocument.getElementsByTagName(TAG_ROLE);

      for (int roleIndex = 0; roleIndex < roleUserNodes.getLength(); roleIndex++) {
        final Node roleUserNode = roleUserNodes.item(roleIndex);
        final String roleName = getAttributeValue(roleUserNode, ATTR_ROLENAME);
        final NodeList userNodes = roleUserNode.getChildNodes();

        for (int userIndex = 0; userIndex < userNodes.getLength(); userIndex++) {
          final Node userNode = userNodes.item(userIndex);

          if (TAG_USER.equals(userNode.getNodeName())) {
            final String userName = getNodeValue(userNode);
            HashSet<String> userRoleSet = XmlAuthorization.userRoles.get(userName);
            if (userRoleSet == null) {
              userRoleSet = new HashSet<>();
              XmlAuthorization.userRoles.put(userName, userRoleSet);
            }
            userRoleSet.add(roleName);

          } else {
            throw new SAXParseException(
                "Unknown tag [" + userNode.getNodeName() + "] as child of tag [" + TAG_ROLE + ']',
                null);
          }
        }
      }

      final NodeList rolePermissionNodes = xmlDocument.getElementsByTagName(TAG_PERMS);

      for (int permIndex = 0; permIndex < rolePermissionNodes.getLength(); permIndex++) {
        final Node rolePermissionNode = rolePermissionNodes.item(permIndex);
        final String roleName = getAttributeValue(rolePermissionNode, ATTR_ROLE);
        Map<String, Map<OperationCode, FunctionSecurityPrmsHolder>> regionOperationMap =
            XmlAuthorization.rolePermissions.get(roleName);

        if (regionOperationMap == null) {
          regionOperationMap =
              new HashMap<>();
          XmlAuthorization.rolePermissions.put(roleName, regionOperationMap);
        }

        final NodeList operationNodes = rolePermissionNode.getChildNodes();
        final HashMap<OperationCode, FunctionSecurityPrmsHolder> operationMap =
            new HashMap<>();

        for (int opIndex = 0; opIndex < operationNodes.getLength(); opIndex++) {
          final Node operationNode = operationNodes.item(opIndex);

          if (TAG_OP.equals(operationNode.getNodeName())) {
            final String operationName = getNodeValue(operationNode);
            final OperationCode code = OperationCode.valueOf(operationName);

            if (code == null) {
              throw new SAXParseException("Unknown operation [" + operationName + ']', null);
            }

            if (code != OperationCode.EXECUTE_FUNCTION) {
              operationMap.put(code, null);

            } else {
              final String optimizeForWrite =
                  getAttributeValue(operationNode, ATTR_FUNCTION_OPTIMIZE_FOR_WRITE);
              final String functionAttr = getAttributeValue(operationNode, ATTR_FUNCTION_IDS);
              final String keysAttr = getAttributeValue(operationNode, ATTR_FUNCTION_KEY_SET);

              Boolean isOptimizeForWrite;
              HashSet<String> functionIds;
              HashSet<String> keySet;

              if (optimizeForWrite == null || optimizeForWrite.length() == 0) {
                isOptimizeForWrite = null;
              } else {
                isOptimizeForWrite = Boolean.parseBoolean(optimizeForWrite);
              }

              if (functionAttr == null || functionAttr.length() == 0) {
                functionIds = null;
              } else {
                final String[] functionArray = functionAttr.split(",");
                functionIds = new HashSet<>();
                for (final String s : functionArray) {
                  functionIds.add(s);
                }
              }

              if (keysAttr == null || keysAttr.length() == 0) {
                keySet = null;
              } else {
                final String[] keySetArray = keysAttr.split(",");
                keySet = new HashSet<>();
                for (final String s : keySetArray) {
                  keySet.add(s);
                }
              }

              final FunctionSecurityPrmsHolder functionContext =
                  new FunctionSecurityPrmsHolder(isOptimizeForWrite, functionIds, keySet);
              operationMap.put(code, functionContext);
            }

          } else {
            throw new SAXParseException("Unknown tag [" + operationNode.getNodeName()
                + "] as child of tag [" + TAG_PERMS + ']', null);
          }
        }

        final String regionNames = getAttributeValue(rolePermissionNode, ATTR_REGIONS);
        if (regionNames == null || regionNames.length() == 0) {
          regionOperationMap.put(EMPTY_VALUE, operationMap);
        } else {
          final String[] regionNamesSplit = regionNames.split(",");
          for (final String s : regionNamesSplit) {
            regionOperationMap.put(normalizeRegionName(s), operationMap);
          }
        }
      }
      XmlAuthorization.currentDocUri = xmlDocumentUri;

    } catch (Exception ex) {
      String message;
      if (ex instanceof NotAuthorizedException) {
        message = ex.getMessage();
      } else {
        message = ex.getClass().getName() + ": " + ex.getMessage();
      }
      systemLogWriter.warning("XmlAuthorization.init: " + message);
      XmlAuthorization.xmlLoadFailure = new NotAuthorizedException(message, ex);
      throw XmlAuthorization.xmlLoadFailure;
    }
  }
Cache authorization information for all users statically. This method is not thread-safe and is
should either be invoked only once, or the caller should take the appropriate locks.

@param cache reference to the cache object for the distributed system
geode-dunit/src/main/java/org/apache/geode/security/templates/XmlAuthorization.java