From 771dca883ea5370c378fef6a3dbd864475621e7c Mon Sep 17 00:00:00 2001 From: Thomas Richner Date: Tue, 2 Apr 2024 12:46:08 +0200 Subject: [PATCH] EPA-81: Configurable User-Agent --- README.md | 1 + .../oviva/epa/client/KonnektorServiceBuilder.java | 9 ++++++++- .../epa/client/internal/KonnektorServiceImpl.java | 8 ++++++-- .../internal/svc/PhrManagementServiceClient.java | 14 +++++++++++++- .../epa/client/KonnektorServiceAcceptanceTest.java | 5 +++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec05003..f3b2d2e 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ sequenceDiagram * You should be able to write an example file in the test environment (RU). ## Normative Documents +- [Specifications ePA - 'Aktensystem ePA für alle'](https://gemspec.gematik.de/docs/gemSpec/gemSpec_Aktensystem_ePAfueralle/latest/) - [DiGA Leitfaden, 3.5 Interoperabilität](https://www.bfarm.de/SharedDocs/Downloads/DE/Medizinprodukte/diga_leitfaden.html) - [DiGA Anwendungssteckbrief](https://gemspec.gematik.de/docs/gemAnw/gemAnw_DiGA/latest/) - [gematik/api-telematik](https://github.com/gematik/api-telematik/tree/OPB5) diff --git a/diga-epa-client/src/main/java/com/oviva/epa/client/KonnektorServiceBuilder.java b/diga-epa-client/src/main/java/com/oviva/epa/client/KonnektorServiceBuilder.java index 542e2db..eff7844 100644 --- a/diga-epa-client/src/main/java/com/oviva/epa/client/KonnektorServiceBuilder.java +++ b/diga-epa-client/src/main/java/com/oviva/epa/client/KonnektorServiceBuilder.java @@ -12,6 +12,7 @@ public class KonnektorServiceBuilder { private String mandantId = "m"; private String clientSystemId = "c"; private String userId = "admin"; + private String userAgent = "DiGA-Lib-Test/0.0.1"; private KonnektorServiceBuilder() {} @@ -44,6 +45,12 @@ public KonnektorServiceBuilder userId(String userId) { return this; } + /** user agent according to A_22470-05 */ + public KonnektorServiceBuilder userAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + public KonnektorService build() { if (connection == null) { @@ -63,7 +70,7 @@ public KonnektorService build() { } var ctx = new KonnektorContext(mandantId, clientSystemId, workplaceId, userId); - var svc = new KonnektorServiceImpl(connection, ctx); + var svc = new KonnektorServiceImpl(userAgent, connection, ctx); return new ExceptionMappedKonnektorService(svc); } } diff --git a/diga-epa-client/src/main/java/com/oviva/epa/client/internal/KonnektorServiceImpl.java b/diga-epa-client/src/main/java/com/oviva/epa/client/internal/KonnektorServiceImpl.java index 316a7aa..b9584f0 100644 --- a/diga-epa-client/src/main/java/com/oviva/epa/client/internal/KonnektorServiceImpl.java +++ b/diga-epa-client/src/main/java/com/oviva/epa/client/internal/KonnektorServiceImpl.java @@ -41,6 +41,7 @@ public class KonnektorServiceImpl implements KonnektorService { private static Logger log = LoggerFactory.getLogger(KonnektorServiceImpl.class); private static final String REGISTRY_STATUS_SUCCESS = "urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"; + private final String userAgent; // A_22470-05 private final EventServiceClient eventServiceClient; private final CardServiceClient cardServiceClient; private final PhrManagementServiceClient phrManagementServiceClient; @@ -48,7 +49,9 @@ public class KonnektorServiceImpl implements KonnektorService { private final SmbInformationServiceClient smbInformationServiceClient; - public KonnektorServiceImpl(KonnektorConnection connection, KonnektorContext konnektorContext) { + public KonnektorServiceImpl( + String userAgent, KonnektorConnection connection, KonnektorContext konnektorContext) { + this.userAgent = userAgent; eventServiceClient = new EventServiceClient(connection.eventService(), konnektorContext); @@ -58,7 +61,8 @@ public KonnektorServiceImpl(KonnektorConnection connection, KonnektorContext kon phrServiceClient = new PhrServiceClient(connection.phrService(), konnektorContext); phrManagementServiceClient = - new PhrManagementServiceClient(connection.phrManagementService(), konnektorContext); + new PhrManagementServiceClient( + connection.phrManagementService(), konnektorContext, userAgent); var certificateServiceClient = new CertificateServiceClient(connection.certificateService(), konnektorContext); diff --git a/diga-epa-client/src/main/java/com/oviva/epa/client/internal/svc/PhrManagementServiceClient.java b/diga-epa-client/src/main/java/com/oviva/epa/client/internal/svc/PhrManagementServiceClient.java index ea3b742..47604f3 100644 --- a/diga-epa-client/src/main/java/com/oviva/epa/client/internal/svc/PhrManagementServiceClient.java +++ b/diga-epa-client/src/main/java/com/oviva/epa/client/internal/svc/PhrManagementServiceClient.java @@ -13,10 +13,22 @@ public class PhrManagementServiceClient { private final PHRManagementServicePortType phrManagementService; private final KonnektorContext konnektorContext; + private final String userAgent; + + /** + * @param phrManagementService + * @param konnektorContext + * @param userAgent A_22470-04 + * - Definition Useragent + */ public PhrManagementServiceClient( - PHRManagementServicePortType phrManagementService, KonnektorContext konnektorContext) { + PHRManagementServicePortType phrManagementService, + KonnektorContext konnektorContext, + String userAgent) { this.phrManagementService = phrManagementService; this.konnektorContext = konnektorContext; + this.userAgent = userAgent; } public GetAuthorizationStateResponse getAuthorizationState(String knvr, String homeCommunityId) { diff --git a/diga-epa-client/src/test/java/com/oviva/epa/client/KonnektorServiceAcceptanceTest.java b/diga-epa-client/src/test/java/com/oviva/epa/client/KonnektorServiceAcceptanceTest.java index b9ff4c3..aeb8022 100644 --- a/diga-epa-client/src/test/java/com/oviva/epa/client/KonnektorServiceAcceptanceTest.java +++ b/diga-epa-client/src/test/java/com/oviva/epa/client/KonnektorServiceAcceptanceTest.java @@ -46,6 +46,10 @@ class KonnektorServiceAcceptanceTest { private static final String KVNR = "X110467329"; private static final String FAKE_KVNR = "A123456780"; + + // A_22470-05 + // https://gemspec.gematik.de/docs/gemSpec/gemSpec_Aktensystem_ePAfueralle/latest/#2.7 + private static final String USER_AGENT = "TEST/0.0.1"; private static final String TI_KONNEKTOR_URI = "https://10.156.145.103:443"; private static final String PROXY_ADDRESS = "127.0.0.1"; private static final String KEYSTORE_FILE = "keys/vKon_Client_172.026.002.035.p12"; @@ -192,6 +196,7 @@ private KonnektorService buildService() throws Exception { .clientSystemId(CLIENT_SYSTEM_ID) .mandantId(MANDANT_ID) .userId(USER_ID) + .userAgent(USER_AGENT) .build(); }