diff options
| author | Ade Lee <alee@redhat.com> | 2016-11-08 15:16:07 -0500 |
|---|---|---|
| committer | Ade Lee <alee@redhat.com> | 2016-11-10 14:33:25 -0500 |
| commit | 62b84bcb8742b090f0c400d341ea7d7790443644 (patch) | |
| tree | f469cf23ec281f4fb56ca81b4f0b675dac405153 /base/java-tools/src | |
| parent | 114cc254b5286b83918bb8253e01ba93c4f1c58a (diff) | |
| download | pki-62b84bcb8742b090f0c400d341ea7d7790443644.tar.gz pki-62b84bcb8742b090f0c400d341ea7d7790443644.tar.xz pki-62b84bcb8742b090f0c400d341ea7d7790443644.zip | |
Add option to pass existing request to retrieveKeyCLI
Continuation of the previous patch. These are client changes
to allow the client to pass through an approved recovery request
to retrieveKey()
Diffstat (limited to 'base/java-tools/src')
| -rw-r--r-- | base/java-tools/src/com/netscape/cmstools/key/KeyRetrieveCLI.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/key/KeyRetrieveCLI.java b/base/java-tools/src/com/netscape/cmstools/key/KeyRetrieveCLI.java index 92389c021..555faa00d 100644 --- a/base/java-tools/src/com/netscape/cmstools/key/KeyRetrieveCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/key/KeyRetrieveCLI.java @@ -15,6 +15,7 @@ import org.apache.commons.cli.ParseException; import com.netscape.certsrv.dbs.keydb.KeyId; import com.netscape.certsrv.key.Key; import com.netscape.certsrv.key.KeyRecoveryRequest; +import com.netscape.certsrv.request.RequestId; import com.netscape.cmstools.cli.CLI; import com.netscape.cmstools.cli.MainCLI; import com.netscape.cmsutil.util.Utils; @@ -39,6 +40,10 @@ public class KeyRetrieveCLI extends CLI { option.setArgName("Key Identifier"); options.addOption(option); + option = new Option(null, "requestID", true, "Request Identifier for approved recovery request."); + option.setArgName("Recovery Request Identifier"); + options.addOption(option); + option = new Option(null, "passphrase", true, "Passphrase to encrypt the key information."); option.setArgName("Passphrase"); options.addOption(option); @@ -125,12 +130,27 @@ public class KeyRetrieveCLI extends CLI { // Using command line options. String keyId = cmd.getOptionValue("keyID"); String passphrase = cmd.getOptionValue("passphrase"); + String requestId = cmd.getOptionValue("requestID"); - if (passphrase != null) { - keyData = keyCLI.keyClient.retrieveKeyByPassphrase(new KeyId(keyId), passphrase); + if ((requestId == null) && (keyId == null)) { + System.out.println("Either requestID or keyID must be specified"); + System.exit(1); + } + if (passphrase != null) { + if (requestId != null) { + keyData = keyCLI.keyClient.retrieveKeyByRequestWithPassphrase( + new RequestId(requestId), passphrase); + } else { + keyData = keyCLI.keyClient.retrieveKeyByPassphrase(new KeyId(keyId), passphrase); + } } else { - keyData = keyCLI.keyClient.retrieveKey(new KeyId(keyId)); + if (requestId != null) { + keyData = keyCLI.keyClient.retrieveKeyByRequest(new RequestId(requestId)); + } else { + keyData = keyCLI.keyClient.retrieveKey(new KeyId(keyId)); + } + clientEncryption = false; // No need to return the encrypted data since encryption |
