|
|
b80204 |
--- patch/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java 2017-06-06 04:56:02.188426066 +0200
|
|
|
b80204 |
+++ pki/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java 2017-06-06 01:50:56.698341052 +0200
|
|
|
b80204 |
@@ -17,6 +17,8 @@
|
|
|
b80204 |
// --- END COPYRIGHT BLOCK ---
|
|
|
b80204 |
package com.netscape.kra;
|
|
|
b80204 |
|
|
|
b80204 |
+import java.math.BigInteger;
|
|
|
b80204 |
+
|
|
|
b80204 |
import com.netscape.certsrv.apps.CMS;
|
|
|
b80204 |
import com.netscape.certsrv.base.EBaseException;
|
|
|
b80204 |
import com.netscape.certsrv.dbs.keydb.KeyId;
|
|
|
b80204 |
@@ -41,6 +43,7 @@ public class SecurityDataRecoveryService
|
|
|
b80204 |
|
|
|
b80204 |
private IKeyRecoveryAuthority kra = null;
|
|
|
b80204 |
private SecurityDataProcessor processor = null;
|
|
|
b80204 |
+ private ILogger signedAuditLogger = CMS.getSignedAuditLogger();
|
|
|
b80204 |
|
|
|
b80204 |
public SecurityDataRecoveryService(IKeyRecoveryAuthority kra) {
|
|
|
b80204 |
this.kra = kra;
|
|
|
b80204 |
@@ -65,8 +68,66 @@ public class SecurityDataRecoveryService
|
|
|
b80204 |
throws EBaseException {
|
|
|
b80204 |
|
|
|
b80204 |
CMS.debug("SecurityDataRecoveryService.serviceRequest()");
|
|
|
b80204 |
- processor.recover(request);
|
|
|
b80204 |
- kra.getRequestQueue().updateRequest(request);
|
|
|
b80204 |
+
|
|
|
b80204 |
+ // parameters for auditing
|
|
|
b80204 |
+ String auditSubjectID = request.getExtDataInString(IRequest.ATTR_REQUEST_OWNER);
|
|
|
b80204 |
+ BigInteger serialNumber = request.getExtDataInBigInteger("serialNumber");
|
|
|
b80204 |
+ KeyId keyId = serialNumber != null ? new KeyId(serialNumber): null;
|
|
|
b80204 |
+ RequestId requestID = request.getRequestId();
|
|
|
b80204 |
+ String approvers = request.getExtDataInString(IRequest.ATTR_APPROVE_AGENTS);
|
|
|
b80204 |
+
|
|
|
b80204 |
+ try {
|
|
|
b80204 |
+ processor.recover(request);
|
|
|
b80204 |
+ kra.getRequestQueue().updateRequest(request);
|
|
|
b80204 |
+ auditRecoveryRequestProcessed(
|
|
|
b80204 |
+ auditSubjectID,
|
|
|
b80204 |
+ ILogger.SUCCESS,
|
|
|
b80204 |
+ requestID,
|
|
|
b80204 |
+ keyId,
|
|
|
b80204 |
+ null,
|
|
|
b80204 |
+ approvers);
|
|
|
b80204 |
+ } catch (EBaseException e) {
|
|
|
b80204 |
+ auditRecoveryRequestProcessed(
|
|
|
b80204 |
+ auditSubjectID,
|
|
|
b80204 |
+ ILogger.FAILURE,
|
|
|
b80204 |
+ requestID,
|
|
|
b80204 |
+ keyId,
|
|
|
b80204 |
+ e.getMessage(),
|
|
|
b80204 |
+ approvers);
|
|
|
b80204 |
+ throw e;
|
|
|
b80204 |
+ }
|
|
|
b80204 |
return false; //TODO: return true?
|
|
|
b80204 |
}
|
|
|
b80204 |
+
|
|
|
b80204 |
+ private void audit(AuditEvent event) {
|
|
|
b80204 |
+
|
|
|
b80204 |
+ String template = event.getMessage();
|
|
|
b80204 |
+ Object[] params = event.getParameters();
|
|
|
b80204 |
+
|
|
|
b80204 |
+ String message = CMS.getLogMessage(template, params);
|
|
|
b80204 |
+
|
|
|
b80204 |
+ audit(message);
|
|
|
b80204 |
+ }
|
|
|
b80204 |
+
|
|
|
b80204 |
+ private void audit(String msg) {
|
|
|
b80204 |
+ if (signedAuditLogger == null)
|
|
|
b80204 |
+ return;
|
|
|
b80204 |
+
|
|
|
b80204 |
+ signedAuditLogger.log(ILogger.EV_SIGNED_AUDIT,
|
|
|
b80204 |
+ null,
|
|
|
b80204 |
+ ILogger.S_SIGNED_AUDIT,
|
|
|
b80204 |
+ ILogger.LL_SECURITY,
|
|
|
b80204 |
+ msg);
|
|
|
b80204 |
+ }
|
|
|
b80204 |
+
|
|
|
b80204 |
+ private void auditRecoveryRequestProcessed(String subjectID, String status, RequestId requestID,
|
|
|
b80204 |
+ KeyId keyID, String reason, String recoveryAgents) {
|
|
|
b80204 |
+ audit(new SecurityDataRecoveryProcessedEvent(
|
|
|
b80204 |
+ subjectID,
|
|
|
b80204 |
+ status,
|
|
|
b80204 |
+ requestID,
|
|
|
b80204 |
+ keyID,
|
|
|
b80204 |
+ reason,
|
|
|
b80204 |
+ recoveryAgents));
|
|
|
b80204 |
+ }
|
|
|
b80204 |
}
|