From ee472461f594706b40cedb39e55f167a034c13ee Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Fri, 21 Feb 2014 21:24:39 -0500 Subject: Added error checking in python client calls 1) Added error checking in python client calls. 2) Allow symmetric key generation with default params. Fix bug for when usages is not defined. 3) Fix bug when requesting key recovery - must check if key exists. 4) Extend key gen to allow for providing trans_wrapped_session_key 5) added constants to python client for key status --- .../certsrv/key/SymKeyGenerationRequest.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'base/common/src/com/netscape/certsrv/key') diff --git a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java index 01326442f..27dc69fd5 100644 --- a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java +++ b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java @@ -25,6 +25,7 @@ public class SymKeyGenerationRequest extends ResourceMessage { private static final String KEY_SIZE = "keySize"; private static final String KEY_ALGORITHM = "keyAlgorithm"; private static final String KEY_USAGE = "keyUsage"; + private static final String TRANS_WRAPPED_SESSION_KEY = "transWrappedSessionKey"; /* Symmetric Key usages */ public static final String UWRAP_USAGE = "unwrap"; @@ -65,6 +66,7 @@ public class SymKeyGenerationRequest extends ResourceMessage { attributes.put(KEY_SIZE, form.getFirst(KEY_SIZE)); attributes.put(KEY_ALGORITHM, form.getFirst(KEY_ALGORITHM)); attributes.put(KEY_USAGE, form.getFirst(KEY_USAGE)); + attributes.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY)); String usageString = attributes.get(KEY_USAGE); if (! StringUtils.isBlank(usageString)) { @@ -96,7 +98,11 @@ public class SymKeyGenerationRequest extends ResourceMessage { * @return the keySize */ public Integer getKeySize() { - return new Integer(attributes.get(KEY_SIZE)); + try { + return new Integer(attributes.get(KEY_SIZE)); + } catch (NumberFormatException e) { + return null; + } } /** @@ -120,6 +126,20 @@ public class SymKeyGenerationRequest extends ResourceMessage { attributes.put(KEY_ALGORITHM, keyAlgorithm); } + /** + * @return the transWrappedSessionKey + */ + public String getTransWrappedSessionKey() { + return attributes.get(TRANS_WRAPPED_SESSION_KEY); + } + + /** + * @param transWrappedSessionKey the wrapped seesion key to set + */ + public void setTransWrappedSessionKey(String transWrappedSessionKey) { + attributes.put(TRANS_WRAPPED_SESSION_KEY, transWrappedSessionKey); + } + public String toString() { try { return ResourceMessage.marshal(this, SymKeyGenerationRequest.class); -- cgit