summaryrefslogtreecommitdiffstats
path: root/base/common/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src')
-rw-r--r--base/common/src/com/netscape/certsrv/tps/token/TokenData.java45
-rw-r--r--base/common/src/com/netscape/certsrv/tps/token/TokenResource.java8
-rw-r--r--base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java54
3 files changed, 83 insertions, 24 deletions
diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenData.java b/base/common/src/com/netscape/certsrv/tps/token/TokenData.java
index 3c6b2d7ba..27ee1fa20 100644
--- a/base/common/src/com/netscape/certsrv/tps/token/TokenData.java
+++ b/base/common/src/com/netscape/certsrv/tps/token/TokenData.java
@@ -53,8 +53,8 @@ public class TokenData {
String id;
String tokenID;
String userID;
- String status;
- String reason;
+ String type;
+ TokenStatus status;
String appletID;
String keyInfo;
Date createTimestamp;
@@ -89,22 +89,22 @@ public class TokenData {
this.userID = userID;
}
- @XmlElement(name="Status")
- public String getStatus() {
- return status;
+ @XmlElement(name="Type")
+ public String getType() {
+ return type;
}
- public void setStatus(String status) {
- this.status = status;
+ public void setType(String type) {
+ this.type = type;
}
- @XmlElement(name="Reason")
- public String getReason() {
- return reason;
+ @XmlElement(name="Status")
+ public TokenStatus getStatus() {
+ return status;
}
- public void setReason(String reason) {
- this.reason = reason;
+ public void setStatus(TokenStatus status) {
+ this.status = status;
}
@XmlElement(name="AppletID")
@@ -162,9 +162,9 @@ public class TokenData {
result = prime * result + ((keyInfo == null) ? 0 : keyInfo.hashCode());
result = prime * result + ((link == null) ? 0 : link.hashCode());
result = prime * result + ((modifyTimestamp == null) ? 0 : modifyTimestamp.hashCode());
- result = prime * result + ((reason == null) ? 0 : reason.hashCode());
result = prime * result + ((status == null) ? 0 : status.hashCode());
result = prime * result + ((tokenID == null) ? 0 : tokenID.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((userID == null) ? 0 : userID.hashCode());
return result;
}
@@ -208,21 +208,18 @@ public class TokenData {
return false;
} else if (!modifyTimestamp.equals(other.modifyTimestamp))
return false;
- if (reason == null) {
- if (other.reason != null)
- return false;
- } else if (!reason.equals(other.reason))
- return false;
- if (status == null) {
- if (other.status != null)
- return false;
- } else if (!status.equals(other.status))
+ if (status != other.status)
return false;
if (tokenID == null) {
if (other.tokenID != null)
return false;
} else if (!tokenID.equals(other.tokenID))
return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ return false;
if (userID == null) {
if (other.userID != null)
return false;
@@ -255,8 +252,8 @@ public class TokenData {
TokenData before = new TokenData();
before.setID("token1");
before.setUserID("user1");
- before.setStatus("revoked");
- before.setReason("lost");
+ before.setType("userKey");
+ before.setStatus(TokenStatus.ACTIVE);
before.setAppletID("APPLET1234");
before.setKeyInfo("key info");
before.setCreateTimestamp(new Date());
diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenResource.java b/base/common/src/com/netscape/certsrv/tps/token/TokenResource.java
index 3f5f305ef..e530a8527 100644
--- a/base/common/src/com/netscape/certsrv/tps/token/TokenResource.java
+++ b/base/common/src/com/netscape/certsrv/tps/token/TokenResource.java
@@ -74,6 +74,14 @@ public interface TokenResource {
@PathParam("tokenID") String tokenID,
TokenData tokenData);
+ @POST
+ @Path("{tokenID}")
+ @ClientResponseType(entityType=TokenData.class)
+ @ACLMapping("tokens.modify")
+ public Response changeTokenStatus(
+ @PathParam("tokenID") String tokenID,
+ @QueryParam("status") TokenStatus tokenStatus);
+
@DELETE
@Path("{tokenID}")
@ClientResponseType(entityType=Void.class)
diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java b/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java
new file mode 100644
index 000000000..3c6d349b3
--- /dev/null
+++ b/base/common/src/com/netscape/certsrv/tps/token/TokenStatus.java
@@ -0,0 +1,54 @@
+// --- 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) 2014 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.certsrv.tps.token;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Endi S. Dewata
+ */
+public enum TokenStatus {
+
+ UNINITIALIZED(0),
+ DAMAGED(1),
+ PERM_LOST(2),
+ TEMP_LOST(3),
+ ACTIVE(4),
+ TEMP_LOST_PERM_LOST(5),
+ TERMINATED(6);
+
+ static Map<Integer, TokenStatus> map = new HashMap<Integer, TokenStatus>();
+
+ Integer value;
+
+ static {
+ for (TokenStatus state : TokenStatus.values()) {
+ map.put(state.value, state);
+ }
+ }
+
+ TokenStatus(Integer value) {
+ this.value = value;
+ }
+
+ public static TokenStatus fromInt(Integer value) {
+ return map.get(value);
+ }
+}