@Test public void testXacmlInit() { logger.info("XACMLRestTest - testInit"); try { XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME); try { XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } System.clearProperty(XACMLProperties.XACML_PROPERTIES_NAME); try { Logger.getRootLogger().setLevel(Level.INFO); XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.pdp.properties"); try { Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.xacmlInit(servletConfig); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn(null); try { XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } try { Logger.getRootLogger().setLevel(Level.INFO); XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { fail("Normal case of initiation of XACML REST failed"); } Mockito.when(servletConfig.getInitParameter("XACML_PROPERTIES_NAME")).thenReturn("xacml.pdp.properties"); List<String> parNameList = new ArrayList<String>() { private static final long serialVersionUID = 1L; { add("Name0"); add("Name1"); add("Name2"); add("XACML_PROPERTIES_NAME"); } }; Mockito.when(servletConfig.getInitParameterNames()).thenReturn(Collections.enumeration(parNameList)); Mockito.when(servletConfig.getInitParameter("Name0")).thenReturn("Value0"); Mockito.when(servletConfig.getInitParameter("Name1")).thenReturn("Value1"); Mockito.when(servletConfig.getInitParameter("Name2")).thenReturn("Value2"); try { XacmlRest.xacmlInit(servletConfig); Logger.getRootLogger().setLevel(Level.DEBUG); XacmlRest.dumpRequest(httpServletRequest); XacmlRest.loadXacmlProperties(null, null); } catch (Exception e) { e.printStackTrace(); fail("Normal case of initiation of XACML REST failed"); } }
public static void xacmlInit(ServletConfig config) { String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); if (propFile != null) { String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME); if (xacmlPropertiesName == null) { if (logger.isDebugEnabled()) { logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); } else { if (logger.isDebugEnabled()) { logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); } } } Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } } }
XacmlRest { public static void xacmlInit(ServletConfig config) { String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); if (propFile != null) { String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME); if (xacmlPropertiesName == null) { if (logger.isDebugEnabled()) { logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); } else { if (logger.isDebugEnabled()) { logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); } } } Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } } } }
XacmlRest { public static void xacmlInit(ServletConfig config) { String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); if (propFile != null) { String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME); if (xacmlPropertiesName == null) { if (logger.isDebugEnabled()) { logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); } else { if (logger.isDebugEnabled()) { logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); } } } Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } } } private  XacmlRest(); }
XacmlRest { public static void xacmlInit(ServletConfig config) { String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); if (propFile != null) { String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME); if (xacmlPropertiesName == null) { if (logger.isDebugEnabled()) { logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); } else { if (logger.isDebugEnabled()) { logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); } } } Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } } } private  XacmlRest(); static void xacmlInit(ServletConfig config); static void loadXacmlProperties(Properties policyProperties, Properties pipProperties); static void dumpRequest(HttpServletRequest request); }
XacmlRest { public static void xacmlInit(ServletConfig config) { String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); if (propFile != null) { String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME); if (xacmlPropertiesName == null) { if (logger.isDebugEnabled()) { logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); } System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); } else { if (logger.isDebugEnabled()) { logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); } } } Enumeration<String> params = config.getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); if (!"XACML_PROPERTIES_NAME".equals(param)) { String value = config.getInitParameter(param); PolicyLogger.info(param + "=" + config.getInitParameter(param)); restProperties.setProperty(param, value); } } } private  XacmlRest(); static void xacmlInit(ServletConfig config); static void loadXacmlProperties(Properties policyProperties, Properties pipProperties); static void dumpRequest(HttpServletRequest request);  }