summaryrefslogtreecommitdiffstats
path: root/base/tps/src
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-04-23 00:50:08 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-05-03 01:55:54 +0200
commit2b5f9e1630bae2e755093447b08c2236ce8db158 (patch)
treefb3f30683227f8bb02df12ece82b26273879e151 /base/tps/src
parent29cee52cfeb4b6c1b10f6ef4b4bdf91bffe0de7c (diff)
downloadpki-2b5f9e1630bae2e755093447b08c2236ce8db158.tar.gz
pki-2b5f9e1630bae2e755093447b08c2236ce8db158.tar.xz
pki-2b5f9e1630bae2e755093447b08c2236ce8db158.zip
Refactored TokenStatus enumeration.
The TokenStatus enumeration has been converted into a class to allow overriding the TokenStatus.valueOf() to provide backward compatibility. https://fedorahosted.org/pki/ticket/2286
Diffstat (limited to 'base/tps/src')
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java2
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java25
2 files changed, 13 insertions, 14 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java b/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
index bc9d12c19..a577a7619 100644
--- a/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
+++ b/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java
@@ -620,7 +620,7 @@ public class TPSEngine {
}
- String transition = oldState.toInt() + ":" + newState.toInt();
+ String transition = oldState.getValue() + ":" + newState.getValue();
CMS.debug("TPSEngine.isOperationTransistionAllowed: checking for transition: " + transition);
diff --git a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
index 78a503994..46a3c12d6 100644
--- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
+++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java
@@ -90,14 +90,14 @@ public class TokenService extends PKIService implements TokenResource {
auditModParams.put("UserID", tokenRecord.getUserID());
- switch (tokenState) {
- case UNINITIALIZED:
+ switch (tokenState.getValue()) {
+ case TokenStatus.TOKEN_UNINITIALIZED:
tokenRecord.setStatus("uninitialized");
newStatus = "uninitialized";
tokenRecord.setReason(null);
break;
- case ACTIVE:
+ case TokenStatus.TOKEN_ACTIVE:
if (tokenRecord.getTokenStatus() == TokenStatus.TEMP_LOST) {
// unrevoke certs
tps.tdb.unRevokeCertsByCUID(tokenRecord.getId(), ipAddress, remoteUser);
@@ -106,11 +106,10 @@ public class TokenService extends PKIService implements TokenResource {
tokenRecord.setStatus("active");
newStatus = "active";
tokenRecord.setReason(null);
-
break;
- case PERM_LOST:
- case TEMP_LOST_PERM_LOST:
+ case TokenStatus.TOKEN_PERM_LOST:
+ case TokenStatus.TOKEN_TEMP_LOST_PERM_LOST:
tokenRecord.setStatus("lost");
newStatus = "lost";
tokenRecord.setReason("keyCompromise");
@@ -120,7 +119,7 @@ public class TokenService extends PKIService implements TokenResource {
tps.tdb.revokeCertsByCUID(tokenRecord.getId(), "keyCompromise", ipAddress, remoteUser);
break;
- case DAMAGED:
+ case TokenStatus.TOKEN_DAMAGED:
tokenRecord.setStatus("lost");
newStatus = "lost";
tokenRecord.setReason("destroyed");
@@ -128,10 +127,9 @@ public class TokenService extends PKIService implements TokenResource {
//revoke certs
tps.tdb.revokeCertsByCUID(tokenRecord.getId(), "destroyed", ipAddress, remoteUser);
-
break;
- case TEMP_LOST:
+ case TokenStatus.TOKEN_TEMP_LOST:
tokenRecord.setStatus("lost");
newStatus = "lost";
tokenRecord.setReason("onHold");
@@ -141,7 +139,7 @@ public class TokenService extends PKIService implements TokenResource {
tps.tdb.revokeCertsByCUID(tokenRecord.getId(), "onHold", ipAddress, remoteUser);
break;
- case TERMINATED:
+ case TokenStatus.TOKEN_TERMINATED:
String reason = "terminated";
String origStatus2 = tokenRecord.getStatus();
String origReason2 = tokenRecord.getReason();
@@ -225,7 +223,7 @@ public class TokenService extends PKIService implements TokenResource {
String tokenID,
String userID,
String type,
- String status,
+ TokenStatus status,
Integer start,
Integer size) {
@@ -249,8 +247,8 @@ public class TokenService extends PKIService implements TokenResource {
attributes.put("type", type);
}
- if (StringUtils.isNotEmpty(status)) {
- attributes.put("status", status);
+ if (status != null) {
+ attributes.put("status", status.toString());
}
start = start == null ? 0 : start;
@@ -603,6 +601,7 @@ public class TokenService extends PKIService implements TokenResource {
"Token ID is null.");
throw new BadRequestException("Token ID is null.");
}
+
auditModParams.put("tokenID", tokenID);
if (tokenStatus == null) {
auditConfigTokenGeneral(ILogger.FAILURE, method, null,