@Test public void testInit() { LOGGER.info("XACMLPdpServletTest - testInit"); try { pdpServlet.init(servletConfig); assertTrue(true); } catch (Exception e) { LOGGER.error(ERROR_TEXT + e); fail(); } }
@Override public void init(ServletConfig config) throws ServletException { String createUpdateResourceName = null; String dependencyGroups = null; XacmlRest.xacmlInit(config); setNotificationDelay(); int queueSize = 50; queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE", String.valueOf(queueSize))); initQueue(queueSize); PDPEngine engine = XACMLPdpLoader.loadEngine(XACMLPdpServlet.status, null, null); if (engine != null) { synchronized (pdpEngineLock) { pdpEngine = engine; } XACMLPdpLoader.sendNotification(); } baseLoggingContext = new OnapLoggingContext(); try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); baseLoggingContext.setServer(hostname); } catch (UnknownHostException e) { logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging" + e); } Properties properties; try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } PolicyLogger.info("\n Properties Given : \n" + properties.toString()); } setPDPResourceName(properties); dependencyGroups = properties.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS); if (dependencyGroups == null) { PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, IntegrityMonitorProperties.DEPENDENCY_GROUPS, "xacml.pdp"); throw new ServletException("dependency_groups is null"); } setDependencyNodes(dependencyGroups); createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); try { logger.info("Creating IntegrityMonitor"); properties.setProperty("javax.persistence.jdbc.password", PeCryptoUtils.decrypt(properties.getProperty("javax.persistence.jdbc.password", ""))); im = IntegrityMonitor.getInstance(pdpResourceName, properties); } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration"); } startThreads(baseLoggingContext, new Thread(this)); }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void init(ServletConfig config) throws ServletException { String createUpdateResourceName = null; String dependencyGroups = null; XacmlRest.xacmlInit(config); setNotificationDelay(); int queueSize = 50; queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE", String.valueOf(queueSize))); initQueue(queueSize); PDPEngine engine = XACMLPdpLoader.loadEngine(XACMLPdpServlet.status, null, null); if (engine != null) { synchronized (pdpEngineLock) { pdpEngine = engine; } XACMLPdpLoader.sendNotification(); } baseLoggingContext = new OnapLoggingContext(); try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); baseLoggingContext.setServer(hostname); } catch (UnknownHostException e) { logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging" + e); } Properties properties; try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } PolicyLogger.info("\n Properties Given : \n" + properties.toString()); } setPDPResourceName(properties); dependencyGroups = properties.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS); if (dependencyGroups == null) { PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, IntegrityMonitorProperties.DEPENDENCY_GROUPS, "xacml.pdp"); throw new ServletException("dependency_groups is null"); } setDependencyNodes(dependencyGroups); createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); try { logger.info("Creating IntegrityMonitor"); properties.setProperty("javax.persistence.jdbc.password", PeCryptoUtils.decrypt(properties.getProperty("javax.persistence.jdbc.password", ""))); im = IntegrityMonitor.getInstance(pdpResourceName, properties); } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration"); } startThreads(baseLoggingContext, new Thread(this)); } }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void init(ServletConfig config) throws ServletException { String createUpdateResourceName = null; String dependencyGroups = null; XacmlRest.xacmlInit(config); setNotificationDelay(); int queueSize = 50; queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE", String.valueOf(queueSize))); initQueue(queueSize); PDPEngine engine = XACMLPdpLoader.loadEngine(XACMLPdpServlet.status, null, null); if (engine != null) { synchronized (pdpEngineLock) { pdpEngine = engine; } XACMLPdpLoader.sendNotification(); } baseLoggingContext = new OnapLoggingContext(); try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); baseLoggingContext.setServer(hostname); } catch (UnknownHostException e) { logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging" + e); } Properties properties; try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } PolicyLogger.info("\n Properties Given : \n" + properties.toString()); } setPDPResourceName(properties); dependencyGroups = properties.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS); if (dependencyGroups == null) { PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, IntegrityMonitorProperties.DEPENDENCY_GROUPS, "xacml.pdp"); throw new ServletException("dependency_groups is null"); } setDependencyNodes(dependencyGroups); createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); try { logger.info("Creating IntegrityMonitor"); properties.setProperty("javax.persistence.jdbc.password", PeCryptoUtils.decrypt(properties.getProperty("javax.persistence.jdbc.password", ""))); im = IntegrityMonitor.getInstance(pdpResourceName, properties); } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration"); } startThreads(baseLoggingContext, new Thread(this)); } XACMLPdpServlet(); }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void init(ServletConfig config) throws ServletException { String createUpdateResourceName = null; String dependencyGroups = null; XacmlRest.xacmlInit(config); setNotificationDelay(); int queueSize = 50; queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE", String.valueOf(queueSize))); initQueue(queueSize); PDPEngine engine = XACMLPdpLoader.loadEngine(XACMLPdpServlet.status, null, null); if (engine != null) { synchronized (pdpEngineLock) { pdpEngine = engine; } XACMLPdpLoader.sendNotification(); } baseLoggingContext = new OnapLoggingContext(); try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); baseLoggingContext.setServer(hostname); } catch (UnknownHostException e) { logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging" + e); } Properties properties; try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } PolicyLogger.info("\n Properties Given : \n" + properties.toString()); } setPDPResourceName(properties); dependencyGroups = properties.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS); if (dependencyGroups == null) { PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, IntegrityMonitorProperties.DEPENDENCY_GROUPS, "xacml.pdp"); throw new ServletException("dependency_groups is null"); } setDependencyNodes(dependencyGroups); createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); try { logger.info("Creating IntegrityMonitor"); properties.setProperty("javax.persistence.jdbc.password", PeCryptoUtils.decrypt(properties.getProperty("javax.persistence.jdbc.password", ""))); im = IntegrityMonitor.getInstance(pdpResourceName, properties); } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration"); } startThreads(baseLoggingContext, new Thread(this)); } XACMLPdpServlet(); static int getNotificationDelay(); IntegrityMonitor getIm(); void setIm(IntegrityMonitor im); @Override void init(ServletConfig config); @Override void destroy(); @Override void run(); static PDPEngine getPDPEngine(); static Constructor<?> getCreateUpdatePolicyConstructor(); static Object getPDPEngineLock(); }
XACMLPdpServlet extends HttpServlet implements Runnable { @Override public void init(ServletConfig config) throws ServletException { String createUpdateResourceName = null; String dependencyGroups = null; XacmlRest.xacmlInit(config); setNotificationDelay(); int queueSize = 50; queueSize = Integer.parseInt(XACMLProperties.getProperty("REQUEST_BUFFER_SIZE", String.valueOf(queueSize))); initQueue(queueSize); PDPEngine engine = XACMLPdpLoader.loadEngine(XACMLPdpServlet.status, null, null); if (engine != null) { synchronized (pdpEngineLock) { pdpEngine = engine; } XACMLPdpLoader.sendNotification(); } baseLoggingContext = new OnapLoggingContext(); try { String hostname = InetAddress.getLocalHost().getCanonicalHostName(); baseLoggingContext.setServer(hostname); } catch (UnknownHostException e) { logger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get hostname for logging" + e); } Properties properties; try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } if (properties.getProperty(XacmlRestProperties.PDP_RESOURCE_NAME) == null) { XACMLProperties.reloadProperties(); try { properties = XACMLProperties.getProperties(); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "Error loading properties with: XACMLProperties.getProperties()"); throw new ServletException(e.getMessage(), e.getCause()); } PolicyLogger.info("\n Properties Given : \n" + properties.toString()); } setPDPResourceName(properties); dependencyGroups = properties.getProperty(IntegrityMonitorProperties.DEPENDENCY_GROUPS); if (dependencyGroups == null) { PolicyLogger.error(MessageCodes.MISS_PROPERTY_ERROR, IntegrityMonitorProperties.DEPENDENCY_GROUPS, "xacml.pdp"); throw new ServletException("dependency_groups is null"); } setDependencyNodes(dependencyGroups); createUpdateResourceName = properties.getProperty("createUpdatePolicy.impl.className", CREATE_UPDATE_POLICY_SERVICE); setCreateUpdatePolicyConstructor(createUpdateResourceName); PeCryptoUtils.initAesKey(properties.getProperty(XacmlRestProperties.PROP_AES_KEY)); try { logger.info("Creating IntegrityMonitor"); properties.setProperty("javax.persistence.jdbc.password", PeCryptoUtils.decrypt(properties.getProperty("javax.persistence.jdbc.password", ""))); im = IntegrityMonitor.getInstance(pdpResourceName, properties); } catch (Exception e) { PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "Failed to create IntegrityMonitor" + e); throw new ServletException(e); } try { System.setProperty("msToscaModel.home", properties.getProperty("msToscaModel.home")); } catch (Exception e) { logger.error("ERROR: Unable to set msToscaModel.home- Please check the configuration"); } startThreads(baseLoggingContext, new Thread(this)); } XACMLPdpServlet(); static int getNotificationDelay(); IntegrityMonitor getIm(); void setIm(IntegrityMonitor im); @Override void init(ServletConfig config); @Override void destroy(); @Override void run(); static PDPEngine getPDPEngine(); static Constructor<?> getCreateUpdatePolicyConstructor(); static Object getPDPEngineLock(); static final PdpRestMonitor monitor; }