diff --git a/auditor/pom.xml b/auditor/pom.xml index aa9c416..bd46e42 100644 --- a/auditor/pom.xml +++ b/auditor/pom.xml @@ -12,6 +12,7 @@ + org.openehealth.ipf.oht.atna ipf-oht-atna-nodeauth @@ -35,18 +36,22 @@ netty-all true + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + provided + + + junit junit test - - org.slf4j - slf4j-log4j12 - org.mockito mockito-all + test org.openehealth.ipf.oht.atna @@ -59,7 +64,46 @@ commons-io test + + org.apache.activemq + activemq-broker + test + + + org.apache.activemq + activemq-pool + test + + + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + false + + + + + diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PAMSourceAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PAMSourceAuditor.java index 89c30bd..fbca42d 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PAMSourceAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PAMSourceAuditor.java @@ -70,7 +70,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -101,7 +101,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -132,6 +132,6 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java index 9cc5be6..8135eb1 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PDQConsumerAuditor.java @@ -75,7 +75,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } /** @@ -91,12 +91,16 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), * @param hl7MessageId The HL7 message.id * @param hl7QueryParameters The HL7 query parameters * @param patientIds List of patient IDs that were seen in this transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditPDQQueryV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixManagerUri, String receivingFacility, String receivingApp, String sendingFacility, String sendingApp, String hl7MessageId, String hl7QueryParameters, - String[] patientIds, List purposesOfUse) + String[] patientIds, + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -107,7 +111,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageId, hl7QueryParameters, - patientIds, purposesOfUse); + patientIds, purposesOfUse, userRoles); } /** @@ -139,7 +143,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java index 9f8167f..d0f5dad 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXAuditor.java @@ -49,6 +49,8 @@ public abstract class PIXAuditor extends IHEAuditor * @param hl7MessageId The HL7 Message ID (v2 from the MSH segment field 10, v3 from message.Id) * @param hl7QueryParameters The HL7 Query Parameters from the QPD segment * @param patientIds List of patient IDs that were seen in this transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditQueryEvent(boolean systemIsSource, IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome, @@ -57,7 +59,8 @@ protected void auditQueryEvent(boolean systemIsSource, String humanRequestor, String hl7MessageId, String hl7QueryParameters, String[] patientIds, - List purposesOfUse) + List purposesOfUse, + List userRoles) { // Create query event QueryEvent queryEvent = new QueryEvent(systemIsSource, eventOutcome, transaction, purposesOfUse); @@ -66,7 +69,7 @@ protected void auditQueryEvent(boolean systemIsSource, queryEvent.addSourceActiveParticipant(EventUtils.concatHL7FacilityApplication(sourceFacility,sourceApp), sourceAltUserId, null, sourceNetworkId, true); // Set the human requestor active participant if (!EventUtils.isEmptyOrNull(humanRequestor)) { - queryEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, null); + queryEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, userRoles); } // Set the destination active participant queryEvent.addDestinationActiveParticipant(EventUtils.concatHL7FacilityApplication(destinationFacility,destinationApp), destinationAltUserId, null, destinationNetworkId, false); @@ -111,6 +114,8 @@ protected void auditQueryEvent(boolean systemIsSource, * @param humanRequestor Identity of the human that initiated the transaction (if known) * @param hl7MessageId The HL7 Message ID (v2 from the MSH segment field 10, v3 from message.Id) * @param patientIds List of patient IDs that were seen in this transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditPatientRecordEvent(boolean systemIsSource, IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome, RFC3881EventActionCodes eventActionCode, @@ -119,7 +124,8 @@ protected void auditPatientRecordEvent(boolean systemIsSource, String humanRequestor, String hl7MessageId, String patientIds[], - List purposesOfUse) + List purposesOfUse, + List userRoles) { // Create Patient Record event PatientRecordEvent patientEvent = new PatientRecordEvent(systemIsSource, eventOutcome, eventActionCode, transaction, purposesOfUse); @@ -128,7 +134,7 @@ protected void auditPatientRecordEvent(boolean systemIsSource, patientEvent.addSourceActiveParticipant(EventUtils.concatHL7FacilityApplication(sourceFacility,sourceApp), sourceAltUserId, null, sourceNetworkId, true); // Set the human requestor active participant if (!EventUtils.isEmptyOrNull(humanRequestor)) { - patientEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, null); + patientEvent.addHumanRequestorActiveParticipant(humanRequestor, null, null, userRoles); } // Set the destination active participant patientEvent.addDestinationActiveParticipant(EventUtils.concatHL7FacilityApplication(destinationFacility,destinationApp), destinationAltUserId, null, destinationNetworkId, false); diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXConsumerAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXConsumerAuditor.java index 852acd5..9c70080 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXConsumerAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXConsumerAuditor.java @@ -77,7 +77,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } /** @@ -93,12 +93,16 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), * @param hl7MessageId The HL7 message.id * @param hl7QueryParameters The HL7 query parameters * @param patientIds List of patient IDs that were seen in this transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditPIXQueryV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixManagerUri, String receivingFacility, String receivingApp, String sendingFacility, String sendingApp, String hl7MessageId, String hl7QueryParameters, - String[] patientIds, List purposesOfUse) + String[] patientIds, + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -109,7 +113,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageId, hl7QueryParameters, - patientIds, purposesOfUse); + patientIds, purposesOfUse, userRoles); } /** @@ -140,7 +144,7 @@ public void auditUpdateNotificationEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), getSystemNetworkId(), null, hl7MessageControlId, - patientIds, null); + patientIds, null, null); } /** @@ -155,13 +159,16 @@ receivingFacility, receivingApp, getSystemAltUserId(), getSystemNetworkId(), * @param sendingApp The HL7 sending application * @param hl7MessageId The HL7 message.id * @param patientIds List of patient IDs that were seen in this transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditUpdateNotificationV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixMgrIpAddress, String sendingFacility, String sendingApp, String receivingFacility, String receivingApp, String hl7MessageId, String[] patientIds, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -172,6 +179,6 @@ public void auditUpdateNotificationV3Event(RFC3881EventOutcomeCodes eventOutcome receivingFacility, receivingApp, getSystemAltUserId(), getSystemNetworkId(), null, hl7MessageId, - patientIds, purposesOfUse); + patientIds, purposesOfUse, userRoles); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXManagerAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXManagerAuditor.java index c26f203..26f0a12 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXManagerAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXManagerAuditor.java @@ -74,7 +74,7 @@ public void auditCreatePatientRecordEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -106,7 +106,7 @@ public void auditDeletePatientRecordEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -137,7 +137,7 @@ public void auditUpdatePatientRecordEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -170,7 +170,7 @@ public void auditPDQQueryEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } /** @@ -203,7 +203,7 @@ public void auditPDVQQueryEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } /** @@ -235,7 +235,7 @@ public void auditPIXQueryEvent(RFC3881EventOutcomeCodes eventOutcome, receivingFacility, receivingApp, getSystemAltUserId(), EventUtils.getAddressForUrl(pixManagerUri, false), null, hl7MessageControlId, hl7QueryParameters, - patientIds, null); + patientIds, null, null); } /** @@ -268,6 +268,6 @@ sendingFacility, sendingApp, getSystemAltUserId(), pixMgrIpAddress, receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(consumerEndpointUri, false), null, hl7MessageControlId, - patientIds, null); + patientIds, null, null); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXSourceAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXSourceAuditor.java index fbcef31..9b5ea8b 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXSourceAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/PIXSourceAuditor.java @@ -74,7 +74,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -89,13 +89,16 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), * @param sendingApp The HL7 sending application * @param hl7MessageId The HL7 message.id * @param patientId The patient ID that was affected by this event + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditCreatePatientRecordV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixManagerUri, String receivingFacility, String receivingApp, String sendingFacility, String sendingApp, String hl7MessageId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -106,7 +109,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageId, - new String[] {patientId}, purposesOfUse); + new String[] {patientId}, purposesOfUse, userRoles); } /** @@ -137,7 +140,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -152,13 +155,16 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), * @param sendingApp The HL7 sending application * @param hl7MessageId The HL7 message.id * @param patientId The patient ID that was affected by this event + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditDeletePatientRecordV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixManagerUri, String receivingFacility, String receivingApp, String sendingFacility, String sendingApp, String hl7MessageId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -169,7 +175,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageId, - new String[] {patientId}, purposesOfUse); + new String[] {patientId}, purposesOfUse, userRoles); } /** @@ -200,7 +206,7 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageControlId, - new String[] {patientId}, null); + new String[] {patientId}, null, null); } /** @@ -215,13 +221,16 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), * @param sendingApp The HL7 sending application * @param hl7MessageId The HL7 message.id * @param patientId The patient ID that was affected by this event + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditUpdatePatientRecordV3Event(RFC3881EventOutcomeCodes eventOutcome, String pixManagerUri, String receivingFacility, String receivingApp, String sendingFacility, String sendingApp, String hl7MessageId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -232,6 +241,6 @@ sendingFacility, sendingApp, getSystemAltUserId(), getSystemNetworkId(), receivingFacility, receivingApp, null, EventUtils.getAddressForUrl(pixManagerUri, false), getHumanRequestor(), hl7MessageId, - new String[] {patientId}, purposesOfUse); + new String[] {patientId}, purposesOfUse, userRoles); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java index a2f0860..79e28bf 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/SVSConsumerAuditor.java @@ -53,12 +53,15 @@ public static SVSConsumerAuditor getAuditor() * @param valueSetUniqueId unique id (OID) of the returned value set * @param valueSetName name associated with the unique id (OID) of the returned value set * @param valueSetVersion version of the returned value set + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveValueSetEvent(RFC3881EventOutcomeCodes eventOutcome, String repositoryEndpointUri, String valueSetUniqueId, String valueSetName, String valueSetVersion, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -68,7 +71,7 @@ public void auditRetrieveValueSetEvent(RFC3881EventOutcomeCodes eventOutcome, importEvent.addSourceActiveParticipant(EventUtils.getAddressForUrl(repositoryEndpointUri, false), null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false); importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true); if (!EventUtils.isEmptyOrNull(getHumanRequestor())) { - importEvent.addHumanRequestorActiveParticipant(getHumanRequestor(), null, null, null); + importEvent.addHumanRequestorActiveParticipant(getHumanRequestor(), null, null, userRoles); } importEvent.addValueSetParticipantObject(valueSetUniqueId, valueSetName, valueSetVersion); audit(importEvent); diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCAInitiatingGatewayAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCAInitiatingGatewayAuditor.java index 358c54e..a5b9eea 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCAInitiatingGatewayAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCAInitiatingGatewayAuditor.java @@ -57,13 +57,15 @@ public static XCAInitiatingGatewayAuditor getAuditor() * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditCrossGatewayQueryEvent( RFC3881EventOutcomeCodes eventOutcome, String respondingGatewayEndpointUri, String initiatingGatewayUserId, String initiatingGatewayUserName, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, - String patientId, List purposesOfUse) + String patientId, List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; @@ -76,7 +78,7 @@ initiatingGatewayUserId, getSystemAltUserId(), initiatingGatewayUserName, getSys initiatingGatewayUserName, initiatingGatewayUserName, false, respondingGatewayEndpointUri, null, storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, - patientId, purposesOfUse); + patientId, purposesOfUse, userRoles); } /** @@ -87,12 +89,14 @@ initiatingGatewayUserId, getSystemAltUserId(), initiatingGatewayUserName, getSys * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityIds The list of home community ids used in the transaction - */ + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) + */ public void auditCrossGatewayRetrieveEvent(RFC3881EventOutcomeCodes eventOutcome, String respondingGatewayEndpointUri, String initiatingGatewayUserId, String initiatingGatewayUserName, String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds, - List purposesOfUse) + List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; @@ -103,7 +107,7 @@ public void auditCrossGatewayRetrieveEvent(RFC3881EventOutcomeCodes eventOutcome importEvent.addDestinationActiveParticipant(initiatingGatewayUserId, getSystemAltUserId(), initiatingGatewayUserName, getSystemNetworkId(), true); if(!EventUtils.isEmptyOrNull(initiatingGatewayUserName)) { - importEvent.addHumanRequestorActiveParticipant(initiatingGatewayUserName, null, initiatingGatewayUserName, null); + importEvent.addHumanRequestorActiveParticipant(initiatingGatewayUserName, null, initiatingGatewayUserName, userRoles); } if (!EventUtils.isEmptyOrNull(documentUniqueIds)) { @@ -125,20 +129,22 @@ public void auditCrossGatewayRetrieveEvent(RFC3881EventOutcomeCodes eventOutcome * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityIds The list of XCA Home Community Ids involved in this transaction (aligned with Document Unique Ids array) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveDocumentSetEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String repositoryEndpointUri, String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds, - List purposesOfUse) + List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; } XDSRepositoryAuditor.getAuditor().auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, repositoryEndpointUri, - documentUniqueIds, repositoryUniqueIds, homeCommunityIds, purposesOfUse); + documentUniqueIds, repositoryUniqueIds, homeCommunityIds, purposesOfUse, userRoles); } /** @@ -153,18 +159,22 @@ public void auditRetrieveDocumentSetEvent( * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegistryStoredQueryEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String registryEndpointUri, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, - String patientId, List purposesOfUse) + String patientId, List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; } - XDSRegistryAuditor.getAuditor().auditRegistryStoredQueryEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, registryEndpointUri, storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, patientId, purposesOfUse); + XDSRegistryAuditor.getAuditor().auditRegistryStoredQueryEvent(eventOutcome, consumerUserId, consumerUserName, + consumerIpAddress, registryEndpointUri, storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, + patientId, purposesOfUse, userRoles); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCARespondingGatewayAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCARespondingGatewayAuditor.java index 4e2d9d7..d063ef7 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCARespondingGatewayAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XCARespondingGatewayAuditor.java @@ -61,6 +61,8 @@ public static XCARespondingGatewayAuditor getAuditor() * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditCrossGatewayQueryEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -68,7 +70,8 @@ public void auditCrossGatewayQueryEvent( String respondingGatewayEndpointUri, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -80,7 +83,7 @@ public void auditCrossGatewayQueryEvent( initiatingGatewayUserName, initiatingGatewayUserName, false, respondingGatewayEndpointUri, getSystemAltUserId(), storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, - patientId, purposesOfUse); + patientId, purposesOfUse, userRoles); } /** @@ -94,6 +97,8 @@ respondingGatewayEndpointUri, getSystemAltUserId(), * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityIds The list of home community ids used in the transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditCrossGatewayRetrieveEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -101,7 +106,8 @@ public void auditCrossGatewayRetrieveEvent( String respondingGatewayEndpointUri, String initiatingGatewayUserName, String[] documentUniqueIds, String[] repositoryUniqueIds, String homeCommunityIds[], - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -111,7 +117,7 @@ public void auditCrossGatewayRetrieveEvent( exportEvent.addSourceActiveParticipant(respondingGatewayEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(respondingGatewayEndpointUri, false), false); if(!EventUtils.isEmptyOrNull(initiatingGatewayUserName)) { - exportEvent.addHumanRequestorActiveParticipant(initiatingGatewayUserName, null, initiatingGatewayUserName, null); + exportEvent.addHumanRequestorActiveParticipant(initiatingGatewayUserName, null, initiatingGatewayUserName, userRoles); } exportEvent.addDestinationActiveParticipant(initiatingGatewayUserId, null, null, initiatingGatewayIpAddress, true); @@ -132,19 +138,21 @@ public void auditCrossGatewayRetrieveEvent( * @param repositoryUniqueIds The XDS.b RepositoryUniqueId value for the repository * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param homeCommunityIds The list of home community ids used in the transaction - */ + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) + */ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, String repositoryEndpointUri, String userName, String[] documentUniqueIds, String[] repositoryUniqueIds, String homeCommunityIds[], - List purposesOfUse) + List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; } XDSConsumerAuditor.getAuditor().auditRetrieveDocumentSetEvent(eventOutcome, repositoryEndpointUri, userName, - documentUniqueIds, repositoryUniqueIds, homeCommunityIds, null, purposesOfUse); + documentUniqueIds, repositoryUniqueIds, homeCommunityIds, null, purposesOfUse, userRoles); } /** @@ -156,6 +164,8 @@ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegistryStoredQueryEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -163,14 +173,15 @@ public void auditRegistryStoredQueryEvent( String consumerUserName, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; } XDSConsumerAuditor.getAuditor().auditRegistryStoredQueryEvent(eventOutcome, registryEndpointUri, consumerUserName, storedQueryUUID, adhocQueryRequestPayload, - homeCommunityId, patientId, purposesOfUse); + homeCommunityId, patientId, purposesOfUse, userRoles); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSAuditor.java index e16eddf..a7b10f3 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSAuditor.java @@ -49,6 +49,8 @@ public abstract class XDSAuditor extends IHEAuditor * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditQueryEvent( boolean systemIsSource, // System Type @@ -60,8 +62,8 @@ protected void auditQueryEvent( boolean humanAfterDestination, String registryEndpointUri, String registryAltUserId, // Destination Participant String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, // Payload Object Participant - String patientId, - List purposesOfUse) // Patient Object Participant + String patientId, // Patient Object Participant + List purposesOfUse, List userRoles) { QueryEvent queryEvent = new QueryEvent(systemIsSource, eventOutcome, transaction, purposesOfUse); queryEvent.setAuditSourceId(auditSourceId, auditSourceEnterpriseSiteId); @@ -72,7 +74,7 @@ protected void auditQueryEvent( } if(!EventUtils.isEmptyOrNull(humanRequestorName)) { - queryEvent.addHumanRequestorActiveParticipant(humanRequestorName, null, humanRequestorName, null); + queryEvent.addHumanRequestorActiveParticipant(humanRequestorName, null, humanRequestorName, userRoles); } if (! humanAfterDestination) { diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java index dcb964c..7a5b2f8 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSConsumerAuditor.java @@ -74,7 +74,7 @@ public void auditRegistryQueryEvent( consumerUserName, consumerUserName, true, registryEndpointUri, null, "", adhocQueryRequestPayload, "", - patientId, null); + patientId, null, null); } @@ -88,6 +88,8 @@ public void auditRegistryQueryEvent( * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegistryStoredQueryEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -95,7 +97,8 @@ public void auditRegistryStoredQueryEvent( String consumerUserName, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -114,7 +117,7 @@ replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), consumerUserName, consumerUserName, false, registryEndpointUri, null, storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, - patientId, purposesOfUse); + patientId, purposesOfUse, userRoles); } @@ -140,7 +143,7 @@ public void auditRetrieveDocumentEvent(RFC3881EventOutcomeCodes eventOutcome, importEvent.addSourceActiveParticipant(repositoryRetrieveUri, null, null, EventUtils.getAddressForUrl(repositoryRetrieveUri, false), false); importEvent.addDestinationActiveParticipant(getSystemUserId(), getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true); if (!EventUtils.isEmptyOrNull(userName)) { - importEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + importEvent.addHumanRequestorActiveParticipant(userName, null, userName, (List) null); } if (!EventUtils.isEmptyOrNull(patientId)) { importEvent.addPatientParticipantObject(patientId); @@ -160,13 +163,16 @@ public void auditRetrieveDocumentEvent(RFC3881EventOutcomeCodes eventOutcome, * @param repositoryUniqueId The XDS.b RepositoryUniqueId value for the repository * @param homeCommunityId The XCA Home Community Id used in the transaction * @param patientId The patient ID the document(s) relate to (if known) - */ + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) + */ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, String repositoryEndpointUri, String userName, String[] documentUniqueIds, String repositoryUniqueId, String homeCommunityId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -183,7 +189,7 @@ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, auditRetrieveDocumentSetEvent(eventOutcome, repositoryEndpointUri, userName, - documentUniqueIds, repositoryUniqueIds, homeCommunityIds, patientId, purposesOfUse); + documentUniqueIds, repositoryUniqueIds, homeCommunityIds, patientId, purposesOfUse, userRoles); } @@ -197,13 +203,16 @@ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityIds The list of XCA Home Community Ids involved in this transaction (aligned with Document Unique Ids array) * @param patientId The patient ID the document(s) relate to (if known) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, String repositoryEndpointUri, String userName, String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -217,7 +226,7 @@ public void auditRetrieveDocumentSetEvent(RFC3881EventOutcomeCodes eventOutcome, String replyToUri = "http://www.w3.org/2005/08/addressing/anonymous"; importEvent.addDestinationActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true); if (!EventUtils.isEmptyOrNull(userName)) { - importEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles); } if (!EventUtils.isEmptyOrNull(patientId)) { importEvent.addPatientParticipantObject(patientId); diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java index 25bfa6a..8613f2f 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRegistryAuditor.java @@ -72,7 +72,7 @@ public void auditRegisterDocumentSetEvent( auditRegisterEvent(new IHETransactionEventTypeCodes.RegisterDocumentSet(), eventOutcome, repositoryUserId, repositoryIpAddress, userName, - registryEndpointUri, submissionSetUniqueId, patientId, null); + registryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -103,7 +103,7 @@ public void auditRegistryQueryEvent( consumerUserName, consumerUserName, true, registryEndpointUri, getSystemAltUserId(), "", adhocQueryRequestPayload, "", - patientId, null); + patientId, null, null); } /** @@ -118,13 +118,15 @@ registryEndpointUri, getSystemAltUserId(), * @param adhocQueryRequestPayload The payload of the adhoc query request element * @param homeCommunityId The home community id of the transaction (if present) * @param patientId The patient ID queried (if query pertained to a patient id) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegistryStoredQueryEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String registryEndpointUri, String storedQueryUUID, String adhocQueryRequestPayload, String homeCommunityId, - String patientId, List purposesOfUse) + String patientId, List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; @@ -136,7 +138,7 @@ public void auditRegistryStoredQueryEvent( consumerUserName, consumerUserName, false, registryEndpointUri, getSystemAltUserId(), storedQueryUUID, adhocQueryRequestPayload, homeCommunityId, - patientId, purposesOfUse); + patientId, purposesOfUse, userRoles); } @Deprecated @@ -149,7 +151,7 @@ public void auditRegistryStoredQueryEvent( { auditRegistryStoredQueryEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, registryEndpointUri, storedQueryUUID, adhocQueryRequestPayload, - homeCommunityId, patientId, null); + homeCommunityId, patientId, null, null); } /** @@ -161,6 +163,8 @@ public void auditRegistryStoredQueryEvent( * @param registryEndpointUri The URI of this registry's endpoint that received the transaction * @param submissionSetUniqueId The UniqueID of the Submission Set registered * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegisterDocumentSetBEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -169,7 +173,8 @@ public void auditRegisterDocumentSetBEvent( String registryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -177,7 +182,7 @@ public void auditRegisterDocumentSetBEvent( auditRegisterEvent(new IHETransactionEventTypeCodes.RegisterDocumentSetB(), eventOutcome, repositoryUserId, repositoryIpAddress, userName, - registryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse); + registryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse, userRoles); } @Deprecated @@ -190,7 +195,7 @@ public void auditRegisterDocumentSetBEvent( String patientId) { auditRegisterDocumentSetBEvent(eventOutcome, repositoryUserId, repositoryIpAddress, - userName, registryEndpointUri, submissionSetUniqueId, patientId, null); + userName, registryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -204,6 +209,8 @@ public void auditRegisterDocumentSetBEvent( * @param registryEndpointUri The URI of this registry's endpoint that received the transaction * @param submissionSetUniqueId The UniqueID of the Submission Set provided * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditRegisterEvent( IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome, @@ -212,13 +219,14 @@ protected void auditRegisterEvent( String registryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { ImportEvent importEvent = new ImportEvent(false, eventOutcome, transaction, purposesOfUse); importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId()); importEvent.addSourceActiveParticipant(repositoryUserId, null, null, repositoryIpAddress, true); if (! EventUtils.isEmptyOrNull(userName)) { - importEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles); } importEvent.addDestinationActiveParticipant(registryEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(registryEndpointUri, false), false); if (!EventUtils.isEmptyOrNull(patientId)) { @@ -239,6 +247,6 @@ protected void auditRegisterEvent( String patientId) { auditRegisterEvent(transaction, eventOutcome, repositoryUserId, repositoryIpAddress, userName, - registryEndpointUri, submissionSetUniqueId, patientId, null); + registryEndpointUri, submissionSetUniqueId, patientId, null, null); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRepositoryAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRepositoryAuditor.java index c82fb32..3eb6db1 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRepositoryAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSRepositoryAuditor.java @@ -76,7 +76,7 @@ public void auditProvideAndRegisterDocumentSetEvent( auditProvideAndRegisterEvent(new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSet(), eventOutcome, sourceUserId, sourceIpAddress, userName, - repositoryEndpointUri, submissionSetUniqueId, patientId, null); + repositoryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -88,6 +88,8 @@ public void auditProvideAndRegisterDocumentSetEvent( * @param repositoryEndpointUri The URI of this repository's endpoint that received the transaction * @param submissionSetUniqueId The UniqueID of the Submission Set provided * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditProvideAndRegisterDocumentSetBEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -96,7 +98,8 @@ public void auditProvideAndRegisterDocumentSetBEvent( String repositoryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -104,7 +107,7 @@ public void auditProvideAndRegisterDocumentSetBEvent( auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSetB(), eventOutcome, sourceUserId, sourceIpAddress, userName, - repositoryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse); + repositoryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse, userRoles); } @Deprecated @@ -117,7 +120,7 @@ public void auditProvideAndRegisterDocumentSetBEvent( String patientId) { auditProvideAndRegisterDocumentSetBEvent(eventOutcome, sourceUserId, sourceIpAddress, - userName, repositoryEndpointUri, submissionSetUniqueId, patientId, null); + userName, repositoryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -140,7 +143,7 @@ public void auditRegisterDocumentSetEvent( } auditRegisterEvent(new IHETransactionEventTypeCodes.RegisterDocumentSet(), eventOutcome, repositoryUserId, userName, - registryEndpointUri, submissionSetUniqueId, patientId, null); + registryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -150,6 +153,8 @@ public void auditRegisterDocumentSetEvent( * @param registryEndpointUri The endpoint of the registry in this transaction * @param submissionSetUniqueId The UniqueID of the Submission Set registered * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRegisterDocumentSetBEvent( RFC3881EventOutcomeCodes eventOutcome, @@ -157,14 +162,15 @@ public void auditRegisterDocumentSetBEvent( String userName, String registryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; } auditRegisterEvent(new IHETransactionEventTypeCodes.RegisterDocumentSetB(), eventOutcome, repositoryUserId, userName, - registryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse); + registryEndpointUri, submissionSetUniqueId, patientId, purposesOfUse, userRoles); } @Deprecated @@ -176,7 +182,7 @@ public void auditRegisterDocumentSetBEvent( String submissionSetUniqueId, String patientId) { auditRegisterDocumentSetBEvent(eventOutcome, repositoryUserId, userName, registryEndpointUri, - submissionSetUniqueId, patientId, null); + submissionSetUniqueId, patientId, null, null); } /** @@ -200,7 +206,7 @@ public void auditRetrieveDocumentEvent( exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId()); exportEvent.addSourceActiveParticipant(repositoryRetrieveUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(repositoryRetrieveUri, false), false); if (!EventUtils.isEmptyOrNull(userName)) { - exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, (List) null); } exportEvent.addDestinationActiveParticipant(consumerIpAddress, null, null, consumerIpAddress, true); //exportEvent.addPatientParticipantObject(patientId); @@ -220,13 +226,15 @@ public void auditRetrieveDocumentEvent( * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueId The XDS.b Repository Unique Id value for this repository * @param homeCommunityId The XCA Home Community Id used in the transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveDocumentSetEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String repositoryEndpointUri, String[] documentUniqueIds, String repositoryUniqueId, String homeCommunityId, - List purposesOfUse) + List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; @@ -239,7 +247,7 @@ public void auditRetrieveDocumentSetEvent( } auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, - repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityId, purposesOfUse); + repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityId, purposesOfUse, userRoles); } @Deprecated @@ -250,7 +258,7 @@ public void auditRetrieveDocumentSetEvent( String[] documentUniqueIds, String repositoryUniqueId, String homeCommunityId) { auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, - repositoryEndpointUri, documentUniqueIds, repositoryUniqueId, homeCommunityId, null); + repositoryEndpointUri, documentUniqueIds, repositoryUniqueId, homeCommunityId, null, null); } /** @@ -265,13 +273,15 @@ public void auditRetrieveDocumentSetEvent( * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityId The XCA Home Community Id used in the transaction + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveDocumentSetEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String repositoryEndpointUri, String[] documentUniqueIds, String[] repositoryUniqueIds, String homeCommunityId, - List purposesOfUse) + List purposesOfUse, List userRoles) { if (!isAuditorEnabled()) { return; @@ -284,7 +294,7 @@ public void auditRetrieveDocumentSetEvent( } auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, - repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityIds, purposesOfUse); + repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityIds, purposesOfUse, userRoles); } @Deprecated @@ -295,7 +305,7 @@ public void auditRetrieveDocumentSetEvent( String[] documentUniqueIds, String[] repositoryUniqueIds, String homeCommunityId) { auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, - repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityId, null); + repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityId, null, null); } /** @@ -310,13 +320,16 @@ public void auditRetrieveDocumentSetEvent( * @param documentUniqueIds The list of Document Entry UniqueId(s) for the document(s) retrieved * @param repositoryUniqueIds The list of XDS.b Repository Unique Ids involved in this transaction (aligned with Document Unique Ids array) * @param homeCommunityIds The list of XCA Home Community Ids involved in this transaction (aligned with Document Unique Ids array) + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditRetrieveDocumentSetEvent( RFC3881EventOutcomeCodes eventOutcome, String consumerUserId, String consumerUserName, String consumerIpAddress, String repositoryEndpointUri, String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -326,7 +339,7 @@ public void auditRetrieveDocumentSetEvent( exportEvent.addSourceActiveParticipant(repositoryEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false); exportEvent.addDestinationActiveParticipant(consumerUserId, null, consumerUserName, consumerIpAddress, true); if (! EventUtils.isEmptyOrNull(consumerUserName)) { - exportEvent.addHumanRequestorActiveParticipant(consumerUserName, null, consumerUserName, null); + exportEvent.addHumanRequestorActiveParticipant(consumerUserName, null, consumerUserName, userRoles); } //exportEvent.addPatientParticipantObject(patientId); @@ -346,7 +359,7 @@ public void auditRetrieveDocumentSetEvent( String[] documentUniqueIds, String[] repositoryUniqueIds, String[] homeCommunityIds) { auditRetrieveDocumentSetEvent(eventOutcome, consumerUserId, consumerUserName, consumerIpAddress, - repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityIds, null); + repositoryEndpointUri, documentUniqueIds, repositoryUniqueIds, homeCommunityIds, null, null); } /** @@ -359,6 +372,8 @@ public void auditRetrieveDocumentSetEvent( * @param repositoryEndpointUri The Web service endpoint URI for this document repository * @param submissionSetUniqueId The UniqueID of the Submission Set registered * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditProvideAndRegisterEvent ( IHETransactionEventTypeCodes transaction, @@ -368,13 +383,14 @@ protected void auditProvideAndRegisterEvent ( String repositoryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { ImportEvent importEvent = new ImportEvent(false, eventOutcome, transaction, purposesOfUse); importEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId()); importEvent.addSourceActiveParticipant(sourceUserId, null, null, sourceIpAddress, true); if (!EventUtils.isEmptyOrNull(userName)) { - importEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + importEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles); } importEvent.addDestinationActiveParticipant(repositoryEndpointUri, getSystemAltUserId(), null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false); if (!EventUtils.isEmptyOrNull(patientId)) { @@ -396,7 +412,7 @@ protected void auditProvideAndRegisterEvent ( String patientId) { auditProvideAndRegisterEvent(transaction, eventOutcome, sourceUserId, sourceIpAddress, userName, - repositoryEndpointUri, submissionSetUniqueId, patientId, null); + repositoryEndpointUri, submissionSetUniqueId, patientId, null, null); } /** @@ -408,6 +424,8 @@ protected void auditProvideAndRegisterEvent ( * @param registryEndpointUri The Web service endpoint URI for the document registry * @param submissionSetUniqueId The UniqueID of the Submission Set registered * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditRegisterEvent( IHETransactionEventTypeCodes transaction, @@ -416,13 +434,14 @@ protected void auditRegisterEvent( String userName, String registryEndpointUri, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { ExportEvent exportEvent = new ExportEvent(true, eventOutcome, transaction, purposesOfUse); exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId()); exportEvent.addSourceActiveParticipant(repositoryUserId, getSystemAltUserId(), null, getSystemNetworkId(), true); if (!EventUtils.isEmptyOrNull(userName)) { - exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles); } exportEvent.addDestinationActiveParticipant(registryEndpointUri, null, null, EventUtils.getAddressForUrl(registryEndpointUri, false), false); if (!EventUtils.isEmptyOrNull(patientId)) { @@ -442,7 +461,7 @@ protected void auditRegisterEvent ( String submissionSetUniqueId, String patientId) { auditRegisterEvent(transaction, eventOutcome, repositoryUserId, userName, registryEndpointUri, - submissionSetUniqueId, patientId, null); + submissionSetUniqueId, patientId, null, null); } } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java index a4796e5..0e3e314 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/XDSSourceAuditor.java @@ -66,7 +66,7 @@ public void auditProvideAndRegisterDocumentSetEvent(RFC3881EventOutcomeCodes eve auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSet(), eventOutcome, repositoryEndpointUri, userName, - submissionSetUniqueId, patientId, null); + submissionSetUniqueId, patientId, null, null); } /** @@ -76,13 +76,16 @@ public void auditProvideAndRegisterDocumentSetEvent(RFC3881EventOutcomeCodes eve * @param repositoryEndpointUri The endpoint of the repository in this transaction * @param submissionSetUniqueId The UniqueID of the Submission Set provided * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ public void auditProvideAndRegisterDocumentSetBEvent(RFC3881EventOutcomeCodes eventOutcome, String repositoryEndpointUri, String userName, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { if (!isAuditorEnabled()) { return; @@ -90,7 +93,7 @@ public void auditProvideAndRegisterDocumentSetBEvent(RFC3881EventOutcomeCodes ev auditProvideAndRegisterEvent( new IHETransactionEventTypeCodes.ProvideAndRegisterDocumentSetB(), eventOutcome, repositoryEndpointUri, userName, - submissionSetUniqueId, patientId, purposesOfUse); + submissionSetUniqueId, patientId, purposesOfUse, userRoles); } /** @@ -101,6 +104,8 @@ public void auditProvideAndRegisterDocumentSetBEvent(RFC3881EventOutcomeCodes ev * @param repositoryEndpointUri The endpoint of the repository in this transaction * @param submissionSetUniqueId The UniqueID of the Submission Set provided * @param patientId The Patient Id that this submission pertains to + * @param purposesOfUse purpose of use codes (may be taken from XUA token) + * @param userRoles roles of the human user (may be taken from XUA token) */ protected void auditProvideAndRegisterEvent( IHETransactionEventTypeCodes transaction, RFC3881EventOutcomeCodes eventOutcome, @@ -108,7 +113,8 @@ protected void auditProvideAndRegisterEvent( String userName, String submissionSetUniqueId, String patientId, - List purposesOfUse) + List purposesOfUse, + List userRoles) { ExportEvent exportEvent = new ExportEvent(true, eventOutcome, transaction, purposesOfUse); exportEvent.setAuditSourceId(getAuditSourceId(), getAuditEnterpriseSiteId()); @@ -121,7 +127,7 @@ protected void auditProvideAndRegisterEvent( exportEvent.addSourceActiveParticipant(replyToUri, getSystemAltUserId(), getSystemUserName(), getSystemNetworkId(), true); if (!EventUtils.isEmptyOrNull(userName)) { - exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, null); + exportEvent.addHumanRequestorActiveParticipant(userName, null, userName, userRoles); } exportEvent.addDestinationActiveParticipant(repositoryEndpointUri, null, null, EventUtils.getAddressForUrl(repositoryEndpointUri, false), false); if (!EventUtils.isEmptyOrNull(patientId)) { diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java index 009ecb9..a8a0cf5 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AbstractAuditEventMessageImpl.java @@ -62,7 +62,7 @@ public abstract class AbstractAuditEventMessageImpl implements AuditEventMessage /** * Date and time the event was generated */ - private final Date eventDateTime = new Date(); + private final Date eventDateTime; /** * Message destination address @@ -83,7 +83,8 @@ public abstract class AbstractAuditEventMessageImpl implements AuditEventMessage /** * Constructor for creating an Audit Event Message */ - protected AbstractAuditEventMessageImpl() { + protected AbstractAuditEventMessageImpl(Date timestamp) { + eventDateTime = timestamp; auditMessage = new AuditMessage(); } @@ -105,7 +106,7 @@ public Date getDateTime() { /* (non-Javadoc) * @see org.openhealthtools.ihe.atna.auditor.events.AuditEventMessage#setDestinationUri(java.net.URI) */ - public void setDestinationUri(URI uri) throws Exception { + public void setDestinationUri(URI uri) { if (EventUtils.isEmptyOrNull(uri)) { LOGGER.error("The destination URI cannot be null"); throw new IllegalArgumentException("The destination URI cannot be null"); @@ -264,7 +265,7 @@ protected EventIdentificationType setEventIdentification( * @return The Active Participant block created */ protected ActiveParticipantType addActiveParticipant(String userID, String altUserID, String userName, - Boolean userIsRequestor, CodedValueType[] roleIdCodes, String networkAccessPointID, RFC3881NetworkAccessPointTypeCodes networkAccessPointTypeCode) { + Boolean userIsRequestor, List roleIdCodes, String networkAccessPointID, RFC3881NetworkAccessPointTypeCodes networkAccessPointTypeCode) { ActiveParticipantType activeParticipantBlock = new ActiveParticipantType(); activeParticipantBlock.setUserID(userID); @@ -272,7 +273,7 @@ protected ActiveParticipantType addActiveParticipant(String userID, String altUs activeParticipantBlock.setUserName(userName); activeParticipantBlock.setUserIsRequestor(userIsRequestor); if (!EventUtils.isEmptyOrNull(roleIdCodes, true)) { - activeParticipantBlock.getRoleIDCode().addAll(Arrays.asList(roleIdCodes)); + activeParticipantBlock.getRoleIDCode().addAll(roleIdCodes); } activeParticipantBlock.setNetworkAccessPointID(networkAccessPointID); if (!EventUtils.isEmptyOrNull(networkAccessPointTypeCode)) { @@ -385,7 +386,7 @@ public ParticipantObjectIdentificationType addParticipantObjectIdentification(Co * @return The Active Participant block created */ protected ActiveParticipantType addActiveParticipant(String userID, String altUserID, String userName, - Boolean userIsRequestor, CodedValueType[] roleIdCodes, String networkAccessPointID) { + Boolean userIsRequestor, List roleIdCodes, String networkAccessPointID) { // Does lookup to see if using IP Address or hostname in Network Access Point ID return addActiveParticipant( userID, altUserID, userName, userIsRequestor, diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AuditEventMessage.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AuditEventMessage.java index 92529d3..4595ec3 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AuditEventMessage.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/AuditEventMessage.java @@ -56,7 +56,7 @@ public interface AuditEventMessage * @param uri The destination * @throws Exception */ - void setDestinationUri(URI uri) throws Exception; + void setDestinationUri(URI uri); /** * Gets the destination address for this message diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java index 7f08457..670ff4b 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/GenericAuditEventMessageImpl.java @@ -16,6 +16,7 @@ import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes; import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType; +import java.util.Date; import java.util.List; /** @@ -31,15 +32,25 @@ public class GenericAuditEventMessageImpl extends AbstractAuditEventMessageImpl { - public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome, - RFC3881EventActionCodes action, - CodedValueType id, CodedValueType[] type, - List purposesOfUse) - { - setEventIdentification(outcome,action,id,type, purposesOfUse); - } + public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome, + RFC3881EventActionCodes action, + CodedValueType id, CodedValueType[] type, + Date eventDateTime, + List purposesOfUse) + { + super(eventDateTime); + setEventIdentification(outcome,action,id,type, purposesOfUse); + } + + public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome, + RFC3881EventActionCodes action, + CodedValueType id, CodedValueType[] type, + List purposesOfUse) + { + this(outcome,action,id,type, new Date(), purposesOfUse); + } - @Deprecated + @Deprecated public GenericAuditEventMessageImpl( RFC3881EventOutcomeCodes outcome, RFC3881EventActionCodes action, CodedValueType id, CodedValueType[] type) diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/ApplicationActivityEvent.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/ApplicationActivityEvent.java index f23c96e..e7ad120 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/ApplicationActivityEvent.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/ApplicationActivityEvent.java @@ -17,6 +17,8 @@ import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes; import org.openhealthtools.ihe.atna.auditor.events.GenericAuditEventMessageImpl; +import java.util.Collections; + /** * Audit Event representing a DICOM 95 Application Activity event (DCM 110100) @@ -55,8 +57,8 @@ public void addApplicationParticipant(String userId, String altUserId, String us userId, altUserId, userName, - false, - new DICOMActiveParticipantRoleIdCodes[] {new DICOMActiveParticipantRoleIdCodes.Application()}, + false, + Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Application()), networkId); } @@ -74,8 +76,8 @@ public void addApplicationStarterParticipant(String userId, String altUserId, St userId, altUserId, userName, - true, - new DICOMActiveParticipantRoleIdCodes[] {new DICOMActiveParticipantRoleIdCodes.ApplicationLauncher()}, + true, + Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.ApplicationLauncher()), networkId); } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java index 203b1f3..11dcb89 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/dicom/UserAuthenticationEvent.java @@ -16,8 +16,9 @@ import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes; import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes; import org.openhealthtools.ihe.atna.auditor.events.GenericAuditEventMessageImpl; -import org.openhealthtools.ihe.atna.auditor.models.rfc3881.CodedValueType; +import java.util.Date; +import java.util.Collections; /** * Audit Event representing a DICOM 95 User Authentication event (DCM 110114) * @@ -25,6 +26,24 @@ */ public class UserAuthenticationEvent extends GenericAuditEventMessageImpl { + /** + * Creates a User Authentication Event for a given event type (e.g. Login, Logout) + * @param outcome The event outcome indicator + * @param type The type of event + * @param eventDateTime timestamp of the event + */ + public UserAuthenticationEvent(RFC3881EventOutcomeCodes outcome, DICOMEventTypeCodes type, Date eventDateTime) + { + super( + outcome, + RFC3881EventCodes.RFC3881EventActionCodes.EXECUTE, + new DICOMEventIdCodes.UserAuthentication(), + new DICOMEventTypeCodes[] {type}, + eventDateTime, + null + ); + } + /** * Creates a User Authentication Event for a given event type (e.g. Login, Logout) * @param outcome The event outcome indicator @@ -33,14 +52,14 @@ public class UserAuthenticationEvent extends GenericAuditEventMessageImpl public UserAuthenticationEvent(RFC3881EventOutcomeCodes outcome, DICOMEventTypeCodes type) { super( - outcome, + outcome, RFC3881EventCodes.RFC3881EventActionCodes.EXECUTE, new DICOMEventIdCodes.UserAuthentication(), new DICOMEventTypeCodes[] {type}, - null + null ); } - + /** * Adds an Active Participant representing the user requesting the authentication * @@ -76,7 +95,7 @@ public void addNodeActiveParticipant(String userId, String altUserId, String use altUserId, userName, true, - new CodedValueType[] {new DICOMActiveParticipantRoleIdCodes.Application()}, + Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Application()), networkId); } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java index b6ac788..f133e56 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/events/ihe/GenericIHEAuditEventMessage.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.openhealthtools.ihe.atna.auditor.events.ihe; +import java.util.Collections; import java.util.LinkedList; import java.util.List; @@ -98,8 +99,8 @@ public void addSourceActiveParticipant(String userId, String altUserId, String u userId, altUserId, userName, - isRequestor, - new DICOMActiveParticipantRoleIdCodes[] {new DICOMActiveParticipantRoleIdCodes.Source()}, + isRequestor, + Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Source()), networkId); } @@ -118,28 +119,47 @@ public void addDestinationActiveParticipant(String userId, String altUserId, Str altUserId, userName, isRequestor, - new DICOMActiveParticipantRoleIdCodes[] {new DICOMActiveParticipantRoleIdCodes.Destination()}, + Collections.singletonList(new DICOMActiveParticipantRoleIdCodes.Destination()), networkId); } - + /** * Adds an Active Participant block representing the human requestor participant * @param userId The Active Participant's User ID * @param altUserId The Active Participant's Alternate UserID * @param userName The Active Participant's UserName + * @param roles The participant's roles + */ + public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, List roles) + { + addActiveParticipant( + userId, + altUserId, + userName, + true, + roles, + null); + } + + /** + * Adds an Active Participant block representing the human requestor participant + * @param userId The Active Participant's User ID + * @param altUserId The Active Participant's Alternate UserID + * @param userName The Active Participant's UserName * @param role The participant's role */ + @Deprecated public void addHumanRequestorActiveParticipant(String userId, String altUserId, String userName, CodedValueType role) { addActiveParticipant( - userId, - altUserId, - userName, + userId, + altUserId, + userName, true, - new CodedValueType[] {role}, + Collections.singletonList(role), null); } - + /** * Adds a Participant Object Identification block that representing a patient * involved in the event @@ -270,7 +290,7 @@ public void addRemovedRegistryObject(IHETransactionParticipantObjectIDTypeCodes registryObjectUuid, RFC3881ParticipantObjectTypeCodes.SYSTEM, RFC3881ParticipantObjectTypeRoleCodes.REPORT, - null, + RFC3881ParticipantObjectCodes.RFC3881ParticipantObjectDataLifeCycleCodes.PERMANENT_ERASURE, null); } diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditMessage.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditMessage.java index b04493a..96fb129 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditMessage.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditMessage.java @@ -80,7 +80,7 @@ public String toString(boolean useSpacing) StringBuilder sb = new StringBuilder(); sb.append(""); sb.append(eventIdentification.toString(useSpacing)); diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceIdentificationType.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceIdentificationType.java index 0ab3769..da107e8 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceIdentificationType.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceIdentificationType.java @@ -20,7 +20,6 @@ package org.openhealthtools.ihe.atna.auditor.models.rfc3881; import org.apache.commons.lang3.StringEscapeUtils; -import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881AuditSourceTypeCodes; import org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881AuditSourceTypes; import org.openhealthtools.ihe.atna.auditor.utils.EventUtils; diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceType.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceType.java index 9d30b43..d3c5369 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceType.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/models/rfc3881/AuditSourceType.java @@ -50,7 +50,7 @@ public String toString() StringBuilder sb = new StringBuilder(); sb.append("false for pooled sessions) + * @param userName user name for JMS authentication + * @param password user password for JMS authentication + * @throws JMSException + */ + public JmsAuditMessageQueue(ConnectionFactory connectionFactory, Destination destination, boolean needCloseSession, String userName, String password) throws JMSException { + this.connection = connectionFactory.createConnection(userName, password); + this.destination = destination; + this.needCloseSession = needCloseSession; + } + + /** + * @param connectionFactory JMS connection factory + * @param destination JMS destination of ATNA messages + * @param needCloseSession whether the JMS session shall be closed after each message (should be false for pooled sessions) + * @throws JMSException + */ + public JmsAuditMessageQueue(ConnectionFactory connectionFactory, Destination destination, boolean needCloseSession) throws JMSException { + this(connectionFactory, destination, needCloseSession, null, null); + } + + @Override + public void sendAuditEvent(AuditEventMessage atnaMessage) { + Session session = null; + try { + connection.start(); + session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + BytesMessage message = session.createBytesMessage(); + message.writeBytes(atnaMessage.getSerializedMessage(false)); + session.createProducer(destination).send(message); + } catch (JMSException e) { + LOG.error("Could not send ATNA message", e); + } finally { + if (needCloseSession && (session != null)) { + try { + session.close(); + } catch (JMSException e1) { + LOG.error("Could not close session", e1); + } + } + } + } + + @Override + public void sendAuditEvent(AuditEventMessage msg, InetAddress destination, int port) { + sendAuditEvent(msg); + } + + @Override + public void flush() { + // nop + } + + @Override + public void shutdown() { + try { + connection.stop(); + } catch (JMSException e) { + LOG.error("Could not shutdown gracefully", e); + } + } + +} diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/NettyTLSSyslogSenderImpl.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/NettyTLSSyslogSenderImpl.java index b46235e..b00c5db 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/NettyTLSSyslogSenderImpl.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/NettyTLSSyslogSenderImpl.java @@ -54,7 +54,7 @@ private static final class NettyDestination implements Destination { private EventLoopGroup workerGroup; private Channel channel; - public NettyDestination(String host, int port, final boolean withLogging) throws Exception { + public NettyDestination(String host, int port, final boolean withLogging) { workerGroup = new NioEventLoopGroup(5); diff --git a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java index 058cb15..183a084 100644 --- a/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java +++ b/auditor/src/main/java/org/openhealthtools/ihe/atna/auditor/sender/TLSSyslogSenderImpl.java @@ -97,7 +97,7 @@ private void send(AuditEventMessage msg, Socket socket) throws Exception } catch(SocketException e) { try { LOGGER.info("Failed to connect with existing TLS socket. Will create a new connection and retry."); - String key = socket.getInetAddress().getHostName() + ":" + socket.getPort(); + String key = socket.getInetAddress().getHostAddress() + ":" + socket.getPort(); synchronized (socketMap) { socketMap.remove(key); Socket newSocket = this.getTLSSocket(socket.getInetAddress(), socket.getPort()); diff --git a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/AuditorIntegrationTest.java b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/AuditorIntegrationTest.java index 698dcfb..a778620 100644 --- a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/AuditorIntegrationTest.java +++ b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/AuditorIntegrationTest.java @@ -39,7 +39,7 @@ public class AuditorIntegrationTest { private Vertx vertx; private int port; private final String host = "localhost"; - private final long waitTime = 1000L; + private final long waitTime = 2000L; private Properties p; @@ -66,7 +66,7 @@ public void setup(TestContext context){ public void tearDown(TestContext context) { System.setProperties(p); SecurityContextFactory.cleanupSecurityContext(); - vertx.close(context.asyncAssertSuccess()); + vertx.close(context.asyncAssertSuccess()); } @Test @@ -85,7 +85,7 @@ public void testTCPNoTLS(TestContext context) throws Exception { Properties properties = initSecurityDomainProperties(); initSecurityDomain(properties, false); Async async = context.async(); - vertx.deployVerticle(createTCPServer(port, async), context.asyncAssertSuccess()); + vertx.deployVerticle(createTCPServer(port, async), context.asyncAssertSuccess()); auditor.auditActorStartEvent(SUCCESS, MESA_SYSTEM_ID, MESA_USER_IDENTITY); async.awaitSuccess(waitTime); } @@ -97,7 +97,7 @@ public void testTCPOneWayTLS(TestContext context) throws Exception { Async async = context.async(); vertx.deployVerticle(createTCPServerOneWayTLS(port, properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE), properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD), async), - context.asyncAssertSuccess()); + context.asyncAssertSuccess()); auditor.auditActorStartEvent(SUCCESS, MESA_SYSTEM_ID, MESA_USER_IDENTITY); async.awaitSuccess(waitTime); } @@ -113,7 +113,7 @@ public void testTCPTwoWayTLS(TestContext context) throws Exception { properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE), properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD), async), - context.asyncAssertSuccess()); + context.asyncAssertSuccess()); auditor.auditActorStartEvent(SUCCESS, MESA_SYSTEM_ID, MESA_USER_IDENTITY); async.awaitSuccess(waitTime); } @@ -134,7 +134,7 @@ public void testTCPTwoWayTLSWrongClientCert(TestContext context) throws Exceptio properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE), properties.getProperty(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD), async), - context.asyncAssertSuccess()); + context.asyncAssertSuccess()); auditor.auditActorStartEvent(SUCCESS, MESA_SYSTEM_ID, MESA_USER_IDENTITY); try { async.awaitSuccess(waitTime); @@ -146,12 +146,13 @@ public void testTCPTwoWayTLSWrongClientCert(TestContext context) throws Exceptio async.complete(); } - private Properties initSecurityDomainProperties() throws Exception { + private Properties initSecurityDomainProperties() { Properties props = new Properties(); props.put(JAVAX_NET_SSL_KEYSTORE_PASSWORD, KEY_STORE_PASS); props.put(JAVAX_NET_SSL_KEYSTORE, this.getClass().getResource(KEY_STORE).getPath()); props.put(JAVAX_NET_SSL_TRUSTSTORE_PASSWORD, TRUST_STORE_PASS); props.put(JAVAX_NET_SSL_TRUSTSTORE, this.getClass().getResource(TRUST_STORE).getPath()); + props.put(JDK_TLS_CLIENT_PROTOCOLS, "TLSv1.2"); return props; } diff --git a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/queue/JmsAuditMessageQueueTest.java b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/queue/JmsAuditMessageQueueTest.java new file mode 100644 index 0000000..fbd34ff --- /dev/null +++ b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/queue/JmsAuditMessageQueueTest.java @@ -0,0 +1,129 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openhealthtools.ihe.atna.auditor.queue; + +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.command.ActiveMQQueue; +import org.apache.activemq.pool.PooledConnectionFactory; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openhealthtools.ihe.atna.auditor.IHEAuditor; +import org.openhealthtools.ihe.atna.auditor.context.AuditorModuleContext; +import org.openhealthtools.ihe.atna.test.JmsAtnaMessageConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jms.ConnectionFactory; +import java.util.Locale; +import java.util.Random; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.stream.IntStream; + +import static org.junit.Assert.assertEquals; +import static org.openhealthtools.ihe.atna.auditor.codes.rfc3881.RFC3881EventCodes.RFC3881EventOutcomeCodes.SUCCESS; +import static org.openhealthtools.ihe.atna.test.SyslogServerFactory.createJMSConsumer; + +/** + * @author Dmytro Rud + */ +public class JmsAuditMessageQueueTest { + + private static final String JMS_BROKER_URL = "tcp://localhost:61616"; + private static final String JMS_QUEUE_NAME = "atna"; + + private static BrokerService jmsBroker; + + private JmsAuditMessageQueue atnaQueue; + + private Logger LOG = LoggerFactory.getLogger(JmsAuditMessageQueueTest.class); + + @BeforeClass + public static void beforeClass() throws Exception { + Locale.setDefault(Locale.ENGLISH); + + // some dummy values + AuditorModuleContext.getContext().getConfig().setAuditRepositoryHost("localhost"); + AuditorModuleContext.getContext().getConfig().setAuditRepositoryPort(514); + + jmsBroker = new BrokerService(); + jmsBroker.addConnector(JMS_BROKER_URL); + jmsBroker.setUseJmx(false); + jmsBroker.setPersistent(false); + jmsBroker.deleteAllMessages(); + jmsBroker.start(); + } + + @After + public void tearDown(){ + if (atnaQueue != null) { + atnaQueue.shutdown(); + } + } + + @Test + public void testActiveMQ() throws Exception { + CountDownLatch latch = new CountDownLatch(1); + createJMSConsumer(JMS_BROKER_URL, JMS_QUEUE_NAME, latch, false); + + PooledConnectionFactory jmsConnectionFactory = new PooledConnectionFactory(JMS_BROKER_URL); + ActiveMQQueue jmsQueue = new ActiveMQQueue(JMS_QUEUE_NAME); + atnaQueue = new JmsAuditMessageQueue(jmsConnectionFactory, jmsQueue, false); + AuditorModuleContext.getContext().setQueue(atnaQueue); + + IHEAuditor.getAuditor().auditActorStartEvent(SUCCESS, "actorName", "actorStarter"); + + latch.await(); + assertEquals(0, latch.getCount()); + } + + @Test + public void testMultiActiveMQ() throws Exception { + CountDownLatch latch = new CountDownLatch(latchCount()); + LOG.info("Latch count: " + latch.getCount()); + ExecutorService executorService = Executors.newFixedThreadPool(2); + IntStream.range(0, (int)latch.getCount()) + .forEach(i -> + executorService.execute(new JmsAtnaMessageConsumer(latch, JMS_BROKER_URL, JMS_QUEUE_NAME)) + ); + + ConnectionFactory jmsConnectionFactory = new PooledConnectionFactory(JMS_BROKER_URL); + ActiveMQQueue jmsQueue = new ActiveMQQueue(JMS_QUEUE_NAME); + atnaQueue = new JmsAuditMessageQueue(jmsConnectionFactory, jmsQueue, false); + AuditorModuleContext.getContext().setQueue(atnaQueue); + + IntStream.range(0, (int)latch.getCount()) + .forEach(i -> + IHEAuditor.getAuditor().auditActorStartEvent(SUCCESS, "actorName" + i, "actorStarter" + i) + ); + + latch.await(); + assertEquals(0, latch.getCount()); + LOG.info("Latch count: " + latch.getCount()); + LOG.info("Shutting down Executor service"); + executorService.shutdown(); + } + + private static int latchCount(){ + Random r = new Random(); + int low = 10; + int high = 100; + return r.nextInt(high-low) + low; + } + +} diff --git a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/AuditorMesaTest.java b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/AuditorMesaTest.java index 0fab441..8485059 100644 --- a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/AuditorMesaTest.java +++ b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/AuditorMesaTest.java @@ -12,7 +12,6 @@ */ package org.openhealthtools.ihe.atna.auditor.tests.mesa; -import org.apache.log4j.BasicConfigurator; import org.junit.Assert; import org.junit.Before; import org.openhealthtools.ihe.atna.auditor.context.AuditorModuleConfig; @@ -31,9 +30,6 @@ public abstract class AuditorMesaTest extends Assert { @Before public void setUp() throws Exception { - // Do basic log4j configuration - BasicConfigurator.configure(); - File keystoreFile = new File(getClass().getResource(TestConfiguration.KEY_STORE).toURI()); File truststoreFile = new File(getClass().getResource(TestConfiguration.TRUST_STORE).toURI()); diff --git a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/Mesa11180.java b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/Mesa11180.java index 139d15e..1d609d0 100644 --- a/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/Mesa11180.java +++ b/auditor/src/test/java/org/openhealthtools/ihe/atna/auditor/tests/mesa/Mesa11180.java @@ -80,7 +80,7 @@ public void test11199() { codedValue.setCode("purposeOfUse"); purposesOfUse.add(codedValue); consumerAuditor.auditRegistryStoredQueryEvent(RFC3881EventOutcomeCodes.SUCCESS, "http://xds-ibm.lgs.com:9080/IBMXDSRegistry/registry", "urn:uuid:1234", "", "1.1.1.1", "1234^^^&1.2.3.4&ISO", - "4711", purposesOfUse); + "4711", purposesOfUse, null); } } diff --git a/auditor/src/test/resources/log4j.xml b/auditor/src/test/resources/log4j.xml deleted file mode 100644 index d6a9b99..0000000 --- a/auditor/src/test/resources/log4j.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/auditor/src/test/resources/log4j2.xml b/auditor/src/test/resources/log4j2.xml new file mode 100644 index 0000000..30fb1c5 --- /dev/null +++ b/auditor/src/test/resources/log4j2.xml @@ -0,0 +1,17 @@ + + + + + + %d{ABSOLUTE} [%t] %-5p - %C{1}.%M(%L) | %m%n + + + + + + + + + + + diff --git a/context/pom.xml b/context/pom.xml index 4f1258d..8f71c8e 100644 --- a/context/pom.xml +++ b/context/pom.xml @@ -27,8 +27,19 @@ slf4j-api - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test diff --git a/context/src/test/resources/log4j2.xml b/context/src/test/resources/log4j2.xml new file mode 100644 index 0000000..30fb1c5 --- /dev/null +++ b/context/src/test/resources/log4j2.xml @@ -0,0 +1,17 @@ + + + + + + %d{ABSOLUTE} [%t] %-5p - %C{1}.%M(%L) | %m%n + + + + + + + + + + + diff --git a/nodeauth/pom.xml b/nodeauth/pom.xml index fa4d085..8accbf8 100644 --- a/nodeauth/pom.xml +++ b/nodeauth/pom.xml @@ -27,8 +27,19 @@ slf4j-api - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test diff --git a/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java b/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java index 3490e39..b41c49b 100644 --- a/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java +++ b/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomain.java @@ -277,7 +277,7 @@ private void setOrClearSystemProperties(String name, Properties source) { * @throws CertificateException * @throws IOException */ - protected void initTrustStore(InputStream truststoreInputStream, char[] truststorePassword) throws SecurityDomainException, NoSuchAlgorithmException, CertificateException, IOException { + protected void initTrustStore(InputStream truststoreInputStream, char[] truststorePassword) throws SecurityDomainException, NoSuchAlgorithmException, CertificateException { if (null == truststoreInputStream) { truststoreInitialized = true; logger.warn("Truststore input stream is null. Using JVM default trust store."); @@ -323,7 +323,7 @@ protected void initTrustStore(InputStream truststoreInputStream, char[] truststo * @throws UnrecoverableKeyException * @throws IOException */ - protected void initKeyStore(InputStream keystoreInputStream, char[] keystorePassword) throws SecurityDomainException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException, IOException { + protected void initKeyStore(InputStream keystoreInputStream, char[] keystorePassword) throws SecurityDomainException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException { for (int typeIndex = 0; typeIndex < SECURITY_STORE_FORMATS.length; typeIndex++) { String storeType = SECURITY_STORE_FORMATS[typeIndex]; try { diff --git a/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java b/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java index 238109d..51d6bce 100644 --- a/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java +++ b/nodeauth/src/main/java/org/openhealthtools/ihe/atna/nodeauth/SecurityDomainManager.java @@ -114,7 +114,7 @@ public void registerDefaultSecurityDomain(SecurityDomain securityDomain) * @throws URISyntaxException * @throws {@link IllegalArgumentException If the specified domain doesn't exist, or if the URI is null */ - public void registerURItoSecurityDomain(URI uri, String name) throws NoSecurityDomainException, URISyntaxException + public void registerURItoSecurityDomain(URI uri, String name) throws URISyntaxException { if (uri == null) throw new IllegalArgumentException("URI parameter cannot be null"); if (! securityDomains.containsKey(name) ) throw new IllegalArgumentException("Security domain "+name+" is not a configured security domain."); diff --git a/nodeauth/src/test/java/org/openhealthtools/ihe/atna/nodeauth/tests/mesa/NodeAuthMesaTest.java b/nodeauth/src/test/java/org/openhealthtools/ihe/atna/nodeauth/tests/mesa/NodeAuthMesaTest.java index 1e539e0..b5a6dfd 100644 --- a/nodeauth/src/test/java/org/openhealthtools/ihe/atna/nodeauth/tests/mesa/NodeAuthMesaTest.java +++ b/nodeauth/src/test/java/org/openhealthtools/ihe/atna/nodeauth/tests/mesa/NodeAuthMesaTest.java @@ -13,7 +13,6 @@ package org.openhealthtools.ihe.atna.nodeauth.tests.mesa; -import org.apache.log4j.BasicConfigurator; import org.junit.Before; import org.openhealthtools.ihe.atna.nodeauth.SecurityDomain; import org.openhealthtools.ihe.atna.nodeauth.context.NodeAuthModuleContext; @@ -34,8 +33,6 @@ public abstract class NodeAuthMesaTest { @Before public void setUp() throws Exception { - // Setup the basic log4j handler - BasicConfigurator.configure(); // Set the security domain information Properties props = new Properties(); diff --git a/pom.xml b/pom.xml index 2574137..36037af 100644 --- a/pom.xml +++ b/pom.xml @@ -7,28 +7,33 @@ pom - 2.6 + 2.0.1 - 3.5.1 + 3.7.0 1.6 2.10.4 1.6.3 2.5.3 3.0.1 + + + 5.15.0 1.10 3.2.2 2.5 - 3.4 - 2.0.15 - 4.1.3.Final - 1.7.21 + 3.6 + 1.1.1 + 2.9.0 + 2.0.16 + 4.1.15.Final + 1.7.25 4.12 1.10.19 https://github.com/oehf/ipf-oht-atna - IPF OHT ATNA is a project containing patched packages of the forked OHT ATNA framework. + IPF OHT ATNA is a project containing patched packages of the forked OHT ATNA framework Open eHealth Foundation @@ -153,9 +158,21 @@ ${slf4j-version} - org.slf4j - slf4j-log4j12 - ${slf4j-version} + org.apache.logging.log4j + log4j-api + ${log4j-version} + test + + + org.apache.logging.log4j + log4j-core + ${log4j-version} + test + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j-version} test @@ -170,16 +187,27 @@ ${mockito-version} test + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + ${geronimo-spec-jms-version} + + + org.apache.activemq + activemq-broker + ${activemq-version} + + + org.apache.activemq + activemq-pool + ${activemq-version} + - - maven-assembly-plugin - ${assembly-plugin-version} - org.apache.maven.plugins maven-release-plugin diff --git a/test/pom.xml b/test/pom.xml index 5b5260a..1557ff3 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -12,7 +12,7 @@ - 3.2.0 + 3.4.2 @@ -26,6 +26,11 @@ vertx-unit ${vertx.version} + + org.apache.activemq + activemq-client + ${activemq-version} + junit junit @@ -36,8 +41,19 @@ slf4j-api - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test diff --git a/test/src/main/java/org/openhealthtools/ihe/atna/test/JmsAtnaMessageConsumer.java b/test/src/main/java/org/openhealthtools/ihe/atna/test/JmsAtnaMessageConsumer.java new file mode 100644 index 0000000..257c76f --- /dev/null +++ b/test/src/main/java/org/openhealthtools/ihe/atna/test/JmsAtnaMessageConsumer.java @@ -0,0 +1,64 @@ +package org.openhealthtools.ihe.atna.test; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.jms.*; +import java.util.concurrent.CountDownLatch; + +/** + * + */ +public class JmsAtnaMessageConsumer implements Runnable, ExceptionListener { + + private final CountDownLatch latch; + private final String jmsBrokerUrl; + private final String jmsQueueName; + + private Logger LOG = LoggerFactory.getLogger(JmsAtnaMessageConsumer.class); + + public JmsAtnaMessageConsumer(CountDownLatch latch, String jmsBrokerUrl, String jmsQueueName) { + this.latch = latch; + this.jmsQueueName = jmsQueueName; + this.jmsBrokerUrl = jmsBrokerUrl; + } + + public void run() { + try { + ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(jmsBrokerUrl); + Connection connection = connectionFactory.createConnection(); + connection.start(); + + connection.setExceptionListener(this); + Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); + Destination destination = session.createQueue(jmsQueueName); + MessageConsumer consumer = session.createConsumer(destination); + Message message = consumer.receive(1000); + + if (message instanceof BytesMessage) { + BytesMessage bytesMessage = (BytesMessage) message; + byte[] bytes = new byte[(int)bytesMessage.getBodyLength()]; + bytesMessage.readBytes(bytes); + String text = new String(bytes); + LOG.info("JMS Consumer Received BytesMessage: " + text); + } else if (message instanceof TextMessage){ + TextMessage textMessage = (TextMessage) message; + String text = textMessage.getText(); + LOG.info("JMS Consumer Received TextMessage: " + text); + } else { + LOG.info("JMS Consumer Received: " + message); + } + latch.countDown(); + consumer.close(); + session.close(); + connection.close(); + } catch (Exception e) { + LOG.error("Exception caught: " + e); + } + } + + public synchronized void onException(JMSException ex) { + LOG.error("JMS Exception occured. Shutting down client."); + } +} diff --git a/test/src/main/java/org/openhealthtools/ihe/atna/test/SyslogServerFactory.java b/test/src/main/java/org/openhealthtools/ihe/atna/test/SyslogServerFactory.java index aaf87e8..f89edc0 100644 --- a/test/src/main/java/org/openhealthtools/ihe/atna/test/SyslogServerFactory.java +++ b/test/src/main/java/org/openhealthtools/ihe/atna/test/SyslogServerFactory.java @@ -3,6 +3,8 @@ import io.vertx.core.Verticle; import io.vertx.ext.unit.Async; +import java.util.concurrent.CountDownLatch; + /** * */ @@ -27,4 +29,11 @@ public static Verticle createTCPServerTwoWayTLS(int port, keystorePath, keystorePassword, async); } + public static void createJMSConsumer(String brokerUrl, String queueName, CountDownLatch latch, boolean daemon){ + Runnable runnable = new JmsAtnaMessageConsumer(latch, brokerUrl, queueName); + Thread brokerThread = new Thread(runnable); + brokerThread.setDaemon(daemon); + brokerThread.start(); + } + } diff --git a/test/src/main/java/org/openhealthtools/ihe/atna/test/TCPSyslogServer.java b/test/src/main/java/org/openhealthtools/ihe/atna/test/TCPSyslogServer.java index a9819c5..402468a 100644 --- a/test/src/main/java/org/openhealthtools/ihe/atna/test/TCPSyslogServer.java +++ b/test/src/main/java/org/openhealthtools/ihe/atna/test/TCPSyslogServer.java @@ -1,8 +1,6 @@ package org.openhealthtools.ihe.atna.test; import io.vertx.core.AbstractVerticle; -import io.vertx.core.Handler; -import io.vertx.core.buffer.Buffer; import io.vertx.core.http.ClientAuth; import io.vertx.core.net.*; import io.vertx.ext.unit.Async; @@ -27,6 +25,7 @@ public TCPSyslogServer(int port, Async async){ this.async = async; nsOptions = new NetServerOptions() .setReuseAddress(true) + .setHost("localhost") .setSsl(false); } @@ -38,6 +37,7 @@ public TCPSyslogServer(int port, String clientAuth, this.async = async; nsOptions = new NetServerOptions() .setReuseAddress(true) + .setHost("localhost") .setClientAuth(ClientAuth.valueOf(clientAuth)) .setTrustStoreOptions(trustStorePath != null? new JksOptions(). setPath(trustStorePath). @@ -51,13 +51,10 @@ public TCPSyslogServer(int port, String clientAuth, @Override public void start() throws Exception { NetServer netServer = vertx.createNetServer(nsOptions); - netServer.connectHandler(netSocket -> netSocket.handler(new Handler() { - @Override - public void handle(Buffer buffer) { - log.debug("================= Received content on " + port + ":" + async.count() + - " =================== \n" + buffer.toString()); - async.countDown(); - } + netServer.connectHandler(netSocket -> netSocket.handler(buffer -> { + log.debug("================= Received content on " + port + ":" + async.count() + + " =================== \n" + buffer.toString()); + async.countDown(); })).listen(port); } } diff --git a/test/src/main/java/org/openhealthtools/ihe/atna/test/UDPSyslogServer.java b/test/src/main/java/org/openhealthtools/ihe/atna/test/UDPSyslogServer.java index 8c2c2ba..b74cbe1 100644 --- a/test/src/main/java/org/openhealthtools/ihe/atna/test/UDPSyslogServer.java +++ b/test/src/main/java/org/openhealthtools/ihe/atna/test/UDPSyslogServer.java @@ -1,7 +1,6 @@ package org.openhealthtools.ihe.atna.test; import io.vertx.core.AbstractVerticle; -import io.vertx.core.AsyncResultHandler; import io.vertx.core.datagram.DatagramSocket; import io.vertx.core.datagram.DatagramSocketOptions; import io.vertx.ext.unit.Async; @@ -34,7 +33,7 @@ public UDPSyslogServer(String host, int udpPort, Async async) { @Override public void start() { final DatagramSocket socket = vertx.createDatagramSocket(dsOptions); - socket.listen(udpPort, host, (AsyncResultHandler) datagramSocketAsyncResult -> { + socket.listen(udpPort, host, datagramSocketAsyncResult -> { if (datagramSocketAsyncResult.succeeded()){ log.info("Listening on UDP port " + udpPort); async.countDown(); diff --git a/util/pom.xml b/util/pom.xml index 71428c3..54ec1c9 100644 --- a/util/pom.xml +++ b/util/pom.xml @@ -22,8 +22,19 @@ slf4j-api - org.slf4j - slf4j-log4j12 + org.apache.logging.log4j + log4j-api + test + + + org.apache.logging.log4j + log4j-core + test + + + org.apache.logging.log4j + log4j-slf4j-impl + test