diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-02-02 04:15:02 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-02-03 01:57:21 +0100 |
commit | ce872456a09f5c5d146c6cb465b2466ad3ddc73d (patch) | |
tree | e0575b424ebc4cbd46577a1b02a0ef5a3ae7727c /base/tps/src/org | |
parent | d42f39334ce4b4f5fa89707bfb6145039ff04579 (diff) | |
download | pki-ce872456a09f5c5d146c6cb465b2466ad3ddc73d.tar.gz pki-ce872456a09f5c5d146c6cb465b2466ad3ddc73d.tar.xz pki-ce872456a09f5c5d146c6cb465b2466ad3ddc73d.zip |
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
Diffstat (limited to 'base/tps/src/org')
3 files changed, 16 insertions, 16 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java index 980fe2d01..5a53ff7a5 100644 --- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java +++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java @@ -26,13 +26,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; -import netscape.security.x509.RevocationReason; - import org.dogtagpki.server.tps.cms.CARemoteRequestHandler; import org.dogtagpki.server.tps.cms.CARevokeCertResponse; import org.dogtagpki.server.tps.dbs.ActivityDatabase; import org.dogtagpki.server.tps.dbs.TPSCertRecord; import org.dogtagpki.server.tps.dbs.TokenRecord; +import org.dogtagpki.server.tps.engine.TPSEngine; import org.dogtagpki.server.tps.main.ExternalRegAttrs; import org.dogtagpki.server.tps.main.ExternalRegCertToRecover; import org.dogtagpki.tps.main.TPSException; @@ -43,6 +42,8 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.tps.token.TokenStatus; +import netscape.security.x509.RevocationReason; + /* * TPSTokendb class offers a collection of tokendb management convenience routines */ @@ -73,7 +74,7 @@ public class TPSTokendb { // load allowed token state transitions CMS.debug("TPSTokendbs: allowed transitions:"); - for (String transition : configStore.getString("tokendb.allowedTransitions").split(",")) { + for (String transition : configStore.getString(TPSEngine.CFG_TOKENDB_ALLOWED_TRANSITIONS).split(",")) { String states[] = transition.split(":"); TokenStatus fromState = TokenStatus.fromInt(Integer.valueOf(states[0])); TokenStatus toState = TokenStatus.fromInt(Integer.valueOf(states[1])); 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 a218a7b4f..32dd7a200 100644 --- a/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java +++ b/base/tps/src/org/dogtagpki/server/tps/engine/TPSEngine.java @@ -194,7 +194,6 @@ public class TPSEngine { public static final String ENROLL_MODE_ENROLLMENT = ENROLL_OP; public static final String ENROLL_MODE_RECOVERY = RECOVERY_OP; public static final String ERNOLL_MODE_RENEWAL = RENEWAL_OP; - private static final String CFG_OPERATIONS_TRANSITIONS = "tps.operations.allowedTransitions"; private static String transitionList; @@ -598,7 +597,7 @@ public class TPSEngine { IConfigStore configStore = CMS.getConfigStore(); - String transConfig = CFG_OPERATIONS_TRANSITIONS; + String transConfig = CFG_OPERATIONS_ALLOWED_TRANSITIONS; CMS.debug("TPSEngine.isOperationTransistionAllowed: getting config: " + transConfig); try { 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 b67922e48..a504d3c33 100644 --- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java +++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java @@ -38,6 +38,7 @@ import org.dogtagpki.server.tps.TPSSubsystem; import org.dogtagpki.server.tps.dbs.ActivityDatabase; import org.dogtagpki.server.tps.dbs.TokenDatabase; import org.dogtagpki.server.tps.dbs.TokenRecord; +import org.dogtagpki.server.tps.engine.TPSEngine; import org.jboss.resteasy.plugins.providers.atom.Link; import com.netscape.certsrv.apps.CMS; @@ -76,7 +77,7 @@ public class TokenService extends PKIService implements TokenResource { // load allowed token state transitions CMS.debug("TokenService: allowed transitions:"); - for (String transition : configStore.getString("tokendb.allowedTransitions").split(",")) { + for (String transition : configStore.getString(TPSEngine.CFG_TOKENDB_ALLOWED_TRANSITIONS).split(",")) { String states[] = transition.split(":"); TokenStatus fromState = TokenStatus.fromInt(Integer.valueOf(states[0])); TokenStatus toState = TokenStatus.fromInt(Integer.valueOf(states[1])); @@ -193,7 +194,11 @@ public class TokenService extends PKIService implements TokenResource { tokenData.setTokenID(tokenRecord.getId()); tokenData.setUserID(tokenRecord.getUserID()); tokenData.setType(tokenRecord.getType()); - tokenData.setStatus(getTokenStatus(tokenRecord)); + + TokenStatus currentState = getTokenStatus(tokenRecord); + tokenData.setStatus(currentState); + tokenData.setNextStates(transitions.get(currentState)); + tokenData.setAppletID(tokenRecord.getAppletID()); tokenData.setKeyInfo(tokenRecord.getKeyInfo()); tokenData.setPolicy(tokenRecord.getPolicy()); @@ -484,26 +489,21 @@ public class TokenService extends PKIService implements TokenResource { TPSSubsystem subsystem = (TPSSubsystem)CMS.getSubsystem(TPSSubsystem.ID); TokenRecord tokenRecord = null; - String msg = ""; + String msg = "change token status"; try { TokenDatabase database = subsystem.getTokenDatabase(); tokenRecord = database.getRecord(tokenID); TokenStatus currentTokenStatus = getTokenStatus(tokenRecord); CMS.debug("TokenService.changeTokenStatus(): current status: " + currentTokenStatus); - msg = "change token status from " + currentTokenStatus + " to " + tokenStatus; + msg = msg + " from " + currentTokenStatus + " to " + tokenStatus; // make sure transition is allowed Collection<TokenStatus> nextStatuses = transitions.get(currentTokenStatus); CMS.debug("TokenService.changeTokenStatus(): allowed next statuses: " + nextStatuses); if (nextStatuses == null || !nextStatuses.contains(tokenStatus)) { CMS.debug("TokenService.changeTokenStatus(): next status not allowed: " + tokenStatus); - msg = msg + ": Invalid token status transition"; - subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord, - ipAddress, msg, - "failure", - remoteUser); - throw new BadRequestException(msg); + throw new BadRequestException("Invalid token status transition"); } CMS.debug("TokenService.changeTokenStatus(): next status allowed: " + tokenStatus); @@ -519,7 +519,7 @@ public class TokenService extends PKIService implements TokenResource { } catch (Exception e) { e.printStackTrace(); - msg = msg + e; + msg = msg + ": " + e; subsystem.tdb.tdbActivity(ActivityDatabase.OP_DO_TOKEN, tokenRecord, ipAddress, msg, "failure", remoteUser); |