summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/certsrv
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/certsrv')
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java75
-rw-r--r--base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java121
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyClient.java75
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyDataInfo.java43
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyDataInfos.java15
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java69
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java120
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyRequestResource.java14
-rw-r--r--base/common/src/com/netscape/certsrv/key/KeyResource.java8
-rw-r--r--base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java36
-rw-r--r--base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java26
11 files changed, 556 insertions, 46 deletions
diff --git a/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java b/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java
index d11e94543..0d887a871 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java
@@ -18,6 +18,12 @@
package com.netscape.certsrv.cert;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -25,6 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.netscape.certsrv.dbs.certdb.CertId;
import com.netscape.certsrv.request.CMSRequestInfo;
+import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "CertRequestInfo")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -82,4 +89,72 @@ public class CertRequestInfo extends CMSRequestInfo {
return new CertId(id);
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((certRequestType == null) ? 0 : certRequestType.hashCode());
+ result = prime * result + ((certURL == null) ? 0 : certURL.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CertRequestInfo other = (CertRequestInfo) obj;
+ if (certRequestType == null) {
+ if (other.certRequestType != null)
+ return false;
+ } else if (!certRequestType.equals(other.certRequestType))
+ return false;
+ if (certURL == null) {
+ if (other.certURL != null)
+ return false;
+ } else if (!certURL.equals(other.certURL))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ try {
+ StringWriter sw = new StringWriter();
+ Marshaller marshaller = JAXBContext.newInstance(CertRequestInfo.class).createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(this, sw);
+ return sw.toString();
+
+ } catch (Exception e) {
+ return super.toString();
+ }
+ }
+
+ public static CertRequestInfo valueOf(String string) throws Exception {
+ try {
+ Unmarshaller unmarshaller = JAXBContext.newInstance(CertRequestInfo.class).createUnmarshaller();
+ return (CertRequestInfo)unmarshaller.unmarshal(new StringReader(string));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ CertRequestInfo before = new CertRequestInfo();
+ before.setRequestType("enrollment");
+ before.setRequestStatus(RequestStatus.COMPLETE);
+ before.setCertRequestType("pkcs10");
+
+ String string = before.toString();
+ System.out.println(string);
+
+ CertRequestInfo after = CertRequestInfo.valueOf(string);
+ System.out.println(after);
+
+ System.out.println(before.equals(after));
+ }
}
diff --git a/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java b/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
index 028bff583..a6a520c23 100644
--- a/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/cert/CertRequestInfos.java
@@ -17,24 +17,38 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.cert;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.netscape.certsrv.base.Link;
+import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "CertRequestInfos")
+@XmlAccessorType(XmlAccessType.FIELD)
public class CertRequestInfos {
- protected Collection<CertRequestInfo> requests;
- protected List<Link> links;
+
+ @XmlElementRef
+ protected Collection<CertRequestInfo> requests = new ArrayList<CertRequestInfo>();
+
+ @XmlElement(name = "Links")
+ protected List<Link> links = new ArrayList<Link>();
/**
* @return the requests
*/
- @XmlElementRef
public Collection<CertRequestInfo> getRequests() {
return requests;
}
@@ -43,13 +57,21 @@ public class CertRequestInfos {
* @param requests the requests to set
*/
public void setRequests(Collection<CertRequestInfo> requests) {
- this.requests = requests;
+ this.requests.clear();
+ if (requests == null) return;
+ this.requests.addAll(requests);
+ }
+
+ /**
+ * @param requests the request to add
+ */
+ public void addRequest(CertRequestInfo request) {
+ requests.add(request);
}
/**
* @return the links
*/
- @XmlElementRef
public List<Link> getLinks() {
return links;
}
@@ -58,14 +80,20 @@ public class CertRequestInfos {
* @param links the links to set
*/
public void setLinks(List<Link> links) {
- this.links = links;
+ this.links.clear();
+ if (links == null) return;
+ this.links.addAll(links);
+ }
+
+ /**
+ * @param links the link to add
+ */
+ public void addLink(Link link) {
+ links.add(link);
}
@XmlTransient
public String getNext() {
- if (links == null) {
- return null;
- }
for (Link link : links) {
if ("next".equals(link.getRelationship())) {
return link.getHref();
@@ -76,9 +104,6 @@ public class CertRequestInfos {
@XmlTransient
public String getPrevious() {
- if (links == null) {
- return null;
- }
for (Link link : links) {
if ("previous".equals(link.getRelationship())) {
return link.getHref();
@@ -86,4 +111,76 @@ public class CertRequestInfos {
}
return null;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((links == null) ? 0 : links.hashCode());
+ result = prime * result + ((requests == null) ? 0 : requests.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CertRequestInfos other = (CertRequestInfos) obj;
+ if (links == null) {
+ if (other.links != null)
+ return false;
+ } else if (!links.equals(other.links))
+ return false;
+ if (requests == null) {
+ if (other.requests != null)
+ return false;
+ } else if (!requests.equals(other.requests))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ try {
+ StringWriter sw = new StringWriter();
+ Marshaller marshaller = JAXBContext.newInstance(CertRequestInfos.class).createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(this, sw);
+ return sw.toString();
+
+ } catch (Exception e) {
+ return super.toString();
+ }
+ }
+
+ public static CertRequestInfos valueOf(String string) throws Exception {
+ try {
+ Unmarshaller unmarshaller = JAXBContext.newInstance(CertRequestInfos.class).createUnmarshaller();
+ return (CertRequestInfos)unmarshaller.unmarshal(new StringReader(string));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ CertRequestInfos before = new CertRequestInfos();
+
+ CertRequestInfo request = new CertRequestInfo();
+ request.setRequestType("enrollment");
+ request.setRequestStatus(RequestStatus.COMPLETE);
+ request.setCertRequestType("pkcs10");
+ before.addRequest(request);
+
+ String string = before.toString();
+ System.out.println(string);
+
+ CertRequestInfos after = CertRequestInfos.valueOf(string);
+ System.out.println(after);
+
+ System.out.println(request.equals(after));
+ }
}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyClient.java b/base/common/src/com/netscape/certsrv/key/KeyClient.java
new file mode 100644
index 000000000..ce2946c1e
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/key/KeyClient.java
@@ -0,0 +1,75 @@
+//--- 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.net.URISyntaxException;
+
+import com.netscape.certsrv.client.ClientConfig;
+import com.netscape.certsrv.client.PKIClient;
+import com.netscape.certsrv.client.PKIConnection;
+import com.netscape.certsrv.request.RequestId;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class KeyClient extends PKIClient {
+
+ public KeyResource keyClient;
+ public KeyRequestResource keyRequestClient;
+
+ public KeyClient(PKIConnection connection) throws URISyntaxException {
+ super(connection);
+ init();
+ }
+
+ public KeyClient(ClientConfig config) throws URISyntaxException {
+ super(config);
+ init();
+ }
+
+ public void init() throws URISyntaxException {
+ keyClient = createProxy(KeyResource.class);
+ keyRequestClient = createProxy(KeyRequestResource.class);
+ }
+
+ public KeyDataInfos findKeys(String clientID, String status, Integer maxSize, Integer maxTime) {
+ return keyClient.listKeys(clientID, status, maxSize, maxTime);
+ }
+
+ public KeyData retrieveKey(KeyRecoveryRequest data) {
+ return keyClient.retrieveKey(data);
+ }
+
+ public KeyRequestInfos findKeyRequests(
+ String requestState,
+ String requestType,
+ String clientID,
+ RequestId start,
+ Integer pageSize,
+ Integer maxResults,
+ Integer maxTime) {
+ return keyRequestClient.listRequests(
+ requestState,
+ requestType,
+ clientID,
+ start,
+ pageSize,
+ maxResults,
+ maxTime);
+ }
+}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java
index 3af348ef3..09d228718 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyDataInfo.java
@@ -42,6 +42,18 @@ public class KeyDataInfo {
@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)
}
@@ -82,4 +94,35 @@ public class KeyDataInfo {
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/KeyDataInfos.java b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
index 4e82f27b5..d9fc885b4 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyDataInfos.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.key;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -29,8 +30,8 @@ import com.netscape.certsrv.base.Link;
@XmlRootElement(name = "KeyDataInfos")
public class KeyDataInfos {
- protected Collection<KeyDataInfo> keyInfos;
- protected List<Link> links;
+ protected Collection<KeyDataInfo> keyInfos = new ArrayList<KeyDataInfo>();
+ protected List<Link> links = new ArrayList<Link>();
/**
* @return the keyInfos
@@ -39,12 +40,21 @@ public class KeyDataInfos {
public Collection<KeyDataInfo> getKeyInfos() {
return keyInfos;
}
+
/**
* @param keyInfos the keyInfos to set
*/
public void setKeyInfos(Collection<KeyDataInfo> keyInfos) {
this.keyInfos = keyInfos;
}
+
+ /**
+ * @param keyInfo the keyInfo to add
+ */
+ public void addKeyInfo(KeyDataInfo keyInfo) {
+ keyInfos.add(keyInfo);
+ }
+
/**
* @return the links
*/
@@ -52,6 +62,7 @@ public class KeyDataInfos {
public List<Link> getLinks() {
return links;
}
+
/**
* @param links the links to set
*/
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
index f18e60e64..d9e5fbf1c 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfo.java
@@ -18,6 +18,12 @@
package com.netscape.certsrv.key;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@@ -25,6 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.netscape.certsrv.dbs.keydb.KeyId;
import com.netscape.certsrv.request.CMSRequestInfo;
+import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "KeyRequestInfo")
@XmlAccessorType(XmlAccessType.FIELD)
@@ -58,4 +65,66 @@ public class KeyRequestInfo extends CMSRequestInfo {
public void setKeyURL(String keyURL) {
this.keyURL = keyURL;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((keyURL == null) ? 0 : keyURL.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ KeyRequestInfo other = (KeyRequestInfo) obj;
+ if (keyURL == null) {
+ if (other.keyURL != null)
+ return false;
+ } else if (!keyURL.equals(other.keyURL))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ try {
+ StringWriter sw = new StringWriter();
+ Marshaller marshaller = JAXBContext.newInstance(KeyRequestInfo.class).createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(this, sw);
+ return sw.toString();
+
+ } catch (Exception e) {
+ return super.toString();
+ }
+ }
+
+ public static KeyRequestInfo valueOf(String string) throws Exception {
+ try {
+ Unmarshaller unmarshaller = JAXBContext.newInstance(KeyRequestInfo.class).createUnmarshaller();
+ return (KeyRequestInfo)unmarshaller.unmarshal(new StringReader(string));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ KeyRequestInfo before = new KeyRequestInfo();
+ before.setRequestType("securityDataEnrollment");
+ before.setRequestStatus(RequestStatus.COMPLETE);
+
+ String string = before.toString();
+ System.out.println(string);
+
+ KeyRequestInfo after = KeyRequestInfo.valueOf(string);
+ System.out.println(after);
+
+ System.out.println(before.equals(after));
+ }
}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
index 1fbd363d3..90756f8d3 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestInfos.java
@@ -17,24 +17,38 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.key;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import com.netscape.certsrv.base.Link;
+import com.netscape.certsrv.request.RequestStatus;
@XmlRootElement(name = "KeyRequestInfos")
+@XmlAccessorType(XmlAccessType.FIELD)
public class KeyRequestInfos {
- protected Collection<KeyRequestInfo> requests;
- protected List<Link> links;
+
+ @XmlElementRef
+ protected Collection<KeyRequestInfo> requests = new ArrayList<KeyRequestInfo>();
+
+ @XmlElement(name = "Link")
+ protected List<Link> links = new ArrayList<Link>();
/**
* @return the requests
*/
- @XmlElementRef
public Collection<KeyRequestInfo> getRequests() {
return requests;
}
@@ -43,13 +57,21 @@ public class KeyRequestInfos {
* @param requests the requests to set
*/
public void setRequests(Collection<KeyRequestInfo> requests) {
- this.requests = requests;
+ this.requests.clear();
+ if (requests == null) return;
+ this.requests.addAll(requests);
+ }
+
+ /**
+ * @param request the request to add
+ */
+ public void addRequest(KeyRequestInfo request) {
+ requests.add(request);
}
/**
* @return the links
*/
- @XmlElementRef
public List<Link> getLinks() {
return links;
}
@@ -58,14 +80,20 @@ public class KeyRequestInfos {
* @param links the links to set
*/
public void setLinks(List<Link> links) {
- this.links = links;
+ this.links.clear();
+ if (links == null) return;
+ this.links.addAll(links);
+ }
+
+ /**
+ * @param links the link to add
+ */
+ public void addLink(Link link) {
+ this.links.add(link);
}
@XmlTransient
public String getNext() {
- if (links == null) {
- return null;
- }
for (Link link : links) {
if ("next".equals(link.getRelationship())) {
return link.getHref();
@@ -76,9 +104,6 @@ public class KeyRequestInfos {
@XmlTransient
public String getPrevious() {
- if (links == null) {
- return null;
- }
for (Link link : links) {
if ("previous".equals(link.getRelationship())) {
return link.getHref();
@@ -86,4 +111,75 @@ public class KeyRequestInfos {
}
return null;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((links == null) ? 0 : links.hashCode());
+ result = prime * result + ((requests == null) ? 0 : requests.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ KeyRequestInfos other = (KeyRequestInfos) obj;
+ if (links == null) {
+ if (other.links != null)
+ return false;
+ } else if (!links.equals(other.links))
+ return false;
+ if (requests == null) {
+ if (other.requests != null)
+ return false;
+ } else if (!requests.equals(other.requests))
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ try {
+ StringWriter sw = new StringWriter();
+ Marshaller marshaller = JAXBContext.newInstance(KeyRequestInfos.class).createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ marshaller.marshal(this, sw);
+ return sw.toString();
+
+ } catch (Exception e) {
+ return super.toString();
+ }
+ }
+
+ public static KeyRequestInfos valueOf(String string) throws Exception {
+ try {
+ Unmarshaller unmarshaller = JAXBContext.newInstance(KeyRequestInfos.class).createUnmarshaller();
+ return (KeyRequestInfos)unmarshaller.unmarshal(new StringReader(string));
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ KeyRequestInfos before = new KeyRequestInfos();
+
+ KeyRequestInfo request = new KeyRequestInfo();
+ request.setRequestType("securityDataEnrollment");
+ request.setRequestStatus(RequestStatus.COMPLETE);
+ before.addRequest(request);
+
+ String string = before.toString();
+ System.out.println(string);
+
+ KeyRequestInfos after = KeyRequestInfos.valueOf(string);
+ System.out.println(after);
+
+ System.out.println(before.equals(after));
+ }
}
diff --git a/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
index 7fecd0610..356fd1569 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyRequestResource.java
@@ -1,7 +1,6 @@
package com.netscape.certsrv.key;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -20,11 +19,6 @@ public interface KeyRequestResource {
public final String PASS_PHRASE_TYPE = "passPhrase";
public final String ASYMMETRIC_KEY_TYPE = "asymmetricKey";
- public static final int DEFAULT_START = 0;
- public static final int DEFAULT_PAGESIZE = 20;
- public static final int DEFAULT_MAXRESULTS = 100;
- public static final int DEFAULT_MAXTIME = 10;
-
/**
* Used to generate list of key requests based on the search parameters
*/
@@ -33,10 +27,10 @@ public interface KeyRequestResource {
public KeyRequestInfos listRequests(@QueryParam("requestState") String requestState,
@QueryParam("requestType") String requestType,
@QueryParam("clientID") String clientID,
- @DefaultValue(""+DEFAULT_START) @QueryParam("start") RequestId start,
- @DefaultValue(""+DEFAULT_PAGESIZE) @QueryParam("pageSize") int pageSize,
- @DefaultValue(""+DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
- @DefaultValue(""+DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
+ @QueryParam("start") RequestId start,
+ @QueryParam("pageSize") Integer pageSize,
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("maxTime") Integer maxTime);
/**
diff --git a/base/common/src/com/netscape/certsrv/key/KeyResource.java b/base/common/src/com/netscape/certsrv/key/KeyResource.java
index a499ca11f..50fe82cc3 100644
--- a/base/common/src/com/netscape/certsrv/key/KeyResource.java
+++ b/base/common/src/com/netscape/certsrv/key/KeyResource.java
@@ -1,7 +1,6 @@
package com.netscape.certsrv.key;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@@ -14,15 +13,12 @@ import javax.ws.rs.core.MultivaluedMap;
@Path("agent/keys")
public interface KeyResource {
- public static final int DEFAULT_MAXTIME = 10;
- public static final int DEFAULT_MAXRESULTS = 100;
-
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public KeyDataInfos listKeys(@QueryParam("clientID") String clientID,
@QueryParam("status") String status,
- @DefaultValue(""+DEFAULT_MAXRESULTS) @QueryParam("maxResults") int maxResults,
- @DefaultValue(""+DEFAULT_MAXTIME) @QueryParam("maxTime") int maxTime);
+ @QueryParam("maxResults") Integer maxResults,
+ @QueryParam("maxTime") Integer maxTime);
/**
diff --git a/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java b/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
index 0be24fbb4..f7b34f0a2 100644
--- a/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
+++ b/base/common/src/com/netscape/certsrv/request/CMSRequestInfo.java
@@ -85,4 +85,40 @@ public class CMSRequestInfo {
this.requestURL = requestURL;
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((requestStatus == null) ? 0 : requestStatus.hashCode());
+ result = prime * result + ((requestType == null) ? 0 : requestType.hashCode());
+ result = prime * result + ((requestURL == null) ? 0 : requestURL.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ CMSRequestInfo other = (CMSRequestInfo) obj;
+ if (requestStatus == null) {
+ if (other.requestStatus != null)
+ return false;
+ } else if (!requestStatus.equals(other.requestStatus))
+ return false;
+ if (requestType == null) {
+ if (other.requestType != null)
+ return false;
+ } else if (!requestType.equals(other.requestType))
+ return false;
+ if (requestURL == null) {
+ if (other.requestURL != null)
+ return false;
+ } else if (!requestURL.equals(other.requestURL))
+ return false;
+ return true;
+ }
}
diff --git a/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java b/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
index cb07caf71..7e9445dbc 100644
--- a/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
+++ b/base/common/src/com/netscape/certsrv/request/CMSRequestInfos.java
@@ -17,6 +17,7 @@
//--- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.request;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -25,8 +26,8 @@ import com.netscape.certsrv.base.Link;
//Convenience class to simply hold a Collection of CMSRequests and a List of Links.
public class CMSRequestInfos {
- protected Collection<CMSRequestInfo> requests;
- protected List<Link> links;
+ protected Collection<CMSRequestInfo> requests = new ArrayList<CMSRequestInfo>();
+ protected List<Link> links = new ArrayList<Link>();
/**
* @return the requests
@@ -39,7 +40,16 @@ public class CMSRequestInfos {
* @param requests the requests to set
*/
public void setRequests(Collection<CMSRequestInfo> requests) {
- this.requests = requests;
+ this.requests.clear();
+ if (requests == null) return;
+ this.requests.addAll(requests);
+ }
+
+ /**
+ * @param requests the requests to add
+ */
+ public void addRequest(CMSRequestInfo request) {
+ requests.add(request);
}
/**
@@ -53,7 +63,15 @@ public class CMSRequestInfos {
* @param links the links to set
*/
public void setLinks(List<Link> links) {
- this.links = links;
+ this.links.clear();
+ if (links == null) return;
+ this.links.addAll(links);
}
+ /**
+ * @param links the link to add
+ */
+ public void addLink(Link link) {
+ links.add(link);
+ }
}