From ce872456a09f5c5d146c6cb465b2466ad3ddc73d Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 2 Feb 2016 04:15:02 +0100 Subject: Fixed TPS token state transitions. The TPS service has been modified to provide a list of allowed state transitions based on the current token state. The TPS UI was modified to display only the allowed state transitions when changing the token status. The allowed state transition list has been modified to remove invalid token transitions including: * UNINITIALIZED -> FOUND * UNINITIALIZED -> TEMP_LOST_PERM_LOST The token FOUND state has been renamed to ACTIVE for clarity. The token TEMP_LOST_PERM_LOST state has been merged into PERM_LOST since they are identical in the database. https://fedorahosted.org/pki/ticket/1289 https://fedorahosted.org/pki/ticket/1291 https://fedorahosted.org/pki/ticket/1684 --- .../com/netscape/certsrv/tps/token/TokenClient.java | 5 +++++ .../src/com/netscape/certsrv/tps/token/TokenData.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'base/common/src/com/netscape') diff --git a/base/common/src/com/netscape/certsrv/tps/token/TokenClient.java b/base/common/src/com/netscape/certsrv/tps/token/TokenClient.java index 32a56b3d4..a62e71cf8 100644 --- a/base/common/src/com/netscape/certsrv/tps/token/TokenClient.java +++ b/base/common/src/com/netscape/certsrv/tps/token/TokenClient.java @@ -60,6 +60,11 @@ public class TokenClient extends Client { return client.getEntity(response, TokenData.class); } + public TokenData changeTokenStatus(String tokenID, TokenStatus tokenStatus) { + Response response = resource.changeTokenStatus(tokenID, tokenStatus); + return client.getEntity(response, TokenData.class); + } + public void removeToken(String tokenID) { Response response = resource.removeToken(tokenID); client.getEntity(response, Void.class); 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 235e86fea..9947bf658 100644 --- a/base/common/src/com/netscape/certsrv/tps/token/TokenData.java +++ b/base/common/src/com/netscape/certsrv/tps/token/TokenData.java @@ -20,6 +20,7 @@ package com.netscape.certsrv.tps.token; import java.io.StringReader; import java.io.StringWriter; +import java.util.Collection; import java.util.Date; import javax.xml.bind.JAXBContext; @@ -54,7 +55,10 @@ public class TokenData { String tokenID; String userID; String type; + TokenStatus status; + Collection nextStates; + String appletID; String keyInfo; String policy; @@ -108,6 +112,15 @@ public class TokenData { this.status = status; } + @XmlElement(name="NextStates") + public Collection getNextStates() { + return nextStates; + } + + public void setNextStates(Collection nextStates) { + this.nextStates = nextStates; + } + @XmlElement(name="AppletID") public String getAppletID() { return appletID; @@ -172,6 +185,7 @@ 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 + ((nextStates == null) ? 0 : nextStates.hashCode()); result = prime * result + ((policy == null) ? 0 : policy.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); result = prime * result + ((tokenID == null) ? 0 : tokenID.hashCode()); @@ -219,6 +233,11 @@ public class TokenData { return false; } else if (!modifyTimestamp.equals(other.modifyTimestamp)) return false; + if (nextStates == null) { + if (other.nextStates != null) + return false; + } else if (!nextStates.equals(other.nextStates)) + return false; if (policy == null) { if (other.policy != null) return false; -- cgit