+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot Proceed without PDP_URLs");
+ }
+ }
+
+ private void readPDPPropertyURL(Properties prop, String propertyKey) throws PolicyEngineException {
+ final String propertyValue = prop.getProperty(propertyKey);
+ if (propertyValue == null) {
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE
+ + "Properties file doesn't have the PDP_URL parameter");
+ }
+ if (propertyValue.contains(SEMICOLLON)) {
+ final List<String> pdpDefault = Arrays.asList(propertyValue.split(REGEX));
+ for (final String pdpVal : pdpDefault) {
+ readPDPParam(pdpVal);
+ }
+ } else {
+ readPDPParam(propertyValue);
+ }
+ }
+
+ private void setNotificationType(final String propertyValue) {
+ if (propertyValue == null) {
+ notificationType.add(DEFAULT_NOTIFICATION);
+ LOGGER.info(
+ "Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets");
+ } else {
+ notificationType = getPropertyValueAsList(propertyValue.trim());
+ }
+ }
+
+ private String getClientKeyFromProperties(final Properties prop) {
+ final String clientKeyValue = prop.getProperty(CLIENT_KEY_PROP_NAME);
+ try {
+ return PolicyUtils.decode(clientKeyValue);
+ } catch (UnsupportedEncodingException | IllegalArgumentException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS
+ + " Cannot Decode the given Password Proceeding with given Password!!", e);
+ }
+ return clientKeyValue;
+ }
+
+ private Properties getProperties(final String propertyFilePath) throws PolicyEngineException {
+ // Adding logic for remote Properties file.
+ if (propertyFilePath.startsWith(HTTP)) {
+ return getRemoteProperties(propertyFilePath);
+ }
+ return getFileProperties(propertyFilePath);
+ }
+
+ private Properties getFileProperties(final String propertyFilePath) throws PolicyEngineException {
+ final 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")) {
+ try (BufferedReader bufferedReader = Files.newBufferedReader(file);) {
+ final Properties prop = new Properties();
+ prop.load(bufferedReader);
+ return prop;
+ } catch (final IOException exception) {
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + exception);
+ throw new PolicyEngineException(
+ XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Load the Properties file", exception);
+ }
+ }
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file " + propertyFilePath);
+ throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Not a .properties file");
+ }
+
+ private Properties getRemoteProperties(final String propertyFilePath) throws PolicyEngineException {
+ try {
+ final URL configURL = new URL(propertyFilePath);
+ final URLConnection connection = configURL.openConnection();
+ final Properties prop = new Properties();
+ prop.load(connection.getInputStream());
+ return prop;
+ } catch (final IOException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);