diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-02-03 23:54:56 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-02-05 16:08:10 +0100 |
commit | 987dda15acdd6e6f4c7c477fed122a76ad40260c (patch) | |
tree | 400ec3be7e2c4a314d64be8dcc7bd6e746cd9262 /base/tps/src/org | |
parent | 4c1f6b632fe5493ba3bfe106257192d3fc088f15 (diff) | |
download | pki-987dda15acdd6e6f4c7c477fed122a76ad40260c.tar.gz pki-987dda15acdd6e6f4c7c477fed122a76ad40260c.tar.xz pki-987dda15acdd6e6f4c7c477fed122a76ad40260c.zip |
Fixed token add operation.
The TPS UI and CLI have been modified to accept only token ID,
and optionally user ID and policy attributes when adding a token.
https://fedorahosted.org/pki/ticket/1477
https://fedorahosted.org/pki/ticket/1687
Diffstat (limited to 'base/tps/src/org')
-rw-r--r-- | base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java | 34 |
1 files changed, 15 insertions, 19 deletions
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 1a3a4e96a..247aa911c 100644 --- a/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java +++ b/base/tps/src/org/dogtagpki/server/tps/rest/TokenService.java @@ -34,6 +34,7 @@ import javax.ws.rs.core.Request; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; +import org.apache.commons.lang.StringUtils; import org.dogtagpki.server.tps.TPSSubsystem; import org.dogtagpki.server.tps.dbs.ActivityDatabase; import org.dogtagpki.server.tps.dbs.TokenDatabase; @@ -223,22 +224,6 @@ public class TokenService extends PKIService implements TokenResource { return tokenData; } - public TokenRecord createTokenRecord(TokenData tokenData, String ipAddress, String remoteUser) throws Exception { - - TokenRecord tokenRecord = new TokenRecord(); - tokenRecord.setId(tokenData.getID()); - tokenRecord.setUserID(tokenData.getUserID()); - tokenRecord.setType(tokenData.getType()); - setTokenStatus(tokenRecord, tokenData.getStatus(), ipAddress, remoteUser); - tokenRecord.setAppletID(tokenData.getAppletID()); - tokenRecord.setKeyInfo(tokenData.getKeyInfo()); - tokenRecord.setPolicy(tokenData.getPolicy()); - tokenRecord.setCreateTimestamp(tokenData.getCreateTimestamp()); - tokenRecord.setModifyTimestamp(tokenData.getModifyTimestamp()); - - return tokenRecord; - } - @Override public Response findTokens(String filter, Integer start, Integer size) { @@ -347,11 +332,22 @@ public class TokenService extends PKIService implements TokenResource { try { TokenDatabase database = subsystem.getTokenDatabase(); + tokenRecord = new TokenRecord(); + tokenRecord.setId(tokenID); + + String userID = tokenData.getUserID(); + if (StringUtils.isNotEmpty(userID)) { + tokenRecord.setUserID(userID); + } + + String policy = tokenData.getPolicy(); + if (StringUtils.isNotEmpty(policy)) { + tokenRecord.setPolicy(policy); + } + // new tokens are uninitialized when created - tokenData.setStatus(TokenStatus.UNINITIALIZED); + tokenRecord.setStatus("uninitialized"); - tokenRecord = createTokenRecord(tokenData, ipAddress, remoteUser); - tokenRecord.setId(tokenID); database.addRecord(tokenID, tokenRecord); subsystem.tdb.tdbActivity(ActivityDatabase.OP_ADD, tokenRecord, ipAddress, msg, "success", remoteUser); |