From 2328fbc97a6484ad443b8a3c88d988381caf1ea8 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Fri, 07 Sep 2007 18:08:46 +0000
Subject: [PATCH] Handle the base DN of the trust store backend properly, taking it from the configuration entry instead of hard-wiring it.

---
 opendj-sdk/opends/src/server/org/opends/server/backends/TrustStoreBackend.java |   28 +++++++++-------------------
 opendj-sdk/opends/src/messages/messages/backend.properties                     |    6 +++---
 opendj-sdk/opends/resource/config/config.ldif                                  |    2 +-
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/opendj-sdk/opends/resource/config/config.ldif b/opendj-sdk/opends/resource/config/config.ldif
index d59f7a8..c04bacf 100644
--- a/opendj-sdk/opends/resource/config/config.ldif
+++ b/opendj-sdk/opends/resource/config/config.ldif
@@ -323,7 +323,7 @@
 ds-cfg-backend-enabled: true
 ds-cfg-backend-class: org.opends.server.backends.TrustStoreBackend
 ds-cfg-backend-writability-mode: enabled
-ds-cfg-backend-base-dn: cn=trust-store
+ds-cfg-backend-base-dn: cn=ads-truststore
 ds-cfg-trust-store-type: JKS
 ds-cfg-trust-store-file: config/ads-truststore
 ds-cfg-trust-store-pin-file: config/ads-truststore.pin
diff --git a/opendj-sdk/opends/src/messages/messages/backend.properties b/opendj-sdk/opends/src/messages/messages/backend.properties
index 1073a7a..ce4afa7 100644
--- a/opendj-sdk/opends/src/messages/messages/backend.properties
+++ b/opendj-sdk/opends/src/messages/messages/backend.properties
@@ -883,9 +883,9 @@
  supported in the trust store backend
 SEVERE_ERR_TRUSTSTORE_MODIFY_DN_NOT_SUPPORTED_305=Modify DN operations are not \
  supported in the trust store backend
-SEVERE_ERR_TRUSTSTORE_CANNOT_DECODE_TRUSTSTORE_ROOT_DN_306=Unable to \
- initialize the trust store backend because an error occurred while \
- attempting to decode the base DN for the backend:  %s
+SEVERE_ERR_TRUSTSTORE_REQUIRES_ONE_BASE_DN_306=Unable to \
+ initialize the trust store backend from configuration entry %s because it \
+ does not contain exactly one base DN
 SEVERE_ERR_TRUSTSTORE_IMPORT_AND_EXPORT_NOT_SUPPORTED_307=LDIF import and \
  export operations are not supported in the trust store backend
 SEVERE_ERR_TRUSTSTORE_BACKUP_AND_RESTORE_NOT_SUPPORTED_308=Backup and \
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/TrustStoreBackend.java b/opendj-sdk/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
index 32ef62d..5621508 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/TrustStoreBackend.java
@@ -150,29 +150,19 @@
   public void initializeBackend()
          throws ConfigException, InitializationException
   {
+    DN configEntryDN = configuration.dn();
+
     // Create the set of base DNs that we will handle.  In this case, it's just
     // the DN of the base trust store entry.
-    try
+    SortedSet<DN> baseDNSet = configuration.getBackendBaseDN();
+    if (baseDNSet.size() != 1)
     {
-      // FIXME -- Deal with this more correctly.
-      baseDN = DN.decode(DN_TRUST_STORE_ROOT);
-      this.baseDNs = new DN[] {baseDN};
+      Message message = ERR_TRUSTSTORE_REQUIRES_ONE_BASE_DN.get(
+           String.valueOf(configEntryDN));
+      throw new InitializationException(message);
     }
-    catch (Exception e)
-    {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, e);
-      }
-
-      Message message =
-          ERR_TRUSTSTORE_CANNOT_DECODE_TRUSTSTORE_ROOT_DN.get(
-               getExceptionMessage(e));
-      throw new InitializationException(message, e);
-    }
-
-
-    DN configEntryDN = configuration.dn();
+    baseDN = baseDNSet.first();
+    baseDNs = new DN[] {baseDN};
 
     // Get the path to the trust store file.
     trustStoreFile = configuration.getTrustStoreFile();

--
Gitblit v1.10.0