From 8842e81a8abf19acc9aa0b33212924e1020e081a Mon Sep 17 00:00:00 2001 From: Boris Stanojevic Date: Thu, 1 Feb 2024 14:24:15 +0100 Subject: [PATCH] small balp refactorings --- .../ipf/commons/audit/BalpAuditContext.java | 17 ++- .../audit/BalpJwtExtractorProperties.java | 15 +++ .../audit/DefaultBalpAuditContext.java | 17 ++- .../ihe/fhir/audit/codes/Constants.java | 2 - .../ihe/fhir/audit/events/BalpJwtUtils.java | 22 ++- .../fhir/audit/server/FhirAuditServer.java | 126 ++++++++++++++++++ .../fhir/audit/server/TLSBalpRepository.java | 118 ++++++++++++++++ .../fhir/extension/FhirAuditRepository.java | 61 ++------- ...bstractFhirAuditSerializationStrategy.java | 7 +- 9 files changed, 321 insertions(+), 64 deletions(-) create mode 100644 commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/FhirAuditServer.java create mode 100644 commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/TLSBalpRepository.java diff --git a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpAuditContext.java b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpAuditContext.java index 573706c679..ba2ac1307c 100644 --- a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpAuditContext.java +++ b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpAuditContext.java @@ -1,7 +1,20 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.audit; -import ca.uhn.fhir.context.FhirContext; - /** * @author Boris Stanojevic * @since 4.8 diff --git a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpJwtExtractorProperties.java b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpJwtExtractorProperties.java index a0b8e315fb..07860ee166 100644 --- a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpJwtExtractorProperties.java +++ b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/BalpJwtExtractorProperties.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.audit; import lombok.Getter; diff --git a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/DefaultBalpAuditContext.java b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/DefaultBalpAuditContext.java index d30a19f294..52275131bc 100644 --- a/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/DefaultBalpAuditContext.java +++ b/commons/audit/src/main/java/org/openehealth/ipf/commons/audit/DefaultBalpAuditContext.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.audit; import lombok.Getter; @@ -5,8 +20,6 @@ public class DefaultBalpAuditContext extends DefaultAuditContext implements BalpAuditContext { - static final AuditContext NO_AUDIT = new DefaultBalpAuditContext(); - @Getter @Setter private String auditRepositoryContextPath; diff --git a/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/codes/Constants.java b/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/codes/Constants.java index 4d8259deb2..8251fbfb47 100644 --- a/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/codes/Constants.java +++ b/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/codes/Constants.java @@ -29,6 +29,4 @@ public class Constants { public static final String AUDIT_LIFECYCLE_SYSTEM_NAME = "http://terminology.hl7.org/CodeSystem/dicom-audit-lifecycle"; public static final String OUSER_AGENT_TYPE_SYSTEM_NAME = " http://terminology.hl7.org/CodeSystem/v3-ParticipationType"; public static final String OUSER_AGENT_TYPE_CODE = "IRCP"; - public static final String OUSER_AGENT_ISSUER_SYSTEM_NAME = " http://terminology.hl7.org/CodeSystem/v3-ParticipationType"; - } diff --git a/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/events/BalpJwtUtils.java b/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/events/BalpJwtUtils.java index bcc4429b10..d88354d6c3 100644 --- a/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/events/BalpJwtUtils.java +++ b/commons/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/audit/events/BalpJwtUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.ihe.fhir.audit.events; import org.openehealth.ipf.commons.audit.AuditContext; @@ -15,7 +30,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.DCM_SYSTEM_NAME; -import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OUSER_AGENT_ISSUER_SYSTEM_NAME; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OUSER_AGENT_TYPE_SYSTEM_NAME; public class BalpJwtUtils { @@ -37,9 +51,7 @@ public static > void addJwtParticipant(D de OUSER_AGENT_TYPE_SYSTEM_NAME, ""))); ap.setUserName(dataSet.getIheIuaSubjectName()); if (isNotBlank(dataSet.getIssuer())) { - ap.getRoleIDCodes().add( - ActiveParticipantRoleId.of(CodedValueType.of(dataSet.getIssuer(), - OUSER_AGENT_ISSUER_SYSTEM_NAME, ""))); + ap.setAlternativeUserID(dataSet.getIssuer()); } delegate.addActiveParticipant(ap); if (isNotBlank(dataSet.getClientId())) { @@ -59,4 +71,4 @@ public static > void addJwtParticipant(D de }); } -} +} \ No newline at end of file diff --git a/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/FhirAuditServer.java b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/FhirAuditServer.java new file mode 100644 index 0000000000..f49e218e15 --- /dev/null +++ b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/FhirAuditServer.java @@ -0,0 +1,126 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.ihe.fhir.audit.server; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.rest.annotation.Create; +import ca.uhn.fhir.rest.annotation.Delete; +import ca.uhn.fhir.rest.annotation.IdParam; +import ca.uhn.fhir.rest.annotation.OptionalParam; +import ca.uhn.fhir.rest.annotation.Read; +import ca.uhn.fhir.rest.annotation.ResourceParam; +import ca.uhn.fhir.rest.annotation.Search; +import ca.uhn.fhir.rest.api.MethodOutcome; +import ca.uhn.fhir.rest.param.TokenParam; +import ca.uhn.fhir.rest.server.IResourceProvider; +import ca.uhn.fhir.rest.server.RestfulServer; +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; +import org.hl7.fhir.dstu3.model.Organization; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.r4.model.AuditEvent; +import org.hl7.fhir.r4.model.IdType; +import org.hl7.fhir.r4.model.ResourceType; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + +public class FhirAuditServer extends RestfulServer implements IResourceProvider { + + private final Map auditEvents = Collections.synchronizedMap(new HashMap<>()); + + public FhirAuditServer() { + setFhirContext(FhirContext.forR4()); + setResourceProviders(this); + } + + public List getAuditEvents() { + return new ArrayList<>(auditEvents.values()); + } + + @Read() + public AuditEvent read(@IdParam IdType theId) { + AuditEvent auditEvent = auditEvents.get(theId.getIdPart()); + if (auditEvent == null) { + throw new ResourceNotFoundException(theId); + } + return auditEvent; + } + + @Delete() + public MethodOutcome delete(@IdParam IdType theId) { + AuditEvent auditEvent = auditEvents.remove(theId.getIdPart()); + if (auditEvent == null) { + throw new ResourceNotFoundException(theId); + } + return new MethodOutcome(theId); + } + + @Create() + public MethodOutcome create(@ResourceParam AuditEvent auditEvent) { + String id = UUID.randomUUID().toString(); + IdType idType = new IdType(ResourceType.AuditEvent.name(), id); + auditEvent.setId(idType); + auditEvents.put(id, auditEvent); + return new MethodOutcome(idType, true); + } + + @Search + public List list(@OptionalParam(name= AuditEvent.SP_TYPE) TokenParam type, + @OptionalParam(name= AuditEvent.SP_SUBTYPE) TokenParam subtype) { + Stream allAuditEvents = getAuditEvents().stream(); + if (type != null) { + if (isNotBlank(type.getSystem()) && isNotBlank(type.getValue())) { + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getType().hasSystem() && auditEvent.getType().getSystem().equals(type.getSystem()) && + auditEvent.getType().hasCode() && auditEvent.getType().getCode().equals(type.getValue())); + } else if (isNotBlank(type.getSystem()) && isBlank(type.getValue())){ + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getType().hasSystem() && auditEvent.getType().getSystem().equals(type.getSystem())); + } else if (isBlank(type.getSystem()) && isNotBlank(type.getValue())){ + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getType().hasCode() && auditEvent.getType().getCode().equals(type.getValue())); + } + } + if (subtype != null) { + if (isNotBlank(subtype.getSystem()) && isNotBlank(subtype.getValue())) { + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getSubtypeFirstRep().hasSystem() && auditEvent.getSubtypeFirstRep().getSystem().equals(subtype.getSystem()) && + auditEvent.getSubtypeFirstRep().hasCode() && auditEvent.getSubtypeFirstRep().getCode().equals(subtype.getValue())); + } else if (isNotBlank(subtype.getSystem()) && isBlank(subtype.getValue())){ + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getSubtypeFirstRep().hasSystem() && auditEvent.getSubtypeFirstRep().getSystem().equals(subtype.getSystem())); + } else if (isBlank(subtype.getSystem()) && isNotBlank(subtype.getValue())){ + allAuditEvents = allAuditEvents.filter(auditEvent -> + auditEvent.getSubtypeFirstRep().hasCode() && auditEvent.getSubtypeFirstRep().getCode().equals(subtype.getValue())); + } + } + return allAuditEvents.collect(Collectors.toList()); + } + + @Override + public Class getResourceType() { + return AuditEvent.class; + } +} diff --git a/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/TLSBalpRepository.java b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/TLSBalpRepository.java new file mode 100644 index 0000000000..a9acf2ecf7 --- /dev/null +++ b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/audit/server/TLSBalpRepository.java @@ -0,0 +1,118 @@ +/* + * Copyright 2024 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.openehealth.ipf.commons.ihe.fhir.audit.server; + +import io.undertow.Handlers; +import io.undertow.Undertow; +import io.undertow.UndertowOptions; +import io.undertow.server.HttpHandler; +import io.undertow.server.handlers.PathHandler; +import io.undertow.servlet.api.DeploymentInfo; +import io.undertow.servlet.api.DeploymentManager; +import io.undertow.servlet.api.InstanceFactory; +import io.undertow.servlet.api.InstanceHandle; +import org.openehealth.ipf.commons.audit.TlsParameters; +import org.openehealth.ipf.commons.ihe.fhir.extension.FhirAuditRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.ServletException; + +import java.io.Closeable; +import java.io.IOException; + +import static io.undertow.servlet.Servlets.defaultContainer; +import static io.undertow.servlet.Servlets.deployment; +import static io.undertow.servlet.Servlets.servlet; + +public class TLSBalpRepository implements Closeable { + + private static final Logger LOG = LoggerFactory.getLogger(TLSBalpRepository.class); + protected final TlsParameters tlsParameters; + private Undertow server; + private final int httpsPort; + + public TLSBalpRepository(TlsParameters tlsParameters, int httpsPort) { + this.tlsParameters = tlsParameters; + this.httpsPort = httpsPort; + } + + public TLSBalpRepository(int httpsPort) { + this.tlsParameters = TlsParameters.getDefault(); + this.httpsPort = httpsPort; + } + + @Override + public void close() throws IOException { + stop(); + } + + public void stop() { + if (server != null) server.stop(); + LOG.info("successfully stopped FHIR Audit Server"); + } + + public Undertow start() throws ServletException { + DeploymentInfo servletBuilder = deployment() + .setClassLoader(FhirAuditRepository.class.getClassLoader()) + .setContextPath("/fhir") + .setDeploymentName("FHIR-Deployment") + .addServlets( + servlet("FhirAuditServer", FhirAuditServer.class, new FhirServletInitiator(new FhirAuditServer())) + .addMapping("/*")); + + DeploymentManager manager = defaultContainer().addDeployment(servletBuilder); + manager.deploy(); + + HttpHandler servletHandler = manager.start(); + PathHandler path = Handlers + .path(Handlers.redirect("/")) + .addPrefixPath("/", servletHandler); + server = Undertow.builder() + .setServerOption(UndertowOptions.ENABLE_HTTP2, true) + .addHttpsListener( + httpsPort,"localhost", tlsParameters.getSSLContext(true)) + .setHandler(path) + .build(); + server.start(); + LOG.info("successfully started FHIR Audit Server on port {}", httpsPort); + return server; + } + static class FhirServletInitiator implements InstanceFactory { + + private final FhirAuditServer fhirAuditServer; + + public FhirServletInitiator(FhirAuditServer fhirAuditServer) { + this.fhirAuditServer = fhirAuditServer; + } + + @Override + public InstanceHandle createInstance() throws InstantiationException { + return new InstanceHandle<>() { + @Override + public FhirAuditServer getInstance() { + return fhirAuditServer; + } + + @Override + public void release() { + + } + }; + } + } + +} diff --git a/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/extension/FhirAuditRepository.java b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/extension/FhirAuditRepository.java index 64a7a59405..6b001a7305 100644 --- a/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/extension/FhirAuditRepository.java +++ b/commons/ihe/fhir/core/src/test/java/org/openehealth/ipf/commons/ihe/fhir/extension/FhirAuditRepository.java @@ -1,11 +1,5 @@ package org.openehealth.ipf.commons.ihe.fhir.extension; -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.rest.annotation.Create; -import ca.uhn.fhir.rest.annotation.ResourceParam; -import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; import io.undertow.Handlers; import io.undertow.Undertow; import io.undertow.UndertowOptions; @@ -16,15 +10,13 @@ import io.undertow.servlet.api.InstanceFactory; import io.undertow.servlet.api.InstanceHandle; import net.java.quickcheck.generator.PrimitiveGenerators; -import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.AuditEvent; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.ResourceType; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.ExtensionContext; import org.openehealth.ipf.commons.audit.CustomTlsParameters; import org.openehealth.ipf.commons.audit.TlsParameters; +import org.openehealth.ipf.commons.ihe.fhir.audit.server.FhirAuditServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.io.ClassPathResource; @@ -33,8 +25,6 @@ import java.net.URI; import java.nio.file.Paths; import java.util.List; -import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; import static io.undertow.servlet.Servlets.defaultContainer; import static io.undertow.servlet.Servlets.deployment; @@ -98,12 +88,12 @@ public void beforeEach(ExtensionContext extensionContext) throws Exception { if (server == null) { fhirAuditServer = new FhirAuditServer(); DeploymentInfo servletBuilder = deployment() - .setClassLoader(FhirAuditRepository.class.getClassLoader()) - .setContextPath("/" + contextPath) - .setDeploymentName("FHIR-Deployment") - .addServlets( - servlet("FhirAuditServer", FhirAuditServer.class, new FhirServletInitiator(fhirAuditServer)) - .addMapping("/*")); + .setClassLoader(FhirAuditRepository.class.getClassLoader()) + .setContextPath("/" + contextPath) + .setDeploymentName("FHIR-Deployment") + .addServlets( + servlet("FhirAuditServer", FhirAuditServer.class, new FhirServletInitiator(fhirAuditServer)) + .addMapping("/*")); DeploymentManager manager = defaultContainer().addDeployment(servletBuilder); manager.deploy(); @@ -113,11 +103,11 @@ public void beforeEach(ExtensionContext extensionContext) throws Exception { .path(Handlers.redirect("/")) .addPrefixPath("/", servletHandler); server = Undertow.builder() - .setServerOption(UndertowOptions.ENABLE_HTTP2, true) - .addHttpsListener( - httpsPort,"localhost", setupDefaultTlsParameter().getSSLContext(true)) - .setHandler(path) - .build(); + .setServerOption(UndertowOptions.ENABLE_HTTP2, true) + .addHttpsListener( + httpsPort,"localhost", setupDefaultTlsParameter().getSSLContext(true)) + .setHandler(path) + .build(); server.start(); } } @@ -146,33 +136,6 @@ private boolean hasStartedUndertow(){ return extensionContext.getRoot().getStore(GLOBAL).get(STORE_KEY) != null; } - static class FhirAuditServer extends RestfulServer implements IResourceProvider { - - private final List auditEvents = new CopyOnWriteArrayList<>(); - - public FhirAuditServer() { - setFhirContext(FhirContext.forR4()); - setResourceProviders(this); - } - - public List getAuditEvents() { - return auditEvents; - } - - @Create() - public MethodOutcome create(@ResourceParam AuditEvent auditEvent) { - auditEvents.add(auditEvent); - return new MethodOutcome( - new IdType(ResourceType.AuditEvent.name(), - UUID.randomUUID().toString()), true); - } - - @Override - public Class getResourceType() { - return AuditEvent.class; - } - } - static class FhirServletInitiator implements InstanceFactory { private final FhirAuditServer fhirAuditServer; diff --git a/commons/ihe/fhir/r4/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/support/audit/marshal/AbstractFhirAuditSerializationStrategy.java b/commons/ihe/fhir/r4/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/support/audit/marshal/AbstractFhirAuditSerializationStrategy.java index 04d6ef8aa4..28fcad3b32 100644 --- a/commons/ihe/fhir/r4/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/support/audit/marshal/AbstractFhirAuditSerializationStrategy.java +++ b/commons/ihe/fhir/r4/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/support/audit/marshal/AbstractFhirAuditSerializationStrategy.java @@ -53,7 +53,6 @@ import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.DCM_OCLIENT_CODE; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.DCM_SYSTEM_NAME; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OBJECT_ROLE_SYSTEM_NAME; -import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OUSER_AGENT_ISSUER_SYSTEM_NAME; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OUSER_AGENT_TYPE_CODE; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.OUSER_AGENT_TYPE_SYSTEM_NAME; import static org.openehealth.ipf.commons.ihe.fhir.audit.codes.Constants.SECURITY_SOURCE_SYSTEM_NAME; @@ -138,7 +137,7 @@ protected AuditEvent.AuditEventSourceComponent auditSourceIdentificationToEventS } protected AuditEvent.AuditEventAgentComponent activeParticipantToAgent(ActiveParticipantType ap) { - Optional oUser = getOAuthAttrFromKnownActiveParticipantRoleIdCode(ap.getRoleIDCodes(), OUSER_AGENT_ISSUER_SYSTEM_NAME); + Optional oUser = getOAuthAttrFromKnownActiveParticipantRoleIdCode(ap.getRoleIDCodes(), OUSER_AGENT_TYPE_SYSTEM_NAME); if (oUser.isPresent()) { return new AuditEvent.AuditEventAgentComponent() .setType(new CodeableConcept( @@ -147,8 +146,8 @@ protected AuditEvent.AuditEventAgentComponent activeParticipantToAgent(ActivePar .setName(ap.getUserName()) .setWho( new Reference(ap.getUserID()) - .setIdentifier(new Identifier().setSystem("").setValue(ap.getUserID())) - .setDisplay(ap.getUserName())) + .setIdentifier(new Identifier().setSystem(ap.getAlternativeUserID()).setValue(ap.getUserID())) + .setDisplay(ap.getUserName())) .setRequestor(ap.isUserIsRequestor()); } Optional oClient = getOAuthAttrFromKnownActiveParticipantRoleIdCode(ap.getRoleIDCodes(), DCM_SYSTEM_NAME);