-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emit Audit Message on failed attempts to initiate association to a re…
- Loading branch information
1 parent
b90f7d2
commit 0fb3bc1
Showing
4 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
dcm4chee-arc-audit/src/main/java/org/dcm4chee/arc/audit/AssociationEventsAuditService.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,63 @@ | ||
package org.dcm4chee.arc.audit; | ||
|
||
import org.dcm4che3.audit.*; | ||
import org.dcm4che3.net.Association; | ||
import org.dcm4che3.util.ReverseDNS; | ||
import org.dcm4chee.arc.AssociationEvent; | ||
import java.util.Calendar; | ||
|
||
/** | ||
* @author Vrinda Nayak <vrinda.nayak@j4care.com> | ||
* @since Oct 2018 | ||
*/ | ||
class AssociationEventsAuditService { | ||
|
||
static AuditInfoBuilder associationFailureAuditInfo(AssociationEvent associationEvent) { | ||
return associationEvent.getType() == AssociationEvent.Type.FAILED | ||
? associationFailedAuditInfo(associationEvent) : associationRejectAuditInfo(associationEvent); | ||
} | ||
|
||
private static AuditInfoBuilder associationFailedAuditInfo(AssociationEvent associationEvent) { | ||
Association association = associationEvent.getAssociation(); | ||
return new AuditInfoBuilder.Builder() | ||
.callingUserID(association.getLocalAET()) | ||
.callingHost(association.getConnection().getHostname()) | ||
.calledUserID(association.getRemoteAET()) | ||
.calledHost(ReverseDNS.hostNameOf(association.getSocket().getInetAddress())) | ||
.outcome(associationEvent.getException().getMessage()) | ||
.build(); | ||
} | ||
|
||
private static AuditInfoBuilder associationRejectAuditInfo(AssociationEvent associationEvent) { | ||
Association association = associationEvent.getAssociation(); | ||
return new AuditInfoBuilder.Builder() | ||
.callingUserID(association.getRemoteAET()) | ||
.callingHost(ReverseDNS.hostNameOf(association.getSocket().getInetAddress())) | ||
.calledUserID(association.getLocalAET()) | ||
.calledHost(association.getConnection().getHostname()) | ||
.outcome(associationEvent.getException().getMessage()) | ||
.build(); | ||
} | ||
|
||
static AuditMessage associationFailureAuditMsg( | ||
AuditInfo auditInfo, AuditServiceUtils.EventType eventType, Calendar eventTime) { | ||
EventIdentificationBuilder eventIdentificationBuilder = new EventIdentificationBuilder.Builder( | ||
eventType.eventID, eventType.eventActionCode, eventTime, AuditMessages.EventOutcomeIndicator.MinorFailure) | ||
.outcomeDesc(auditInfo.getField(AuditInfo.OUTCOME)) | ||
.eventTypeCode(eventType.eventTypeCode) | ||
.build(); | ||
|
||
ActiveParticipantBuilder[] activeParticipantBuilders = new ActiveParticipantBuilder[2]; | ||
activeParticipantBuilders[0] = new ActiveParticipantBuilder.Builder( | ||
auditInfo.getField(AuditInfo.CALLING_USERID), auditInfo.getField(AuditInfo.CALLING_HOST)) | ||
.userIDTypeCode(AuditMessages.UserIDTypeCode.StationAETitle) | ||
.isRequester() | ||
.build(); | ||
activeParticipantBuilders[1] = new ActiveParticipantBuilder.Builder( | ||
auditInfo.getField(AuditInfo.CALLED_USERID), auditInfo.getField(AuditInfo.CALLED_HOST)) | ||
.userIDTypeCode(AuditMessages.UserIDTypeCode.StationAETitle) | ||
.build(); | ||
|
||
return AuditMessages.createMessage(eventIdentificationBuilder, activeParticipantBuilders); | ||
} | ||
} |
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
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
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