From cf425dfa25bccb467c63b9a966adf3a7eec791df Mon Sep 17 00:00:00 2001 From: Ade Lee Date: Mon, 3 Feb 2014 13:19:46 -0500 Subject: Address review comments 1. Remove Link attribute from ResourceMessage, 2. Rename KeyDataInfo and KeyDataInfoCollection. 3. Move KEYGEN_ALGORITHMS 4. Fix missing space in PKIException 5. Move properties to attributes in ResourceMessage 6. Add missing code to update the request and set IRequest.RESULT --- .../com/netscape/certsrv/base/PKIException.java | 6 +- .../com/netscape/certsrv/base/ResourceMessage.java | 86 ++++++-------- .../certsrv/base/UserNotFoundException.java | 4 +- .../certsrv/cert/CertNotFoundException.java | 4 +- .../certsrv/group/GroupNotFoundException.java | 4 +- .../netscape/certsrv/key/KeyArchivalRequest.java | 20 ++-- .../src/com/netscape/certsrv/key/KeyClient.java | 2 +- .../src/com/netscape/certsrv/key/KeyDataInfo.java | 128 --------------------- .../certsrv/key/KeyDataInfoCollection.java | 34 ------ .../src/com/netscape/certsrv/key/KeyInfo.java | 128 +++++++++++++++++++++ .../netscape/certsrv/key/KeyInfoCollection.java | 34 ++++++ .../netscape/certsrv/key/KeyRecoveryRequest.java | 44 +++---- .../src/com/netscape/certsrv/key/KeyResource.java | 2 +- .../certsrv/key/SymKeyGenerationRequest.java | 52 ++++----- .../src/com/netscape/certsrv/kra/KRAClient.java | 14 +-- .../certsrv/profile/ProfileNotFoundException.java | 4 +- .../certsrv/request/RequestNotFoundException.java | 4 +- 17 files changed, 273 insertions(+), 297 deletions(-) delete mode 100644 base/common/src/com/netscape/certsrv/key/KeyDataInfo.java delete mode 100644 base/common/src/com/netscape/certsrv/key/KeyDataInfoCollection.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyInfo.java create mode 100644 base/common/src/com/netscape/certsrv/key/KeyInfoCollection.java (limited to 'base/common/src') diff --git a/base/common/src/com/netscape/certsrv/base/PKIException.java b/base/common/src/com/netscape/certsrv/base/PKIException.java index 65ff6db8e..f1f377352 100644 --- a/base/common/src/com/netscape/certsrv/base/PKIException.java +++ b/base/common/src/com/netscape/certsrv/base/PKIException.java @@ -84,7 +84,7 @@ public class PKIException extends RuntimeException { } @XmlRootElement(name="PKIException") - public static class Data extends ResourceMessage{ + public static class Data extends ResourceMessage { @XmlElement(name="Code") public int code; @@ -111,8 +111,8 @@ public class PKIException extends RuntimeException { data.className = PKIException.class.getName(); data.code = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); data.message = "An error has occured"; - data.setProperty("attr1", "value1"); - data.setProperty("attr2", "value2"); + data.setAttribute("attr1", "value1"); + data.setAttribute("attr2", "value2"); JAXBContext context = JAXBContext.newInstance(Data.class); Marshaller marshaller = context.createMarshaller(); diff --git a/base/common/src/com/netscape/certsrv/base/ResourceMessage.java b/base/common/src/com/netscape/certsrv/base/ResourceMessage.java index dd2f48078..57b5539b8 100644 --- a/base/common/src/com/netscape/certsrv/base/ResourceMessage.java +++ b/base/common/src/com/netscape/certsrv/base/ResourceMessage.java @@ -20,16 +20,13 @@ import javax.xml.bind.annotation.XmlValue; import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.jboss.resteasy.plugins.providers.atom.Link; - /** * @author Ade Lee */ @XmlRootElement(name="ResourceMessage") public class ResourceMessage { - protected Map properties = new LinkedHashMap(); - Link link; + protected Map attributes = new LinkedHashMap(); String className; public ResourceMessage() { @@ -38,7 +35,7 @@ public class ResourceMessage { public ResourceMessage(MultivaluedMap form) { for (Map.Entry> entry: form.entrySet()) { - properties.put(entry.getKey(), entry.getValue().get(0)); + attributes.put(entry.getKey(), entry.getValue().get(0)); } } @@ -51,61 +48,61 @@ public class ResourceMessage { this.className = className; } - @XmlElement(name = "Properties") + @XmlElement(name = "Attributes") @XmlJavaTypeAdapter(MapAdapter.class) - public Map getProperties() { - return properties; + public Map getAttributes() { + return attributes; } - public void setProperties(Map properties) { - this.properties.clear(); - this.properties.putAll(properties); + public void setAttributes(Map attributes) { + this.attributes.clear(); + this.attributes.putAll(attributes); } - public Collection getPropertyNames() { - return properties.keySet(); + public Collection getAttributeNames() { + return attributes.keySet(); } - public String getProperty(String name) { - return properties.get(name); + public String getAttribute(String name) { + return attributes.get(name); } - public void setProperty(String name, String value) { - properties.put(name, value); + public void setAttribute(String name, String value) { + attributes.put(name, value); } - public String removeProperty(String name) { - return properties.remove(name); + public String removeAttribute(String name) { + return attributes.remove(name); } - public static class MapAdapter extends XmlAdapter> { + public static class MapAdapter extends XmlAdapter> { - public PropertyList marshal(Map map) { - PropertyList list = new PropertyList(); + public AttributeList marshal(Map map) { + AttributeList list = new AttributeList(); for (Map.Entry entry : map.entrySet()) { - Property property = new Property(); - property.name = entry.getKey(); - property.value = entry.getValue(); - list.properties.add(property); + Attribute attribute = new Attribute(); + attribute.name = entry.getKey(); + attribute.value = entry.getValue(); + list.attrs.add(attribute); } return list; } - public Map unmarshal(PropertyList list) { + public Map unmarshal(AttributeList list) { Map map = new LinkedHashMap(); - for (Property property : list.properties) { - map.put(property.name, property.value); + for (Attribute attribute : list.attrs) { + map.put(attribute.name, attribute.value); } return map; } } - public static class PropertyList { - @XmlElement(name = "Property") - public List properties = new ArrayList(); + public static class AttributeList { + @XmlElement(name = "Attribute") + public List attrs = new ArrayList(); } - public static class Property { + public static class Attribute { @XmlAttribute public String name; @@ -114,21 +111,11 @@ public class ResourceMessage { public String value; } - @XmlElement(name = "Link") - public Link getLink() { - return link; - } - - public void setLink(Link link) { - this.link = link; - } - @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((link == null) ? 0 : link.hashCode()); - result = prime * result + ((properties == null) ? 0 : properties.hashCode()); + result = prime * result + ((attributes == null) ? 0 : attributes.hashCode()); result = prime * result + ((className == null) ? 0 : className.hashCode()); return result; } @@ -142,15 +129,10 @@ public class ResourceMessage { if (getClass() != obj.getClass()) return false; ResourceMessage other = (ResourceMessage) obj; - if (link == null) { - if (other.link != null) - return false; - } else if (!link.equals(other.link)) - return false; - if (properties == null) { - if (other.properties != null) + if (attributes == null) { + if (other.attributes != null) return false; - } else if (!properties.equals(other.properties)) + } else if (!attributes.equals(other.attributes)) return false; if (className == null) { if (other.className != null) diff --git a/base/common/src/com/netscape/certsrv/base/UserNotFoundException.java b/base/common/src/com/netscape/certsrv/base/UserNotFoundException.java index ec14b59aa..63df7067a 100644 --- a/base/common/src/com/netscape/certsrv/base/UserNotFoundException.java +++ b/base/common/src/com/netscape/certsrv/base/UserNotFoundException.java @@ -21,12 +21,12 @@ public class UserNotFoundException extends ResourceNotFoundException { public UserNotFoundException(Data data) { super(data); - userId = data.getProperty("userId"); + userId = data.getAttribute("userId"); } public Data getData() { Data data = super.getData(); - data.setProperty("userId", userId); + data.setAttribute("userId", userId); return data; } diff --git a/base/common/src/com/netscape/certsrv/cert/CertNotFoundException.java b/base/common/src/com/netscape/certsrv/cert/CertNotFoundException.java index 5b694ad15..171c2763d 100644 --- a/base/common/src/com/netscape/certsrv/cert/CertNotFoundException.java +++ b/base/common/src/com/netscape/certsrv/cert/CertNotFoundException.java @@ -42,12 +42,12 @@ public class CertNotFoundException extends ResourceNotFoundException { public CertNotFoundException(Data data) { super(data); - certId = new CertId(data.getProperty("certId")); + certId = new CertId(data.getAttribute("certId")); } public Data getData() { Data data = super.getData(); - data.setProperty("certId", certId.toString()); + data.setAttribute("certId", certId.toString()); return data; } diff --git a/base/common/src/com/netscape/certsrv/group/GroupNotFoundException.java b/base/common/src/com/netscape/certsrv/group/GroupNotFoundException.java index c5167db8f..3bd9241b6 100644 --- a/base/common/src/com/netscape/certsrv/group/GroupNotFoundException.java +++ b/base/common/src/com/netscape/certsrv/group/GroupNotFoundException.java @@ -23,12 +23,12 @@ public class GroupNotFoundException extends ResourceNotFoundException { public GroupNotFoundException(Data data) { super(data); - groupId = data.getProperty("groupId"); + groupId = data.getAttribute("groupId"); } public Data getData() { Data data = super.getData(); - data.setProperty("groupId", groupId); + data.setAttribute("groupId", groupId); return data; } diff --git a/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java b/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java index c72bad4b9..1655fdb28 100644 --- a/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java +++ b/base/common/src/com/netscape/certsrv/key/KeyArchivalRequest.java @@ -46,14 +46,14 @@ public class KeyArchivalRequest extends ResourceMessage { } public KeyArchivalRequest(MultivaluedMap form) { - properties.put(CLIENT_ID, form.getFirst(CLIENT_ID)); - properties.put(DATA_TYPE, form.getFirst(DATA_TYPE)); - properties.put(WRAPPED_PRIVATE_DATA, form.getFirst(WRAPPED_PRIVATE_DATA)); + attributes.put(CLIENT_ID, form.getFirst(CLIENT_ID)); + attributes.put(DATA_TYPE, form.getFirst(DATA_TYPE)); + attributes.put(WRAPPED_PRIVATE_DATA, form.getFirst(WRAPPED_PRIVATE_DATA)); setClassName(getClass().getName()); } public KeyArchivalRequest(ResourceMessage data) { - properties.putAll(data.getProperties()); + attributes.putAll(data.getAttributes()); setClassName(getClass().getName()); } @@ -61,42 +61,42 @@ public class KeyArchivalRequest extends ResourceMessage { * @return the clientId */ public String getClientId() { - return properties.get(CLIENT_ID); + return attributes.get(CLIENT_ID); } /** * @param clientId the clientId to set */ public void setClientId(String clientId) { - properties.put(CLIENT_ID, clientId); + attributes.put(CLIENT_ID, clientId); } /** * @return the dataType */ public String getDataType() { - return properties.get(DATA_TYPE); + return attributes.get(DATA_TYPE); } /** * @param dataType the dataType to set */ public void setDataType(String dataType) { - properties.put(DATA_TYPE, dataType); + attributes.put(DATA_TYPE, dataType); } /** * @return the wrappedPrivateData */ public String getWrappedPrivateData() { - return properties.get(WRAPPED_PRIVATE_DATA); + return attributes.get(WRAPPED_PRIVATE_DATA); } /** * @param wrappedPrivateData the wrappedPrivateData to set */ public void setWrappedPrivateData(String wrappedPrivateData) { - properties.put(WRAPPED_PRIVATE_DATA, wrappedPrivateData); + attributes.put(WRAPPED_PRIVATE_DATA, wrappedPrivateData); } public String toString() { diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java index 06c7cfd79..280b10c49 100644 --- a/base/common/src/com/netscape/certsrv/key/KeyClient.java +++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java @@ -44,7 +44,7 @@ public class KeyClient extends Client { keyRequestClient = createProxy(KeyRequestResource.class); } - public KeyDataInfoCollection findKeys(String clientID, String status, Integer maxSize, Integer maxTime, + public KeyInfoCollection findKeys(String clientID, String status, Integer maxSize, Integer maxTime, Integer start, Integer size) { return keyClient.listKeys(clientID, status, maxSize, maxTime, start, size); } diff --git a/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java deleted file mode 100644 index 09d228718..000000000 --- a/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java +++ /dev/null @@ -1,128 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2011 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -/** - * - */ -package com.netscape.certsrv.key; - - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -import com.netscape.certsrv.dbs.keydb.KeyId; - -/** - * @author alee - * - */ -@XmlRootElement(name="KeyDataInfo") -@XmlAccessorType(XmlAccessType.FIELD) -public class KeyDataInfo { - - @XmlElement - protected String keyURL; - - @XmlElement - protected String clientID; - - @XmlElement - protected String status; - - @XmlElement - protected String algorithm; - - @XmlElement - protected Integer size; - - @XmlElement - protected String ownerName; - - public KeyDataInfo() { - // required for JAXB (defaults) - } - - /** - * @return the keyURL - */ - public String getKeyURL() { - return keyURL; - } - - /** - * @param keyURL the keyURL to set - */ - public void setKeyURL(String keyURL) { - this.keyURL = keyURL; - } - - /** - * @return the key ID in the keyURL - */ - public KeyId getKeyId() { - String id = keyURL.substring(keyURL.lastIndexOf("/") + 1); - return new KeyId(id); - } - - /** - * @return the clientID - */ - public String getClientID() { - return clientID; - } - - /** - * @param clientID the clientID to set - */ - public void setClientID(String clientID) { - this.clientID = clientID; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getAlgorithm() { - return algorithm; - } - - public void setAlgorithm(String algorithm) { - this.algorithm = algorithm; - } - - public Integer getSize() { - return size; - } - - public void setSize(Integer size) { - this.size = size; - } - - public String getOwnerName() { - return ownerName; - } - - public void setOwnerName(String ownerName) { - this.ownerName = ownerName; - } -} diff --git a/base/common/src/com/netscape/certsrv/key/KeyDataInfoCollection.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfoCollection.java deleted file mode 100644 index 4e67e2a44..000000000 --- a/base/common/src/com/netscape/certsrv/key/KeyDataInfoCollection.java +++ /dev/null @@ -1,34 +0,0 @@ -// --- BEGIN COPYRIGHT BLOCK --- -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; version 2 of the License. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License along -// with this program; if not, write to the Free Software Foundation, Inc., -// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// -// (C) 2012 Red Hat, Inc. -// All rights reserved. -// --- END COPYRIGHT BLOCK --- -package com.netscape.certsrv.key; - -import java.util.Collection; - -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlRootElement; - -import com.netscape.certsrv.base.DataCollection; - -@XmlRootElement(name = "KeyDataInfos") -public class KeyDataInfoCollection extends DataCollection { - - @XmlElementRef - public Collection getEntries() { - return super.getEntries(); - } -} diff --git a/base/common/src/com/netscape/certsrv/key/KeyInfo.java b/base/common/src/com/netscape/certsrv/key/KeyInfo.java new file mode 100644 index 000000000..a4f4e62f3 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/key/KeyInfo.java @@ -0,0 +1,128 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2011 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +/** + * + */ +package com.netscape.certsrv.key; + + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +import com.netscape.certsrv.dbs.keydb.KeyId; + +/** + * @author alee + * + */ +@XmlRootElement(name="KeyInfo") +@XmlAccessorType(XmlAccessType.FIELD) +public class KeyInfo { + + @XmlElement + protected String keyURL; + + @XmlElement + protected String clientID; + + @XmlElement + protected String status; + + @XmlElement + protected String algorithm; + + @XmlElement + protected Integer size; + + @XmlElement + protected String ownerName; + + public KeyInfo() { + // required for JAXB (defaults) + } + + /** + * @return the keyURL + */ + public String getKeyURL() { + return keyURL; + } + + /** + * @param keyURL the keyURL to set + */ + public void setKeyURL(String keyURL) { + this.keyURL = keyURL; + } + + /** + * @return the key ID in the keyURL + */ + public KeyId getKeyId() { + String id = keyURL.substring(keyURL.lastIndexOf("/") + 1); + return new KeyId(id); + } + + /** + * @return the clientID + */ + public String getClientID() { + return clientID; + } + + /** + * @param clientID the clientID to set + */ + public void setClientID(String clientID) { + this.clientID = clientID; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public String getOwnerName() { + return ownerName; + } + + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } +} diff --git a/base/common/src/com/netscape/certsrv/key/KeyInfoCollection.java b/base/common/src/com/netscape/certsrv/key/KeyInfoCollection.java new file mode 100644 index 000000000..3d411da69 --- /dev/null +++ b/base/common/src/com/netscape/certsrv/key/KeyInfoCollection.java @@ -0,0 +1,34 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2012 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.certsrv.key; + +import java.util.Collection; + +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; + +import com.netscape.certsrv.base.DataCollection; + +@XmlRootElement(name = "KeyInfoCollection") +public class KeyInfoCollection extends DataCollection { + + @XmlElementRef + public Collection getEntries() { + return super.getEntries(); + } +} diff --git a/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java b/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java index 4b521a57c..e12b414b1 100644 --- a/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java +++ b/base/common/src/com/netscape/certsrv/key/KeyRecoveryRequest.java @@ -53,21 +53,21 @@ public class KeyRecoveryRequest extends ResourceMessage { public KeyRecoveryRequest(MultivaluedMap form) { if (form.containsKey(KEY_ID)) { - properties.put(KEY_ID, form.getFirst(KEY_ID)); + attributes.put(KEY_ID, form.getFirst(KEY_ID)); } if (form.containsKey(REQUEST_ID)) { - properties.put(REQUEST_ID, form.getFirst(REQUEST_ID)); + attributes.put(REQUEST_ID, form.getFirst(REQUEST_ID)); } - properties.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY)); - properties.put(SESSION_WRAPPED_PASSPHRASE, form.getFirst(SESSION_WRAPPED_PASSPHRASE)); - properties.put(NONCE_DATA, form.getFirst(NONCE_DATA)); - properties.put(CERTIFICATE, form.getFirst(CERTIFICATE)); - properties.put(PASSPHRASE, form.getFirst(PASSPHRASE)); + attributes.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY)); + attributes.put(SESSION_WRAPPED_PASSPHRASE, form.getFirst(SESSION_WRAPPED_PASSPHRASE)); + attributes.put(NONCE_DATA, form.getFirst(NONCE_DATA)); + attributes.put(CERTIFICATE, form.getFirst(CERTIFICATE)); + attributes.put(PASSPHRASE, form.getFirst(PASSPHRASE)); setClassName(getClass().getName()); } public KeyRecoveryRequest(ResourceMessage data) { - properties.putAll(data.getProperties()); + attributes.putAll(data.getAttributes()); setClassName(getClass().getName()); } @@ -75,56 +75,56 @@ public class KeyRecoveryRequest extends ResourceMessage { * @return the keyId */ public KeyId getKeyId() { - return new KeyId(properties.get(KEY_ID)); + return new KeyId(attributes.get(KEY_ID)); } /** * @param keyId the keyId to set */ public void setKeyId(KeyId keyId) { - properties.put(KEY_ID, keyId.toString()); + attributes.put(KEY_ID, keyId.toString()); } /** * @return the requestId */ public RequestId getRequestId() { - return new RequestId(properties.get(REQUEST_ID)); + return new RequestId(attributes.get(REQUEST_ID)); } /** * @param requestId the requestId to set */ public void setRequestId(RequestId requestId) { - properties.put(REQUEST_ID, requestId.toString()); + attributes.put(REQUEST_ID, requestId.toString()); } /** * @return the transWrappedSessionKey */ public String getTransWrappedSessionKey() { - return properties.get(TRANS_WRAPPED_SESSION_KEY); + return attributes.get(TRANS_WRAPPED_SESSION_KEY); } /** * @param transWrappedSessionKey the transWrappedSessionKey to set */ public void setTransWrappedSessionKey(String transWrappedSessionKey) { - properties.put(TRANS_WRAPPED_SESSION_KEY, transWrappedSessionKey); + attributes.put(TRANS_WRAPPED_SESSION_KEY, transWrappedSessionKey); } /** * @return the sessionWrappedPassphrase */ public String getSessionWrappedPassphrase() { - return properties.get(SESSION_WRAPPED_PASSPHRASE); + return attributes.get(SESSION_WRAPPED_PASSPHRASE); } /** * @param sessionWrappedPassphrase the sessionWrappedPassphrase to set */ public void setSessionWrappedPassphrase(String sessionWrappedPassphrase) { - properties.put(SESSION_WRAPPED_PASSPHRASE, sessionWrappedPassphrase); + attributes.put(SESSION_WRAPPED_PASSPHRASE, sessionWrappedPassphrase); } /** @@ -132,7 +132,7 @@ public class KeyRecoveryRequest extends ResourceMessage { */ public String getNonceData() { - return properties.get(NONCE_DATA); + return attributes.get(NONCE_DATA); } /** @@ -140,35 +140,35 @@ public class KeyRecoveryRequest extends ResourceMessage { */ public void setNonceData(String nonceData) { - properties.put(NONCE_DATA, nonceData); + attributes.put(NONCE_DATA, nonceData); } /** * @return the certificate */ public String getCertificate() { - return properties.get(CERTIFICATE); + return attributes.get(CERTIFICATE); } /** * @param certificate the certificate to set */ public void setCertificate(String certificate) { - properties.put(CERTIFICATE, certificate); + attributes.put(CERTIFICATE, certificate); } /** * @return the passphrase */ public String getPassphrase() { - return properties.get(PASSPHRASE); + return attributes.get(PASSPHRASE); } /** * @param passphrase the passphrase to set */ public void setPassphrase(String passphrase) { - properties.put(PASSPHRASE, passphrase); + attributes.put(PASSPHRASE, passphrase); } diff --git a/base/common/src/com/netscape/certsrv/key/KeyResource.java b/base/common/src/com/netscape/certsrv/key/KeyResource.java index 68efb7770..04d57fd2b 100644 --- a/base/common/src/com/netscape/certsrv/key/KeyResource.java +++ b/base/common/src/com/netscape/certsrv/key/KeyResource.java @@ -20,7 +20,7 @@ public interface KeyResource { @GET @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public KeyDataInfoCollection listKeys(@QueryParam("clientID") String clientID, + public KeyInfoCollection listKeys(@QueryParam("clientID") String clientID, @QueryParam("status") String status, @QueryParam("maxResults") Integer maxResults, @QueryParam("maxTime") Integer maxTime, diff --git a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java index 88f3e2381..f9feb6410 100644 --- a/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java +++ b/base/common/src/com/netscape/certsrv/key/SymKeyGenerationRequest.java @@ -2,9 +2,7 @@ package com.netscape.certsrv.key; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import javax.xml.bind.annotation.XmlAccessType; @@ -12,7 +10,6 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import org.apache.commons.lang.StringUtils; -import org.mozilla.jss.crypto.KeyGenAlgorithm; import com.netscape.certsrv.base.ResourceMessage; @@ -29,6 +26,14 @@ public class SymKeyGenerationRequest extends ResourceMessage { private static final String KEY_ALGORITHM = "keyAlgorithm"; private static final String KEY_USAGE = "keyUsage"; + /* Symmetric Key Algorithms */ + public static final String DES_ALGORITHM = "DES"; + public static final String DESEDE_ALGORITHM = "DESede"; + public static final String DES3_ALGORITHM = "DES3"; + public static final String RC2_ALGORITHM = "RC2"; + public static final String RC4_ALGORITHM = "RC4"; + public static final String AES_ALGORITHM = "AES"; + /* Symmetric Key usages */ public static final String UWRAP_USAGE = "unwrap"; public static final String WRAP_USAGE = "wrap"; @@ -37,19 +42,8 @@ public class SymKeyGenerationRequest extends ResourceMessage { public static final String DECRYPT_USAGE = "decrypt"; public static final String ENCRYPT_USAGE = "encrypt"; - public static final Map KEYGEN_ALGORITHMS; - static { - KEYGEN_ALGORITHMS = new HashMap(); - KEYGEN_ALGORITHMS.put("DES", KeyGenAlgorithm.DES); - KEYGEN_ALGORITHMS.put("DESede", KeyGenAlgorithm.DESede); - KEYGEN_ALGORITHMS.put("DES3", KeyGenAlgorithm.DES3); - KEYGEN_ALGORITHMS.put("RC2", KeyGenAlgorithm.RC2); - KEYGEN_ALGORITHMS.put("RC4", KeyGenAlgorithm.RC4); - KEYGEN_ALGORITHMS.put("AES", KeyGenAlgorithm.AES); - } - public List getUsages() { - String usageString = properties.get(KEY_USAGE); + String usageString = attributes.get(KEY_USAGE); if (! StringUtils.isBlank(usageString)) { return new ArrayList(Arrays.asList(usageString.split(","))); } @@ -57,7 +51,7 @@ public class SymKeyGenerationRequest extends ResourceMessage { } public void setUsages(List usages) { - properties.put(KEY_USAGE, StringUtils.join(usages, ",")); + attributes.put(KEY_USAGE, StringUtils.join(usages, ",")); } public void addUsage(String usage) { @@ -75,12 +69,12 @@ public class SymKeyGenerationRequest extends ResourceMessage { } public SymKeyGenerationRequest(MultivaluedMap form) { - properties.put(CLIENT_ID, form.getFirst(CLIENT_ID)); - properties.put(KEY_SIZE, form.getFirst(KEY_SIZE)); - properties.put(KEY_ALGORITHM, form.getFirst(KEY_ALGORITHM)); - properties.put(KEY_USAGE, form.getFirst(KEY_USAGE)); + attributes.put(CLIENT_ID, form.getFirst(CLIENT_ID)); + attributes.put(KEY_SIZE, form.getFirst(KEY_SIZE)); + attributes.put(KEY_ALGORITHM, form.getFirst(KEY_ALGORITHM)); + attributes.put(KEY_USAGE, form.getFirst(KEY_USAGE)); - String usageString = properties.get(KEY_USAGE); + String usageString = attributes.get(KEY_USAGE); if (! StringUtils.isBlank(usageString)) { setUsages(new ArrayList(Arrays.asList(usageString.split(",")))); } @@ -88,7 +82,7 @@ public class SymKeyGenerationRequest extends ResourceMessage { } public SymKeyGenerationRequest(ResourceMessage data) { - properties.putAll(data.getProperties()); + attributes.putAll(data.getAttributes()); setClassName(getClass().getName()); } @@ -96,42 +90,42 @@ public class SymKeyGenerationRequest extends ResourceMessage { * @return the clientId */ public String getClientId() { - return properties.get(CLIENT_ID); + return attributes.get(CLIENT_ID); } /** * @param clientId the clientId to set */ public void setClientId(String clientId) { - properties.put(CLIENT_ID, clientId); + attributes.put(CLIENT_ID, clientId); } /** * @return the keySize */ public int getKeySize() { - return Integer.parseInt(properties.get(KEY_SIZE)); + return Integer.parseInt(attributes.get(KEY_SIZE)); } /** * @param keySize the key size to set */ public void setKeySize(int keySize) { - properties.put(KEY_SIZE, Integer.toString(keySize)); + attributes.put(KEY_SIZE, Integer.toString(keySize)); } /** * @return the keyAlgorithm */ public String getKeyAlgorithm() { - return properties.get(KEY_ALGORITHM); + return attributes.get(KEY_ALGORITHM); } /** * @param keyAlgorithm the key algorithm to set */ public void setKeyAlgorithm(String keyAlgorithm) { - properties.put(KEY_ALGORITHM, keyAlgorithm); + attributes.put(KEY_ALGORITHM, keyAlgorithm); } public String toString() { @@ -154,7 +148,7 @@ public class SymKeyGenerationRequest extends ResourceMessage { SymKeyGenerationRequest before = new SymKeyGenerationRequest(); before.setClientId("vek 12345"); - before.setKeyAlgorithm("AES"); + before.setKeyAlgorithm(SymKeyGenerationRequest.AES_ALGORITHM); before.setKeySize(128); before.addUsage(SymKeyGenerationRequest.DECRYPT_USAGE); before.addUsage(SymKeyGenerationRequest.ENCRYPT_USAGE); diff --git a/base/common/src/com/netscape/certsrv/kra/KRAClient.java b/base/common/src/com/netscape/certsrv/kra/KRAClient.java index 2522820f4..943a6f21f 100644 --- a/base/common/src/com/netscape/certsrv/kra/KRAClient.java +++ b/base/common/src/com/netscape/certsrv/kra/KRAClient.java @@ -14,8 +14,8 @@ import com.netscape.certsrv.dbs.keydb.KeyId; import com.netscape.certsrv.group.GroupClient; import com.netscape.certsrv.key.KeyArchivalRequest; import com.netscape.certsrv.key.KeyData; -import com.netscape.certsrv.key.KeyDataInfo; -import com.netscape.certsrv.key.KeyDataInfoCollection; +import com.netscape.certsrv.key.KeyInfo; +import com.netscape.certsrv.key.KeyInfoCollection; import com.netscape.certsrv.key.KeyRecoveryRequest; import com.netscape.certsrv.key.KeyRequestInfo; import com.netscape.certsrv.key.KeyRequestInfoCollection; @@ -83,13 +83,13 @@ public class KRAClient extends SubsystemClient { return client.getEntity(response); } - public KeyDataInfo getKeyData(String clientId, String status) { - KeyDataInfoCollection infos = keyClient.listKeys(clientId, status, null, null, null, null); - Collection list = infos.getEntries(); - Iterator iter = list.iterator(); + public KeyInfo getKeyData(String clientId, String status) { + KeyInfoCollection infos = keyClient.listKeys(clientId, status, null, null, null, null); + Collection list = infos.getEntries(); + Iterator iter = list.iterator(); while (iter.hasNext()) { - KeyDataInfo info = iter.next(); + KeyInfo info = iter.next(); if (info != null) { // return the first one return info; diff --git a/base/common/src/com/netscape/certsrv/profile/ProfileNotFoundException.java b/base/common/src/com/netscape/certsrv/profile/ProfileNotFoundException.java index 25c6d4bfd..c6a549b07 100644 --- a/base/common/src/com/netscape/certsrv/profile/ProfileNotFoundException.java +++ b/base/common/src/com/netscape/certsrv/profile/ProfileNotFoundException.java @@ -41,12 +41,12 @@ public class ProfileNotFoundException extends ResourceNotFoundException { public ProfileNotFoundException(Data data) { super(data); - profileId = data.getProperty("profileId"); + profileId = data.getAttribute("profileId"); } public Data getData() { Data data = super.getData(); - data.setProperty("profileId", profileId); + data.setAttribute("profileId", profileId); return data; } diff --git a/base/common/src/com/netscape/certsrv/request/RequestNotFoundException.java b/base/common/src/com/netscape/certsrv/request/RequestNotFoundException.java index d1032dc2b..478675ab0 100644 --- a/base/common/src/com/netscape/certsrv/request/RequestNotFoundException.java +++ b/base/common/src/com/netscape/certsrv/request/RequestNotFoundException.java @@ -24,12 +24,12 @@ public class RequestNotFoundException extends ResourceNotFoundException { public RequestNotFoundException(Data data) { super(data); - requestId = new RequestId(data.getProperty("requestId")); + requestId = new RequestId(data.getAttribute("requestId")); } public Data getData() { Data data = super.getData(); - data.setProperty("requestId", requestId.toString()); + data.setAttribute("requestId", requestId.toString()); return data; } -- cgit