Skip to content

Commit

Permalink
Merged TOKEN_APPLET_UPGRADE events.
Browse files Browse the repository at this point in the history
The TOKEN_APPLET_UPGRADE_* events have been merged into a single
event with different outcomes. Also, it has been encapsulated into
TokenAppletUpgradeEvent class.

https://pagure.io/dogtagpki/issue/2656

Change-Id: Ifa34eacaa5a0da1c8026eb702e09828234d7f0f5
(cherry picked from commit c006503)
  • Loading branch information
edewata committed Jan 26, 2018
1 parent 4b48f2c commit 5d3ddcd
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 17 deletions.
4 changes: 0 additions & 4 deletions base/common/src/com/netscape/certsrv/logging/AuditEvent.java
Expand Up @@ -133,10 +133,6 @@ public class AuditEvent extends LogEvent {
"LOGGING_SIGNED_AUDIT_TOKEN_FORMAT_SUCCESS_9";
public final static String TOKEN_FORMAT_FAILURE =
"LOGGING_SIGNED_AUDIT_TOKEN_FORMAT_FAILURE_9";
public final static String TOKEN_APPLET_UPGRADE_SUCCESS =
"LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_SUCCESS_9";
public final static String TOKEN_APPLET_UPGRADE_FAILURE =
"LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_FAILURE_9";
public final static String TOKEN_KEY_CHANGEOVER_REQUIRED =
"LOGGING_SIGNED_AUDIT_TOKEN_KEY_CHANGEOVER_REQUIRED_10";
public final static String TOKEN_KEY_CHANGEOVER_SUCCESS =
Expand Down
@@ -0,0 +1,56 @@
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2018 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.certsrv.logging.event;

import com.netscape.certsrv.logging.SignedAuditEvent;

public class TokenAppletUpgradeEvent extends SignedAuditEvent {

private static final long serialVersionUID = 1L;

public final static String TOKEN_APPLET_UPGRADE_SUCCESS =
"LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_SUCCESS";

public final static String TOKEN_APPLET_UPGRADE_FAILURE =
"LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_FAILURE";

public TokenAppletUpgradeEvent(
String messageID,
String ip,
String subjectID,
String cuid,
String msn,
String outcome,
String keyVersion,
String oldAppletVersion,
String newAppletVersion,
String info) {

super(messageID);

setAttribute("IP", ip);
setAttribute("SubjectID", subjectID);
setAttribute("CUID", cuid);
setAttribute("MSN", msn);
setAttribute("Outcome", outcome);
setAttribute("KeyVersion", keyVersion);
setAttribute("oldAppletVersion", oldAppletVersion);
setAttribute("newAppletVersion", newAppletVersion);
setAttribute("Info", info);
}
}
8 changes: 4 additions & 4 deletions base/server/cmsbundle/src/LogMessages.properties
Expand Up @@ -2235,8 +2235,8 @@ LOGGING_SIGNED_AUDIT_CMC_SIGNED_REQUEST_SIG_VERIFY=<type=CMC_SIGNED_REQUEST_SIG_
# CertSubject must be the certificate subject name of the certificate request
# CMCSignerInfo must be a unique String representation for the CMC request signer
#
LOGGING_SIGNED_AUDIT_CMC_USER_SIGNED_REQUEST_SIG_VERIFY_SUCCESS=<type=CMC_USER_SIGNED_REQUEST_SIG_VERIFY>:[AuditEvent=CMC_USER_SIGNED_REQUEST_SIG_VERIFY] User signed CMC request signature verification success
LOGGING_SIGNED_AUDIT_CMC_USER_SIGNED_REQUEST_SIG_VERIFY_FAILURE=<type=CMC_USER_SIGNED_REQUEST_SIG_VERIFY>:[AuditEvent=CMC_USER_SIGNED_REQUEST_SIG_VERIFY] User signed CMC request signature verification failure
LOGGING_SIGNED_AUDIT_CMC_USER_SIGNED_REQUEST_SIG_VERIFY_SUCCESS=<type=CMC_USER_SIGNED_REQUEST_SIG_VERIFY>:[AuditEvent=CMC_USER_SIGNED_REQUEST_SIG_VERIFY]{0} User signed CMC request signature verification success
LOGGING_SIGNED_AUDIT_CMC_USER_SIGNED_REQUEST_SIG_VERIFY_FAILURE=<type=CMC_USER_SIGNED_REQUEST_SIG_VERIFY>:[AuditEvent=CMC_USER_SIGNED_REQUEST_SIG_VERIFY]{0} User signed CMC request signature verification failure

# LOGGING_SIGNED_AUDIT_COMPUTE_RANDOM_DATA_REQUEST
# - used for TPS to TKS to get random challenge data
Expand Down Expand Up @@ -2613,12 +2613,12 @@ LOGGING_SIGNED_AUDIT_TOKEN_FORMAT_FAILURE_9=<type=TOKEN_FORMAT_FAILURE>:[AuditEv
#
# LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_SUCCESS
# - used when token apple upgrade succeeded
LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_SUCCESS_9=<type=TOKEN_APPLET_UPGRADE_SUCCESS>:[AuditEvent=TOKEN_APPLET_UPGRADE_SUCCESS][IP={0}][SubjectID={1}][CUID={2}][MSN={3}][Outcome={4}][KeyVersion={5}][oldAppletVersion={6}][newAppletVersion={7}][Info={8}] token applet upgrade success
LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_SUCCESS=<type=TOKEN_APPLET_UPGRADE>:[AuditEvent=TOKEN_APPLET_UPGRADE]{0} token applet upgrade success
#
#
# LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_FAILURE
# - used when token apple upgrade failed
LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_FAILURE_9=<type=TOKEN_APPLET_UPGRADE_FAILURE>:[AuditEvent=TOKEN_APPLET_UPGRADE_FAILURE][IP={0}][SubjectID={1}][CUID={2}][MSN={3}][Outcome={4}][KeyVersion={5}][oldAppletVersion={6}][newAppletVersion={7}][Info={8}] token applet upgrade failure
LOGGING_SIGNED_AUDIT_TOKEN_APPLET_UPGRADE_FAILURE=<type=TOKEN_APPLET_UPGRADE>:[AuditEvent=TOKEN_APPLET_UPGRADE]{0} token applet upgrade failure
#
# LOGGING_SIGNED_AUDIT_TOKEN_KEY_CHANGEOVER_REQUIRED
# - used when token key changeover is required
Expand Down
21 changes: 12 additions & 9 deletions base/tps/src/org/dogtagpki/server/tps/processor/TPSProcessor.java
Expand Up @@ -95,6 +95,7 @@
import com.netscape.certsrv.common.Constants;
import com.netscape.certsrv.logging.AuditEvent;
import com.netscape.certsrv.logging.LogEvent;
import com.netscape.certsrv.logging.event.TokenAppletUpgradeEvent;
import com.netscape.certsrv.tps.token.TokenStatus;
import com.netscape.cms.logging.Logger;
import com.netscape.cms.logging.SignedAuditLogger;
Expand Down Expand Up @@ -4164,27 +4165,29 @@ protected void auditAppletUpgrade(AppletInfo aInfo,
String newVersion,
String info) {

String auditType = "";
String auditType;

switch (status) {
case "success":
auditType = AuditEvent.TOKEN_APPLET_UPGRADE_SUCCESS;
auditType = TokenAppletUpgradeEvent.TOKEN_APPLET_UPGRADE_SUCCESS;
break;
default:
auditType = AuditEvent.TOKEN_APPLET_UPGRADE_FAILURE;
auditType = TokenAppletUpgradeEvent.TOKEN_APPLET_UPGRADE_FAILURE;
}

String auditMessage = CMS.getLogMessage(
TokenAppletUpgradeEvent event = new TokenAppletUpgradeEvent(
auditType,
(session != null) ? session.getIpAddress() : null,
session != null ? session.getIpAddress() : null,
userid,
(aInfo != null) ? aInfo.getCUIDhexStringPlain() : null,
(aInfo != null) ? aInfo.getMSNString() : null,
aInfo != null ? aInfo.getCUIDhexStringPlain() : null,
aInfo != null ? aInfo.getMSNString() : null,
status,
keyVersion,
(aInfo != null) ? aInfo.getFinalAppletVersion() : null,
aInfo != null ? aInfo.getFinalAppletVersion() : null,
newVersion,
info);
audit(auditMessage);

signedAuditLogger.log(event);
}

protected void auditKeyChangeoverRequired(AppletInfo aInfo,
Expand Down

0 comments on commit 5d3ddcd

Please sign in to comment.