From ebd33cf77950cf62624c4615d9ff829c51395539 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Mon, 26 Aug 2013 13:45:55 -0400
Subject: [PATCH] Added TPS connection resource.

A skeleton for TPS connection services and the clients have been added.
The service implementation will be added later.

Ticket #652
---
 .../src/com/netscape/certsrv/tps/TPSClient.java    |   2 +
 .../certsrv/tps/connection/ConnectionClient.java   |  76 ++++++
 .../tps/connection/ConnectionCollection.java}      |  33 +--
 .../certsrv/tps/connection/ConnectionData.java     | 169 +++++++++++++
 .../certsrv/tps/connection/ConnectionInfo.java     | 152 ++++++++++++
 .../tps/connection/ConnectionModification.java     | 169 +++++++++++++
 .../certsrv/tps/connection/ConnectionResource.java |  80 +++++++
 .../com/netscape/cmstools/cert/CertShowCLI.java    |   6 +-
 .../src/com/netscape/cmstools/cli/TPSCLI.java      |   2 +
 .../cmstools/tps/connection/ConnectionAddCLI.java  | 107 +++++++++
 .../cmstools/tps/connection/ConnectionCLI.java     | 108 +++++++++
 .../cmstools/tps/connection/ConnectionFindCLI.java |  94 ++++++++
 .../tps/connection/ConnectionModifyCLI.java        | 107 +++++++++
 .../tps/connection/ConnectionRemoveCLI.java}       |  40 ++--
 .../connection/ConnectionShowCLI.java}             |  48 ++--
 .../org/dogtagpki/server/tps/TPSApplication.java   |   4 +
 .../src/org/dogtagpki/server/tps/TPSSubsystem.java |   6 +
 .../server/tps/connection/ConnectionDatabase.java  |  60 +++++
 .../server/tps/connection/ConnectionRecord.java    |  91 +++++++
 .../server/tps/connection/ConnectionService.java   | 264 +++++++++++++++++++++
 .../dogtagpki/server/tps/token/TokenDatabase.java  |  18 ++
 .../dogtagpki/server/tps/token/TokenService.java   |  15 +-
 22 files changed, 1573 insertions(+), 78 deletions(-)
 create mode 100644 base/common/src/com/netscape/certsrv/tps/connection/ConnectionClient.java
 copy base/{tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java => common/src/com/netscape/certsrv/tps/connection/ConnectionCollection.java} (52%)
 create mode 100644 base/common/src/com/netscape/certsrv/tps/connection/ConnectionData.java
 create mode 100644 base/common/src/com/netscape/certsrv/tps/connection/ConnectionInfo.java
 create mode 100644 base/common/src/com/netscape/certsrv/tps/connection/ConnectionModification.java
 create mode 100644 base/common/src/com/netscape/certsrv/tps/connection/ConnectionResource.java
 create mode 100644 base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionAddCLI.java
 create mode 100644 base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionCLI.java
 create mode 100644 base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
 create mode 100644 base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionModifyCLI.java
 copy base/{tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java => java-tools/src/com/netscape/cmstools/tps/connection/ConnectionRemoveCLI.java} (50%)
 copy base/java-tools/src/com/netscape/cmstools/{cert/CertShowCLI.java => tps/connection/ConnectionShowCLI.java} (57%)
 create mode 100644 base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java
 create mode 100644 base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java
 create mode 100644 base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java

diff --git a/base/common/src/com/netscape/certsrv/tps/TPSClient.java b/base/common/src/com/netscape/certsrv/tps/TPSClient.java
index 94a906cdfc4354b41165e163c08d8f77a3bf09ab..00da49b20f9b0412985564f79d08a6136a4593e6 100644
--- a/base/common/src/com/netscape/certsrv/tps/TPSClient.java
+++ b/base/common/src/com/netscape/certsrv/tps/TPSClient.java
@@ -24,6 +24,7 @@ import com.netscape.certsrv.client.SubsystemClient;
 import com.netscape.certsrv.group.GroupClient;
 import com.netscape.certsrv.logging.ActivityClient;
 import com.netscape.certsrv.tps.cert.TPSCertClient;
+import com.netscape.certsrv.tps.connection.ConnectionClient;
 import com.netscape.certsrv.tps.token.TokenClient;
 import com.netscape.certsrv.user.UserClient;
 
@@ -39,6 +40,7 @@ public class TPSClient extends SubsystemClient {
 
     public void init() throws URISyntaxException {
         addClient(new ActivityClient(client, name));
+        addClient(new ConnectionClient(client, name));
         addClient(new GroupClient(client, name));
         addClient(new TokenClient(client, name));
         addClient(new TPSCertClient(client, name));
diff --git a/base/common/src/com/netscape/certsrv/tps/connection/ConnectionClient.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..74ec14616e000c8c93adcb941fdd33cc76a04e85
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionClient.java
@@ -0,0 +1,76 @@
+//--- 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) 2013 Red Hat, Inc.
+//All rights reserved.
+//--- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.tps.connection;
+
+import java.net.URISyntaxException;
+
+import org.jboss.resteasy.client.ClientResponse;
+
+import com.netscape.certsrv.client.Client;
+import com.netscape.certsrv.client.PKIClient;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionClient extends Client {
+
+    public ConnectionResource resource;
+
+    public ConnectionClient(PKIClient client) throws URISyntaxException {
+        this(client, client.getSubsystem());
+    }
+
+    public ConnectionClient(PKIClient client, String subsystem) throws URISyntaxException {
+        super(client, subsystem, "connection");
+        init();
+    }
+
+    public void init() throws URISyntaxException {
+        resource = createProxy(ConnectionResource.class);
+    }
+
+    public ConnectionCollection findConnections(Integer start, Integer size) {
+        return resource.findConnections(start, size);
+    }
+
+    public ConnectionData getConnection(String connectionID) {
+        return resource.getConnection(connectionID);
+    }
+
+    public ConnectionData addConnection(ConnectionData connectionData) {
+        @SuppressWarnings("unchecked")
+        ClientResponse<ConnectionData> response = (ClientResponse<ConnectionData>)resource.addConnection(connectionData);
+        return client.getEntity(response);
+    }
+
+    public ConnectionData updateConnection(String connectionID, ConnectionData connectionData) {
+        @SuppressWarnings("unchecked")
+        ClientResponse<ConnectionData> response = (ClientResponse<ConnectionData>)resource.updateConnection(connectionID, connectionData);
+        return client.getEntity(response);
+    }
+
+    public ConnectionData modifyConnection(String connectionID, ConnectionModification connectionModification) {
+        @SuppressWarnings("unchecked")
+        ClientResponse<ConnectionData> response = (ClientResponse<ConnectionData>)resource.modifyConnection(connectionID, connectionModification);
+        return client.getEntity(response);
+    }
+
+    public void removeConnection(String connectionID) {
+        resource.removeConnection(connectionID);
+    }
+}
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionCollection.java
similarity index 52%
copy from base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
copy to base/common/src/com/netscape/certsrv/tps/connection/ConnectionCollection.java
index 87d4cbc5b2512fa6c32086629a8b2c0c879b7866..b26a7308d758077fa3d8197143833a427e4b0383 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionCollection.java
@@ -16,34 +16,23 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.token;
+package com.netscape.certsrv.tps.connection;
 
-import java.util.Date;
+import java.util.Collection;
 
-import com.netscape.cmscore.dbs.Database;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import com.netscape.certsrv.base.DataCollection;
 
 /**
- * This class implements in-memory token database. In the future this
- * will be replaced with LDAP database.
- *
  * @author Endi S. Dewata
  */
-public class TokenDatabase extends Database<TokenRecord> {
+@XmlRootElement(name="Connections")
+public class ConnectionCollection extends DataCollection<ConnectionInfo> {
 
-    public TokenDatabase() {
-        super("Token");
-    }
-
-    public void addRecord(TokenRecord tokenRecord) throws Exception {
-        tokenRecord.setStatus("ENABLED");
-        tokenRecord.setCreateTimestamp(new Date());
-
-        addRecord(tokenRecord.getID(), tokenRecord);
-    }
-
-    public void updateRecord(TokenRecord tokenRecord) throws Exception {
-        tokenRecord.setModifyTimestamp(new Date());
-
-        updateRecord(tokenRecord.getID(), tokenRecord);
+    @XmlElementRef
+    public Collection<ConnectionInfo> getEntries() {
+        return super.getEntries();
     }
 }
diff --git a/base/common/src/com/netscape/certsrv/tps/connection/ConnectionData.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionData.java
new file mode 100644
index 0000000000000000000000000000000000000000..573bb9543bdf38e604a078b2a87f94da40e019fc
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionData.java
@@ -0,0 +1,169 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.certsrv.tps.connection;
+
+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 org.jboss.resteasy.plugins.providers.atom.Link;
+
+/**
+ * @author Endi S. Dewata
+ */
+@XmlRootElement(name="Connection")
+public class ConnectionData {
+
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
+
+    static {
+        try {
+            marshaller = JAXBContext.newInstance(ConnectionData.class).createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = JAXBContext.newInstance(ConnectionData.class).createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    String id;
+    String status;
+    String contents;
+
+    Link link;
+
+    @XmlAttribute(name="id")
+    public String getID() {
+        return id;
+    }
+
+    public void setID(String id) {
+        this.id = id;
+    }
+
+    @XmlElement(name="Status")
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    @XmlElement(name="Contents")
+    public String getContents() {
+        return contents;
+    }
+
+    public void setContents(String contents) {
+        this.contents = contents;
+    }
+
+    @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 + ((contents == null) ? 0 : contents.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((link == null) ? 0 : link.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.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;
+        ConnectionData other = (ConnectionData) obj;
+        if (contents == null) {
+            if (other.contents != null)
+                return false;
+        } else if (!contents.equals(other.contents))
+            return false;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (link == null) {
+            if (other.link != null)
+                return false;
+        } else if (!link.equals(other.link))
+            return false;
+        if (status == null) {
+            if (other.status != null)
+                return false;
+        } else if (!status.equals(other.status))
+            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 ConnectionData valueOf(String string) throws Exception {
+        try {
+            return (ConnectionData)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        ConnectionData before = new ConnectionData();
+        before.setID("connection1");
+        before.setStatus("ENABLED");
+        before.setContents("name=connection1\nparam=value");
+
+        String string = before.toString();
+        System.out.println(string);
+
+        ConnectionData after = ConnectionData.valueOf(string);
+        System.out.println(before.equals(after));
+    }
+}
diff --git a/base/common/src/com/netscape/certsrv/tps/connection/ConnectionInfo.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9d93517ec0dcd35bc28540e5da4b53948ce756a
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionInfo.java
@@ -0,0 +1,152 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.certsrv.tps.connection;
+
+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 org.jboss.resteasy.plugins.providers.atom.Link;
+
+/**
+ * @author Endi S. Dewata
+ */
+@XmlRootElement(name="Connection")
+public class ConnectionInfo {
+
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
+
+    static {
+        try {
+            marshaller = JAXBContext.newInstance(ConnectionInfo.class).createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = JAXBContext.newInstance(ConnectionInfo.class).createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    String id;
+    String status;
+
+    Link link;
+
+    @XmlAttribute(name="id")
+    public String getID() {
+        return id;
+    }
+
+    public void setID(String id) {
+        this.id = id;
+    }
+
+    @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 + ((link == null) ? 0 : link.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.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;
+        ConnectionInfo other = (ConnectionInfo) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (link == null) {
+            if (other.link != null)
+                return false;
+        } else if (!link.equals(other.link))
+            return false;
+        if (status == null) {
+            if (other.status != null)
+                return false;
+        } else if (!status.equals(other.status))
+            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 ConnectionInfo valueOf(String string) throws Exception {
+        try {
+            return (ConnectionInfo)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        ConnectionInfo before = new ConnectionInfo();
+        before.setID("connection1");
+        before.setStatus("ENABLED");
+
+        String string = before.toString();
+        System.out.println(string);
+
+        ConnectionInfo after = ConnectionInfo.valueOf(string);
+        System.out.println(before.equals(after));
+    }
+}
diff --git a/base/common/src/com/netscape/certsrv/tps/connection/ConnectionModification.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionModification.java
new file mode 100644
index 0000000000000000000000000000000000000000..7e48074b2c41c2fb4547ec81614d784bb0d6ca9a
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionModification.java
@@ -0,0 +1,169 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.certsrv.tps.connection;
+
+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 org.jboss.resteasy.plugins.providers.atom.Link;
+
+/**
+ * @author Endi S. Dewata
+ */
+@XmlRootElement(name="ConnectionModifyRequest")
+public class ConnectionModification {
+
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
+
+    static {
+        try {
+            marshaller = JAXBContext.newInstance(ConnectionModification.class).createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = JAXBContext.newInstance(ConnectionModification.class).createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    String id;
+    String status;
+    String contents;
+
+    Link link;
+
+    @XmlAttribute(name="id")
+    public String getID() {
+        return id;
+    }
+
+    public void setID(String id) {
+        this.id = id;
+    }
+
+    @XmlElement(name="Status")
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    @XmlElement(name="Contents")
+    public String getContents() {
+        return contents;
+    }
+
+    public void setContents(String contents) {
+        this.contents = contents;
+    }
+
+    @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 + ((contents == null) ? 0 : contents.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((link == null) ? 0 : link.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.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;
+        ConnectionModification other = (ConnectionModification) obj;
+        if (contents == null) {
+            if (other.contents != null)
+                return false;
+        } else if (!contents.equals(other.contents))
+            return false;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (link == null) {
+            if (other.link != null)
+                return false;
+        } else if (!link.equals(other.link))
+            return false;
+        if (status == null) {
+            if (other.status != null)
+                return false;
+        } else if (!status.equals(other.status))
+            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 ConnectionModification valueOf(String string) throws Exception {
+        try {
+            return (ConnectionModification)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        ConnectionModification before = new ConnectionModification();
+        before.setID("connection1");
+        before.setStatus("ENABLED");
+        before.setContents("name=connection1\nparam=value");
+
+        String string = before.toString();
+        System.out.println(string);
+
+        ConnectionModification after = ConnectionModification.valueOf(string);
+        System.out.println(before.equals(after));
+    }
+}
diff --git a/base/common/src/com/netscape/certsrv/tps/connection/ConnectionResource.java b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionResource.java
new file mode 100644
index 0000000000000000000000000000000000000000..ee971b052e4e8f50e935d571632248ab8f84c392
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/connection/ConnectionResource.java
@@ -0,0 +1,80 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.certsrv.tps.connection;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.jboss.resteasy.annotations.ClientResponseType;
+
+
+/**
+ * @author Endi S. Dewata
+ */
+@Path("connections")
+public interface ConnectionResource {
+
+    @GET
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public ConnectionCollection findConnections(
+            @QueryParam("start") Integer start,
+            @QueryParam("size") Integer size);
+
+    @GET
+    @Path("{connectionID}")
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public ConnectionData getConnection(@PathParam("connectionID") String connectionID);
+
+    @POST
+    @ClientResponseType(entityType=ConnectionData.class)
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public Response addConnection(ConnectionData connectionData);
+
+    @PUT
+    @Path("{connectionID}")
+    @ClientResponseType(entityType=ConnectionData.class)
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public Response updateConnection(
+            @PathParam("connectionID") String connectionID,
+            ConnectionData connectionData);
+
+    @POST
+    @Path("{connectionID}")
+    @ClientResponseType(entityType=ConnectionData.class)
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public Response modifyConnection(
+            @PathParam("connectionID") String connectionID,
+            ConnectionModification request);
+
+    @DELETE
+    @Path("{connectionID}")
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public void removeConnection(@PathParam("connectionID") String connectionID);
+}
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java
index d1d6132ae597baeb00ad124d1e96e9756e4f87b6..a048ebff365dbd2b3583e9a08827b204e8353ee5 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java
@@ -83,9 +83,9 @@ public class CertShowCLI extends CLI {
         String encoded = certData.getEncoded();
         if (encoded != null && file != null) {
             // store cert to file
-            PrintWriter out = new PrintWriter(new FileWriter(file));
-            out.print(encoded);
-            out.close();
+            try (PrintWriter out = new PrintWriter(new FileWriter(file))) {
+                out.print(encoded);
+            }
         }
 
         MainCLI.printMessage("Certificate \"" + certID.toHexString() + "\"");
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/TPSCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/TPSCLI.java
index 2f28ada7d3557ce0745aa66005c20a7a771a19bd..7a14b59f64e2d7b0f5d8a8a79d583f7be6ae685a 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/TPSCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/TPSCLI.java
@@ -23,6 +23,7 @@ import com.netscape.certsrv.tps.TPSClient;
 import com.netscape.cmstools.group.GroupCLI;
 import com.netscape.cmstools.logging.ActivityCLI;
 import com.netscape.cmstools.tps.cert.TPSCertCLI;
+import com.netscape.cmstools.tps.connection.ConnectionCLI;
 import com.netscape.cmstools.tps.token.TokenCLI;
 import com.netscape.cmstools.user.UserCLI;
 
@@ -37,6 +38,7 @@ public class TPSCLI extends SubsystemCLI {
         super("tps", "TPS management commands", mainCLI);
 
         addModule(new ActivityCLI(this));
+        addModule(new ConnectionCLI(this));
         addModule(new GroupCLI(this));
         addModule(new TokenCLI(this));
         addModule(new TPSCertCLI(this));
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionAddCLI.java
new file mode 100644
index 0000000000000000000000000000000000000000..bb2beda13c1bbfe732eda952733eefca32cd4aff
--- /dev/null
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionAddCLI.java
@@ -0,0 +1,107 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cmstools.tps.connection;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.tps.connection.ConnectionData;
+import com.netscape.cmstools.cli.CLI;
+import com.netscape.cmstools.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionAddCLI extends CLI {
+
+    public ConnectionCLI connectionCLI;
+
+    public ConnectionAddCLI(ConnectionCLI connectionCLI) {
+        super("add", "Add connection", connectionCLI);
+        this.connectionCLI = connectionCLI;
+    }
+
+    public void printHelp() {
+        formatter.printHelp(getFullName() + " <Connection ID> [OPTIONS...]", options);
+    }
+
+    public void execute(String[] args) throws Exception {
+
+        Option option = new Option(null, "status", true, "Status: ENABLED, DISABLED.");
+        option.setArgName("status");
+        option.setRequired(true);
+        options.addOption(option);
+
+        option = new Option(null, "contents", true, "Input file containing connection attributes.");
+        option.setArgName("file");
+        option.setRequired(true);
+        options.addOption(option);
+
+        CommandLine cmd = null;
+
+        try {
+            cmd = parser.parse(options, args);
+
+        } catch (Exception e) {
+            System.err.println("Error: " + e.getMessage());
+            printHelp();
+            System.exit(1);
+        }
+
+        String[] cmdArgs = cmd.getArgs();
+
+        if (cmdArgs.length != 1) {
+            printHelp();
+            System.exit(1);
+        }
+
+        String connectionID = cmdArgs[0];
+        String status = cmd.getOptionValue("status");
+        String contents = cmd.getOptionValue("contents");
+
+        ConnectionData connectionData = new ConnectionData();
+        connectionData.setID(connectionID);
+        connectionData.setStatus(status);
+
+        if (contents != null) {
+            try (BufferedReader in = new BufferedReader(new FileReader(contents));
+                StringWriter sw = new StringWriter();
+                PrintWriter out = new PrintWriter(sw, true)) {
+
+                String line;
+                while ((line = in.readLine()) != null) {
+                    out.println(line);
+                }
+
+                connectionData.setContents(sw.toString());
+            }
+        }
+
+        connectionData = connectionCLI.connectionClient.addConnection(connectionData);
+
+        MainCLI.printMessage("Added connection \"" + connectionID + "\"");
+
+        ConnectionCLI.printConnectionData(connectionData);
+    }
+}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionCLI.java
new file mode 100644
index 0000000000000000000000000000000000000000..5371dbe9d0a4241d14696889932845718055c18b
--- /dev/null
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionCLI.java
@@ -0,0 +1,108 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cmstools.tps.connection;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Arrays;
+
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
+import com.netscape.certsrv.tps.connection.ConnectionClient;
+import com.netscape.certsrv.tps.connection.ConnectionData;
+import com.netscape.certsrv.tps.connection.ConnectionInfo;
+import com.netscape.cmstools.cli.CLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionCLI extends CLI {
+
+    public ConnectionClient connectionClient;
+
+    public ConnectionCLI(CLI parent) {
+        super("connection", "Connection management commands", parent);
+
+        addModule(new ConnectionAddCLI(this));
+        addModule(new ConnectionFindCLI(this));
+        addModule(new ConnectionModifyCLI(this));
+        addModule(new ConnectionRemoveCLI(this));
+        addModule(new ConnectionShowCLI(this));
+    }
+
+    public void execute(String[] args) throws Exception {
+
+        client = parent.getClient();
+        connectionClient = (ConnectionClient)parent.getClient("connection");
+
+        if (args.length == 0) {
+            printHelp();
+            System.exit(1);
+        }
+
+        String command = args[0];
+        String[] commandArgs = Arrays.copyOfRange(args, 1, args.length);
+
+        if (command == null) {
+            printHelp();
+            System.exit(1);
+        }
+
+        CLI module = getModule(command);
+        if (module != null) {
+            module.execute(commandArgs);
+
+        } else {
+            System.err.println("Error: Invalid command \"" + command + "\"");
+            printHelp();
+            System.exit(1);
+        }
+    }
+
+    public static void printConnectionInfo(ConnectionInfo connectionInfo) {
+        System.out.println("  Connection ID: " + connectionInfo.getID());
+        if (connectionInfo.getStatus() != null) System.out.println("  Status: " + connectionInfo.getStatus());
+
+        Link link = connectionInfo.getLink();
+        if (verbose && link != null) {
+            System.out.println("  Link: " + link.getHref());
+        }
+    }
+
+    public static void printConnectionData(ConnectionData connectionData) throws IOException {
+        System.out.println("  Connection ID: " + connectionData.getID());
+        if (connectionData.getStatus() != null) System.out.println("  Status: " + connectionData.getStatus());
+
+        System.out.println("  Contents:");
+        String contents = connectionData.getContents();
+        if (contents != null) {
+            BufferedReader in = new BufferedReader(new StringReader(contents));
+            String line;
+            while ((line = in.readLine()) != null) {
+                System.out.println("    " + line);
+            }
+        }
+
+        Link link = connectionData.getLink();
+        if (verbose && link != null) {
+            System.out.println("  Link: " + link.getHref());
+        }
+    }
+}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
new file mode 100644
index 0000000000000000000000000000000000000000..9218edee4ff357c9ef0a65b0e59bdcb4aa0c965b
--- /dev/null
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionFindCLI.java
@@ -0,0 +1,94 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cmstools.tps.connection;
+
+import java.util.Collection;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.tps.connection.ConnectionCollection;
+import com.netscape.certsrv.tps.connection.ConnectionInfo;
+import com.netscape.cmstools.cli.CLI;
+import com.netscape.cmstools.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionFindCLI extends CLI {
+
+    public ConnectionCLI connectionCLI;
+
+    public ConnectionFindCLI(ConnectionCLI tokenCLI) {
+        super("find", "Find connections", tokenCLI);
+        this.connectionCLI = tokenCLI;
+    }
+
+    public void printHelp() {
+        formatter.printHelp(getFullName() + " [OPTIONS...]", options);
+    }
+
+    public void execute(String[] args) throws Exception {
+
+        Option option = new Option(null, "start", true, "Page start");
+        option.setArgName("start");
+        options.addOption(option);
+
+        option = new Option(null, "size", true, "Page size");
+        option.setArgName("size");
+        options.addOption(option);
+
+        CommandLine cmd = null;
+
+        try {
+            cmd = parser.parse(options, args);
+
+        } catch (Exception e) {
+            System.err.println("Error: " + e.getMessage());
+            printHelp();
+            System.exit(1);
+        }
+
+        String s = cmd.getOptionValue("start");
+        Integer start = s == null ? null : Integer.valueOf(s);
+
+        s = cmd.getOptionValue("size");
+        Integer size = s == null ? null : Integer.valueOf(s);
+
+        ConnectionCollection result = connectionCLI.connectionClient.findConnections(start, size);
+        Collection<ConnectionInfo> connections = result.getEntries();
+
+        MainCLI.printMessage(connections.size() + " connection(s) matched");
+
+        boolean first = true;
+
+        for (ConnectionInfo connectionInfo : connections) {
+
+            if (first) {
+                first = false;
+            } else {
+                System.out.println();
+            }
+
+            ConnectionCLI.printConnectionInfo(connectionInfo);
+        }
+
+        MainCLI.printMessage("Number of entries returned " + connections.size());
+    }
+}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionModifyCLI.java
new file mode 100644
index 0000000000000000000000000000000000000000..f3e44913214e818fd893ebeca4e1c53f45786a48
--- /dev/null
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionModifyCLI.java
@@ -0,0 +1,107 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cmstools.tps.connection;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+
+import com.netscape.certsrv.tps.connection.ConnectionData;
+import com.netscape.certsrv.tps.connection.ConnectionModification;
+import com.netscape.cmstools.cli.CLI;
+import com.netscape.cmstools.cli.MainCLI;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionModifyCLI extends CLI {
+
+    public ConnectionCLI connectionCLI;
+
+    public ConnectionModifyCLI(ConnectionCLI connectionCLI) {
+        super("mod", "Modify connection", connectionCLI);
+        this.connectionCLI = connectionCLI;
+    }
+
+    public void printHelp() {
+        formatter.printHelp(getFullName() + " <Connection ID> [OPTIONS...]", options);
+    }
+
+    public void execute(String[] args) throws Exception {
+
+        Option option = new Option(null, "status", true, "Status: ENABLED, DISABLED.");
+        option.setArgName("status");
+        options.addOption(option);
+
+        option = new Option(null, "contents", true, "Input file containing connection attributes.");
+        option.setArgName("file");
+        options.addOption(option);
+
+        CommandLine cmd = null;
+
+        try {
+            cmd = parser.parse(options, args);
+
+        } catch (Exception e) {
+            System.err.println("Error: " + e.getMessage());
+            printHelp();
+            System.exit(1);
+        }
+
+        String[] cmdArgs = cmd.getArgs();
+
+        if (cmdArgs.length != 1) {
+            printHelp();
+            System.exit(1);
+        }
+
+        String connectionID = cmdArgs[0];
+        String status = cmd.getOptionValue("status");
+        String contents = cmd.getOptionValue("contents");
+
+        ConnectionModification connectionModification = new ConnectionModification();
+        connectionModification.setID(connectionID);
+        connectionModification.setStatus(status);
+
+        if (contents != null) {
+            // load contents from file
+            StringWriter sw = new StringWriter();
+            try (BufferedReader in = new BufferedReader(new FileReader(contents));
+                PrintWriter out = new PrintWriter(sw, true)) {
+
+                String line;
+                while ((line = in.readLine()) != null) {
+                    out.println(line);
+                }
+
+                connectionModification.setContents(sw.toString());
+            }
+        }
+
+        ConnectionData connectionData = connectionCLI.connectionClient.modifyConnection(connectionID, connectionModification);
+
+        MainCLI.printMessage("Modified connection \"" + connectionID + "\"");
+
+        ConnectionCLI.printConnectionData(connectionData);
+    }
+}
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionRemoveCLI.java
similarity index 50%
copy from base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
copy to base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionRemoveCLI.java
index 87d4cbc5b2512fa6c32086629a8b2c0c879b7866..5169f23d9953204b23e139d8c489cf8a7ed0173f 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionRemoveCLI.java
@@ -16,34 +16,38 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.token;
+package com.netscape.cmstools.tps.connection;
 
-import java.util.Date;
-
-import com.netscape.cmscore.dbs.Database;
+import com.netscape.cmstools.cli.CLI;
+import com.netscape.cmstools.cli.MainCLI;
 
 /**
- * This class implements in-memory token database. In the future this
- * will be replaced with LDAP database.
- *
  * @author Endi S. Dewata
  */
-public class TokenDatabase extends Database<TokenRecord> {
+public class ConnectionRemoveCLI extends CLI {
 
-    public TokenDatabase() {
-        super("Token");
-    }
+    public ConnectionCLI connectionCLI;
 
-    public void addRecord(TokenRecord tokenRecord) throws Exception {
-        tokenRecord.setStatus("ENABLED");
-        tokenRecord.setCreateTimestamp(new Date());
+    public ConnectionRemoveCLI(ConnectionCLI connectionCLI) {
+        super("del", "Remove connection", connectionCLI);
+        this.connectionCLI = connectionCLI;
+    }
 
-        addRecord(tokenRecord.getID(), tokenRecord);
+    public void printHelp() {
+        formatter.printHelp(getFullName() + " <Connection ID>", options);
     }
 
-    public void updateRecord(TokenRecord tokenRecord) throws Exception {
-        tokenRecord.setModifyTimestamp(new Date());
+    public void execute(String[] args) throws Exception {
+
+        if (args.length != 1) {
+            printHelp();
+            System.exit(1);
+        }
+
+        String connectionID = args[0];
+
+        connectionCLI.connectionClient.removeConnection(connectionID);
 
-        updateRecord(tokenRecord.getID(), tokenRecord);
+        MainCLI.printMessage("Deleted connection \"" + connectionID + "\"");
     }
 }
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionShowCLI.java
similarity index 57%
copy from base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java
copy to base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionShowCLI.java
index d1d6132ae597baeb00ad124d1e96e9756e4f87b6..7e660d3946ce4169ee1ad0574874da1669ce7555 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/connection/ConnectionShowCLI.java
@@ -12,11 +12,11 @@
 // 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.
+// (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmstools.cert;
+package com.netscape.cmstools.tps.connection;
 
 import java.io.FileWriter;
 import java.io.PrintWriter;
@@ -24,36 +24,32 @@ import java.io.PrintWriter;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.Option;
 
-import com.netscape.certsrv.cert.CertData;
-import com.netscape.certsrv.dbs.certdb.CertId;
+import com.netscape.certsrv.tps.connection.ConnectionData;
 import com.netscape.cmstools.cli.CLI;
 import com.netscape.cmstools.cli.MainCLI;
 
 /**
  * @author Endi S. Dewata
  */
-public class CertShowCLI extends CLI {
+public class ConnectionShowCLI extends CLI {
 
-    public CertCLI certCLI;
+    public ConnectionCLI connectionCLI;
 
-    public CertShowCLI(CertCLI certCLI) {
-        super("show", "Show certificate", certCLI);
-        this.certCLI = certCLI;
+    public ConnectionShowCLI(ConnectionCLI connectionCLI) {
+        super("show", "Show connection", connectionCLI);
+        this.connectionCLI = connectionCLI;
     }
 
     public void printHelp() {
-        formatter.printHelp(getFullName() + " <Serial Number> [OPTIONS...]", options);
+        formatter.printHelp(getFullName() + " <Connection ID>", options);
     }
 
     public void execute(String[] args) throws Exception {
 
-        Option option = new Option(null, "output", true, "Output file");
+        Option option = new Option(null, "contents", true, "Output file to store connection attributes.");
         option.setArgName("file");
         options.addOption(option);
 
-        options.addOption(null, "pretty", false, "Pretty print");
-        options.addOption(null, "encoded", false, "Base-64 encoded");
-
         CommandLine cmd = null;
 
         try {
@@ -65,9 +61,6 @@ public class CertShowCLI extends CLI {
             System.exit(1);
         }
 
-        boolean showPrettyPrint = cmd.hasOption("pretty");
-        boolean showEncoded = cmd.hasOption("encoded");
-
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 1) {
@@ -75,21 +68,20 @@ public class CertShowCLI extends CLI {
             System.exit(1);
         }
 
-        CertId certID = new CertId(cmdArgs[0]);
-        String file = cmd.getOptionValue("output");
+        String connectionID = args[0];
+        String file = cmd.getOptionValue("contents");
 
-        CertData certData = certCLI.certClient.getCert(certID);
+        ConnectionData connectionData = connectionCLI.connectionClient.getConnection(connectionID);
 
-        String encoded = certData.getEncoded();
-        if (encoded != null && file != null) {
-            // store cert to file
+        MainCLI.printMessage("Connection \"" + connectionID + "\"");
+        ConnectionCLI.printConnectionData(connectionData);
+
+        if (file != null) {
+            // store contents to file
             PrintWriter out = new PrintWriter(new FileWriter(file));
-            out.print(encoded);
+            String contents = connectionData.getContents();
+            if (contents != null) out.print(contents);
             out.close();
         }
-
-        MainCLI.printMessage("Certificate \"" + certID.toHexString() + "\"");
-
-        CertCLI.printCertData(certData, showPrettyPrint, showEncoded);
     }
 }
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java
index b0eac50f8934b52183e12b9dfd91bb39462f01d4..a7722720af2edafd748255ba57067451d6f9de0d 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java
@@ -23,6 +23,7 @@ import java.util.Set;
 import javax.ws.rs.core.Application;
 
 import org.dogtagpki.server.tps.cert.TPSCertService;
+import org.dogtagpki.server.tps.connection.ConnectionService;
 import org.dogtagpki.server.tps.logging.ActivityService;
 import org.dogtagpki.server.tps.token.TokenService;
 
@@ -67,6 +68,9 @@ public class TPSApplication extends Application {
         // activities
         classes.add(ActivityService.class);
 
+        // connections
+        classes.add(ConnectionService.class);
+
         // certificates
         classes.add(TPSCertService.class);
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
index 5c27c1233d8855eea002f8c3f749de7c8e818548..13b90fe05dc61bf8beb8a9cac2bfafd0bd49b572 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
@@ -18,6 +18,7 @@
 package org.dogtagpki.server.tps;
 
 import org.dogtagpki.server.tps.cert.TPSCertDatabase;
+import org.dogtagpki.server.tps.connection.ConnectionDatabase;
 import org.dogtagpki.server.tps.logging.ActivityDatabase;
 import org.dogtagpki.server.tps.token.TokenDatabase;
 import org.mozilla.jss.CryptoManager;
@@ -49,6 +50,7 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
     public IConfigStore config;
 
     public ActivityDatabase activityDatabase = new ActivityDatabase();
+    public ConnectionDatabase connectionDatabase = new ConnectionDatabase();
     public TPSCertDatabase certDatabase = new TPSCertDatabase();
     public TokenDatabase tokenDatabase = new TokenDatabase();
 
@@ -121,6 +123,10 @@ public class TPSSubsystem implements IAuthority, ISubsystem {
         return activityDatabase;
     }
 
+    public ConnectionDatabase getConnectionDatabase() {
+        return connectionDatabase;
+    }
+
     public TPSCertDatabase getCertDatabase() {
         return certDatabase;
     }
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java
new file mode 100644
index 0000000000000000000000000000000000000000..cb7fb981f848119b4dd8d2d32b8431587cf7403a
--- /dev/null
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java
@@ -0,0 +1,60 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.server.tps.connection;
+
+import com.netscape.cmscore.dbs.Database;
+
+/**
+ * This class implements in-memory connection database. In the future this
+ * will be replaced with LDAP database.
+ *
+ * @author Endi S. Dewata
+ */
+public class ConnectionDatabase extends Database<ConnectionRecord> {
+
+    public ConnectionDatabase() {
+        super("Connection");
+
+        // add sample records
+        try {
+            ConnectionRecord record1 = new ConnectionRecord();
+            record1.setID("connection1");
+            record1.setStatus("ENABLED");
+            record1.setContents("name=connection1\nparam=value");
+            addRecord(record1);
+
+            ConnectionRecord record2 = new ConnectionRecord();
+            record2.setID("connection2");
+            record2.setStatus("DISABLED");
+            record2.setContents("name=connection2\nparam=value");
+            addRecord(record2);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void addRecord(ConnectionRecord connectionRecord) throws Exception {
+        addRecord(connectionRecord.getID(), connectionRecord);
+    }
+
+    public void updateRecord(ConnectionRecord connectionRecord) throws Exception {
+        updateRecord(connectionRecord.getID(), connectionRecord);
+    }
+}
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java
new file mode 100644
index 0000000000000000000000000000000000000000..c4bcc1ded5ff95fe015a70a99e4fdf9bf3e5298a
--- /dev/null
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java
@@ -0,0 +1,91 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.server.tps.connection;
+
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionRecord {
+
+    String id;
+    String status;
+    String contents;
+
+    public String getID() {
+        return id;
+    }
+
+    public void setID(String id) {
+        this.id = id;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getContents() {
+        return contents;
+    }
+
+    public void setContents(String contents) {
+        this.contents = contents;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((contents == null) ? 0 : contents.hashCode());
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.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;
+        ConnectionRecord other = (ConnectionRecord) obj;
+        if (contents == null) {
+            if (other.contents != null)
+                return false;
+        } else if (!contents.equals(other.contents))
+            return false;
+        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;
+        return true;
+    }
+}
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
new file mode 100644
index 0000000000000000000000000000000000000000..a6ecbbadde75510e4866a8d3f971d91bd93a3a06
--- /dev/null
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
@@ -0,0 +1,264 @@
+// --- 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) 2013 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package org.dogtagpki.server.tps.connection;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.util.Iterator;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.dogtagpki.server.tps.TPSSubsystem;
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.certsrv.base.PKIException;
+import com.netscape.certsrv.tps.connection.ConnectionCollection;
+import com.netscape.certsrv.tps.connection.ConnectionData;
+import com.netscape.certsrv.tps.connection.ConnectionInfo;
+import com.netscape.certsrv.tps.connection.ConnectionModification;
+import com.netscape.certsrv.tps.connection.ConnectionResource;
+import com.netscape.cms.servlet.base.PKIService;
+
+/**
+ * @author Endi S. Dewata
+ */
+public class ConnectionService extends PKIService implements ConnectionResource {
+
+    public final static int DEFAULT_SIZE = 20;
+
+    public ConnectionService() {
+        CMS.debug("ConnectionService.<init>()");
+    }
+
+    public ConnectionInfo createConnectionInfo(ConnectionRecord connectionRecord) {
+
+        ConnectionInfo connectionInfo = new ConnectionInfo();
+        connectionInfo.setID(connectionRecord.getID());
+        connectionInfo.setStatus(connectionRecord.getStatus());
+
+        String connectionID = connectionRecord.getID();
+        try {
+            connectionID = URLEncoder.encode(connectionID, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+
+        URI uri = uriInfo.getBaseUriBuilder().path(ConnectionResource.class).path("{connectionID}").build(connectionID);
+        connectionInfo.setLink(new Link("self", uri));
+
+        return connectionInfo;
+    }
+
+    public ConnectionData createConnectionData(ConnectionRecord connectionRecord) {
+
+        ConnectionData connectionData = new ConnectionData();
+        connectionData.setID(connectionRecord.getID());
+        connectionData.setStatus(connectionRecord.getStatus());
+        connectionData.setContents(connectionRecord.getContents());
+
+        String connectionID = connectionRecord.getID();
+        try {
+            connectionID = URLEncoder.encode(connectionID, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+
+        URI uri = uriInfo.getBaseUriBuilder().path(ConnectionResource.class).path("{connectionID}").build(connectionID);
+        connectionData.setLink(new Link("self", uri));
+
+        return connectionData;
+    }
+
+    public ConnectionRecord createConnectionRecord(ConnectionData connectionData) {
+
+        ConnectionRecord connectionRecord = new ConnectionRecord();
+        connectionRecord.setID(connectionData.getID());
+        connectionRecord.setStatus(connectionData.getStatus());
+        connectionRecord.setContents(connectionData.getContents());
+
+        return connectionRecord;
+    }
+
+    @Override
+    public ConnectionCollection findConnections(Integer start, Integer size) {
+
+        CMS.debug("ConnectionService.findConnections()");
+
+        try {
+            start = start == null ? 0 : start;
+            size = size == null ? DEFAULT_SIZE : size;
+
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+
+            Iterator<ConnectionRecord> connections = database.getRecords().iterator();
+
+            ConnectionCollection response = new ConnectionCollection();
+
+            int i = 0;
+
+            // skip to the start of the page
+            for ( ; i<start && connections.hasNext(); i++) connections.next();
+
+            // return entries up to the page size
+            for ( ; i<start+size && connections.hasNext(); i++) {
+                response.addEntry(createConnectionInfo(connections.next()));
+            }
+
+            // count the total entries
+            for ( ; connections.hasNext(); i++) connections.next();
+
+            if (start > 0) {
+                URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", Math.max(start-size, 0)).build();
+                response.addLink(new Link("prev", uri));
+            }
+
+            if (start+size < i) {
+                URI uri = uriInfo.getRequestUriBuilder().replaceQueryParam("start", start+size).build();
+                response.addLink(new Link("next", uri));
+            }
+
+            return response;
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+
+    @Override
+    public ConnectionData getConnection(String connectionID) {
+
+        CMS.debug("ConnectionService.getConnection(\"" + connectionID + "\")");
+
+        try {
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+
+            return createConnectionData(database.getRecord(connectionID));
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+
+    @Override
+    public Response addConnection(ConnectionData connectionData) {
+
+        CMS.debug("ConnectionService.addConnection(\"" + connectionData.getID() + "\")");
+
+        try {
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+
+            database.addRecord(createConnectionRecord(connectionData));
+            connectionData = createConnectionData(database.getRecord(connectionData.getID()));
+
+            return Response
+                    .created(connectionData.getLink().getHref())
+                    .entity(connectionData)
+                    .type(MediaType.APPLICATION_XML)
+                    .build();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+
+    @Override
+    public Response updateConnection(String connectionID, ConnectionData connectionData) {
+
+        CMS.debug("ConnectionService.updateConnection(\"" + connectionID + "\")");
+
+        try {
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+
+            database.updateRecord(createConnectionRecord(connectionData));
+            connectionData = createConnectionData(database.getRecord(connectionID));
+
+            return Response
+                    .ok(connectionData)
+                    .type(MediaType.APPLICATION_XML)
+                    .build();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+
+    @Override
+    public Response modifyConnection(String connectionID, ConnectionModification request) {
+
+        CMS.debug("ConnectionService.modifyConnection(\"" + connectionID + "\", request");
+
+        try {
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+
+            ConnectionRecord connectionRecord = database.getRecord(connectionID);
+
+            String status = request.getStatus();
+            if (status != null) {
+                connectionRecord.setStatus(status);
+            }
+
+            String contents = request.getContents();
+            if (contents != null) {
+                connectionRecord.setContents(contents);
+            }
+
+            database.updateRecord(connectionRecord);
+            ConnectionData connectionData = createConnectionData(database.getRecord(connectionID));
+
+            return Response
+                    .ok(connectionData)
+                    .type(MediaType.APPLICATION_XML)
+                    .build();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+
+    @Override
+    public void removeConnection(String connectionID) {
+
+        CMS.debug("ConnectionService.removeConnection(\"" + connectionID + "\")");
+
+        try {
+            TPSSubsystem subsystem = TPSSubsystem.getInstance();
+            ConnectionDatabase database = subsystem.getConnectionDatabase();
+            database.removeRecord(connectionID);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new PKIException(e.getMessage());
+        }
+    }
+}
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
index 87d4cbc5b2512fa6c32086629a8b2c0c879b7866..a4c8e34c5cb289378c51aac94a7121ea4dfe874a 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
@@ -32,6 +32,24 @@ public class TokenDatabase extends Database<TokenRecord> {
 
     public TokenDatabase() {
         super("Token");
+
+        // add sample records
+        try {
+            TokenRecord record1 = new TokenRecord();
+            record1.setID("token1");
+            record1.setUserID("user1");
+            record1.setStatus("ENABLED");
+            addRecord(record1);
+
+            TokenRecord record2 = new TokenRecord();
+            record2.setID("token2");
+            record2.setUserID("user2");
+            record2.setStatus("DISABLED");
+            addRecord(record2);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     public void addRecord(TokenRecord tokenRecord) throws Exception {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
index 66f96f9324e03d6f390b3737150215b4fc87a29a..06c92b7ffc64885ce48815b29a8c30a3f7d1b795 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
@@ -29,6 +29,7 @@ import javax.ws.rs.core.Response;
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
+import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.tps.token.TokenCollection;
 import com.netscape.certsrv.tps.token.TokenData;
@@ -44,7 +45,7 @@ public class TokenService extends PKIService implements TokenResource {
     public final static int DEFAULT_SIZE = 20;
 
     public TokenService() {
-        System.out.println("TokenService.<init>()");
+        CMS.debug("TokenService.<init>()");
     }
 
     public TokenData createTokenData(TokenRecord tokenRecord) {
@@ -91,7 +92,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public TokenCollection findTokens(Integer start, Integer size) {
 
-        System.out.println("TokenService.findTokens()");
+        CMS.debug("TokenService.findTokens()");
 
         try {
             start = start == null ? 0 : start;
@@ -138,7 +139,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public TokenData getToken(String tokenID) {
 
-        System.out.println("TokenService.getToken(\"" + tokenID + "\")");
+        CMS.debug("TokenService.getToken(\"" + tokenID + "\")");
 
         try {
             TPSSubsystem subsystem = TPSSubsystem.getInstance();
@@ -155,7 +156,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public Response addToken(TokenData tokenData) {
 
-        System.out.println("TokenService.addToken(\"" + tokenData.getID() + "\")");
+        CMS.debug("TokenService.addToken(\"" + tokenData.getID() + "\")");
 
         try {
             TPSSubsystem subsystem = TPSSubsystem.getInstance();
@@ -179,7 +180,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public Response updateToken(String tokenID, TokenData tokenData) {
 
-        System.out.println("TokenService.updateToken(\"" + tokenID + "\")");
+        CMS.debug("TokenService.updateToken(\"" + tokenID + "\")");
 
         try {
             TPSSubsystem subsystem = TPSSubsystem.getInstance();
@@ -205,7 +206,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public Response modifyToken(String tokenID, TokenModifyRequest request) {
 
-        System.out.println("TokenService.modifyToken(\"" + tokenID + "\", request");
+        CMS.debug("TokenService.modifyToken(\"" + tokenID + "\", request");
 
         try {
             TPSSubsystem subsystem = TPSSubsystem.getInstance();
@@ -230,7 +231,7 @@ public class TokenService extends PKIService implements TokenResource {
     @Override
     public void removeToken(String tokenID) {
 
-        System.out.println("TokenService.removeToken(\"" + tokenID + "\")");
+        CMS.debug("TokenService.removeToken(\"" + tokenID + "\")");
 
         try {
             TPSSubsystem subsystem = TPSSubsystem.getInstance();
-- 
1.8.1.4

