+ private static void startInitiateThreadService(Thread thread) {
+ initiateThread = thread;
+ initiateThread.start();
+ }
+
+ private static void startHeartBeatService(Heartbeat heartbeat) {
+ XACMLPapServlet.heartbeat = heartbeat;
+ XACMLPapServlet.heartbeatThread = new Thread(XACMLPapServlet.heartbeat);
+ XACMLPapServlet.heartbeatThread.start();
+ }
+
+ private static void setPolicyDBDao() throws ServletException {
+ try {
+ policyDBDao = PolicyDBDao.getPolicyDBDaoInstance(getEmf());
+ } catch (Exception e) {
+ throw new ServletException("Unable to Create Policy DBDao Instance",e);
+ }
+ }
+
+ private static void setEMF(Properties properties) throws ServletException {
+ emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT, properties);
+ if (emf == null) {
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " Error creating entity manager factory with persistence unit: "
+ + PERSISTENCE_UNIT);
+ throw new ServletException("Unable to create Entity Manager Factory");
+ }
+ }
+
+ private static void setPAPURL(String papURL) {
+ XACMLPapServlet.papURL = papURL;
+ }
+
+ private static void setPAPEngine(PAPPolicyEngine newEngine) {
+ XACMLPapServlet.papEngine = newEngine;
+ }
+
+ private static void setPAPDependencyGroups(String papDependencyGroups) throws PAPException {
+ try{
+ //Now we have flattened the array into a simple comma-separated list
+ papDependencyGroupsFlatArray = papDependencyGroups.split("[;,]");
+ //clean up the entries
+ for (int i = 0 ; i < papDependencyGroupsFlatArray.length ; i ++){
+ papDependencyGroupsFlatArray[i] = papDependencyGroupsFlatArray[i].trim();
+ }
+ try{
+ if(XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS) != null){
+ papIntegrityAuditPeriodSeconds = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS).trim());
+ }
+ }catch(Exception e){
+ String msg = "integrity_audit_period_seconds ";
+ LOGGER.error("\n\nERROR: " + msg + "Bad property entry: " + e.getMessage() + "\n");
+ PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "XACMLPapServlet", " ERROR: " + msg +"Bad property entry");
+ throw e;
+ }
+ }catch(Exception e){
+ PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "XACMLPapServlet", " ERROR: Bad property entry");
+ throw new PAPException(e);
+ }
+ }
+
+ private static void setCommonProperties() throws PAPException {
+ setConfigHome();
+ setActionHome();
+ papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
+ if(papDbDriver == null){
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE,"XACMLPapServlet", " ERROR: Bad papDbDriver property entry");
+ throw new PAPException("papDbDriver is null");
+ }
+ setPapDbDriver(papDbDriver);
+ papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
+ if(papDbUrl == null){
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE,"XACMLPapServlet", " ERROR: Bad papDbUrl property entry");
+ throw new PAPException("papDbUrl is null");
+ }
+ setPapDbUrl(papDbUrl);
+ papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER);
+ if(papDbUser == null){
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE,"XACMLPapServlet", " ERROR: Bad papDbUser property entry");
+ throw new PAPException("papDbUser is null");
+ }
+ setPapDbUser(papDbUser);
+ papDbPassword = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD);
+ if(papDbPassword == null){
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE,"XACMLPapServlet", " ERROR: Bad papDbPassword property entry");
+ throw new PAPException("papDbPassword is null");
+ }
+ setPapDbPassword(papDbPassword);
+ papResourceName = XACMLProperties.getProperty(XACMLRestProperties.PAP_RESOURCE_NAME);
+ if(papResourceName == null){
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE,"XACMLPapServlet", " ERROR: Bad papResourceName property entry");
+ throw new PAPException("papResourceName is null");
+ }
+ environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL");
+ //Micro Service Properties
+ msOnapName=XACMLProperties.getProperty("xacml.policy.msOnapName");
+ setMsOnapName(msOnapName);
+ msPolicyName=XACMLProperties.getProperty("xacml.policy.msPolicyName");
+ setMsPolicyName(msPolicyName);
+ // PDPId File location
+ XACMLPapServlet.pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
+ if (XACMLPapServlet.pdpFile == null) {
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " The PDP Id Authentication File Property is not valid: "
+ + XACMLRestProperties.PROP_PDP_IDFILE);
+ throw new PAPException("The PDP Id Authentication File Property :"+ XACMLRestProperties.PROP_PDP_IDFILE+ " is not Valid. ");
+ }
+ }
+
+ /**