@Test @Category(UnitTest.class) public void testGettingUnencryptedPropertyWhenMasterPasswordIsSet() { setUpPropererties(true); assertEquals(decryptedValue, MrGeoProperties.getInstance().getProperty(ENCRYPTED_TEST_PROPERTY)); }
@SuppressWarnings("squid:S1166") @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") public static synchronized Properties getInstance() { if (properties == null) { String masterPassword = System.getProperty(MRGEO_ENCRYPTION_MASTER_PASSWORD_PROPERTY); if (masterPassword != null) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(masterPassword); properties = new EncryptableProperties(encryptor); } else { properties = new Properties(); } FileInputStream fis = null; try { String conf = findMrGeoConf(); fis = new FileInputStream(conf); properties.load(fis); } catch (IOException e) { try { properties.load(MrGeoProperties.class.getClassLoader().getResourceAsStream(MrGeoConstants.MRGEO_SETTINGS)); } catch (Exception ignored) { } } finally { if (fis != null) { try { fis.close(); } catch (IOException ignored) { } } } } return properties; }
MrGeoProperties { @SuppressWarnings("squid:S1166") @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") public static synchronized Properties getInstance() { if (properties == null) { String masterPassword = System.getProperty(MRGEO_ENCRYPTION_MASTER_PASSWORD_PROPERTY); if (masterPassword != null) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(masterPassword); properties = new EncryptableProperties(encryptor); } else { properties = new Properties(); } FileInputStream fis = null; try { String conf = findMrGeoConf(); fis = new FileInputStream(conf); properties.load(fis); } catch (IOException e) { try { properties.load(MrGeoProperties.class.getClassLoader().getResourceAsStream(MrGeoConstants.MRGEO_SETTINGS)); } catch (Exception ignored) { } } finally { if (fis != null) { try { fis.close(); } catch (IOException ignored) { } } } } return properties; } }
MrGeoProperties { @SuppressWarnings("squid:S1166") @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") public static synchronized Properties getInstance() { if (properties == null) { String masterPassword = System.getProperty(MRGEO_ENCRYPTION_MASTER_PASSWORD_PROPERTY); if (masterPassword != null) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(masterPassword); properties = new EncryptableProperties(encryptor); } else { properties = new Properties(); } FileInputStream fis = null; try { String conf = findMrGeoConf(); fis = new FileInputStream(conf); properties.load(fis); } catch (IOException e) { try { properties.load(MrGeoProperties.class.getClassLoader().getResourceAsStream(MrGeoConstants.MRGEO_SETTINGS)); } catch (Exception ignored) { } } finally { if (fis != null) { try { fis.close(); } catch (IOException ignored) { } } } } return properties; } private  MrGeoProperties(); }
MrGeoProperties { @SuppressWarnings("squid:S1166") @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") public static synchronized Properties getInstance() { if (properties == null) { String masterPassword = System.getProperty(MRGEO_ENCRYPTION_MASTER_PASSWORD_PROPERTY); if (masterPassword != null) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(masterPassword); properties = new EncryptableProperties(encryptor); } else { properties = new Properties(); } FileInputStream fis = null; try { String conf = findMrGeoConf(); fis = new FileInputStream(conf); properties.load(fis); } catch (IOException e) { try { properties.load(MrGeoProperties.class.getClassLoader().getResourceAsStream(MrGeoConstants.MRGEO_SETTINGS)); } catch (Exception ignored) { } } finally { if (fis != null) { try { fis.close(); } catch (IOException ignored) { } } } } return properties; } private  MrGeoProperties(); @SuppressWarnings("squid:S1166") // Exception caught and handled @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") static synchronized Properties getInstance(); static boolean isDevelopmentMode(); @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "false positive, no user control of path") static String findMrGeoConf(); static void resetProperties(); }
MrGeoProperties { @SuppressWarnings("squid:S1166") @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") public static synchronized Properties getInstance() { if (properties == null) { String masterPassword = System.getProperty(MRGEO_ENCRYPTION_MASTER_PASSWORD_PROPERTY); if (masterPassword != null) { StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(masterPassword); properties = new EncryptableProperties(encryptor); } else { properties = new Properties(); } FileInputStream fis = null; try { String conf = findMrGeoConf(); fis = new FileInputStream(conf); properties.load(fis); } catch (IOException e) { try { properties.load(MrGeoProperties.class.getClassLoader().getResourceAsStream(MrGeoConstants.MRGEO_SETTINGS)); } catch (Exception ignored) { } } finally { if (fis != null) { try { fis.close(); } catch (IOException ignored) { } } } } return properties; } private  MrGeoProperties(); @SuppressWarnings("squid:S1166") // Exception caught and handled @SuppressFBWarnings(value = {"DE_MIGHT_IGNORE", "PATH_TRAVERSAL_IN"}, justification = "Ignored exception causes empty properties object, which is fine, " + "false positive, user can't control the path") static synchronized Properties getInstance(); static boolean isDevelopmentMode(); @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "false positive, no user control of path") static String findMrGeoConf(); static void resetProperties();  }