Skip to content

Commit

Permalink
#11 ATNA auditing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thopap committed May 28, 2024
1 parent 8a01888 commit 389cdb2
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
<groupId>org.openehealth.ipf.boot</groupId>
<artifactId>ipf-hl7-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.openehealth.ipf.commons</groupId>
<artifactId>ipf-commons-ihe-xua</artifactId>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter-no-dependencies</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.openehealth.app.xdstofhir.registry.audit;

import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;

@Component
@Endpoint(id="atna")
@RequiredArgsConstructor
@ConditionalOnBean(RecentATNAEvents.class)
public class ATNAEventActuator {
private final RecentATNAEvents atnaEvents;

@ReadOperation(produces = "text/plain")
public String getReleaseNotes() {
return atnaEvents.getMessages().reversed().stream()
.collect(Collectors.joining(System.lineSeparator()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.openehealth.app.xdstofhir.registry.audit;

import java.util.ArrayList;
import java.util.List;

import lombok.Getter;
import org.openehealth.ipf.commons.audit.AuditContext;
import org.openehealth.ipf.commons.audit.AuditMetadataProvider;
import org.openehealth.ipf.commons.audit.protocol.AuditTransmissionProtocol;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

@Component
@ConditionalOnProperty(value = "ipf.atna.mock.enabled", havingValue = "true")
public class RecentATNAEvents implements AuditTransmissionProtocol {
@Getter
private final List<String> messages = new ArrayList<>();

@Value("${ipf.atna.mock.recent:20}")
private int recentAuditValues;

@Override
public void send(AuditContext auditContext, AuditMetadataProvider auditMetadataProvider, String auditMessage) {
if (auditMessage != null) {
messages.add(auditMessage);
}
if (messages.size()>recentAuditValues)
messages.removeFirst();
}

@Override
public void shutdown() {
// no-op
}

@Override
public String getTransportName() {
return "recentEventsMock";
}


}
9 changes: 8 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ xds.endpoint.iti8=xds-iti8:0.0.0.0:2575

fhir.server.profile.bootstrap=false

ipf.atna.auditEnabled=true

# Capture recent N atna messages and expose on /actuator/atna
# Disable mock to configure IPF's UDP or TLS ATNA sender
ipf.atna.mock.enabled=true
ipf.atna.mock.recent=20

server.port=8081

management.endpoints.web.exposure.include=health,info,configprops
management.endpoints.web.exposure.include=health,info,configprops,atna
1 change: 1 addition & 0 deletions src/main/resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
<h1>IHE XDS.b to FHIR adapter</h1>
<a href="/services" >SOAP Service List</a></br>
<a href="https://github.com/oehf/xds-registry-to-fhir" >Github Project Page</a>
<a href="/actuator" >Service Actuator's</a>
</body>
</html>

0 comments on commit 389cdb2

Please sign in to comment.