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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations