- // Adding logic for remote Properties file.
- Properties prop = new Properties();
- if (propertyFilePath.startsWith("http")) {
- URL configURL;
- try {
- configURL = new URL(propertyFilePath);
- URLConnection connection = null;
- connection = configURL.openConnection();
- prop.load(connection.getInputStream());
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- throw new PolicyEngineException(
- XACMLErrorConstants.ERROR_DATA_ISSUE + "Maformed property URL " + e.getMessage());
- }
- } else {
- Path file = Paths.get(propertyFilePath);
- if (!file.toFile().exists()) {
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE
- + "File doesn't exist in the specified Path " + file.toString());
- }
- if (file.toString().endsWith(".properties")) {
- InputStream in;
- prop = new Properties();
- try {
- in = new FileInputStream(file.toFile());
- prop.load(in);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- throw new PolicyEngineException(
- XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", e);
- }
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath);
- throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file");
- }
- }
- // UEB and DMAAP Settings
- String checkType = prop.getProperty("NOTIFICATION_TYPE");
- String serverList = prop.getProperty("NOTIFICATION_SERVERS");
- topic = prop.getProperty("NOTIFICATION_TOPIC");
- apiKey = prop.getProperty("UEB_API_KEY");
- apiSecret = prop.getProperty("UEB_API_SECRET");
-
- if (checkType == null) {
- notificationType.add(DEFAULT_NOTIFICATION);
- LOGGER.info(
- "Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets");
- } else {
- checkType = checkType.trim();
- if (checkType.contains(",")) {
- notificationType = new ArrayList<>(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(",")));
- } else {
- notificationType = new ArrayList<>();
- notificationType.add(checkType);
- }
- }
- if (serverList == null) {
- notificationType.clear();
- notificationType.add(DEFAULT_NOTIFICATION);
- LOGGER.info(
- "Properties file doesn't have the NOTIFICATION_SERVERS parameter system will use defualt websockets");
- } else {
- serverList = serverList.trim();
- if (serverList.contains(",")) {
- notificationURLList = new ArrayList<>(Arrays.asList(serverList.split(",")));
- } else {
- notificationURLList = new ArrayList<>();
- notificationURLList.add(serverList);
- }
- }