diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-13 01:31:40 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-08-15 12:07:50 -0500 |
commit | d66adcc04b43ac01a28c59c2649ee88685ed1849 (patch) | |
tree | aafc4ffb74239a10bffbe27a325fc1dc5176e77f /base | |
parent | 1aa02e5207514d210e903d23e1d698b85fc29344 (diff) | |
download | pki-d66adcc04b43ac01a28c59c2649ee88685ed1849.tar.gz pki-d66adcc04b43ac01a28c59c2649ee88685ed1849.tar.xz pki-d66adcc04b43ac01a28c59c2649ee88685ed1849.zip |
Fixed REST common class dependency.
The ConfigurationResponse previously has a method that uses a class
that exists on the server only, creating a dependency issue since
the ConfigurationResponse will be used by the client as well. The
method now has been moved into a separate factory class.
Ticket #259
Diffstat (limited to 'base')
3 files changed, 49 insertions, 19 deletions
diff --git a/base/common/src/com/netscape/certsrv/system/ConfigurationResponse.java b/base/common/src/com/netscape/certsrv/system/ConfigurationResponse.java index 489970c9c..6d3275a51 100644 --- a/base/common/src/com/netscape/certsrv/system/ConfigurationResponse.java +++ b/base/common/src/com/netscape/certsrv/system/ConfigurationResponse.java @@ -20,8 +20,6 @@ package com.netscape.certsrv.system; import java.security.cert.CertificateEncodingException; import java.util.ArrayList; import java.util.Collection; -import java.util.Enumeration; -import java.util.Vector; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -32,7 +30,6 @@ import javax.xml.bind.annotation.XmlRootElement; import netscape.security.x509.X509CertImpl; import com.netscape.certsrv.apps.CMS; -import com.netscape.cms.servlet.csadmin.Cert; /** * @author alee @@ -56,20 +53,6 @@ public class ConfigurationResponse { adminCert = new SystemCertData(); } - public void setSystemCerts(Vector<Cert> certs) { - systemCerts.clear(); - Enumeration<Cert> e = certs.elements(); - while (e.hasMoreElements()) { - Cert cert = e.nextElement(); - SystemCertData cdata = new SystemCertData(); - cdata.setCert(cert.getCert()); - cdata.setRequest(cert.getRequest()); - cdata.setTag(cert.getCertTag()); - cdata.setCertChain(cert.getCertChain()); - systemCerts.add(cdata); - } - } - /** * @return the systemCerts */ diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemCertDataFactory.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemCertDataFactory.java new file mode 100644 index 000000000..bd23c8f16 --- /dev/null +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemCertDataFactory.java @@ -0,0 +1,47 @@ +// --- 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.cms.servlet.csadmin; + +import java.util.ArrayList; +import java.util.Collection; + +import com.netscape.certsrv.system.SystemCertData; + +/** + * @author edewata + */ +public class SystemCertDataFactory { + + public static SystemCertData create(Cert cert) { + SystemCertData data = new SystemCertData(); + data.setCert(cert.getCert()); + data.setRequest(cert.getRequest()); + data.setTag(cert.getCertTag()); + data.setCertChain(cert.getCertChain()); + return data; + } + + public static Collection<SystemCertData> create(Collection<Cert> certs) { + Collection<SystemCertData> result = new ArrayList<SystemCertData>(); + for (Cert cert : certs) { + result.add(create(cert)); + } + return result; + } +} diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java index c7560fbc4..53b004846 100644 --- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java +++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java @@ -545,7 +545,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou // submitting to external ca if ((data.getIssuingCA()!= null) && data.getIssuingCA().equals("External CA") && (!hasSigningCert)) { - response.setSystemCerts(certs); + response.setSystemCerts(SystemCertDataFactory.create(certs)); return response; } @@ -564,7 +564,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou throw new PKIException("Error in confguring system certificates"); } } - response.setSystemCerts(certs); + response.setSystemCerts(SystemCertDataFactory.create(certs)); // BackupKeyCertPanel/SavePKCS12Panel if (data.getBackupKeys().equals("true")) { |