From 7bdcb41c0f62967ec42d552f6002577dfb7019ca Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 02 Nov 2010 15:45:49 +0000
Subject: [PATCH] Sync from OpenDS (matthew_swift) Remove Platform class as it is no longer needed. Remove all getter methods which return passwords as Strings. Replace all setter methods which accept passwords as Strings with methods which accept passwords as char arrays, as per Java API security recommendations.
---
sdk/src/org/opends/sdk/KeyManagers.java | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/sdk/src/org/opends/sdk/KeyManagers.java b/sdk/src/org/opends/sdk/KeyManagers.java
index ecd45ea..4d2322f 100644
--- a/sdk/src/org/opends/sdk/KeyManagers.java
+++ b/sdk/src/org/opends/sdk/KeyManagers.java
@@ -267,14 +267,12 @@
* If {@code file} was {@code null}.
*/
public static X509KeyManager useKeyStoreFile(final String file,
- final String password, final String format)
+ final char[] password, final String format)
throws GeneralSecurityException, IOException, NullPointerException
{
Validator.ensureNotNull(file);
final File keyStoreFile = new File(file);
- final char[] keyStorePassword = password != null ? password.toCharArray()
- : null;
final String keyStoreFormat = format != null ? format : KeyStore
.getDefaultType();
@@ -284,7 +282,7 @@
try
{
fos = new FileInputStream(keyStoreFile);
- keyStore.load(fos, keyStorePassword);
+ keyStore.load(fos, password);
}
finally
{
@@ -303,7 +301,7 @@
final KeyManagerFactory kmf = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(keyStore, keyStorePassword);
+ kmf.init(keyStore, password);
X509KeyManager x509km = null;
for (final KeyManager km : kmf.getKeyManagers())
@@ -340,16 +338,14 @@
* @throws IOException
* If the PKCS#11 token could not be found or could not be read.
*/
- public static X509KeyManager usePKCS11Token(final String password)
+ public static X509KeyManager usePKCS11Token(final char[] password)
throws GeneralSecurityException, IOException
{
- final char[] keyStorePassword = password != null ? password.toCharArray()
- : null;
final KeyStore keyStore = KeyStore.getInstance("PKCS11");
- keyStore.load(null, keyStorePassword);
+ keyStore.load(null, password);
final KeyManagerFactory kmf = KeyManagerFactory
.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(keyStore, keyStorePassword);
+ kmf.init(keyStore, password);
X509KeyManager x509km = null;
for (final KeyManager km : kmf.getKeyManagers())
--
Gitblit v1.10.0