* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.att.research.xacml.util.FactoryException;
import com.att.research.xacml.util.XACMLProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Splitter;
import java.io.File;
import java.io.FileInputStream;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.im.IntegrityMonitorProperties;
import org.onap.policy.common.im.StandbyStatusException;
-import org.onap.policy.common.logging.ONAPLoggingContext;
-import org.onap.policy.common.logging.ONAPLoggingUtils;
+import org.onap.policy.common.logging.OnapLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingUtils;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.components.HandleIncomingNotifications;
-import org.onap.policy.pap.xacml.rest.components.PolicyDBDao;
-import org.onap.policy.pap.xacml.rest.components.PolicyDBDaoTransaction;
+import org.onap.policy.pap.xacml.rest.components.PolicyDbDao;
+import org.onap.policy.pap.xacml.rest.components.PolicyDbDaoTransaction;
import org.onap.policy.pap.xacml.rest.handler.APIRequestHandler;
import org.onap.policy.pap.xacml.rest.handler.PushPolicyHandler;
import org.onap.policy.pap.xacml.rest.handler.SavePolicyHandler;
import org.onap.policy.pap.xacml.restAuth.CheckPDP;
-import org.onap.policy.rest.XACMLRest;
-import org.onap.policy.rest.XACMLRestProperties;
-import org.onap.policy.rest.dao.PolicyDBException;
-import org.onap.policy.utils.CryptoUtils;
+import org.onap.policy.rest.XacmlRest;
+import org.onap.policy.rest.XacmlRestProperties;
+import org.onap.policy.rest.dao.PolicyDbException;
+import org.onap.policy.utils.PeCryptoUtils;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.api.pap.ONAPPapEngineFactory;
import org.onap.policy.xacml.std.pap.StdPDPStatus;
/**
- * Servlet implementation class XacmlPapServlet
+ * Servlet implementation class XacmlPapServlet.
*/
-@WebServlet(description = "Implements the XACML PAP RESTful API.", urlPatterns = {"/"}, loadOnStartup = 1,
- initParams = {@WebInitParam(name = "XACML_PROPERTIES_NAME", value = "xacml.pap.properties",
- description = "The location of the properties file holding configuration information.")})
+@WebServlet(
+ description = "Implements the XACML PAP RESTful API.",
+ urlPatterns = {"/"},
+ loadOnStartup = 1,
+ initParams = {@WebInitParam(
+ name = "XACML_PROPERTIES_NAME",
+ value = "xacml.pap.properties",
+ description = "The location of the properties file holding configuration information.")})
public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeListener, Runnable {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = FlexLogger.getLogger(XACMLPapServlet.class);
/*
* List of Admin Console URLs. Used to send notifications when configuration changes.
*
- * The CopyOnWriteArrayList *should* protect from concurrency errors. This list is seldom changed
- * but often read, so the costs of this approach make sense.
+ * The CopyOnWriteArrayList *should* protect from concurrency errors. This list is seldom
+ * changed but often read, so the costs of this approach make sense.
*/
private static final CopyOnWriteArrayList<String> adminConsoleURLStringList = new CopyOnWriteArrayList<>();
private static String configHome;
private static String actionHome;
/*
- * This PAP instance's own URL. Need this when creating URLs to send to the PDPs so they can GET the
- * Policy files from this process.
+ * This PAP instance's own URL. Need this when creating URLs to send to the PDPs so they can GET
+ * the Policy files from this process.
*/
- public static String papURL = null;
+ private static String papUrl = null;
// The heartbeat thread.
private static Heartbeat heartbeat = null;
private static Thread heartbeatThread = null;
- private static EntityManagerFactory emf;
- public static PolicyDBDao policyDBDao;
+ private static PolicyDbDao policyDbDao;
/*
* papEngine - This is our engine workhorse that manages the PDP Groups and Nodes.
*/
* this servlet starts. Its configurable by the admin.
*/
private static transient Thread initiateThread = null;
- private transient ONAPLoggingContext baseLoggingContext = null;
+ private transient OnapLoggingContext baseLoggingContext = null;
private static final String GROUPID = "groupId";
/**
public void init(ServletConfig config) throws ServletException {
try {
// Logging
- baseLoggingContext = new ONAPLoggingContext();
+ baseLoggingContext = new OnapLoggingContext();
// fixed data that will be the same in all logging output goes here
try {
String hostname = InetAddress.getLocalHost().getCanonicalHostName();
}
// Initialize
- XACMLRest.xacmlInit(config);
+ XacmlRest.xacmlInit(config);
// Load the properties
- XACMLRest.loadXacmlProperties(null, null);
+ XacmlRest.loadXacmlProperties(null, null);
/*
* Retrieve the property values
*/
setCommonProperties();
- String papSiteName = XACMLProperties.getProperty(XACMLRestProperties.PAP_SITE_NAME);
+ String papSiteName = XACMLProperties.getProperty(XacmlRestProperties.PAP_SITE_NAME);
if (papSiteName == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papSiteName property entry");
+ " ERROR: Bad papSiteName property entry");
throw new PAPException("papSiteName is null");
}
- String papNodeType = XACMLProperties.getProperty(XACMLRestProperties.PAP_NODE_TYPE);
+ String papNodeType = XACMLProperties.getProperty(XacmlRestProperties.PAP_NODE_TYPE);
if (papNodeType == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papNodeType property entry");
+ " ERROR: Bad papNodeType property entry");
throw new PAPException("papNodeType is null");
}
// Integer will throw an exception of anything is missing or
// unrecognized
- int papTransWait = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_WAIT));
+ int papTransWait = Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_WAIT));
int papTransTimeout =
- Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_TRANS_TIMEOUT));
+ Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_TRANS_TIMEOUT));
int papAuditTimeout =
- Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_TIMEOUT));
+ Integer.parseInt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_AUDIT_TIMEOUT));
// Boolean will default to false if anything is missing or
// unrecognized
boolean papAuditFlag =
- Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_RUN_AUDIT_FLAG));
+ Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_RUN_AUDIT_FLAG));
boolean papFileSystemAudit =
- Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_AUDIT_FLAG));
- String papDependencyGroups = XACMLProperties.getProperty(XACMLRestProperties.PAP_DEPENDENCY_GROUPS);
+ Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_AUDIT_FLAG));
+ String papDependencyGroups = XACMLProperties.getProperty(XacmlRestProperties.PAP_DEPENDENCY_GROUPS);
if (papDependencyGroups == null) {
throw new PAPException("papDependencyGroups is null");
}
// Integer will throw an exception of anything is missing or
// unrecognized
int fpMonitorInterval =
- Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL));
+ Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.FP_MONITOR_INTERVAL));
int failedCounterThreshold =
- Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD));
+ Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.FAILED_COUNTER_THRESHOLD));
int testTransInterval =
- Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL));
+ Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.TEST_TRANS_INTERVAL));
int writeFpcInterval =
- Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL));
+ Integer.parseInt(XACMLProperties.getProperty(IntegrityMonitorProperties.WRITE_FPC_INTERVAL));
LOGGER.debug("\n\n\n**************************************" + "\n*************************************"
- + "\n" + "\n papDbDriver = " + papDbDriver + "\n papDbUrl = " + papDbUrl + "\n papDbUser = "
- + papDbUser + "\n papTransWait = " + papTransWait + "\n papTransTimeout = " + papTransTimeout
- + "\n papAuditTimeout = " + papAuditTimeout + "\n papAuditFlag = " + papAuditFlag
- + "\n papFileSystemAudit = " + papFileSystemAudit + "\n papResourceName = " + papResourceName
- + "\n fpMonitorInterval = " + fpMonitorInterval + "\n failedCounterThreshold = "
- + failedCounterThreshold + "\n testTransInterval = " + testTransInterval + "\n writeFpcInterval = "
- + writeFpcInterval + "\n papSiteName = " + papSiteName + "\n papNodeType = " + papNodeType
- + "\n papDependencyGroupsList = " + papDependencyGroups + "\n papIntegrityAuditPeriodSeconds = "
- + papIntegrityAuditPeriodSeconds + "\n\n*************************************"
- + "\n**************************************");
+ + "\n" + "\n papDbDriver = " + papDbDriver + "\n papDbUrl = " + papDbUrl + "\n papDbUser = "
+ + papDbUser + "\n papTransWait = " + papTransWait + "\n papTransTimeout = " + papTransTimeout
+ + "\n papAuditTimeout = " + papAuditTimeout + "\n papAuditFlag = " + papAuditFlag
+ + "\n papFileSystemAudit = " + papFileSystemAudit + "\n papResourceName = " + papResourceName
+ + "\n fpMonitorInterval = " + fpMonitorInterval + "\n failedCounterThreshold = "
+ + failedCounterThreshold + "\n testTransInterval = " + testTransInterval + "\n writeFpcInterval = "
+ + writeFpcInterval + "\n papSiteName = " + papSiteName + "\n papNodeType = " + papNodeType
+ + "\n papDependencyGroupsList = " + papDependencyGroups + "\n papIntegrityAuditPeriodSeconds = "
+ + papIntegrityAuditPeriodSeconds + "\n\n*************************************"
+ + "\n**************************************");
// Pull custom persistence settings
Properties properties;
try {
properties = XACMLProperties.getProperties();
LOGGER.debug("\n\n\n**************************************" + "\n**************************************"
- + "\n\n" + "properties = " + properties + "\n\n**************************************");
+ + "\n\n" + "properties = " + properties + "\n\n**************************************");
} catch (IOException e) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPapServlet",
- " Error loading properties with: " + "XACMLProperties.getProperties()");
+ " Error loading properties with: " + "XACMLProperties.getProperties()");
throw new ServletException(e.getMessage(), e.getCause());
}
// Create an IntegrityMonitor
if (properties.getProperty(PERSISTENCE_JDBC_PWD) != null) {
properties.setProperty(PERSISTENCE_JDBC_PWD,
- CryptoUtils.decryptTxtNoExStr(properties.getProperty(PERSISTENCE_JDBC_PWD, "")));
+ PeCryptoUtils.decrypt(properties.getProperty(PERSISTENCE_JDBC_PWD, "")));
}
im = IntegrityMonitor.getInstance(papResourceName, properties);
// Create an IntegrityAudit
ia = new IntegrityAudit(papResourceName, AUDIT_PAP_PERSISTENCE_UNIT, properties);
ia.startAuditThread();
-
// we are about to call the PDPs and give them their configuration.
// To do that we need to have the URL of this PAP so we can
// construct the Policy file URLs
- setPAPURL(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL));
+ setPapUrl(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_URL));
// Create the policyDBDao
- setPolicyDBDao();
+ setPolicyDbDao();
// Load our PAP engine, first create a factory
ONAPPapEngineFactory factory = ONAPPapEngineFactory
- .newInstance(XACMLProperties.getProperty(XACMLProperties.PROP_PAP_PAPENGINEFACTORY));
+ .newInstance(XACMLProperties.getProperty(XACMLProperties.PROP_PAP_PAPENGINEFACTORY));
// The factory knows how to go about creating a PAP Engine
setPAPEngine(factory.newEngine());
if (((org.onap.policy.xacml.std.pap.StdEngine) papEngine).wasDefaultGroupJustAdded) {
createDefaultGroupOnInit();
}
- policyDBDao.setPapEngine(XACMLPapServlet.papEngine);
- if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_RUN_AUDIT_FLAG))) {
+ policyDbDao.setPapEngine(XACMLPapServlet.papEngine);
+ if (Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_RUN_AUDIT_FLAG))) {
/*
* Auditing the local File System groups to be in sync with the Database
*/
// get an AuditTransaction to lock out all other transactions
- PolicyDBDaoTransaction auditTrans = policyDBDao.getNewAuditTransaction();
+ PolicyDbDaoTransaction auditTrans = policyDbDao.getNewAuditTransaction();
LOGGER.info("PapServlet: calling auditLocalFileSystem for PDP group audit");
LOGGER.info("PapServlet: old group is " + papEngine.getDefaultGroup().toString());
- // get the current filesystem group and update from the database if needed
+ // get the current filesystem group and update from the database
+ // if needed
StdPDPGroup group = (StdPDPGroup) papEngine.getDefaultGroup();
- StdPDPGroup updatedGroup = policyDBDao.auditLocalFileSystem(group);
+ StdPDPGroup updatedGroup = policyDbDao.auditLocalFileSystem(group);
if (updatedGroup != null) {
papEngine.updateGroup(updatedGroup);
}
// sync up the config data from DB to file system
LOGGER.info("PapServlet: Sync config data from DB to file system");
- policyDBDao.synchronizeConfigDataInFileSystem();
+ policyDbDao.synchronizeConfigDataInFileSystem();
// release the transaction lock
auditTrans.close();
// Configurable - have the PAP servlet initiate sending the latest
// PDP policy/pip configuration
// to all its known PDP nodes.
- if (Boolean.parseBoolean(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_INITIATE_PDP_CONFIG))) {
+ if (Boolean.parseBoolean(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_INITIATE_PDP_CONFIG))) {
startInitiateThreadService(new Thread(this));
}
// After startup, the PAP does Heartbeat's to each of the PDPs
throw new ServletException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP not initialized; error: " + e);
} catch (Exception e) {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "XACMLPapServlet",
- " Failed to create engine - unexpected error");
+ " Failed to create engine - unexpected error");
throw new ServletException(
- XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP not initialized; unexpected error: " + e);
+ XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP not initialized; unexpected error: " + e);
}
}
private void createDefaultGroupOnInit() {
- PolicyDBDaoTransaction addNewGroup = null;
+ PolicyDbDaoTransaction addNewGroup = null;
try {
- addNewGroup = policyDBDao.getNewTransaction();
+ addNewGroup = policyDbDao.getNewTransaction();
OnapPDPGroup group = papEngine.getDefaultGroup();
addNewGroup.createGroup(group.getId(), group.getName(), group.getDescription(), "automaticallyAdded");
addNewGroup.commitTransaction();
- addNewGroup = policyDBDao.getNewTransaction();
+ addNewGroup = policyDbDao.getNewTransaction();
addNewGroup.changeDefaultGroup(group, "automaticallyAdded");
addNewGroup.commitTransaction();
} catch (Exception e) {
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "XACMLPapServlet",
- " Error creating new default group in the database");
+ " Error creating new default group in the database");
if (addNewGroup != null) {
addNewGroup.rollbackTransaction();
}
initiateThread.start();
}
- private static void mapperWriteValue(ObjectMapper mapper, HttpServletResponse response, Object value) {
+ @VisibleForTesting
+ protected static void mapperWriteValue(ObjectMapper mapper, HttpServletResponse response, Object value) {
try {
mapper.writeValue(response.getOutputStream(), value);
} catch (Exception e) {
XACMLPapServlet.heartbeatThread.start();
}
- private static void setPolicyDBDao() throws ServletException {
+ private static void setPolicyDbDao() throws ServletException {
try {
- policyDBDao = PolicyDBDao.getPolicyDBDaoInstance();
+ policyDbDao = PolicyDbDao.getPolicyDbDaoInstance();
} 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");
- }
+ public static PolicyDbDao getPolicyDbDao() {
+ return policyDbDao;
+ }
+
+ private static void setPapUrl(String papUrl) {
+ XACMLPapServlet.papUrl = papUrl;
}
- private static void setPAPURL(String papURL) {
- XACMLPapServlet.papURL = papURL;
+ public static String getPapUrl() {
+ return papUrl;
}
- private static void setPAPEngine(PAPPolicyEngine newEngine) {
+ @VisibleForTesting
+ protected static void setPAPEngine(PAPPolicyEngine newEngine) {
XACMLPapServlet.papEngine = newEngine;
}
papDependencyGroupsFlatArray[i] = papDependencyGroupsFlatArray[i].trim();
}
try {
- if (XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS) != null) {
+ if (XACMLProperties.getProperty(XacmlRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS) != null) {
papIntegrityAuditPeriodSeconds = Integer.parseInt(
- XACMLProperties.getProperty(XACMLRestProperties.PAP_INTEGRITY_AUDIT_PERIOD_SECONDS).trim());
+ 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");
+ " ERROR: " + msg + "Bad property entry");
throw e;
}
} catch (Exception e) {
private static void setCommonProperties() throws PAPException {
setConfigHome();
setActionHome();
- papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
+ papDbDriver = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_DRIVER);
if (papDbDriver == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papDbDriver property entry");
+ " ERROR: Bad papDbDriver property entry");
throw new PAPException("papDbDriver is null");
}
setPapDbDriver(papDbDriver);
- papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
+ 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);
+ papDbUser = XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_USER);
if (papDbUser == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papDbUser property entry");
+ " ERROR: Bad papDbUser property entry");
throw new PAPException("papDbUser is null");
}
setPapDbUser(papDbUser);
- papDbPd = CryptoUtils
- .decryptTxtNoExStr(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD, ""));
+ PeCryptoUtils.initAesKey(XACMLProperties.getProperty(XacmlRestProperties.PROP_AES_KEY));
+ papDbPd = PeCryptoUtils.decrypt(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_DB_PASSWORD));
if (papDbPd == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papDbPassword property entry");
+ " ERROR: Bad papDbPassword property entry");
throw new PAPException("papDbPassword is null");
}
setPapDbPassword(papDbPd);
- papResourceName = XACMLProperties.getProperty(XACMLRestProperties.PAP_RESOURCE_NAME);
+ papResourceName = XACMLProperties.getProperty(XacmlRestProperties.PAP_RESOURCE_NAME);
if (papResourceName == null) {
PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "XACMLPapServlet",
- " ERROR: Bad papResourceName property entry");
+ " ERROR: Bad papResourceName property entry");
throw new PAPException("papResourceName is null");
}
environment = XACMLProperties.getProperty("ENVIRONMENT", "DEVL");
msPolicyName = XACMLProperties.getProperty("xacml.policy.msPolicyName");
setMsPolicyName(msPolicyName);
// PDPId File location
- XACMLPapServlet.pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
+ 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. ");
+ + XacmlRestProperties.PROP_PDP_IDFILE);
+ throw new PAPException(
+ "The PDP Id Authentication File Property :" + XacmlRestProperties.PROP_PDP_IDFILE + " is not Valid. ");
}
}
/**
- * Thread used only during PAP startup to initiate change messages to all known PDPs. This must be
- * on a separate thread so that any GET requests from the PDPs during this update can be serviced.
+ * Thread used only during PAP startup to initiate change messages to all known PDPs. This must
+ * be on a separate thread so that any GET requests from the PDPs during this update can be
+ * serviced.
*/
@Override
public void run() {
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, e, "XACMLPapServlet", " Error stopping thread");
}
}
+ // reset pap url
+ setPapUrl(null);
}
private ConsoleAndApiService getAcServiceInstance() {
}
/**
- * Called by: - PDP nodes to register themselves with the PAP, and - Admin Console to make changes
- * in the PDP Groups.
+ * Called by: - PDP nodes to register themselves with the PAP, and - Admin Console to make
+ * changes in the PDP Groups.
*
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ throws ServletException, IOException {
+ OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doPost", "PAP.post");
- PolicyDBDaoTransaction pdpTransaction = null;
+ PolicyDbDaoTransaction pdpTransaction = null;
try {
loggingContext.metricStarted();
im.startTransaction();
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
} catch (AdministrativeStateException ae) {
- String message = "POST interface called for PAP " + papResourceName + " but it has an Administrative"
- + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: "
- + PolicyUtils.CATCH_EXCEPTION;
+ String message =
+ "POST interface called for PAP " + papResourceName + " but it has an Administrative state of "
+ + im.getStateManager().getAdminState() + "\n Exception Message: " + PolicyUtils.CATCH_EXCEPTION;
LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, ae);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
PolicyLogger.audit("Transaction Failed - See Error.log");
setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
return;
- } catch (StandbyStatusException se) {
- String message = "POST interface called for PAP " + papResourceName + " but it has a Standby Status"
- + " of " + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
- LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, se);
+ } catch (IntegrityMonitorException ime) {
+ String message =
+ "POST interface called for PAP " + papResourceName + " but it has an Administrative state of "
+ + im.getStateManager().getAdminState() + " and a Standby Status of "
+ + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+ LOGGER.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message, ime);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPost im startTransaction");
loggingContext.transactionEnded();
}
try {
loggingContext.metricStarted();
- XACMLRest.dumpRequest(request);
+ XacmlRest.dumpRequest(request);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPost dumpRequest");
// since getParameter reads the content string, explicitly get the
LOGGER.info("Unknown PDP: " + id);
// Check PDP ID
if (CheckPDP.validateID(id)) {
- pdpTransaction = policyDBDao.getNewTransaction();
+ pdpTransaction = policyDbDao.getNewTransaction();
try {
pdpTransaction.addPdpToGroup(id, XACMLPapServlet.papEngine.getDefaultGroup().getId(), id,
- "Registered on first startup", Integer.parseInt(jmxport), "PDP autoregister");
+ "Registered on first startup", Integer.parseInt(jmxport), "PDP autoregister");
XACMLPapServlet.papEngine.newPDP(id, XACMLPapServlet.papEngine.getDefaultGroup(), id,
- "Registered on first startup", Integer.parseInt(jmxport));
+ "Registered on first startup", Integer.parseInt(jmxport));
} catch (NullPointerException | PAPException | IllegalArgumentException | IllegalStateException
- | PersistenceException | PolicyDBException e) {
+ | PersistenceException | PolicyDbException e) {
pdpTransaction.rollbackTransaction();
String message = "Failed to create new PDP for id: " + id;
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet", " " + message);
loggingContext.transactionEnded();
PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS + " " + message);
setResponseError(response, HttpServletResponse.SC_UNAUTHORIZED,
- "PDP not Authorized to connect to this PAP. Please contact the PAP Admin for registration.");
+ "PDP not Authorized to connect to this PAP. Please contact the PAP Admin for registration.");
PolicyLogger.audit("Transaction Failed - See Error.log");
im.endTransaction();
return;
PolicyLogger.metrics("XACMLPapServlet doPost commitTransaction");
} catch (Exception e) {
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet",
- "Could not commit transaction to put pdp in the database");
+ "Could not commit transaction to put pdp in the database");
}
}
if (jmxport != null && !"".equals(jmxport)) {
LOGGER.error(e);
}
if (group == null) {
- PolicyLogger.error(
- MessageCodes.ERROR_PROCESS_FLOW + " PDP not associated with any group, even the default");
+ PolicyLogger
+ .error(MessageCodes.ERROR_PROCESS_FLOW + " PDP not associated with any group, even the default");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
setResponseError(response, HttpServletResponse.SC_UNAUTHORIZED,
- "PDP not associated with any group, even the default");
+ "PDP not associated with any group, even the default");
im.endTransaction();
return;
}
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ throws ServletException, IOException {
+ OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doGet", "PAP.get");
loggingContext.metricStarted();
- XACMLRest.dumpRequest(request);
+ XacmlRest.dumpRequest(request);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doGet dumpRequest");
String pathInfo = request.getRequestURI();
im.startTransaction();
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doGet im startTransaction");
- } catch (AdministrativeStateException ae) {
- String message = "GET interface called for PAP " + papResourceName + " but it has an Administrative"
- + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: " + ae.getMessage();
- LOGGER.info(message, ae);
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
- return;
- } catch (StandbyStatusException se) {
- String message = "GET interface called for PAP " + papResourceName + " but it has a Standby Status" + " of "
- + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
- LOGGER.info(message, se);
+ } catch (IntegrityMonitorException ime) {
+ String message =
+ "GET interface called for PAP " + papResourceName + " but it has an Administrative state of "
+ + im.getStateManager().getAdminState() + " and a Standby Status of "
+ + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+ LOGGER.info(message, ime);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
return;
} else {
String message =
- "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
+ "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
return;
}
String message =
- "Unknown PDP: " + id + " from " + request.getRemoteHost() + " us: " + request.getLocalAddr();
+ "Unknown PDP: " + id + " from " + request.getRemoteHost() + " us: " + request.getLocalAddr();
PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
}
try {
LOGGER.warn("PolicyDebugging: Policy Validity: " + policy.isValid() + "\n " + "Policy Name : "
- + policy.getName() + "\n Policy URI: " + policy.getLocation().toString());
+ + policy.getName() + "\n Policy URI: " + policy.getLocation().toString());
} catch (PAPException | IOException e) {
LOGGER.error(e);
}
- try (InputStream is =
+ try (
+ InputStream is =
new FileInputStream(((StdPDPGroup) group).getDirectory().toString() + File.separator + policyId);
- OutputStream os = response.getOutputStream()) {
+ OutputStream os = response.getOutputStream()) {
// Send the policy back
IOUtils.copy(is, os);
response.setStatus(HttpServletResponse.SC_OK);
*/
@Override
protected void doPut(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ throws ServletException, IOException {
+ OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doPut", "PAP.put");
try {
loggingContext.metricStarted();
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPut im startTransaction");
} catch (IntegrityMonitorException e) {
- String message = "PUT interface called for PAP " + papResourceName;
- if (e instanceof AdministrativeStateException) {
- message += " but it has an Administrative state of " + im.getStateManager().getAdminState();
- } else if (e instanceof StandbyStatusException) {
- message += " but it has a Standby Status of " + im.getStateManager().getStandbyStatus();
- } else {
- message += " but an exception occurred";
-
- }
- message += "\n Exception Message: " + e.getMessage();
-
+ String message =
+ "PUT interface called for PAP " + papResourceName + " but it has an Administrative state of "
+ + im.getStateManager().getAdminState() + " and a Standby Status of "
+ + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + e.getMessage();
LOGGER.info(message, e);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
String apiflag = request.getParameter("apiflag");
// For Debug purposes
if (!"api".equals(apiflag) && PolicyLogger.isDebugEnabled()) {
- XACMLRest.dumpRequest(request);
+ XacmlRest.dumpRequest(request);
PolicyLogger.metrics("XACMLPapServlet doPut dumpRequest");
}
loggingContext.metricEnded();
LOGGER.info("XACMLPapServlet: Calling PolicyDBDao to handlIncomingHttpNotification");
HandleIncomingNotifications handleIncomingNotifications = new HandleIncomingNotifications();
handleIncomingNotifications.handleIncomingHttpNotification(policyDBDaoRequestUrl,
- policyDBDaoRequestEntityId, policyDBDaoRequestEntityType, policyDBDaoRequestExtraData, this);
+ policyDBDaoRequestEntityId, policyDBDaoRequestEntityType, policyDBDaoRequestExtraData, this);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doPut handle incoming http notification");
response.setStatus(200);
return;
} else {
String message =
- "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
+ "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
return;
}
/*
- * This is to update the PDP Group with the policy/policies being pushed Part of a 2 step process to
- * push policies to the PDP that can now be done From both the Admin Console and the PolicyEngine
- * API
+ * This is to update the PDP Group with the policy/policies being pushed Part of a 2 step
+ * process to push policies to the PDP that can now be done From both the Admin Console and
+ * the PolicyEngine API
*/
String groupId = request.getParameter(GROUPID);
if (groupId != null) {
if (apiflag != null) {
if (!authorizeRequest(request)) {
String message =
- "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
+ "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
*/
@Override
protected void doDelete(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- ONAPLoggingContext loggingContext = ONAPLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
+ throws ServletException, IOException {
+ OnapLoggingContext loggingContext = OnapLoggingUtils.getLoggingContextForRequest(request, baseLoggingContext);
setLoggingContext(loggingContext, "doDelete", "PAP.delete");
try {
loggingContext.metricStarted();
im.startTransaction();
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doDelete im startTransaction");
- } catch (AdministrativeStateException ae) {
- String message = "DELETE interface called for PAP " + papResourceName + " but it has an Administrative"
- + " state of " + im.getStateManager().getAdminState() + "\n Exception Message: " + ae.getMessage();
- LOGGER.info(message, ae);
- PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
- loggingContext.transactionEnded();
- PolicyLogger.audit("Transaction Failed - See Error.log");
- setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message);
- return;
- } catch (StandbyStatusException se) {
- String message = "PUT interface called for PAP " + papResourceName + " but it has a Standby Status" + " of "
- + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + se.getMessage();
- LOGGER.info(message, se);
+ } catch (IntegrityMonitorException ime) {
+ String message =
+ "DELETE interface called for PAP " + papResourceName + " but it has an Administrative state of "
+ + im.getStateManager().getAdminState() + " and a Standby Status of "
+ + im.getStateManager().getStandbyStatus() + "\n Exception Message: " + ime.getMessage();
+ LOGGER.info(message, ime);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
return;
}
loggingContext.metricStarted();
- XACMLRest.dumpRequest(request);
+ XacmlRest.dumpRequest(request);
loggingContext.metricEnded();
PolicyLogger.metrics("XACMLPapServlet doDelete dumpRequest");
String groupId = request.getParameter(GROUPID);
if (apiflag != null) {
if (!authorizeRequest(request)) {
String message =
- "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
+ "PEP not Authorized for making this Request!! \n Contact Administrator for this Scope. ";
PolicyLogger.error(MessageCodes.ERROR_PERMISSIONS + " " + message);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
String localReferencedPolicies = policies.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES);
if (localRootPolicies == null || localReferencedPolicies == null) {
LOGGER.warn(XACMLErrorConstants.ERROR_DATA_ISSUE + "Missing property on PAP server: RootPolicies="
- + localRootPolicies + " ReferencedPolicies=" + localReferencedPolicies);
+ + localRootPolicies + " ReferencedPolicies=" + localReferencedPolicies);
return false;
}
// Compare the policies and pipconfig properties to the pdpProperties
Properties pdpPolicies = XACMLProperties.getPolicyProperties(pdpProperties, false);
Properties pdpPipConfig = XACMLProperties.getPipProperties(pdpProperties);
if (localRootPolicies.equals(pdpPolicies.getProperty(XACMLProperties.PROP_ROOTPOLICIES))
- && localReferencedPolicies.equals(pdpPolicies.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES))
- && pdpPipConfig.equals(pipconfig)) {
+ && localReferencedPolicies.equals(pdpPolicies.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES))
+ && pdpPipConfig.equals(pipconfig)) {
// The PDP is current
return true;
}
return false;
}
- private void populatePolicyURL(StringBuffer urlPath, Properties policies) {
+ @VisibleForTesting
+ protected void populatePolicyURL(StringBuffer urlPath, Properties policies) {
String lists[] = new String[2];
lists[0] = policies.getProperty(XACMLProperties.PROP_ROOTPOLICIES);
lists[1] = policies.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES);
}
protected String getPDPID(HttpServletRequest request) {
- String pdpURL = request.getHeader(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID);
+ String pdpURL = request.getHeader(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID);
if (pdpURL == null || pdpURL.isEmpty()) {
// Should send back its port for identification
LOGGER.warn(XACMLErrorConstants.ERROR_DATA_ISSUE + "PDP did not send custom header");
}
protected String getPDPJMX(HttpServletRequest request) {
- String pdpJMMX = request.getHeader(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT);
+ String pdpJMMX = request.getHeader(XacmlRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT);
if (pdpJMMX == null || pdpJMMX.isEmpty()) {
// Should send back its port for identification
LOGGER.warn(XACMLErrorConstants.ERROR_DATA_ISSUE
- + "PDP did not send custom header for JMX Port so the value of 0 is assigned");
+ + "PDP did not send custom header for JMX Port so the value of 0 is assigned");
return null;
}
return pdpJMMX;
* @throws IOException
*/
public void updateGroupsFromAPI(HttpServletRequest request, HttpServletResponse response, String groupId,
- ONAPLoggingContext loggingContext) throws IOException {
- PolicyDBDaoTransaction acPutTransaction = policyDBDao.getNewTransaction();
+ OnapLoggingContext loggingContext) throws IOException {
+ PolicyDbDaoTransaction acPutTransaction = policyDbDao.getNewTransaction();
PolicyLogger.audit("PolicyDBDaoTransaction started for updateGroupsFromAPI");
try {
String userId = request.getParameter("userId");
LOGGER.info("Removing old version of the policy");
for (PDPPolicy existingPolicy : group.getPolicies()) {
if (existingPolicy.getName().equals(policy.getName())
- && !existingPolicy.getId().equals(policy.getId())) {
+ && !existingPolicy.getId().equals(policy.getId())) {
group.removePolicy(existingPolicy);
LOGGER.info("Removing policy: " + existingPolicy);
break;
// Assume that this is an update of an existing PDP Group
loggingContext.setServiceName("PolicyEngineAPI:PAP.updateGroup");
try {
- acPutTransaction.updateGroup(group, "XACMLPapServlet.doACPut", null);
+ acPutTransaction.updateGroup(group, "XACMLPapServlet.doACPut", userId);
} catch (Exception e) {
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet",
- " Error while updating group in the database: " + "group=" + group.getId());
+ " Error while updating group in the database: " + "group=" + group.getId());
throw new PAPException(e.getMessage());
}
LOGGER.info("Success");
if (policy != null
- && ((policy.getId().contains("Config_MS_")) || (policy.getId().contains("BRMS_Param")))) {
+ && ((policy.getId().contains("Config_MS_")) || (policy.getId().contains("BRMS_Param")))) {
PushPolicyHandler pushPolicyHandler = PushPolicyHandler.getInstance();
if (pushPolicyHandler.preSafetyCheck(policy, configHome)) {
LOGGER.debug("Precheck Successful.");
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
String message = XACMLErrorConstants.ERROR_PROCESS_FLOW
- + "Exception in request to update group from API - See Error.log on on the PAP.";
+ + "Exception in request to update group from API - See Error.log on on the PAP.";
setResponseError(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.addHeader("error", ADD_GROUP_ERROR);
}
/*
- * HELPER to change Group status when PDP status is changed (Must NOT be called from a method that
- * is synchronized on the papEngine or it may deadlock)
+ * HELPER to change Group status when PDP status is changed (Must NOT be called from a method
+ * that is synchronized on the papEngine or it may deadlock)
*/
public void setPDPSummaryStatus(OnapPDP pdp, PDPStatus.Status newStatus) throws PAPException {
setPDPSummaryStatus(pdp, newStatus.toString());
}
/*
- * Callback methods telling this servlet to notify PDPs of changes made by the PAP StdEngine in the
- * PDP group directories
+ * Callback methods telling this servlet to notify PDPs of changes made by the PAP StdEngine in
+ * the PDP group directories
*/
@Override
public void changed() {
}
}
- public void changed(ONAPLoggingContext loggingContext) {
+ public void changed(OnapLoggingContext loggingContext) {
// all PDPs in all groups need to be updated/sync'd
Set<OnapPDPGroup> groups;
try {
}
}
- public void groupChanged(OnapPDPGroup group, ONAPLoggingContext loggingContext) {
+ public void groupChanged(OnapPDPGroup group, OnapLoggingContext loggingContext) {
// all PDPs within one group need to be updated/sync'd
for (OnapPDP pdp : group.getOnapPdps()) {
pdpChanged(pdp, loggingContext, getPdpDataByGroup(group));
}
}
- public void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext) {
+ public void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext) {
// kick off a thread to do an event notification for each PDP.
// This needs to be on a separate thread so that PDPs that do not
// respond (down, non-existent, etc)
}
}
- private void pdpChanged(OnapPDP pdp, ONAPLoggingContext loggingContext, List<Properties> pdpDataByGroup) {
+ private void pdpChanged(OnapPDP pdp, OnapLoggingContext loggingContext, List<Properties> pdpDataByGroup) {
Thread t = new Thread(new UpdatePdpThread(pdp, loggingContext, pdpDataByGroup));
if (CheckPDP.validateID(pdp.getId())) {
t.start();
return dataToNotify.setPolicyConfigProperties(pdp, papEngine);
}
- private void testService(ONAPLoggingContext loggingContext, HttpServletResponse response) throws IOException {
+ private void testService(OnapLoggingContext loggingContext, HttpServletResponse response) throws IOException {
LOGGER.info("Test request received");
try {
im.evaluateSanity();
submsg = " Standby Status is NOT PROVIDING SERVICE.";
}
- String message = "GET:/pap/test called and PAP " + papResourceName + submsg + " Exception Message: "
- + e.getMessage();
+ String message =
+ "GET:/pap/test called and PAP " + papResourceName + submsg + " Exception Message: " + e.getMessage();
LOGGER.info(message, e);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
eMsg = "No Exception Message";
}
String message = "GET:/pap/test called and PAP " + papResourceName + " has had a subsystem failure."
- + " Exception Message: " + eMsg;
+ + " Exception Message: " + eMsg;
LOGGER.info(message, e);
PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR + " " + message);
loggingContext.transactionEnded();
}
}
- private void setLoggingContext(ONAPLoggingContext loggingContext, String methodType, String serviceName) {
+ private void setLoggingContext(OnapLoggingContext loggingContext, String methodType, String serviceName) {
loggingContext.transactionStarted();
loggingContext.setServiceName(serviceName);
- if (loggingContext.getRequestID() == null || "".equals(loggingContext.getRequestID())) {
+ if (loggingContext.getRequestId() == null || "".equals(loggingContext.getRequestId())) {
UUID requestID = UUID.randomUUID();
- loggingContext.setRequestID(requestID.toString());
- PolicyLogger.info(
- "requestID not provided in call to XACMLPapServlet ('" + methodType + "') so we generated one");
+ loggingContext.setRequestId(requestID.toString());
+ PolicyLogger
+ .info("requestID not provided in call to XACMLPapServlet ('" + methodType + "') so we generated one");
} else {
PolicyLogger.info("requestID was provided in call to XACMLPapServlet ('" + methodType + "')");
}
private static void loadWebapps() throws PAPException {
if (actionHome == null || configHome == null) {
- Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS));
+ Path webappsPath = Paths.get(XACMLProperties.getProperty(XacmlRestProperties.PROP_PAP_WEBAPPS));
// Sanity Check
if (webappsPath == null) {
- PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
+ PolicyLogger.error("Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS);
throw new PAPException(
- "Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
+ "Invalid Webapps Path Location property : " + XacmlRestProperties.PROP_PAP_WEBAPPS);
}
Path webappsPathConfig = Paths.get(webappsPath.toString() + File.separator + "Config");
Path webappsPathAction = Paths.get(webappsPath.toString() + File.separator + "Action");
Files.createDirectories(webappsPathConfig);
} catch (IOException e) {
PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XACMLPapServlet",
- "Failed to create config directory: " + webappsPathConfig.toAbsolutePath().toString());
+ "Failed to create config directory: " + webappsPathConfig.toAbsolutePath().toString());
}
}
if (Files.notExists(webappsPathAction)) {
Files.createDirectories(webappsPathAction);
} catch (IOException e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create action directory: "
- + webappsPathAction.toAbsolutePath().toString(), e);
+ + webappsPathAction.toAbsolutePath().toString(), e);
}
}
actionHome = webappsPathAction.toString();
actionHome = getActionHome();
}
- public static EntityManagerFactory getEmf() {
- return emf;
- }
-
public IntegrityAudit getIa() {
return ia;
}
return papEngine;
}
- public static PolicyDBDaoTransaction getDbDaoTransaction() {
- return policyDBDao.getNewTransaction();
+ public static PolicyDbDaoTransaction getDbDaoTransaction() {
+ return policyDbDao.getNewTransaction();
}
public static String getPapDbDriver() {
XACMLPapServlet.msPolicyName = msPolicyName;
}
- public ONAPLoggingContext getBaseLoggingContext() {
+ public OnapLoggingContext getBaseLoggingContext() {
return baseLoggingContext;
}
- public void setBaseLoggingContext(ONAPLoggingContext baseLoggingContext) {
+ public void setBaseLoggingContext(OnapLoggingContext baseLoggingContext) {
this.baseLoggingContext = baseLoggingContext;
}
}