diff options
Diffstat (limited to 'base/common')
3 files changed, 34 insertions, 25 deletions
diff --git a/base/common/src/com/netscape/certsrv/cert/CertClient.java b/base/common/src/com/netscape/certsrv/cert/CertClient.java index 53118aba1..215153fd1 100644 --- a/base/common/src/com/netscape/certsrv/cert/CertClient.java +++ b/base/common/src/com/netscape/certsrv/cert/CertClient.java @@ -76,6 +76,10 @@ public class CertClient extends PKIClient { return certRequestResource.enrollCert(data); } + public CertRequestInfo getRequest(RequestId id) { + return certRequestResource.getRequestInfo(id); + } + public CertReviewResponse reviewRequest(RequestId id) { return certRequestResource.reviewRequest(id); } diff --git a/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java b/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java index 0d887a871..430f47726 100644 --- a/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java +++ b/base/common/src/com/netscape/certsrv/cert/CertRequestInfo.java @@ -28,8 +28,10 @@ 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 javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import com.netscape.certsrv.dbs.certdb.CertId; +import com.netscape.certsrv.dbs.certdb.CertIdAdapter; import com.netscape.certsrv.request.CMSRequestInfo; import com.netscape.certsrv.request.RequestStatus; @@ -40,6 +42,10 @@ public class CertRequestInfo extends CMSRequestInfo { public static final String REQ_COMPLETE = "complete"; @XmlElement + @XmlJavaTypeAdapter(CertIdAdapter.class) + protected CertId certId; + + @XmlElement protected String certURL; @XmlElement @@ -82,17 +88,19 @@ public class CertRequestInfo extends CMSRequestInfo { /** * @return the certId */ - public CertId getCertId() { - if (certURL == null) return null; - String id = certURL.substring(certURL.lastIndexOf("/") + 1); - return new CertId(id); + return certId; + } + + public void setCertId(CertId certId) { + this.certId = certId; } @Override public int hashCode() { final int prime = 31; - int result = 1; + int result = super.hashCode(); + result = prime * result + ((certId == null) ? 0 : certId.hashCode()); result = prime * result + ((certRequestType == null) ? 0 : certRequestType.hashCode()); result = prime * result + ((certURL == null) ? 0 : certURL.hashCode()); return result; @@ -102,11 +110,16 @@ public class CertRequestInfo extends CMSRequestInfo { public boolean equals(Object obj) { if (this == obj) return true; - if (obj == null) + if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; CertRequestInfo other = (CertRequestInfo) obj; + if (certId == null) { + if (other.certId != null) + return false; + } else if (!certId.equals(other.certId)) + return false; if (certRequestType == null) { if (other.certRequestType != null) return false; @@ -148,6 +161,7 @@ public class CertRequestInfo extends CMSRequestInfo { before.setRequestType("enrollment"); before.setRequestStatus(RequestStatus.COMPLETE); before.setCertRequestType("pkcs10"); + before.setCertId(new CertId("5")); String string = before.toString(); System.out.println(string); diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertRequestInfoFactory.java b/base/common/src/com/netscape/cms/servlet/cert/CertRequestInfoFactory.java index fc16bd5f0..2fbc2096c 100644 --- a/base/common/src/com/netscape/cms/servlet/cert/CertRequestInfoFactory.java +++ b/base/common/src/com/netscape/cms/servlet/cert/CertRequestInfoFactory.java @@ -26,11 +26,10 @@ import javax.ws.rs.core.UriInfo; import netscape.security.x509.X509CertImpl; -import org.apache.commons.lang.StringUtils; - import com.netscape.certsrv.cert.CertRequestInfo; import com.netscape.certsrv.cert.CertRequestResource; import com.netscape.certsrv.cert.CertResource; +import com.netscape.certsrv.dbs.certdb.CertId; import com.netscape.certsrv.profile.IEnrollProfile; import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.RequestId; @@ -57,27 +56,19 @@ public class CertRequestInfoFactory { reqBuilder.path(certRequestPath.value() + "/" + requestId); info.setRequestURL(reqBuilder.build().toString()); - //Get Cert info if issued. + if (requestType == null || requestStatus != RequestStatus.COMPLETE) return info; - String serialNoStr = null; + X509CertImpl impl = request.getExtDataInCert(IEnrollProfile.REQUEST_ISSUED_CERT); + if (impl == null) return info; - if (requestType != null && requestStatus == RequestStatus.COMPLETE) { - X509CertImpl impl[] = new X509CertImpl[1]; - impl[0] = request.getExtDataInCert(IEnrollProfile.REQUEST_ISSUED_CERT); + BigInteger serialNo = impl.getSerialNumber(); + info.setCertId(new CertId(serialNo)); - BigInteger serialNo; - if (impl[0] != null) { - serialNo = impl[0].getSerialNumber(); - serialNoStr = serialNo.toString(); - } - } + Path certPath = CertResource.class.getAnnotation(Path.class); + UriBuilder certBuilder = uriInfo.getBaseUriBuilder(); + certBuilder.path(certPath.value() + "/" + serialNo); - if (!StringUtils.isEmpty(serialNoStr)) { - Path certPath = CertResource.class.getAnnotation(Path.class); - UriBuilder certBuilder = uriInfo.getBaseUriBuilder(); - certBuilder.path(certPath.value() + "/" + serialNoStr); - info.setCertURL(certBuilder.build().toString()); - } + info.setCertURL(certBuilder.build().toString()); return info; } |