Skip to content

Commit

Permalink
Cleanup from audit
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@3514 3d1905a2-6b24-0410-a738-b14d5a86fcbd
  • Loading branch information
mguessan committed Jan 13, 2024
1 parent 078454e commit 5c4a83a
Showing 1 changed file with 70 additions and 70 deletions.
140 changes: 70 additions & 70 deletions src/java/davmail/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class Settings {
private Settings() {
}

private static final Properties SETTINGS = new Properties() {
private static final Properties SETTINGS_PROPERTIES = new Properties() {
@Override
public synchronized Enumeration<Object> keys() {
Enumeration<Object> keysEnumeration = super.keys();
Expand Down Expand Up @@ -108,7 +108,7 @@ public static synchronized boolean isFirstStart() {
* @throws IOException on error
*/
public static synchronized void load(InputStream inputStream) throws IOException {
SETTINGS.load(inputStream);
SETTINGS_PROPERTIES.load(inputStream);
updateLoggingConfig();
}

Expand Down Expand Up @@ -144,70 +144,70 @@ public static synchronized void load() {
* Ports above 1024 for unix/linux
*/
public static void setDefaultSettings() {
SETTINGS.put("davmail.mode", "EWS");
SETTINGS.put("davmail.url", O365_URL);
SETTINGS.put("davmail.popPort", "1110");
SETTINGS.put("davmail.imapPort", "1143");
SETTINGS.put("davmail.smtpPort", "1025");
SETTINGS.put("davmail.caldavPort", "1080");
SETTINGS.put("davmail.ldapPort", "1389");
SETTINGS.put("davmail.clientSoTimeout", "");
SETTINGS.put("davmail.keepDelay", "30");
SETTINGS.put("davmail.sentKeepDelay", "0");
SETTINGS.put("davmail.caldavPastDelay", "0");
SETTINGS.put("davmail.caldavAutoSchedule", Boolean.TRUE.toString());
SETTINGS.put("davmail.imapIdleDelay", "");
SETTINGS.put("davmail.folderSizeLimit", "");
SETTINGS.put("davmail.enableKeepAlive", Boolean.FALSE.toString());
SETTINGS.put("davmail.allowRemote", Boolean.FALSE.toString());
SETTINGS.put("davmail.bindAddress", "");
SETTINGS.put("davmail.useSystemProxies", Boolean.FALSE.toString());
SETTINGS.put("davmail.enableProxy", Boolean.FALSE.toString());
SETTINGS.put("davmail.enableKerberos", "false");
SETTINGS.put("davmail.disableUpdateCheck", "false");
SETTINGS.put("davmail.proxyHost", "");
SETTINGS.put("davmail.proxyPort", "");
SETTINGS.put("davmail.proxyUser", "");
SETTINGS.put("davmail.proxyPassword", "");
SETTINGS.put("davmail.noProxyFor", "");
SETTINGS.put("davmail.server", Boolean.FALSE.toString());
SETTINGS.put("davmail.server.certificate.hash", "");
SETTINGS.put("davmail.caldavAlarmSound", "");
SETTINGS.put("davmail.carddavReadPhoto", Boolean.TRUE.toString());
SETTINGS.put("davmail.forceActiveSyncUpdate", Boolean.FALSE.toString());
SETTINGS.put("davmail.showStartupBanner", Boolean.TRUE.toString());
SETTINGS.put("davmail.disableGuiNotifications", Boolean.FALSE.toString());
SETTINGS.put("davmail.disableTrayActivitySwitch", Boolean.FALSE.toString());
SETTINGS.put("davmail.imapAutoExpunge", Boolean.TRUE.toString());
SETTINGS.put("davmail.imapAlwaysApproxMsgSize", Boolean.FALSE.toString());
SETTINGS.put("davmail.popMarkReadOnRetr", Boolean.FALSE.toString());
SETTINGS.put("davmail.smtpSaveInSent", Boolean.TRUE.toString());
SETTINGS.put("davmail.ssl.keystoreType", "");
SETTINGS.put("davmail.ssl.keystoreFile", "");
SETTINGS.put("davmail.ssl.keystorePass", "");
SETTINGS.put("davmail.ssl.keyPass", "");
SETTINGS_PROPERTIES.put("davmail.mode", "EWS");
SETTINGS_PROPERTIES.put("davmail.url", O365_URL);
SETTINGS_PROPERTIES.put("davmail.popPort", "1110");
SETTINGS_PROPERTIES.put("davmail.imapPort", "1143");
SETTINGS_PROPERTIES.put("davmail.smtpPort", "1025");
SETTINGS_PROPERTIES.put("davmail.caldavPort", "1080");
SETTINGS_PROPERTIES.put("davmail.ldapPort", "1389");
SETTINGS_PROPERTIES.put("davmail.clientSoTimeout", "");
SETTINGS_PROPERTIES.put("davmail.keepDelay", "30");
SETTINGS_PROPERTIES.put("davmail.sentKeepDelay", "0");
SETTINGS_PROPERTIES.put("davmail.caldavPastDelay", "0");
SETTINGS_PROPERTIES.put("davmail.caldavAutoSchedule", Boolean.TRUE.toString());
SETTINGS_PROPERTIES.put("davmail.imapIdleDelay", "");
SETTINGS_PROPERTIES.put("davmail.folderSizeLimit", "");
SETTINGS_PROPERTIES.put("davmail.enableKeepAlive", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.allowRemote", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.bindAddress", "");
SETTINGS_PROPERTIES.put("davmail.useSystemProxies", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.enableProxy", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.enableKerberos", "false");
SETTINGS_PROPERTIES.put("davmail.disableUpdateCheck", "false");
SETTINGS_PROPERTIES.put("davmail.proxyHost", "");
SETTINGS_PROPERTIES.put("davmail.proxyPort", "");
SETTINGS_PROPERTIES.put("davmail.proxyUser", "");
SETTINGS_PROPERTIES.put("davmail.proxyPassword", "");
SETTINGS_PROPERTIES.put("davmail.noProxyFor", "");
SETTINGS_PROPERTIES.put("davmail.server", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.server.certificate.hash", "");
SETTINGS_PROPERTIES.put("davmail.caldavAlarmSound", "");
SETTINGS_PROPERTIES.put("davmail.carddavReadPhoto", Boolean.TRUE.toString());
SETTINGS_PROPERTIES.put("davmail.forceActiveSyncUpdate", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.showStartupBanner", Boolean.TRUE.toString());
SETTINGS_PROPERTIES.put("davmail.disableGuiNotifications", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.disableTrayActivitySwitch", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.imapAutoExpunge", Boolean.TRUE.toString());
SETTINGS_PROPERTIES.put("davmail.imapAlwaysApproxMsgSize", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.popMarkReadOnRetr", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.smtpSaveInSent", Boolean.TRUE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.keystoreType", "");
SETTINGS_PROPERTIES.put("davmail.ssl.keystoreFile", "");
SETTINGS_PROPERTIES.put("davmail.ssl.keystorePass", "");
SETTINGS_PROPERTIES.put("davmail.ssl.keyPass", "");
if (isWindows()) {
// default to MSCAPI on windows for native client certificate access
SETTINGS.put("davmail.ssl.clientKeystoreType", "MSCAPI");
SETTINGS_PROPERTIES.put("davmail.ssl.clientKeystoreType", "MSCAPI");
} else {
SETTINGS.put("davmail.ssl.clientKeystoreType", "");
SETTINGS_PROPERTIES.put("davmail.ssl.clientKeystoreType", "");
}
SETTINGS.put("davmail.ssl.clientKeystoreFile", "");
SETTINGS.put("davmail.ssl.clientKeystorePass", "");
SETTINGS.put("davmail.ssl.pkcs11Library", "");
SETTINGS.put("davmail.ssl.pkcs11Config", "");
SETTINGS.put("davmail.ssl.nosecurepop", Boolean.FALSE.toString());
SETTINGS.put("davmail.ssl.nosecureimap", Boolean.FALSE.toString());
SETTINGS.put("davmail.ssl.nosecuresmtp", Boolean.FALSE.toString());
SETTINGS.put("davmail.ssl.nosecurecaldav", Boolean.FALSE.toString());
SETTINGS.put("davmail.ssl.nosecureldap", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.clientKeystoreFile", "");
SETTINGS_PROPERTIES.put("davmail.ssl.clientKeystorePass", "");
SETTINGS_PROPERTIES.put("davmail.ssl.pkcs11Library", "");
SETTINGS_PROPERTIES.put("davmail.ssl.pkcs11Config", "");
SETTINGS_PROPERTIES.put("davmail.ssl.nosecurepop", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.nosecureimap", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.nosecuresmtp", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.nosecurecaldav", Boolean.FALSE.toString());
SETTINGS_PROPERTIES.put("davmail.ssl.nosecureldap", Boolean.FALSE.toString());

// logging
SETTINGS.put("log4j.rootLogger", Level.WARN.toString());
SETTINGS.put("log4j.logger.davmail", Level.DEBUG.toString());
SETTINGS.put("log4j.logger.httpclient.wire", Level.WARN.toString());
SETTINGS.put("log4j.logger.httpclient", Level.WARN.toString());
SETTINGS.put("davmail.logFilePath", "");
SETTINGS_PROPERTIES.put("log4j.rootLogger", Level.WARN.toString());
SETTINGS_PROPERTIES.put("log4j.logger.davmail", Level.DEBUG.toString());
SETTINGS_PROPERTIES.put("log4j.logger.httpclient.wire", Level.WARN.toString());
SETTINGS_PROPERTIES.put("log4j.logger.httpclient", Level.WARN.toString());
SETTINGS_PROPERTIES.put("davmail.logFilePath", "");
}

/**
Expand Down Expand Up @@ -332,7 +332,7 @@ public static synchronized void save() {
if (configFilePath != null) {
// clone settings
Properties properties = new Properties();
properties.putAll(SETTINGS);
properties.putAll(SETTINGS_PROPERTIES);
// file lines
ArrayList<String> lines = new ArrayList<>();

Expand Down Expand Up @@ -436,7 +436,7 @@ private static String escapeValue(String value) {
* @return property value
*/
public static synchronized String getProperty(String property) {
String value = SETTINGS.getProperty(property);
String value = SETTINGS_PROPERTIES.getProperty(property);
// return null on empty value
if (value != null && value.isEmpty()) {
value = null;
Expand Down Expand Up @@ -483,9 +483,9 @@ public static synchronized char[] getCharArrayProperty(String property) {
*/
public static synchronized void setProperty(String property, String value) {
if (value != null) {
SETTINGS.setProperty(property, value);
SETTINGS_PROPERTIES.setProperty(property, value);
} else {
SETTINGS.setProperty(property, "");
SETTINGS_PROPERTIES.setProperty(property, "");
}
}

Expand All @@ -509,7 +509,7 @@ public static synchronized int getIntProperty(String property) {
public static synchronized int getIntProperty(String property, int defaultValue) {
int value = defaultValue;
try {
String propertyValue = SETTINGS.getProperty(property);
String propertyValue = SETTINGS_PROPERTIES.getProperty(property);
if (propertyValue != null && !propertyValue.isEmpty()) {
value = Integer.parseInt(propertyValue);
}
Expand All @@ -526,7 +526,7 @@ public static synchronized int getIntProperty(String property, int defaultValue)
* @return property value
*/
public static synchronized boolean getBooleanProperty(String property) {
String propertyValue = SETTINGS.getProperty(property);
String propertyValue = SETTINGS_PROPERTIES.getProperty(property);
return Boolean.parseBoolean(propertyValue);
}

Expand All @@ -539,7 +539,7 @@ public static synchronized boolean getBooleanProperty(String property) {
*/
public static synchronized boolean getBooleanProperty(String property, boolean defaultValue) {
boolean value = defaultValue;
String propertyValue = SETTINGS.getProperty(property);
String propertyValue = SETTINGS_PROPERTIES.getProperty(property);
if (propertyValue != null && !propertyValue.isEmpty()) {
value = Boolean.parseBoolean(propertyValue);
}
Expand Down Expand Up @@ -646,7 +646,7 @@ private static String getLoggingPrefix(String category) {
*/
public static synchronized Level getLoggingLevel(String category) {
String prefix = getLoggingPrefix(category);
String currentValue = SETTINGS.getProperty(prefix + category);
String currentValue = SETTINGS_PROPERTIES.getProperty(prefix + category);

if (currentValue != null && !currentValue.isEmpty()) {
return Level.toLevel(currentValue);
Expand All @@ -673,7 +673,7 @@ public static synchronized Properties getSubProperties(String scope) {
keyStart = scope + '.';
}
Properties result = new Properties();
for (Map.Entry<Object, Object> entry : SETTINGS.entrySet()) {
for (Map.Entry<Object, Object> entry : SETTINGS_PROPERTIES.entrySet()) {
String key = (String) entry.getKey();
if (key.startsWith(keyStart)) {
String value = (String) entry.getValue();
Expand All @@ -692,7 +692,7 @@ public static synchronized Properties getSubProperties(String scope) {
public static synchronized void setLoggingLevel(String category, Level level) {
if (level != null) {
String prefix = getLoggingPrefix(category);
SETTINGS.setProperty(prefix + category, level.toString());
SETTINGS_PROPERTIES.setProperty(prefix + category, level.toString());
if ("rootLogger".equals(category)) {
Logger.getRootLogger().setLevel(level);
} else {
Expand Down

0 comments on commit 5c4a83a

Please sign in to comment.