diff options
author | Endi S. Dewata <edewata@redhat.com> | 2017-04-14 01:46:36 +0200 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2017-04-25 21:50:11 +0200 |
commit | 6f457f2c5e0df576f067b46a78b481eb5dc197e8 (patch) | |
tree | 7e4e44db9e938f24b4ca0fd97f14325821f4535e /base/common/src | |
parent | 36a606e4b51de17c56da0f9ee4daab062ec4acf3 (diff) | |
download | pki-6f457f2c5e0df576f067b46a78b481eb5dc197e8.tar.gz pki-6f457f2c5e0df576f067b46a78b481eb5dc197e8.tar.xz pki-6f457f2c5e0df576f067b46a78b481eb5dc197e8.zip |
Added CertRequestProcessedEvent constructor for IRequest.
A new CertRequestProcessedEvent constructor has been added to
encapsulate CERT_REQUEST_PROCESSED events that takes an IRequest
object.
The auditInfoValue() method in CAProcessor has been moved into
CertRequestProcessedEvent.
https://pagure.io/dogtagpki/issue/2636
Change-Id: I892f1476835b45910fdc3e64bd9f6fc9e2f016fb
Diffstat (limited to 'base/common/src')
-rw-r--r-- | base/common/src/com/netscape/certsrv/logging/event/CertRequestProcessedEvent.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/logging/event/CertRequestProcessedEvent.java b/base/common/src/com/netscape/certsrv/logging/event/CertRequestProcessedEvent.java index 3e5041ddf..777434bd7 100644 --- a/base/common/src/com/netscape/certsrv/logging/event/CertRequestProcessedEvent.java +++ b/base/common/src/com/netscape/certsrv/logging/event/CertRequestProcessedEvent.java @@ -21,6 +21,7 @@ import java.security.cert.CertificateEncodingException; import com.netscape.certsrv.logging.AuditEvent; import com.netscape.certsrv.logging.ILogger; +import com.netscape.certsrv.request.IRequest; import com.netscape.cmsutil.util.Utils; import netscape.security.x509.X509CertImpl; @@ -29,6 +30,8 @@ public class CertRequestProcessedEvent extends AuditEvent { private static final long serialVersionUID = 1L; + public final static String SIGNED_AUDIT_CERT_REQUEST_REASON = "requestNotes"; + public CertRequestProcessedEvent( String subjectID, String outcome, @@ -65,6 +68,24 @@ public class CertRequestProcessedEvent extends AuditEvent { }); } + public CertRequestProcessedEvent( + String subjectID, + String outcome, + String requesterID, + String infoName, + IRequest request) { + + super(CERT_REQUEST_PROCESSED); + + setParameters(new Object[] { + subjectID, + outcome, + requesterID, + infoName, + auditInfoValue(request) + }); + } + /** * Signed Audit Log Info Certificate Value * @@ -111,4 +132,36 @@ public class CertRequestProcessedEvent extends AuditEvent { return ILogger.SIGNED_AUDIT_EMPTY_VALUE; } } + + /** + * Signed Audit Log Info Value + * + * This method is called to obtain the "reason" for + * a signed audit log message. + * <P> + * + * @param request the actual request + * @return reason string containing the signed audit log message reason + */ + String auditInfoValue(IRequest request) { + + String reason = ILogger.SIGNED_AUDIT_EMPTY_VALUE; + + if (request != null) { + // overwrite "reason" if and only if "info" != null + String info = + request.getExtDataInString(SIGNED_AUDIT_CERT_REQUEST_REASON); + + if (info != null) { + reason = info.trim(); + + // overwrite "reason" if and only if "reason" is empty + if (reason.equals("")) { + reason = ILogger.SIGNED_AUDIT_EMPTY_VALUE; + } + } + } + + return reason; + } } |