From 58841cd1273d5238691e74b1d9f44318486fe42a Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Tue, 25 Sep 2007 22:11:45 +0000
Subject: [PATCH] Implement Get Symmetric Key Extended Operation for crypto manager symmetric key distribution.
---
opends/src/server/org/opends/server/backends/TrustStoreBackend.java | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/TrustStoreBackend.java b/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
index 4c85335..89e9c22 100644
--- a/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
+++ b/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -39,6 +39,7 @@
import java.util.*;
import java.security.KeyStore;
import java.security.KeyStoreException;
+import java.security.Key;
import org.opends.server.api.Backend;
import org.opends.server.config.ConfigException;
@@ -1425,6 +1426,63 @@
}
+ /**
+ * Returns the key associated with the given alias, using the trust
+ * store pin to recover it.
+ *
+ * @param alias The alias name.
+ *
+ * @return The requested key, or null if the given alias does not exist
+ * or does not identify a key-related entry.
+ *
+ * @throws DirectoryException If an error occurs while retrieving the key.
+ */
+ public Key getKey(String alias)
+ throws DirectoryException
+ {
+ KeyStore trustStore;
+ try
+ {
+ trustStore = KeyStore.getInstance(trustStoreType);
+
+ FileInputStream inputStream =
+ new FileInputStream(getFileForPath(trustStoreFile));
+ trustStore.load(inputStream, trustStorePIN);
+ inputStream.close();
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_TRUSTSTORE_CANNOT_LOAD.get(
+ trustStoreFile, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
+
+
+ try
+ {
+ return trustStore.getKey(alias, trustStorePIN);
+ }
+ catch (Exception e)
+ {
+ if (debugEnabled())
+ {
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
+ }
+
+ Message message = ERR_TRUSTSTORE_ERROR_READING_KEY.get(
+ alias, trustStoreFile, getExceptionMessage(e));
+ throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
+ message, e);
+ }
+ }
+
+
private void addCertificate(Entry entry)
throws DirectoryException
{
--
Gitblit v1.10.0