summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2014-06-19 17:48:03 -0400
committerEndi S. Dewata <edewata@redhat.com>2014-06-20 15:55:07 -0400
commit6bb64604f3422e1c4f72a14707bfb6ffbeb23458 (patch)
treec17129614611c4ca95bed8c936cf86c033453816
parentae94ccc0164c6e8bdf30a0946c3003438254d85d (diff)
downloadpki-6bb64604f3422e1c4f72a14707bfb6ffbeb23458.tar.gz
pki-6bb64604f3422e1c4f72a14707bfb6ffbeb23458.tar.xz
pki-6bb64604f3422e1c4f72a14707bfb6ffbeb23458.zip
Fixed NumberFormatException in key-request-find.
Previously if a key archival failed, the REST service would return an invalid key URL, which would cause an exception when the CLI tried to parse it. The service has been fixed to return a null URL which can be detected to avoid parsing invalid value. The Python library has been modified to handle missing key URL. Ticket #1043
-rw-r--r--base/common/python/pki/key.py5
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java1
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java11
3 files changed, 12 insertions, 5 deletions
diff --git a/base/common/python/pki/key.py b/base/common/python/pki/key.py
index 337ae76ff..5a24c2a31 100644
--- a/base/common/python/pki/key.py
+++ b/base/common/python/pki/key.py
@@ -183,7 +183,10 @@ class KeyRequestInfo(object):
key_request_info = cls()
key_request_info.request_url = attr_list['requestURL']
key_request_info.request_type = attr_list['requestType']
- key_request_info.key_url = attr_list['keyURL']
+
+ if 'keyURL' in attr_list:
+ key_request_info.key_url = attr_list['keyURL']
+
key_request_info.request_status = attr_list['requestStatus']
return key_request_info
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
index d9e5fbf1c..45f8b1335 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
@@ -55,6 +55,7 @@ public class KeyRequestInfo extends CMSRequestInfo {
* @return the key ID in the keyURL
*/
public KeyId getKeyId() {
+ if (keyURL == null) return null;
String id = keyURL.substring(keyURL.lastIndexOf("/") + 1);
return new KeyId(id);
}
diff --git a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
index 3686ec776..dd0393aab 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
@@ -351,11 +351,14 @@ public class KeyRequestDAO extends CMSRequestDAO {
ret.setRequestURL(reqBuilder.build().toString());
Path keyPath = KeyResource.class.getAnnotation(Path.class);
- String kid = request.getExtDataInString("keyrecord");
+ String keyID = request.getExtDataInString("keyrecord");
- UriBuilder keyBuilder = uriInfo.getBaseUriBuilder();
- keyBuilder.path(keyPath.value() + "/" + kid);
- ret.setKeyURL(keyBuilder.build().toString());
+ if (keyID != null) {
+ // set key URL only if key ID is available
+ UriBuilder keyBuilder = uriInfo.getBaseUriBuilder();
+ keyBuilder.path(keyPath.value() + "/" + keyID);
+ ret.setKeyURL(keyBuilder.build().toString());
+ }
return ret;
}