diff options
| author | Christina Fu <cfu@redhat.com> | 2016-05-17 17:57:11 -0700 |
|---|---|---|
| committer | Christina Fu <cfu@redhat.com> | 2016-05-18 10:18:48 -0700 |
| commit | 5fe2ebbf66a5ebe0acc11ea7868db8a79b332ddb (patch) | |
| tree | bda4b60c941995d9e65172c832e0aa323ea32e4b /base/tps/src | |
| parent | 81c1d8fdd2c6e6248190cdeafe3ce032c8876e95 (diff) | |
| download | pki-5fe2ebbf66a5ebe0acc11ea7868db8a79b332ddb.tar.gz pki-5fe2ebbf66a5ebe0acc11ea7868db8a79b332ddb.tar.xz pki-5fe2ebbf66a5ebe0acc11ea7868db8a79b332ddb.zip | |
Ticket #1527 reopened: retrieved wrong ca connector config parameter
This ticket was reopened due to retrieving wrong ca connector config param for the case when format is done within an enrollment.
The following is attempted:
op.enroll.userKey.ca.conn
while the following is intended:
op.format.userKey.ca.conn
In addition, this patch also fixes the following issues;
a. reason param name is not conforming: "reason" instead of "revokeReason"
b. adding default reason to format TPS profiles
c. by default mappingResolver.formatProfileMappingResolver resolves
to tokenKey, while enroll resolves to userKey.
-> now changed the userKey
d. if revocation fails during format, it was forgiving.
-> now changed so that error is logged in activity log and exception
thrown and bail out
Diffstat (limited to 'base/tps/src')
| -rw-r--r-- | base/tps/src/org/dogtagpki/server/tps/cms/CARemoteRequestHandler.java | 37 | ||||
| -rw-r--r-- | base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java | 22 |
2 files changed, 51 insertions, 8 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/cms/CARemoteRequestHandler.java b/base/tps/src/org/dogtagpki/server/tps/cms/CARemoteRequestHandler.java index 0a68e6583..ace5f389f 100644 --- a/base/tps/src/org/dogtagpki/server/tps/cms/CARemoteRequestHandler.java +++ b/base/tps/src/org/dogtagpki/server/tps/cms/CARemoteRequestHandler.java @@ -108,6 +108,9 @@ public class CARemoteRequestHandler extends RemoteRequestHandler (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID); HttpConnector conn = (HttpConnector) subsystem.getConnectionManager().getConnector(connid); + if (conn == null) { + throw new EBaseException("CARemoteRequestHandler: enrollCertificate() to connid: " + connid + ": HttpConnector conn null."); + } CMS.debug("CARemoteRequestHandler: enrollCertificate(): sending request to CA"); String encodedPubKey = null; try { @@ -192,12 +195,14 @@ public class CARemoteRequestHandler extends RemoteRequestHandler CMS.debug("CARemoteRequestHandler: enrollCertificate(): sendMsg =" + sendMsg); HttpResponse resp = conn.send("enrollment", sendMsg); + if (resp == null) { + throw new EBaseException("CARemoteRequestHandler: enrollCertificate() to connid: " + connid + ": response null."); + } String content = resp.getContent(); - CMS.debug("CARemoteRequestHandler: enrollCertificate(): got content = " + content); - if (content != null && !content.equals("")) { + CMS.debug("CARemoteRequestHandler: enrollCertificate(): got content = " + content); XMLObject xmlResponse = getXMLparser(content); @@ -298,12 +303,18 @@ public class CARemoteRequestHandler extends RemoteRequestHandler (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID); HttpConnector conn = (HttpConnector) subsystem.getConnectionManager().getConnector(connid); + if (conn == null) { + throw new EBaseException("CARemoteRequestHandler: retrieveCertificate() to connid: " + connid + ": HttpConnector conn null."); + } CMS.debug("CARemoteRequestHandler: retrieveCertificate(): sending request to CA"); HttpResponse resp = conn.send("getcert", IRemoteRequest.GET_XML + "=" + true + "&" + IRemoteRequest.CA_GET_CERT_B64CertOnly + "=" + true + "&" + IRemoteRequest.CA_GET_CERT_SERIAL + "=" + serialno.toString()); + if (resp == null) { + throw new EBaseException("CARemoteRequestHandler: retrieveCertificate() to connid: " + connid + ": response null."); + } String content = resp.getContent(); if (content != null && !content.equals("")) { @@ -395,6 +406,9 @@ public class CARemoteRequestHandler extends RemoteRequestHandler (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID); HttpConnector conn = (HttpConnector) subsystem.getConnectionManager().getConnector(connid); + if (conn == null) { + throw new EBaseException("CARemoteRequestHandler: renewCertificate() to connid: " + connid + ": HttpConnector conn null."); + } CMS.debug("CARemoteRequestHandler: renewCertificate(): sending request to CA"); HttpResponse resp = conn.send("renewal", @@ -403,6 +417,9 @@ public class CARemoteRequestHandler extends RemoteRequestHandler "&" + IRemoteRequest.CA_RENEWAL_SerialNum + "=" + serialno.toString() + "&" + IRemoteRequest.CA_ProfileId + "=" + profileId); + if (resp == null) { + throw new EBaseException("CARemoteRequestHandler: renewCertificate() to connid: " + connid + ": response null."); + } String content = resp.getContent(); if (content != null && !content.equals("")) { @@ -503,6 +520,9 @@ public class CARemoteRequestHandler extends RemoteRequestHandler (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID); HttpConnector conn = (HttpConnector) subsystem.getConnectionManager().getConnector(connid); + if (conn == null) { + throw new EBaseException("CARemoteRequestHandler: revokeCertificate() to connid: " + connid + ": HttpConnector conn null."); + } CMS.debug("CARemoteRequestHandler: revokeCertificate(): sending request to CA"); HttpResponse resp = conn.send("revoke", @@ -511,10 +531,13 @@ public class CARemoteRequestHandler extends RemoteRequestHandler "&" + IRemoteRequest.CA_REVOKE_ALL + "=(" + IRemoteRequest.CA_REVOKE_SERIAL + "=" + serialno + ")&" + IRemoteRequest.CA_REVOKE_COUNT + "=1"); + if (resp == null) { + throw new EBaseException("CARemoteRequestHandler: revokeCertificate() to connid: " + connid + ": response null."); + } String content = resp.getContent(); - CMS.debug("CARemoteRequestHandler: revokeCertificate(): got content = " + content); if (content != null && !content.equals("")) { + CMS.debug("CARemoteRequestHandler: revokeCertificate(): got content = " + content); Hashtable<String, Object> response = parseResponse(content); @@ -570,14 +593,20 @@ public class CARemoteRequestHandler extends RemoteRequestHandler (TPSSubsystem) CMS.getSubsystem(TPSSubsystem.ID); HttpConnector conn = (HttpConnector) subsystem.getConnectionManager().getConnector(connid); + if (conn == null) { + throw new EBaseException("CARemoteRequestHandler: unrevokeCertificate() to connid: " + connid + ": HttpConnector conn null."); + } CMS.debug("CARemoteRequestHandler: unrevokeCertificate(): sending request to CA"); HttpResponse resp = conn.send("unrevoke", IRemoteRequest.CA_UNREVOKE_SERIAL + "=" + serialno); + if (resp == null) { + throw new EBaseException("CARemoteRequestHandler: unrevokeCertificate() to connid: " + connid + ": response null."); + } String content = resp.getContent(); - CMS.debug("CARemoteRequestHandler: unrevokeCertificate(): got content = " + content); if (content != null && !content.equals("")) { + CMS.debug("CARemoteRequestHandler: unrevokeCertificate(): got content = " + content); Hashtable<String, Object> response = parseResponse(content); diff --git a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java index bbc9fcb5e..5b471ca24 100644 --- a/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java +++ b/base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java @@ -1376,7 +1376,7 @@ public class TPSProcessor { ".ca.conn"; CMS.debug(method + " finding config: " + config); } else { - config = "op." + currentTokenOperation + "." + + config = TPSEngine.OP_FORMAT_PREFIX + "." + selectedTokenType + ".ca.conn"; CMS.debug(method + " finding config: " + config); @@ -1424,7 +1424,9 @@ public class TPSProcessor { String logMsg; IConfigStore configStore = CMS.getConfigStore(); - String configName = TPSEngine.OP_FORMAT_PREFIX + "." + selectedTokenType + ".revokeCert.revokeReason"; + String configName = TPSEngine.OP_FORMAT_PREFIX + "." + selectedTokenType + ".revokeCert.reason"; + CMS.debug(method + " finding config: " + configName); + RevocationReason revokeReason = RevocationReason.UNSPECIFIED; try { int revokeReasonInt = configStore.getInteger(configName); @@ -2137,7 +2139,19 @@ public class TPSProcessor { revokeCertificates(tokenRecord.getId(), reason, caConnId); } catch (TPSException te) { // failed revocation; capture message and continue - logMsg = te.getMessage(); + String failMsg = "revoke certificates failure"; + logMsg = failMsg + ":" + te.toString(); + CMS.debug("TPSProcessor.format: " + logMsg); + tps.tdb.tdbActivity(ActivityDatabase.OP_FORMAT, tokenRecord, session.getIpAddress(), logMsg, + "failure"); + throw new TPSException(logMsg, TPSStatus.STATUS_ERROR_CONTACT_ADMIN); + } catch (Exception ee) { + String failMsg = "revoke certificates failure"; + logMsg = failMsg + ":" + ee.toString(); + CMS.debug("TPSProcessor.format: " + logMsg); + tps.tdb.tdbActivity(ActivityDatabase.OP_FORMAT, tokenRecord, session.getIpAddress(), logMsg, + "failure"); + throw new TPSException(logMsg, TPSStatus.STATUS_ERROR_CONTACT_ADMIN); } } @@ -2160,7 +2174,7 @@ public class TPSProcessor { tps.tdb.tdbActivity(ActivityDatabase.OP_FORMAT, tokenRecord, session.getIpAddress(), failMsg, "failure"); - throw new TPSException(logMsg); + throw new TPSException(logMsg, TPSStatus.STATUS_ERROR_CONTACT_ADMIN); } logMsg = "format operation succeeded"; |
