Search in sources :

Example 1 with AuditSourceType

use of org.hl7.fhir.r4.model.codesystems.AuditSourceType in project SORMAS-Project by hzi-braunschweig.

the class AuditLoggerEjb method logApplicationLifecycle.

private void logApplicationLifecycle(Coding subtype, String outcomeDesc) {
    AuditEvent applicationStartAudit = new AuditEvent();
    applicationStartAudit.setType(new Coding(VALUESET_AUDIT_EVENT_TYPE_HTML, "110100", "Application Activity"));
    applicationStartAudit.setSubtype(Collections.singletonList(subtype));
    applicationStartAudit.setAction(AuditEvent.AuditEventAction.E);
    applicationStartAudit.setRecorded(Calendar.getInstance(TimeZone.getDefault()).getTime());
    // success
    applicationStartAudit.setOutcome(AuditEvent.AuditEventOutcome._0);
    applicationStartAudit.setOutcomeDesc(outcomeDesc);
    AuditEvent.AuditEventAgentComponent agent = new AuditEvent.AuditEventAgentComponent();
    CodeableConcept codeableConcept = new CodeableConcept();
    codeableConcept.addCoding(new Coding("https://www.hl7.org/fhir/valueset-participation-role-type.html", "110151", "Application Launcher"));
    agent.setType(codeableConcept);
    agent.setName("SYSTEM");
    applicationStartAudit.addAgent(agent);
    AuditEvent.AuditEventSourceComponent source = new AuditEvent.AuditEventSourceComponent();
    source.setSite(auditSourceSite);
    // Application Server
    AuditSourceType auditSourceType = AuditSourceType._4;
    source.addType(new Coding(auditSourceType.getSystem(), auditSourceType.toCode(), auditSourceType.getDisplay()));
    applicationStartAudit.setSource(source);
    AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent();
    entity.setWhat(new Reference("StartupShutdownService"));
    // System Object
    AuditEntityType entityType = AuditEntityType._2;
    entity.setType(new Coding(entityType.getSystem(), entityType.toCode(), entityType.getDisplay()));
    applicationStartAudit.addEntity(entity);
    accept(applicationStartAudit);
}
Also used : AuditSourceType(org.hl7.fhir.r4.model.codesystems.AuditSourceType) AuditEntityType(org.hl7.fhir.r4.model.codesystems.AuditEntityType) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) AuditEvent(org.hl7.fhir.r4.model.AuditEvent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with AuditSourceType

use of org.hl7.fhir.r4.model.codesystems.AuditSourceType in project SORMAS-Project by hzi-braunschweig.

the class AuditLoggerEjb method logRestCall.

@Override
public void logRestCall(String path, String method) {
    AuditEvent restCall = new AuditEvent();
    restCall.setType(new Coding(VALUESET_AUDIT_EVENT_TYPE_HTML, "rest", "RESTful Operation"));
    restCall.setAction(inferRestAction(method));
    restCall.setRecorded(Calendar.getInstance(TimeZone.getDefault()).getTime());
    // agent
    AuditEvent.AuditEventAgentComponent agent = getAuditEventAgentComponent();
    restCall.addAgent(agent);
    // source
    AuditEvent.AuditEventSourceComponent source = new AuditEvent.AuditEventSourceComponent();
    source.setSite(String.format("%s - SORMAS REST API", auditSourceSite));
    // Web Server
    AuditSourceType auditSourceType = AuditSourceType._3;
    source.addType(new Coding(auditSourceType.getSystem(), auditSourceType.toCode(), auditSourceType.getDisplay()));
    restCall.setSource(source);
    // entity
    AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent();
    entity.setWhat(new Reference(path));
    restCall.addEntity(entity);
    accept(restCall);
}
Also used : AuditSourceType(org.hl7.fhir.r4.model.codesystems.AuditSourceType) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) AuditEvent(org.hl7.fhir.r4.model.AuditEvent)

Example 3 with AuditSourceType

use of org.hl7.fhir.r4.model.codesystems.AuditSourceType in project SORMAS-Project by hzi-braunschweig.

the class AuditLoggerEjb method logBackendCall.

public void logBackendCall(Method calledMethod, List<String> params, String returnValue, Date start, Date end) {
    AuditEvent backendCall = new AuditEvent();
    backendCall.setAction(inferBackendAction(calledMethod.getName()));
    makePeriod(start, end, backendCall);
    backendCall.setRecorded(Calendar.getInstance(TimeZone.getDefault()).getTime());
    backendCall.setOutcomeDesc(returnValue);
    AuditEvent.AuditEventAgentComponent agent = new AuditEvent.AuditEventAgentComponent();
    CodeableConcept codeableConcept = new CodeableConcept();
    AgentDetails agentDetails = new AgentDetails(currentUserService, sessionContext);
    if (agentDetails.name.equals("SYSTEM") || agentDetails.name.equals("ANONYMOUS")) {
        codeableConcept.addCoding(new Coding(VALUESET_PARTICIPATION_ROLE_TYPE_HTML, "110150", "Application"));
        agent.setType(codeableConcept);
    } else {
        codeableConcept.addCoding(new Coding(VALUESET_PARTICIPATION_ROLE_TYPE_HTML, "humanuser", "human user"));
        agent.setType(codeableConcept);
    }
    agent.setName(agentDetails.name);
    Reference who = new Reference();
    Identifier identifier = new Identifier();
    if (!agentDetails.name.equals("SYSTEM") && !agentDetails.name.equals("ANONYMOUS")) {
        identifier.setValue(agentDetails.uuid);
    }
    who.setIdentifier(identifier);
    agent.setWho(who);
    backendCall.addAgent(agent);
    AuditEvent.AuditEventSourceComponent source = new AuditEvent.AuditEventSourceComponent();
    source.setSite(auditSourceSite);
    // Application Server process
    AuditSourceType auditSourceType = AuditSourceType._4;
    source.addType(new Coding(auditSourceType.getSystem(), auditSourceType.toCode(), auditSourceType.getDisplay()));
    backendCall.setSource(source);
    AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent();
    entity.setWhat(new Reference(calledMethod.toString()));
    List<AuditEvent.AuditEventEntityDetailComponent> details = new ArrayList<>();
    params.forEach(p -> {
        AuditEvent.AuditEventEntityDetailComponent detail = new AuditEvent.AuditEventEntityDetailComponent(new StringType("param"), new StringType(p));
        details.add(detail);
    });
    entity.setDetail(details);
    backendCall.addEntity(entity);
    accept(backendCall);
}
Also used : AuditSourceType(org.hl7.fhir.r4.model.codesystems.AuditSourceType) StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) AuditEvent(org.hl7.fhir.r4.model.AuditEvent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Aggregations

AuditEvent (org.hl7.fhir.r4.model.AuditEvent)3 Coding (org.hl7.fhir.r4.model.Coding)3 Reference (org.hl7.fhir.r4.model.Reference)3 AuditSourceType (org.hl7.fhir.r4.model.codesystems.AuditSourceType)3 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 ArrayList (java.util.ArrayList)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 StringType (org.hl7.fhir.r4.model.StringType)1 AuditEntityType (org.hl7.fhir.r4.model.codesystems.AuditEntityType)1