summaryrefslogtreecommitdiffstats
path: root/base/common/src/com
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2014-08-28 19:05:36 -0400
committerAbhishek Koneru <akoneru@redhat.com>2014-08-29 11:24:48 -0400
commita4c36d953281967d653ef8a1d33dae6a8ba34a77 (patch)
tree5f611a5d32899c785b7d2f06eee590dd57d3df84 /base/common/src/com
parenta7f8076a5f20812eceac31f7230e4156adf74471 (diff)
Makes output of secrets consistent for all clients.
All the secrets/keys retrieved using the client API's using Java/python clients will be of the type - byte array. This applies to output of the retrieveKey method and the public key attribute of the KeyInfo object.
Diffstat (limited to 'base/common/src/com')
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyClient.java2
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyInfo.java31
2 files changed, 27 insertions, 6 deletions
diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java
index 262a33d8f..ade3765a9 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyClient.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java
@@ -725,7 +725,7 @@ public class KeyClient extends Client {
* For RSA, JSS accepts key sizes that fall in this set of values:
* {256 + (16 * n), where 0 <= n <= 1008
*
- * For DSA, JSS accepts key sizes 512, 768, 1024 only when there are no p,q,g params specified.
+ * For DSA, JSS accepts key sizes 512, 768, 1024 only, when there are no p,q,g params specified.
*/
if (keyAlgorithm.equals(KeyRequestResource.RSA_ALGORITHM)) {
if (keySize >= 256) {
diff --git a/base/common/src/com/netscape/certsrv/key/KeyInfo.java b/base/common/src/com/netscape/certsrv/key/KeyInfo.java
index 71a858e6b..204cac493 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyInfo.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyInfo.java
@@ -27,6 +27,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.netscape.certsrv.dbs.keydb.KeyId;
+import com.netscape.cmsutil.util.Utils;
/**
* @author alee
@@ -55,7 +56,7 @@ public class KeyInfo {
protected String ownerName;
@XmlElement
- protected String publicKey;
+ private String publicKey;
public KeyInfo() {
// required for JAXB (defaults)
@@ -129,11 +130,31 @@ public class KeyInfo {
this.ownerName = ownerName;
}
- public String getPublicKey() {
- return publicKey;
+ /**
+ * Converts the stored base64 encoded public key to a byte
+ * array and returns that value. Returns null, if public key is null.
+ *
+ * @return public key - as a byte array
+ */
+ public byte[] getPublicKey() {
+ if (publicKey != null) {
+ return Utils.base64decode(publicKey);
+ }
+ return null;
}
- public void setPublicKey(String publicKey) {
- this.publicKey = publicKey;
+ /**
+ * Sets the binary data of the public key in a
+ * base64 encoded string format.
+ *
+ * @param publicKey - if null, getPublicKey returns null.
+ */
+ public void setPublicKey(byte[] publicKey) {
+ if (publicKey != null) {
+ this.publicKey = Utils.base64encode(publicKey);
+ } else {
+ this.publicKey = null;
+ }
}
+
}