From 0ac4adb276948a8aab3f02d82121f85229e6b613 Mon Sep 17 00:00:00 2001
From: david_page <david_page@localhost>
Date: Wed, 10 Oct 2007 18:08:06 +0000
Subject: [PATCH] issue 2440 bin/backup --encrypt and --signHash require online backup

---
 opends/src/messages/messages/tools.properties           |    3 +++
 opends/src/server/org/opends/server/tools/BackUpDB.java |   13 +++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index b78f776..685e7ec 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -535,6 +535,9 @@
  backups
 SEVERE_ERR_RESTOREDB_ERROR_DURING_BACKUP_317=An unexpected error occurred \
  while attempting to restore backup %s from %s:  %s
+SEVERE_ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE_325=The use of the \
+ %s argument or the %s argument requires a connection to an online server \
+ instance
 SEVERE_ERR_BACKUPDB_SIGN_REQUIRES_HASH_326=The use of the %s argument \
  requires that the %s argument is also provided
 INFO_DESCRIPTION_NOOP_327=Show what would be done but do not perform any \
diff --git a/opends/src/server/org/opends/server/tools/BackUpDB.java b/opends/src/server/org/opends/server/tools/BackUpDB.java
index 6e5d144..34cd4a3 100644
--- a/opends/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -354,6 +354,19 @@
       }
     }
 
+    // Encryption or signing requires the ADS backend be available for
+    // CryptoManager access to secret key entries. If no connection arguments
+    //  are present, infer an offline backup.
+    if ((encrypt.isPresent() || signHash.isPresent())
+            && ! argParser.connectionArgumentsPresent()) {
+      Message message =
+              ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE.get(
+                      encrypt.getLongIdentifier(),
+                      signHash.getLongIdentifier());
+      err.println(wrapText(message, MAX_LINE_WIDTH));
+      return 1;
+    }
+
     // If the signHash option was provided, then make sure that the hash option
     // was given.
     if (signHash.isPresent() && (! hash.isPresent()))

--
Gitblit v1.10.0