@@ -0,0 +1,2542 @@
+package com.kony.prateek.filters;%0Aimport java.io.File;%0Aimport java.util.ArrayList;%0Aimport java.util.HashMap;%0A%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0A%0Aimport org.apache.log4j.Logger;%0Aimport org.w3c.dom.Document;%0Aimport org.w3c.dom.Element;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0Aimport com.konylabs.middleware.common.MiddlewareValidationListener;%0A%0A/**%0A * Utility to read xml content from config file and populate a hashmap in memory for quick access%0A * @author Prateek%0A */%0Apublic class UtilXMLReader%0A%7B%0A%09private final static String SERVICE_ELT = %22service%22;%0A%09private final static String ROLES = %22role%22;%0A%09private final static String TYPE = %22type%22;%0A%09private final static Logger log = Logger.getLogger(UtilXMLReader.class);%0A%09private static HashMap%3CString,ArrayList%3CString%3E%3E serviceMap = null;%0A%09private static final String propertyFilePath = MiddlewareValidationListener.getMIDDLEWARE_HOME() + %22/middleware/middleware-bootconfig/AuthFilter.xml%22;%0A%09static%7B%0A%09%09try%7B%0A%09%09%09serviceMap = UtilXMLReader.populateServiceMap(propertyFilePath);%0A%09%09%7Dcatch(Exception e)%7B%0A%09%09%09log.error(%22Exception while reading configuration file:%22+propertyFilePath+e.getMessage());%0A%09%09%7D%0A%09%7D%0A%09%0A%09public static HashMap%3CString,ArrayList%3CString%3E%3E getServiceMap()%7B%0A%09%09return serviceMap;%0A%09%7D%0A%09%0A%09/**%0A%09 * @param path to read the config file%0A%09 * @return Hashmap containing services mapped to each role%0A%09 * @throws Exception%0A%09 */%0A%09public static HashMap%3CString,ArrayList%3CString%3E%3E populateServiceMap(String path) throws Exception%0A%09%7B%0A%09%09HashMap%3CString,ArrayList%3CString%3E%3E hm = null;%0A%0A%09%09hm = new HashMap%3CString,ArrayList%3CString%3E%3E();%0A%09%09File xmlFile = new File(path);  %0A%09%09DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();  %0A%09%09DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder();  %0A%09%09Document doc = documentBuilder.parse(xmlFile);%0A%09%09doc.getDocumentElement().normalize();%0A%0A%09%09NodeList roles = doc.getElementsByTagName(ROLES);%0A%09%09for(int i=0;i%3Croles.getLength();i++)%0A%09%09%7B%0A%09%09%09ArrayList%3CString%3E ar = new ArrayList%3CString%3E();%0A%09%09%09Element roleElt = (Element) roles.item(i);%0A%09%09%09String id = getElementValue(roleElt.getElementsByTagName(TYPE).item(0));%0A%09%09%09 %0A%09%09%09NodeList services = roleElt.getElementsByTagName(SERVICE_ELT);%0A%09%09%09for(int x=0;x%3Cservices.getLength();x++)%0A%09%09%09%7B%0A%09%09%09%09ar.add(getElementValue(services.item(x)));%09%09%09%09%0A%09%09%09%7D%0A%09%09%09 %0A%09%09%09hm.put(id, ar);%0A%09%09 %7D%09%09%0A%09%09%0A%09%09return hm;%0A%09%7D%0A%09%0A%09public static String getElementValue(Node node) throws Exception%0A%09%7B%0A%09%09return node.getTextContent().toString().trim();%0A%09%7D%0A%09%0A%7D%0A

Create UtilXMLReader.java