-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Mandatory UserID and Network Access Point info is missing in Destin…
- Loading branch information
1 parent
0fb3bc1
commit 25343b9
Showing
3 changed files
with
141 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
...ee-arc-audit/src/main/java/org/dcm4chee/arc/audit/ProvideAndRegisterAuditInfoBuilder.java
This file was deleted.
Oops, something went wrong.
133 changes: 133 additions & 0 deletions
133
dcm4chee-arc-audit/src/main/java/org/dcm4chee/arc/audit/ProvideAndRegisterAuditService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package org.dcm4chee.arc.audit; | ||
|
||
import org.dcm4che3.audit.*; | ||
import org.dcm4che3.net.audit.AuditLogger; | ||
import org.dcm4chee.arc.conf.ArchiveDeviceExtension; | ||
import org.dcm4chee.arc.exporter.ExportContext; | ||
import org.dcm4chee.arc.qmgt.HttpServletRequestInfo; | ||
|
||
import java.net.URI; | ||
import java.util.Calendar; | ||
|
||
/** | ||
* @author Vrinda Nayak <vrinda.nayak@j4care.com> | ||
* @since Oct 2018 | ||
*/ | ||
class ProvideAndRegisterAuditService { | ||
|
||
static AuditInfoBuilder provideRegisterAuditInfo(ExportContext ctx, ArchiveDeviceExtension arcDev) { | ||
return ctx.getHttpServletRequestInfo() != null | ||
? restfulTriggeredProvideRegisterAuditInfo(ctx, arcDev) | ||
: schedulerTriggeredProvideRegisterAuditInfo(ctx, arcDev); | ||
} | ||
|
||
private static AuditInfoBuilder restfulTriggeredProvideRegisterAuditInfo( | ||
ExportContext ctx, ArchiveDeviceExtension arcDev) { | ||
HttpServletRequestInfo httpServletRequestInfo = ctx.getHttpServletRequestInfo(); | ||
URI destination = ctx.getExporter().getExporterDescriptor().getExportURI(); | ||
return new AuditInfoBuilder.Builder() | ||
.callingUserID(httpServletRequestInfo.requesterUserID) | ||
.callingHost(httpServletRequestInfo.requesterHost) | ||
.calledUserID(httpServletRequestInfo.requestURI) | ||
.destUserID(destination.toString()) | ||
.destNapID(destinationHost(destination)) | ||
.outcome(outcome(ctx)) | ||
.pIDAndName(ctx.getXDSiManifest(), arcDev) | ||
.submissionSetUID(ctx.getSubmissionSetUID()).build(); | ||
} | ||
|
||
private static AuditInfoBuilder schedulerTriggeredProvideRegisterAuditInfo( | ||
ExportContext ctx, ArchiveDeviceExtension arcDev) { | ||
URI destination = ctx.getExporter().getExporterDescriptor().getExportURI(); | ||
return new AuditInfoBuilder.Builder() | ||
.callingUserID(arcDev.getDevice().getDeviceName()) | ||
.destUserID(destination.toString()) | ||
.destNapID(destinationHost(destination)) | ||
.outcome(outcome(ctx)) | ||
.pIDAndName(ctx.getXDSiManifest(), arcDev) | ||
.submissionSetUID(ctx.getSubmissionSetUID()).build(); | ||
} | ||
|
||
private static String destinationHost(URI destination) { | ||
String schemeSpecificPart = destination.getSchemeSpecificPart(); | ||
return schemeSpecificPart.substring(schemeSpecificPart.indexOf("://") + 3, schemeSpecificPart.lastIndexOf(":")); | ||
} | ||
|
||
private static String outcome(ExportContext ctx) { | ||
return ctx.getException() != null ? ctx.getException().getMessage() : null; | ||
} | ||
|
||
static AuditMessage provideRegisterAuditMsg( | ||
AuditInfo auditInfo, AuditLogger auditLogger, AuditServiceUtils.EventType eventType, Calendar eventTime) { | ||
String outcome = auditInfo.getField(AuditInfo.OUTCOME); | ||
EventIdentificationBuilder eventIdentificationBuilder | ||
= new EventIdentificationBuilder.Builder( | ||
eventType.eventID, | ||
eventType.eventActionCode, | ||
eventTime, | ||
outcome != null ? AuditMessages.EventOutcomeIndicator.MinorFailure : AuditMessages.EventOutcomeIndicator.Success) | ||
.outcomeDesc(outcome) | ||
.eventTypeCode(eventType.eventTypeCode).build(); | ||
|
||
ParticipantObjectIdentificationBuilder patientPOI = new ParticipantObjectIdentificationBuilder.Builder( | ||
auditInfo.getField(AuditInfo.P_ID), | ||
AuditMessages.ParticipantObjectIDTypeCode.PatientNumber, | ||
AuditMessages.ParticipantObjectTypeCode.Person, | ||
AuditMessages.ParticipantObjectTypeCodeRole.Patient) | ||
.name(auditInfo.getField(AuditInfo.P_NAME)) | ||
.build(); | ||
|
||
ParticipantObjectIdentificationBuilder submissionSetPOI = new ParticipantObjectIdentificationBuilder.Builder( | ||
auditInfo.getField(AuditInfo.SUBMISSION_SET_UID), | ||
AuditMessages.ParticipantObjectIDTypeCode.IHE_XDS_METADATA, | ||
AuditMessages.ParticipantObjectTypeCode.SystemObject, | ||
AuditMessages.ParticipantObjectTypeCodeRole.Job) | ||
.build(); | ||
|
||
return AuditMessages.createMessage( | ||
eventIdentificationBuilder, | ||
activeParticipantBuilders(auditLogger, eventType, auditInfo), | ||
patientPOI, | ||
submissionSetPOI); | ||
} | ||
|
||
private static ActiveParticipantBuilder[] activeParticipantBuilders( | ||
AuditLogger auditLogger, AuditServiceUtils.EventType eventType, AuditInfo auditInfo) { | ||
ActiveParticipantBuilder[] activeParticipantBuilder = new ActiveParticipantBuilder[3]; | ||
activeParticipantBuilder[0] = new ActiveParticipantBuilder.Builder( | ||
auditInfo.getField(AuditInfo.DEST_USER_ID), | ||
auditInfo.getField(AuditInfo.DEST_NAP_ID)) | ||
.userIDTypeCode(AuditMessages.UserIDTypeCode.URI) | ||
.roleIDCode(eventType.destination) | ||
.build(); | ||
String callingUserID = auditInfo.getField(AuditInfo.CALLING_USERID); | ||
if (auditInfo.getField(AuditInfo.CALLING_HOST) != null) { | ||
activeParticipantBuilder[1] = new ActiveParticipantBuilder.Builder( | ||
auditInfo.getField(AuditInfo.CALLED_USERID), | ||
getLocalHostName(auditLogger)) | ||
.userIDTypeCode(AuditMessages.UserIDTypeCode.URI) | ||
.altUserID(AuditLogger.processID()) | ||
.roleIDCode(eventType.source) | ||
.build(); | ||
activeParticipantBuilder[2] = new ActiveParticipantBuilder.Builder( | ||
callingUserID, | ||
auditInfo.getField(AuditInfo.CALLING_HOST)) | ||
.userIDTypeCode(AuditMessages.userIDTypeCode(callingUserID)) | ||
.isRequester() | ||
.build(); | ||
} else | ||
activeParticipantBuilder[1] = new ActiveParticipantBuilder.Builder( | ||
callingUserID, | ||
getLocalHostName(auditLogger)) | ||
.altUserID(AuditLogger.processID()) | ||
.userIDTypeCode(AuditMessages.UserIDTypeCode.DeviceName) | ||
.isRequester() | ||
.roleIDCode(eventType.source) | ||
.build(); | ||
return activeParticipantBuilder; | ||
} | ||
|
||
private static String getLocalHostName(AuditLogger auditLogger) { | ||
return auditLogger.getConnections().get(0).getHostname(); | ||
} | ||
} |