Bug 223089 Do we need "-password", "-keyring"
diff --git a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/SecAuthMessages.java b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/SecAuthMessages.java
index 47f5da3..c91d782 100644
--- a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/SecAuthMessages.java
+++ b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/SecAuthMessages.java
@@ -85,6 +85,7 @@
 	public static String noDigest;
 	public static String failedCreateRecovery;
 	public static String initCancelled;
+	public static String unableToReadPswdFile;
 
 	static {
 		// load message values from bundle file
diff --git a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/messages.properties b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/messages.properties
index a6994f9..45af5de 100644
--- a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/messages.properties
+++ b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/auth/nls/messages.properties
@@ -78,3 +78,4 @@
 noDigest = Digest algorithm  \"{0}\" is not available.
 failedCreateRecovery = Unable to create value for the password recovery.
 initCancelled = Secure Storage initialization was canceled; please try again.
+unableToReadPswdFile = Unable to read password from the file \"{0}\".
diff --git a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesMapper.java b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesMapper.java
index aa0cc75..2d18f7d 100644
--- a/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesMapper.java
+++ b/bundles/org.eclipse.equinox.security/src/org/eclipse/equinox/internal/security/storage/SecurePreferencesMapper.java
@@ -10,8 +10,7 @@
  *******************************************************************************/
 package org.eclipse.equinox.internal.security.storage;
 
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
 import java.net.URL;
 import java.util.*;
 import javax.crypto.spec.PBEKeySpec;
@@ -76,10 +75,8 @@
 						continue;
 					}
 					if (PASSWORD_ARGUMENT.equalsIgnoreCase(args[i])) {
-						if (options == null)
-							options = new HashMap(1);
-						if (!options.containsKey(IProviderHints.DEFAULT_PASSWORD))
-							options.put(IProviderHints.DEFAULT_PASSWORD, new PBEKeySpec(args[i + 1].toCharArray()));
+						options = processPassword(options, args[i + 1]);
+						continue;
 					}
 				}
 			}
@@ -147,4 +144,45 @@
 		}
 	}
 
+	static private Map processPassword(Map options, String arg) {
+		if (arg == null || arg.length() == 0)
+			return options;
+		File file = new File(arg);
+		if (!file.canRead()) {
+			String msg = NLS.bind(SecAuthMessages.unableToReadPswdFile, arg);
+			AuthPlugin.getDefault().logError(msg, null);
+			return options;
+		}
+		BufferedReader is = null;
+		try {
+			is = new BufferedReader(new FileReader(file));
+			StringBuffer buffer = new StringBuffer();
+			for (;;) { // this eliminates new line characters but that's fine
+				String tmp = is.readLine();
+				if (tmp == null)
+					break;
+				buffer.append(tmp);
+			}
+			if (buffer.length() == 0)
+				return options;
+			if (options == null)
+				options = new HashMap(1);
+			if (!options.containsKey(IProviderHints.DEFAULT_PASSWORD))
+				options.put(IProviderHints.DEFAULT_PASSWORD, new PBEKeySpec(buffer.toString().toCharArray()));
+		} catch (IOException e) {
+			String msg = NLS.bind(SecAuthMessages.unableToReadPswdFile, arg);
+			AuthPlugin.getDefault().logError(msg, e);
+		} finally {
+			if (is != null) {
+				try {
+					is.close();
+				} catch (IOException e) {
+					String msg = NLS.bind(SecAuthMessages.unableToReadPswdFile, arg);
+					AuthPlugin.getDefault().logError(msg, e);
+				}
+			}
+		}
+		return options;
+	}
+
 }