summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java')
-rw-r--r--base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java173
1 files changed, 0 insertions, 173 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
deleted file mode 100644
index 4c6a9b19e..000000000
--- a/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
+++ /dev/null
@@ -1,173 +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.cms.servlet.cert.model;
-
-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.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
-
-import org.jboss.resteasy.plugins.providers.atom.Link;
-
-import com.netscape.certsrv.dbs.certdb.CertId;
-import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
-
-/**
- * @author alee
- *
- */
-@XmlRootElement(name = "CertDataInfo")
-public class CertDataInfo {
-
- public static Marshaller marshaller;
- public static Unmarshaller unmarshaller;
-
- static {
- try {
- JAXBContext context = JAXBContext.newInstance(CertDataInfo.class);
- marshaller = context.createMarshaller();
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
- unmarshaller = context.createUnmarshaller();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- CertId id;
- String subjectDN;
- String status;
-
- Link link;
-
- @XmlAttribute(name="id")
- @XmlJavaTypeAdapter(CertIdAdapter.class)
- public CertId getID() {
- return id;
- }
-
- public void setID(CertId id) {
- this.id = id;
- }
-
- @XmlElement(name="SubjectDN")
- public String getSubjectDN() {
- return subjectDN;
- }
-
- public void setSubjectDN(String subjectDN) {
- this.subjectDN = subjectDN;
- }
-
- @XmlElement(name="Status")
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
- @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 + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((status == null) ? 0 : status.hashCode());
- result = prime * result + ((subjectDN == null) ? 0 : subjectDN.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;
- CertDataInfo other = (CertDataInfo) obj;
- if (id == null) {
- if (other.id != null)
- return false;
- } else if (!id.equals(other.id))
- return false;
- if (status == null) {
- if (other.status != null)
- return false;
- } else if (!status.equals(other.status))
- return false;
- if (subjectDN == null) {
- if (other.subjectDN != null)
- return false;
- } else if (!subjectDN.equals(other.subjectDN))
- return false;
- return true;
- }
-
- public String toString() {
- try {
- StringWriter sw = new StringWriter();
- marshaller.marshal(this, sw);
- return sw.toString();
-
- } catch (Exception e) {
- return super.toString();
- }
- }
-
- public static CertDataInfo valueOf(String string) throws Exception {
- try {
- return (CertDataInfo)unmarshaller.unmarshal(new StringReader(string));
- } catch (Exception e) {
- return null;
- }
- }
-
- public static void main(String args[]) throws Exception {
-
- CertDataInfo before = new CertDataInfo();
- before.setID(new CertId("12512514865863765114"));
- before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
- before.setStatus("VALID");
-
- String string = before.toString();
- System.out.println(string);
-
- CertDataInfo after = CertDataInfo.valueOf(string);
-
- System.out.println(before.equals(after));
- }
-}