Search in sources :

Example 16 with AuditEvent

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

the class AuditLoggerEjb method logLabMessageSuccess.

private void logLabMessageSuccess(Coding type, Reference what, String outcome, List<AuditEvent.AuditEventEntityDetailComponent> details, Date start, Date end, String authAlias) {
    AuditEvent logLabMessage = new AuditEvent();
    logLabMessage.setType(type);
    logLabMessage.setAction(AuditEvent.AuditEventAction.E);
    makePeriod(start, end, logLabMessage);
    logLabMessage.setRecorded(Calendar.getInstance(TimeZone.getDefault()).getTime());
    logLabMessage.setOutcome(AuditEvent.AuditEventOutcome._0);
    logLabMessage.setOutcomeDesc(outcome);
    logLabMessage.addAgent(getAuditEventAgentComponentWithAuthAlias(authAlias));
    AuditEvent.AuditEventSourceComponent source = new AuditEvent.AuditEventSourceComponent();
    source.setSite(String.format("%s - DEMIS", auditSourceSite));
    logLabMessage.setSource(source);
    AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent();
    entity.setWhat(what);
    entity.setDetail(details);
    logLabMessage.addEntity(entity);
    accept(logLabMessage);
}
Also used : AuditEvent(org.hl7.fhir.r4.model.AuditEvent)

Example 17 with AuditEvent

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

the class AuditLoggerEjb method makePeriod.

private void makePeriod(Date start, Date end, AuditEvent event) {
    Period period = new Period();
    period.setStart(start);
    period.setEnd(end);
    event.setPeriod(period);
}
Also used : Period(org.hl7.fhir.r4.model.Period)

Example 18 with AuditEvent

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

the class AuditLoggerEjb method logFailedUiLogin.

@Override
public void logFailedUiLogin(String caller, String method, String pathInfo) {
    AuditEvent uiLoginFail = new AuditEvent();
    uiLoginFail.setType(USER_AUTHENTICATION_CODING);
    uiLoginFail.addSubtype(LOGIN_CODING);
    uiLoginFail.setAction(AuditEvent.AuditEventAction.E);
    uiLoginFail.setRecorded(Calendar.getInstance(TimeZone.getDefault()).getTime());
    uiLoginFail.setOutcome(AuditEvent.AuditEventOutcome._4);
    uiLoginFail.setOutcomeDesc("Authentication failed");
    AuditEvent.AuditEventAgentComponent agent = new AuditEvent.AuditEventAgentComponent();
    agent.setName(caller);
    uiLoginFail.addAgent(agent);
    AuditEvent.AuditEventSourceComponent source = new AuditEvent.AuditEventSourceComponent();
    source.setSite(String.format("%s - UI MultiAuthenticationMechanism", auditSourceSite));
    uiLoginFail.setSource(source);
    AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent();
    entity.setWhat(new Reference(String.format("%s %s", method, pathInfo)));
    uiLoginFail.addEntity(entity);
    accept(uiLoginFail);
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) AuditEvent(org.hl7.fhir.r4.model.AuditEvent)

Example 19 with AuditEvent

use of org.hl7.fhir.r4.model.AuditEvent 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 20 with AuditEvent

use of org.hl7.fhir.r4.model.AuditEvent 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)10 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)6 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)6 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)6 Reference (org.hl7.fhir.r4.model.Reference)5 Coding (org.hl7.fhir.r4.model.Coding)4 AuditSourceType (org.hl7.fhir.r4.model.codesystems.AuditSourceType)3 Test (org.junit.jupiter.api.Test)3 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)2 Date (java.util.Date)2 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 StringType (org.hl7.fhir.r4.model.StringType)2 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)1 ArrayList (java.util.ArrayList)1 AuditEvent (org.hl7.fhir.dstu3.model.AuditEvent)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 InstantType (org.hl7.fhir.r4.model.InstantType)1 Period (org.hl7.fhir.r4.model.Period)1