diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ab6d092 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +on: + - push + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: eskatos/gradle-command-action@v1 + with: + gradle-version: 5.6.2 + arguments: build -x test -x distTar + - uses: actions/upload-artifact@v1 + with: + name: VZD-Client + path: build/distributions diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55741bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build + +# generated # +generated/jaxb/* + +#testData# +.bsp*Command.xml +.idea/ + +#Incluede TestServer# +!src/test/resources/exec/Testserver.jar diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..734a90c --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2020 gematik GmbH + +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. diff --git a/README.md b/README.md index e69de29..9cb334e 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,315 @@ +# VZD-Client + +## Introduction + +Der VZD-Client dient als Werkzeug um einen Verzeichnisdienst mit Einträgen +so wie Zertifikaten zu füllen, zu bearbeiten, zu löschen oder auszulesen. + +## API Documentation + +Generated API docs are available at . + +## License + +Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). + +## Overview + +## Getting Started + +Im Folgenden wird erklärt wie der `VZD-Client` herunterzuladen und zu verwenden ist. + +### VZD-Client herunterladen + +Der `VZD-Client` kann als git repository oder von Maven Central heruntergeladen werden. + +- Git + + + + git clone https://github.com/gematik/app-VZD-Client.git + +- Maven Central + + + + https://search.maven.org/artifact/de.gematik.ti.epa/VZD-CLient + +### Build setup + +Zum Compilieren des `VZD-Clients` wird das Verwenden von Java11 und gradle 5.6.2 empfohlen. + +Nach dem Compilieren wird eine .zip-Datei in den build/distributions Ordner abgelegt. +Dieser enthält eine ausführbare .bat-Datei. +Die dazugehörige .jar-Datei befindet sich im Ordner build/libs. + +## Handling + +### Starten des VZD-Clients + +In der erstellten oder heruntergeladenen .zip-Datei befinden sich 2 ausführbare .bat-Dateien. + +- startVzdClient.bat → Startet den `VZD-Client` mit den angegebenen [Parameter](#_parameter). + +- startVzdC\_Log.bat → Diese .bat-Datei erwartet als ersten Parameter den gewünschten OutputPath für das Logfile. + Danach werden die [Parameter](#_parameter) angeführt. + +Beim Verwenden der .jar-Datei kann das Log-Level und der Pfad des Logs wie in [Logging](#Logging) verwendet werden. + +### Parameter + +Zum Bedienen des `VZD-Clients` müssen mindestens 2 Parameter überreicht werden. +Dies geschieht in der Kommandozeile über die Parameter: + +Pflicht: + +- -c <Pfad zur Credentials-Datei> (.txt-Datei) + +- -p <Pfad zu Grundeinstellungen> (.txt-Datei) + +Optional: + +- -b <Pfad zur Command-Datei> (.xml-Datei) ← überschreibt eventuelle Angaben in den Grundeinstellungen + +- -h <ProxyHost IP> ← überschreibt eventuelle Angaben in den Grundeinstellungen + +- -d <Proxy Port> ← überschreibt eventuelle Angaben in den Grundeinstellungen + +### Dateistruktur + +1. **Credentials-Datei:** + Diese Datei beinhaltet die User-ID und das Passwort. + Diese müssen wie folgt in eine .txt-Datei geschrieben werden (die Reihenfolge ist hierbei nicht relevant): + + - id=<UserId> + + - secret=<Passwort> + +2. **Grundeinstellungen:** + Diese Datei beinhaltet einen BasePath (IP-Adresse oder URL zum anzusprechenden Server), einen RetryingOAuthPath (IP Adresse oder URL zum OAuth2 + Token Server) und optional einen CommandsPath (Pfad zur lokalen .xml-Datei) in der die auszuführenden Operationen definiert sind sowie ein Proxy-Host + einen dazugehörigen Proxy-Port. Außerdem können Angaben zum parallelen Ausführen gemacht werden. Eine genauere Beschreibung wie sich die Angaben + auf den Programmablauf auswirken, kann unter [Paralleles Ausführen](#_paralleles_ausführen) nachgelesen werden. + Eine weitergehende Beschreibung der Kommandodatei findet sich unter [Bedienung](#Bedienung). + Die Angaben werden wie folgt in eine .txt-Datei geschrieben (die Reihenfolge ist hierbei nicht relevant): + + - base=<URL or IP zum Server> + + - retryingOAuth=<URL or IP zum Server> + + - proxyHost=<ProxyHost IP> + + - proxyPort=<Proxy Port> + + - commands=<Pfad zur .xml-Datei> + + - maxOperation=<Anzahl an Operationsarten> + + - maxExecutionsPerOperation=<Anzahl an parallelen Operationen> + +### Bedienung + +Die Definition der Kommandos geschieht durch eine .xml-Datei. +Dieser Datei liegt ein generelles Schema zugrunde, welches durch die commands.xsd in der .zip-Datei eingesehen werden kann. +Hierbei ist der Name der Operation verpflichtend. Eine Angabe einer "commandId" ist nicht notwendig, kann jedoch wahlweise gesetzt werden. Sollte +sie nicht gesetzt werden, wird der Client eine ID vergeben, bei der er von 1 an durch iteriert. Dies dient der späteren Zuordnung welche Antwort zu +welchem Kommando gehört. + +Abhängig davon welche Operation durchgeführt werden soll, sind gewisse Angaben verpflichtend und manche optional. +Sollte ein Parameter angegeben werden und für das betreffende Kommando nicht verwendet werden können, so wird dieser ignoriert. +In `gemSpec_VZD` wird in `Kapitel 4.6.1` Operationen der Schnittstelle I\_Directory\_Administration beschrieben, welches Kommando welche Parameter +berücksichtigt und welche verpflichtend benötigt werden. + +### Logging + +Das Logging geschieht auf der Konsole, sowie in einem File. Es wird immer ein File erstellt. Sollte kein spezieller Ort für das Logging angegeben +werden, wird das Log im java.io.temp Ordner abgelegt. Standardmäßig ist das Log-Level in der Konsole "INFO" und im File "DEBUG". + +#### Logging mit .bat-Datei + +Um das Log-Level der Konsole zu beeinflussen kann ein weiterer Parameter beim Starten der .bat-Datei angegeben werden: + +(case sensitive) + +- -info ← Level INFO + +- -trace ← Level TRACE + +- -error ← Level ERROR + +- -debug ← Level DEBUG + +Beispiel Aufruf + + /startVzdC_Log.bat -c /credentials.txt -p /config.txt -debug + +#### Logging mit jar Datei + +Um hier Einfluss auf die Logeigenschaften zu nehmen, muss der Java-VM die entsprechenden Systemvariablen übergeben werden. + +- l4j.lvl=<LogLevel> → für das Log-Level + +- l4j.logDir=<LogDir> → für das Log-Output-Directroy + +Beispiel Aufruf + + java -Dl4j.lvl=DEBUG -Dl4j.logDir= -jar /vzd.jar -c /credentials.txt -p /config.txt + +### Ausführen des VZD-Clients mit Proxy + +Um den VZD-Client über einen Proxy starten, müssen wie unter [Dateistruktur](#Dateistruktur) unter Grundeinstellungen Angaben in der Konfigurationsdatei zu Host +und Port angegeben werden. + +Außerdem ist es möglich den Host über den Parameter "-h" und den Port über "-d" direkt in der Kommandozeile zu übergeben. Sollte dies gemacht werden, +so überschreibt dies die Einstellungen, die eventuell in der Configurationsdatei angegeben wurden. + +### Paralleles Ausführen + +Durch das Konfigurationsfile können Einstellungen getätigt werden, die die Ausführung der Operationen des `VZD-Client` beschleunigen (Wie diese +Angaben korrekt getätigt werden, dann unter [Parameter](#_parameter) nachgelesen werden). + +Der `VZD-Client` kann mehrere Operationsarten (AddDirectory, +ModifyDirectory etc.) gleichzeitig ausführen. Hierzu dient die Angabe maxOperations. Der Maximalwert +dieser Angabe liegt bei 8. Es kann keinen Einfluss auf die Reihenfolge genommen werden. + +Die Einstellung maxExecutionsPerOperation beschreibt wie viele gleichartige Operationen gleichzeitig ausgeführt werden. Diese Zahl ist aufgrund von +Ressourcenplanung auf 20 limitiert. + +## Abarbeiungsflows + +Der Workflow ist in der Abbildung [figure\_title](#Abarbeitungsworkflow) abzulesen. +Alle Operationen müssen über ein Commandfile, wie in 2.3 Bedienung beschrieben, übergeben werden und werden vom `VZD-Client` ausgelesen. +Bevor sie ausgeführt werden, wird abhängig der Operation eine Validitätsprüfung durchgeführt. Genauere Angaben der Validitätsprüfung, können +unter der jeweiligen Operation unter [Abarbeiungsflows](#Abarbeiungsflows) eingesehen werden. + +Sollte diese bei einem Command fehlschlagen, so wird die Durchführung abgebrochen. +Der Workflow unterscheidet zwischen „Modify“, „Add“, „Read“ und „Delete“. In der Abarbeitung gibt es jedoch leichte Unterschiede, die unter +[Abarbeiungsflows](#Abarbeiungsflows) behandelt werden.Vor dem Ausführen des Requests wird überprüft, ob der OAuth2 Token noch Gültigkeit besitzt. +Anschließend wird der Request ausgeführt und das Ergebnis in ein Logfile geschrieben, das ausgewertet werden kann. + +![Abarbeitungsworkflow](de.gematik.ti.openhealthcard.events/doc/images/Workfows_VZD.png) + +### Add Directory Entry / Certificate + +#### Validitätsprüfung + +Erforderliche Einträge für ein Add Directory Entry ist mindestens ein `UserCertificate`. Jedes dieser `UserCertificate` muss mindesten +eine `telematikID` oder ein `userCertificate` beinhalten. Alle weiteren Angaben sind optional. + +Beim Ausführen eines Add Directory Entry Certificate werden für jedes Zertifikat die `uids` mit der im `BaseDirectoryEntry` angegebenen `uid` +verglichen. Sollte die `uid` abweichen so gilt das Kommando als nicht valide. + +#### Ablauf + +Bevor ein Add Directory Entry ausgeführt wird überprüft der Client, ob bereits ein Eintrag existiert. Sollte dies der Fall sein, wird anstelle eines Add- +ein Modify Directory Entry ausgeführt. + +Bei einem Add Directory Entry Certificate werden die angegebenen Parameter an den `VZD` gesendet. + +Bei erfolgreicher Durchführung wird jeweils die Antwort `distinguished name` des Servers in den Log geschrieben. + +### Read Directory Entry / Certificate + +#### Validitätsprüfung + +Es wird nur überprüft, ob mindestens eins der Attribute nach denen gesucht werden kann angegeben wurde. + +Mögliche Parameter für das Lesen eines Entries: + +- uid / telematikID + +- givenName + +- sn + +- cn + +- displayName + +- streetAddress + +- postalCode + +- localityName + +- stateOrProvinceName + +- title + +- organisation + +- otherName + +- specialization + +- domainID + +- personalEntry + +- dataFromAuthority + +Mögliche Parameter für das Lesen eines Zertifikats (hierbei wird nur das Element `UserCertificate` betrachtet): + +- uid + +- entryType + +- telematikId + +- professionOID + +- usage + +#### Ablauf + +Alle in dem Kommando genannten Parameter werden zusammengefügt und als Request an den `VZD` gesendet. Bei erfolgreicher Anfrage wird eine Liste aller +auf die Suchkriterien zutreffende Einträge in das Log geschrieben. + +### Modify Directory Entry / Certificate + +#### Validitätsprüfung + +Bei einem Modify Directory Entry wird die Angabe einer uid vom `VZD-Client` überprüft. **Eine Modify Directory Entry Certificate Operation +ist derzeit nicht vorgesehen**. Sollte versucht werden dieses Kommando auszuführen, wird dies zu einem Fehler führen. + +#### Ablauf + +Bevor ein Modify Directory Entry ausgeführt überprüft der Client, ob bereits ein Eintrag zu der uid existiert. Sollte dies nicht der Fall +sein, so wird anstelle eines Modify- ein Add Directory Entry ausgeführt. +Bei erfolgreicher Durchführung wird der jeweils zurückgelieferte `distinguished name` ins Log geschrieben. + +ACHTUNG: + +Wenn ein Modify Directory Entry durchgeführt wird, werden alle veränderbaren Attribute, die in dem Kommando nicht gesetzt wurden auf null gesetzt. +Sollte nur ein Attribut überschrieben werden, kann die Funktion [Save Modify Directory Entry](#_save_modify_directory_entry) verwendet werden. + +### Delete Directory Entry / Certificate + +#### Validitätsprüfung + +Bei einem Delete Directory Entry Kommando wird die Angabe einer uid vom `VZD-Client` überprüft. Anschließend wird der Löschbefehl gesendet. + +Bei einem Delete Directory Entry Certificate Kommando wird die uid aus dem `UserCertificate` ausgelesen. Dieses muss mit der uid im `BaseDirectorEntry` +überein stimmen, sofern angegeben. Außerdem muss ein `cn` im `UserCertificate` angegeben werden. Sollte eine dieser Voraussetzungen nicht zutreffen, +bricht der VZD die Bearbeitung ab. + +#### Ablauf + +Bevor ein Delete Directory Entry ausgeführt überprüft der Client, ob bereits ein Eintrag zu der `telematikID` existiert. Sollte dies die Löschanfrage +nicht gesendet. + +Sollte der Request erfolgreich sein, so wird die gelöschte uid als Bestätigung in das Log geschrieben. + +### Save Modify Directory Entry + +Dies ist eine ergänzende Funktion die nicht in der Spezifikation festgehalten ist. Sie soll den Umgang erleichtern und die Fehleranfälligkeit +verringern. Sie kann dazu genutzt werden einzelne Attribute eines Eintrages zu überschreiben ohne die restlichen Attribute zu löschen. + +#### Validitätsprüfung + +Die Validitätsprüfung ist deckungsgleich zu der unter [Modify Directory Entry / Certificate](#_modify_directory_entry_certificate) + +#### Ablauf + +Im gegensatz zu dem Modify-Directory-Entry-Befehl wird der Eintrag bei dieser Operation nicht komplett mit den angegebenen Daten ersetzt. Der +`VZD-Client` führt vorher eine Readoperation durch und vergleicht die Daten die unterschiedlich sind und ersetzt die im Command angegebenen Daten. diff --git a/ReleaseNotes.md b/ReleaseNotes.md new file mode 100644 index 0000000..0cd5008 --- /dev/null +++ b/ReleaseNotes.md @@ -0,0 +1,27 @@ +# Release 1.1.1 +Features: +- Version des Clients wird beim Ausführen angegeben und ist über "-version" abzufragen + +BugFixes: +- Suche nach nicht vorhandenem Eintrag führt nun zu Fehler + + +# Release 1.1.0 +Neue Funktionalitäten: +- Proxyfunktion +- Multithreading ready +- SaveModify (Modify ohne Überschreiben) + +# Release 1.0.1 +- Funktionality for modify directory entries + - Funktionality for add certificates entries + - Funktionality for delete certificates entries + - Funktionality for read certificates entries + + +# Release 0.5.0 +- Funktionality for add directory entries + - Funktionality for delete directory entries + - Funktionality for read directory entries + + diff --git a/bspData/Beispiel_Command_Datei.xml b/bspData/Beispiel_Command_Datei.xml new file mode 100644 index 0000000..7257c40 --- /dev/null +++ b/bspData/Beispiel_Command_Datei.xml @@ -0,0 +1,115 @@ + + + + readDirectoryEntries + + uid + + cn + givenName + sn + displayName + otherName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + specialization + domainID + + telematikId + + + + addDirectoryEntries + displayName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + otherName + specialization + domainID + + telematikId + usage + userCertificate + description + + + + modifyDirectoryEntries + + uid + + cn + displayName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + otherName + specialization + domainID + + + safeModifyDirectoryEntries + + uid + + cn + displayName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + otherName + specialization + domainID + + + deleteDirectoryEntries + + uid + + + + addDirectoryEntryCertificate + + 1-HBA-Testkarte-883110000218572 + + uid + + usage + userCertificate + description + + + + readDirectoryEntryCertificate + + telematikId + entryType + usage + professionOID + + + + deleteDirectoryEntryCertificate + + telematikId + + uid + cn + + + + \ No newline at end of file diff --git a/bspData/Beispiel_Config_Datei.txt b/bspData/Beispiel_Config_Datei.txt new file mode 100644 index 0000000..4414eeb --- /dev/null +++ b/bspData/Beispiel_Config_Datei.txt @@ -0,0 +1,13 @@ +base=https://LocationOfVzd:443 +retryingOAuth=https://LocationOfOAuth2Server:8443/oauth/token + +proxyHost=192.168.230.85 +proxyPort=3128 + +// This is the maximum +maxExecutionsPerOperation=20 +// This is the maximum +maxOperations=9 + +commands=src\main\resources\bspCommands.xml + diff --git a/bspData/Beispiel_Credential_Datei.txt b/bspData/Beispiel_Credential_Datei.txt new file mode 100644 index 0000000..0ce6b34 --- /dev/null +++ b/bspData/Beispiel_Credential_Datei.txt @@ -0,0 +1,2 @@ +id=someId +secret=someSecret \ No newline at end of file diff --git a/bspData/startVzdC_Log.bat b/bspData/startVzdC_Log.bat new file mode 100644 index 0000000..ebdab3b --- /dev/null +++ b/bspData/startVzdC_Log.bat @@ -0,0 +1,27 @@ +@echo off +cls + +if not "%OPENJDK11_HOME%" == "" ( + set JAVA=%OPENJDK11_HOME% +) else ( + if not "%OPENJDK_HOME%" == "" ( + set JAVA=%OPENJDK_HOME% + ) else ( + set JAVA=%JAVA_HOME% + ) +) + +set PATH=%JAVA_HOME%\bin;%PATH% + +rem Checks if the user want's to debug the program on the console +for %%z in (%*) do ( + if "%%z"=="-debug" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=DEBUG + if "%%z"=="-info" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=INFO + if "%%z"=="-trace" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=TRACE + if "%%z"=="-error" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=ERROR + if "%%z"=="-warn" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=WARN +) + +set EXTRA_JVM_ARGUMENTS=%EXTRA_JVM_ARGUMENTS% -Dl4j.logDir=%1 + +call java %EXTRA_JVM_ARGUMENTS% -jar %~dp0.\VZD-Client\VZD-Client.jar %* \ No newline at end of file diff --git a/bspData/startVzdClient.bat b/bspData/startVzdClient.bat new file mode 100644 index 0000000..34c7373 --- /dev/null +++ b/bspData/startVzdClient.bat @@ -0,0 +1,24 @@ +@echo off +cls + +if not "%OPENJDK11_HOME%" == "" ( + set JAVA=%OPENJDK11_HOME% +) else ( + if not "%OPENJDK_HOME%" == "" ( + set JAVA=%OPENJDK_HOME% + ) else ( + set JAVA=%JAVA_HOME% + ) +) +set PATH=%JAVA_HOME%\bin;%PATH% + +rem Checks if the user want's to debug the program on the console +for %%z in (%*) do ( + if "%%z"=="-debug" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=DEBUG + if "%%z"=="-info" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=INFO + if "%%z"=="-trace" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=TRACE + if "%%z"=="-error" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=ERROR + if "%%z"=="-warn" set EXTRA_JVM_ARGUMENTS=-Dl4j.lvl=WARN +) + +call java %EXTRA_JVM_ARGUMENTS% -jar %~dp0.\VZD-Client\VZD-Client.jar %* \ No newline at end of file diff --git a/bspData/vorlage_commands_data.xml b/bspData/vorlage_commands_data.xml new file mode 100644 index 0000000..78b668e --- /dev/null +++ b/bspData/vorlage_commands_data.xml @@ -0,0 +1,152 @@ + + + + addDirectoryEntries + + + + + + + + + + + + + + + + + + <organization/> + <otherName/> + <specialization/> + <domainID/> + <mail/> + <UserCertificate> + <dn> + <cn/> + <uid/> + <dc/> + <dc/> + </dn> + <telematikID/> + <entryType/> + <professionOID/> + <usage/> + <userCertificate/> + <description/> + </UserCertificate> + <personalEntry/> + <dataFromAuthority/> + </Command> + <Command> + <name>readDirectoryEntries</name> + <dn> + <uid/> + <dc/> + <dc/> + </dn> + <givenName/> + <sn/> + <streetAddress/> + <postalCode/> + <localityName/> + <stateOrProvinceName/> + <cn/> + <displayName/> + <title/> + <organization/> + <otherName/> + <specialization/> + <domainID/> + <mail/> + <UserCertificate> + <dn> + <cn/> + <uid/> + <dc/> + <dc/> + </dn> + <telematikID/> + <entryType/> + <professionOID/> + <usage/> + <userCertificate/> + <description/> + </UserCertificate> + <personalEntry/> + <dataFromAuthority/> + </Command> + <Command> + <name>modifyDirectoryEntries</name> + <dn> + <uid required="true"/> + </dn> + <displayName/> + <otherName/> + <streetAddress/> + <postalCode/> + <localityName/> + <stateOrProvinceName/> + <title/> + <organization/> + <specialization/> + <domainID/> + </Command> + <Command> + <name>deleteDirectoryEntries</name> + <dn> + <uid required="true"/> + </dn> + </Command> + <Command> + <name>addDirectoryEntryCertificate</name> + <dn> + <uid required="true"/> + </dn> + <UserCertificate> + <usage/> + <userCertificate required="true"/> + <description/> + </UserCertificate> + </Command> + <Command> + <name>readDirectoryEntryCertificate</name> + <dn> + <uid/> + </dn> + <UserCertificate> + <dn> + <uid/> + </dn> + <telematikID/> + </UserCertificate> + </Command> + <Command> + <name>modifyDirectoryEntryCertificate</name> + <uid required="true"/> + <UserCertificate> + <dn> + <cn required="true"/> + <uid required="true"/> + </dn> + <usage/> + <userCertificate required="true"/> + <description/> + </UserCertificate> + </Command> + <Command> + <name>deleteDirectoryEntryCertificate</name> + <dn> + <uid required="true"/> + </dn> + <UserCertificate> + <dn> + <cn required="true"/> + </dn> + <description/> + </UserCertificate> + </Command> +</CommandList> \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ea6efca --- /dev/null +++ b/build.gradle @@ -0,0 +1,168 @@ +allprojects { + repositories { + jcenter() + } +} + +buildscript { + dependencies { + classpath 'de.gematik:gematik-parent-plugin:1.2.1' + classpath 'de.gematik:documentation-plugin:1.1.2' + } + repositories { + jcenter() + maven { url 'https://jitpack.io' } + maven { url "https://plugins.gradle.org/m2/" } + } +} + +apply plugin: 'de.gematik.parent' +apply plugin: 'de.gematik.publish' +apply plugin: 'de.gematik.asciidoctor' +apply plugin: 'distribution' + +group = 'de.gematik.ti.epa' +description = 'Verzeichnisdienst Client' + +sourceSets { + main.java.srcDirs = ['src/main/java', 'build/generated-sources/jaxb'] + test.java.srcDirs = ['src/test/java'] +} + +javadoc { + failOnError = false + options.noTimestamp = true +} + +configurations { + jaxb +} + +dependencies { + implementation 'io.swagger:swagger-annotations:1.5.22' + implementation 'com.google.code.findbugs:jsr305:3.0.2' + implementation 'com.squareup.okhttp3:okhttp:3.14.2' + implementation 'com.squareup.okhttp3:logging-interceptor:3.14.2' + implementation 'com.google.code.gson:gson:2.8.5' + implementation 'io.gsonfire:gson-fire:1.8.3' + implementation 'org.apache.commons:commons-lang3:3.9' + implementation 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.client:1.0.2' + implementation 'org.apache.oltu.oauth2:org.apache.oltu.oauth2.common:1.0.2' + implementation 'org.apache.logging.log4j:log4j-core:2.11.2' + implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.11.2' + implementation 'org.apache.httpcomponents:httpclient:4.5' + implementation 'org.slf4j:slf4j-api:1.7.9' + implementation 'javax.xml.bind:jaxb-api:2.3.1' + implementation 'com.sun.xml.bind:jaxb-impl:2.3.1' + implementation 'com.sun.xml.bind:jaxb-core:2.3.0.1' + jaxb 'com.sun.xml.bind:jaxb-xjc:2.3.1' + jaxb 'org.glassfish.jaxb:jaxb-runtime:2.3.1' + testImplementation 'junit:junit:4.13' + testImplementation 'org.mockito:mockito-core:3.1.0' +} + +jar { + manifest.attributes 'Main-Class': 'de.gematik.ti.epa.vzd.gem.Main' + baseName project.name + from configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } +} + +task jaxb { + description 'Converts xsds to classes' + doLast { + def jaxbTargetDir = file("build/generated-sources/jaxb/") + jaxbTargetDir.mkdirs() + ant.taskdef( + name: 'xjc', + classname: 'com.sun.tools.xjc.XJCTask', + classpath: configurations.jaxb.asPath + ) + ant.jaxbTargetDir = jaxbTargetDir + ant.xjc( + destdir: '${jaxbTargetDir}', + package: 'generated', + schema: 'src/main/resources/xsd/commands.xsd', + binding: 'src/main/resources/jaxb-binding/binding.xml', + extension: 'true') + } +} + +compileJava.dependsOn jaxb + +task sourceJar(type: Jar) { + classifier "sources" + from "${project.buildDir}/../src/main/java/" + include "**/*.java" +} + +task testSourceJar(type: Jar) { + classifier "test-sources" + from "${project.buildDir}/../src/test/java/" + include "**/*.java" +} + +task adocJar(type: Jar) { + classifier "adoc" + from "${project.buildDir}/../doc" + into "${project.name}" + exclude "**/generated/**/*.*" +} + +task javadocJar(type: Jar) { + classifier "javadoc" + from "${project.buildDir}/docs/javadoc" + into "${project.name}" +} + +artifacts { + archives sourceJar + archives testSourceJar + archives adocJar + archives javadocJar +} + +gematikPublish { + name = project.name + description = "VZD-Client to add, remove and change data" + gitHubProjectName = "app-VZD-Client" +} + +distributions { + main { + baseName = project.name + contents { + into(project.name) { + from jar + rename '(.*)-.*.jar', project.name + '.jar' + } + into('') { + from '.' + include 'vorlage_commands_data.xml' + include 'doc/**' + from 'bspData/' + include 'startVzdClient.bat' + include 'startVzdC_Log.bat' + include 'Beispiel_Config_Datei.txt' + include 'Beispiel_Credential_Datei.txt' + include 'Beispiel_Command_Datei.xml' + from 'src/main/resources/xsd/' + include 'commands.xsd' + } + } + } +} + +test { + include '**/UnitTestsuite.class' + include '**/IntegrationTestsuite.class' + finalizedBy jacocoTestReport // report is always generated after tests run +} + + +jacocoTestReport { + reports { + xml.enabled true + xml.destination file("${buildDir}/jacoco/dependency-check-report.xml") + csv.enabled false + } +} \ No newline at end of file diff --git a/doc/images/Workfows_VZD.png b/doc/images/Workfows_VZD.png new file mode 100644 index 0000000..0259d9d Binary files /dev/null and b/doc/images/Workfows_VZD.png differ diff --git a/doc/javadoc/config.adoc b/doc/javadoc/config.adoc new file mode 100644 index 0000000..0bf3921 --- /dev/null +++ b/doc/javadoc/config.adoc @@ -0,0 +1,24 @@ +// asciidoc settings for EN (English) +// ================================== + +:toc-title: Table of Contents + +// enable table-of-contents +:toc: +:toclevels: 4 + +:javadoc: true + +:classdia-caption: Class diagram + +// where are images located? +:imagesdir: ../doc/images +:imagesoutdir: ../doc/images +:testdir: ../src/test/java/de/gematik/ti +:sourcedir: ../src/main/java/de/gematik/ti +:plantumldir: ../plantuml +:userguide: ../doc/userguide + + + + diff --git a/doc/userguide/ReadmeConfig.adoc b/doc/userguide/ReadmeConfig.adoc new file mode 100644 index 0000000..601b68c --- /dev/null +++ b/doc/userguide/ReadmeConfig.adoc @@ -0,0 +1,29 @@ +ifndef::globalConfig[] +:globalConfig: true +:useCachePlantuml: true +// asciidoc settings for EN (English) +// ================================== + + +:toc-title: Table of Contents + +// enable table-of-contents +:toc: +:toclevels: 4 + +:classdia-caption: Class diagram +:seqdia-caption: Sequence diagram + +:source-highlighter: prettify + +// where are images located? +:imagesdir: de.gematik.ti.openhealthcard.events/doc/images +:imagesoutdir: de.gematik.ti.openhealthcard.events/doc/images/ +:testdir: ../../src/test/java/de/gematik/ti +:sourcedir: /de.gematik.ti.openhealthcard.events/src/main/java/de/gematik/ti +:plantumldir: ../plantuml + + + + +endif::globalConfig[] \ No newline at end of file diff --git a/doc/userguide/VZDCL_API.adoc b/doc/userguide/VZDCL_API.adoc new file mode 100644 index 0000000..a32aed1 --- /dev/null +++ b/doc/userguide/VZDCL_API.adoc @@ -0,0 +1,5 @@ +include::config.adoc[] + +== API Documentation + +Generated API docs are available at https://gematik.github.io/app-VZD-Client. diff --git a/doc/userguide/VZDCL_GettingStarted.adoc b/doc/userguide/VZDCL_GettingStarted.adoc new file mode 100644 index 0000000..5cf7af2 --- /dev/null +++ b/doc/userguide/VZDCL_GettingStarted.adoc @@ -0,0 +1,258 @@ +include::config.adoc[] + +== Getting Started + +Im Folgenden wird erklärt wie der `VZD-Client` herunterzuladen und zu verwenden ist. + +=== VZD-Client herunterladen + +Der `VZD-Client` kann als git repository oder von Maven Central heruntergeladen werden. + +* Git + +[source,cmd] +---------------- +git clone https://github.com/gematik/app-VZD-Client.git +---------------- + +* Maven Central + +---------------- +https://search.maven.org/artifact/de.gematik.ti.epa/VZD-CLient +---------------- + +=== Build setup + +Zum Compilieren des `VZD-Clients` wird das Verwenden von Java11 und gradle 5.6.2 empfohlen. + +Nach dem Compilieren wird eine .zip-Datei in den build/distributions Ordner abgelegt. +Dieser enthält eine ausführbare .bat-Datei. +Die dazugehörige .jar-Datei befindet sich im Ordner build/libs. + +== Handling + +=== Starten des VZD-Clients + +In der erstellten oder heruntergeladenen .zip-Datei befinden sich 2 ausführbare .bat-Dateien. + +* startVzdClient.bat -> Startet den `VZD-Client` mit den angegebenen <<Parameter>>. +* startVzdC_Log.bat -> Diese .bat-Datei erwartet als ersten Parameter den gewünschten OutputPath für das Logfile. +Danach werden die <<Parameter>> angeführt. + +Beim Verwenden der .jar-Datei kann das Log-Level und der Pfad des Logs wie in <<Logging>> verwendet werden. + +=== Parameter + +Zum Bedienen des `VZD-Clients` müssen mindestens 2 Parameter überreicht werden. +Dies geschieht in der Kommandozeile über die Parameter: + +Pflicht: + +* -c <Pfad zur Credentials-Datei> (.txt-Datei) +* -p <Pfad zu Grundeinstellungen> (.txt-Datei) + +Optional: + +* -b <Pfad zur Command-Datei> (.xml-Datei) <- überschreibt eventuelle Angaben in den Grundeinstellungen +* -h <ProxyHost IP> <- überschreibt eventuelle Angaben in den Grundeinstellungen +* -d <Proxy Port> <- überschreibt eventuelle Angaben in den Grundeinstellungen + +[[Dateistruktur]] +=== Dateistruktur + +1. *Credentials-Datei:* +Diese Datei beinhaltet die User-ID und das Passwort. +Diese müssen wie folgt in eine .txt-Datei geschrieben werden (die Reihenfolge ist hierbei nicht relevant): +* id=<UserId> +* secret=<Passwort> +2. *Grundeinstellungen:* +Diese Datei beinhaltet einen BasePath (IP-Adresse oder URL zum anzusprechenden Server), einen RetryingOAuthPath (IP Adresse oder URL zum OAuth2 +Token Server) und optional einen CommandsPath (Pfad zur lokalen .xml-Datei) in der die auszuführenden Operationen definiert sind sowie ein Proxy-Host +einen dazugehörigen Proxy-Port. Außerdem können Angaben zum parallelen Ausführen gemacht werden. Eine genauere Beschreibung wie sich die Angaben +auf den Programmablauf auswirken, kann unter <<Paralleles Ausführen>> nachgelesen werden. +Eine weitergehende Beschreibung der Kommandodatei findet sich unter <<Bedienung>>. +Die Angaben werden wie folgt in eine .txt-Datei geschrieben (die Reihenfolge ist hierbei nicht relevant): + +* base=<URL or IP zum Server> +* retryingOAuth=<URL or IP zum Server> +* proxyHost=<ProxyHost IP> +* proxyPort=<Proxy Port> +* commands=<Pfad zur .xml-Datei> +* maxOperation=<Anzahl an Operationsarten> +* maxExecutionsPerOperation=<Anzahl an parallelen Operationen> + +[[Bedienung]] +=== Bedienung +Die Definition der Kommandos geschieht durch eine .xml-Datei. +Dieser Datei liegt ein generelles Schema zugrunde, welches durch die commands.xsd in der .zip-Datei eingesehen werden kann. +Hierbei ist der Name der Operation verpflichtend. Eine Angabe einer "commandId" ist nicht notwendig, kann jedoch wahlweise gesetzt werden. Sollte +sie nicht gesetzt werden, wird der Client eine ID vergeben, bei der er von 1 an durch iteriert. Dies dient der späteren Zuordnung welche Antwort zu +welchem Kommando gehört. + +Abhängig davon welche Operation durchgeführt werden soll, sind gewisse Angaben verpflichtend und manche optional. +Sollte ein Parameter angegeben werden und für das betreffende Kommando nicht verwendet werden können, so wird dieser ignoriert. +In `gemSpec_VZD` wird in `Kapitel 4.6.1` Operationen der Schnittstelle I_Directory_Administration beschrieben, welches Kommando welche Parameter +berücksichtigt und welche verpflichtend benötigt werden. + +[[Logging]] +=== Logging + +Das Logging geschieht auf der Konsole, sowie in einem File. Es wird immer ein File erstellt. Sollte kein spezieller Ort für das Logging angegeben +werden, wird das Log im java.io.temp Ordner abgelegt. Standardmäßig ist das Log-Level in der Konsole "INFO" und im File "DEBUG". + +==== Logging mit .bat-Datei +Um das Log-Level der Konsole zu beeinflussen kann ein weiterer Parameter beim Starten der .bat-Datei angegeben werden: + +(case sensitive) + +* -info <- Level INFO +* -trace <- Level TRACE +* -error <- Level ERROR +* -debug <- Level DEBUG + +Beispiel Aufruf +[src,cmd] +----------- +<workspace>/startVzdC_Log.bat <log_outputdir> -c <workspace>/credentials.txt -p <workspace>/config.txt -debug +----------- + +==== Logging mit jar Datei + +Um hier Einfluss auf die Logeigenschaften zu nehmen, muss der Java-VM die entsprechenden Systemvariablen übergeben werden. + +* l4j.lvl=<LogLevel> -> für das Log-Level +* l4j.logDir=<LogDir> -> für das Log-Output-Directroy + +Beispiel Aufruf +[src,cmd] +----------- +java -Dl4j.lvl=DEBUG -Dl4j.logDir=<log_outputdir> -jar <workspace>/vzd<version>.jar <outputdir> -c <workspace>/credentials.txt -p <workspace>/config.txt +----------- + +=== Ausführen des VZD-Clients mit Proxy + +Um den VZD-Client über einen Proxy starten, müssen wie unter <<Dateistruktur>> unter Grundeinstellungen Angaben in der Konfigurationsdatei zu Host +und Port angegeben werden. + +Außerdem ist es möglich den Host über den Parameter "-h" und den Port über "-d" direkt in der Kommandozeile zu übergeben. Sollte dies gemacht werden, +so überschreibt dies die Einstellungen, die eventuell in der Configurationsdatei angegeben wurden. + +=== Paralleles Ausführen + +Durch das Konfigurationsfile können Einstellungen getätigt werden, die die Ausführung der Operationen des `VZD-Client` beschleunigen (Wie diese +Angaben korrekt getätigt werden, dann unter <<Parameter>> nachgelesen werden). + +Der `VZD-Client` kann mehrere Operationsarten (AddDirectory, +ModifyDirectory etc.) gleichzeitig ausführen. Hierzu dient die Angabe maxOperations. Der Maximalwert +dieser Angabe liegt bei 8. Es kann keinen Einfluss auf die Reihenfolge genommen werden. + +Die Einstellung maxExecutionsPerOperation beschreibt wie viele gleichartige Operationen gleichzeitig ausgeführt werden. Diese Zahl ist aufgrund von +Ressourcenplanung auf 20 limitiert. + +[[Abarbeiungsflows]] +== Abarbeiungsflows + +Der Workflow ist in der Abbildung <<Abarbeitungsworkflow>> abzulesen. +Alle Operationen müssen über ein Commandfile, wie in 2.3 Bedienung beschrieben, übergeben werden und werden vom `VZD-Client` ausgelesen. +Bevor sie ausgeführt werden, wird abhängig der Operation eine Validitätsprüfung durchgeführt. Genauere Angaben der Validitätsprüfung, können +unter der jeweiligen Operation unter <<Abarbeiungsflows>> eingesehen werden. + +Sollte diese bei einem Command fehlschlagen, so wird die Durchführung abgebrochen. +Der Workflow unterscheidet zwischen „Modify“, „Add“, „Read“ und „Delete“. In der Abarbeitung gibt es jedoch leichte Unterschiede, die unter +<<Abarbeiungsflows>> behandelt werden.Vor dem Ausführen des Requests wird überprüft, ob der OAuth2 Token noch Gültigkeit besitzt. +Anschließend wird der Request ausgeführt und das Ergebnis in ein Logfile geschrieben, das ausgewertet werden kann. + +[[Abarbeitungsworkflow]] +.Abarbeitungsworkflow +image::../images/Workfows_VZD.png[width=800] + +=== Add Directory Entry / Certificate +==== Validitätsprüfung +Erforderliche Einträge für ein Add Directory Entry ist mindestens ein `UserCertificate`. Jedes dieser `UserCertificate` muss mindesten +eine `telematikID` oder ein `userCertificate` beinhalten. Alle weiteren Angaben sind optional. + +Beim Ausführen eines Add Directory Entry Certificate werden für jedes Zertifikat die `uids` mit der im `BaseDirectoryEntry` angegebenen `uid` +verglichen. Sollte die `uid` abweichen so gilt das Kommando als nicht valide. + +==== Ablauf +Bevor ein Add Directory Entry ausgeführt wird überprüft der Client, ob bereits ein Eintrag existiert. Sollte dies der Fall sein, wird anstelle eines Add- +ein Modify Directory Entry ausgeführt. + +Bei einem Add Directory Entry Certificate werden die angegebenen Parameter an den `VZD` gesendet. + +Bei erfolgreicher Durchführung wird jeweils die Antwort `distinguished name` des Servers in den Log geschrieben. + +=== Read Directory Entry / Certificate +==== Validitätsprüfung +Es wird nur überprüft, ob mindestens eins der Attribute nach denen gesucht werden kann angegeben wurde. + +Mögliche Parameter für das Lesen eines Entries: + +- uid / telematikID +- givenName +- sn +- cn +- displayName +- streetAddress +- postalCode +- localityName +- stateOrProvinceName +- title +- organisation +- otherName +- specialization +- domainID +- personalEntry +- dataFromAuthority + +Mögliche Parameter für das Lesen eines Zertifikats (hierbei wird nur das Element `UserCertificate` betrachtet): + +- uid +- entryType +- telematikId +- professionOID +- usage + +==== Ablauf +Alle in dem Kommando genannten Parameter werden zusammengefügt und als Request an den `VZD` gesendet. Bei erfolgreicher Anfrage wird eine Liste aller +auf die Suchkriterien zutreffende Einträge in das Log geschrieben. + +=== Modify Directory Entry / Certificate +==== Validitätsprüfung +Bei einem Modify Directory Entry wird die Angabe einer uid vom `VZD-Client` überprüft. *Eine Modify Directory Entry Certificate Operation +ist derzeit nicht vorgesehen*. Sollte versucht werden dieses Kommando auszuführen, wird dies zu einem Fehler führen. + +==== Ablauf +Bevor ein Modify Directory Entry ausgeführt überprüft der Client, ob bereits ein Eintrag zu der uid existiert. Sollte dies nicht der Fall +sein, so wird anstelle eines Modify- ein Add Directory Entry ausgeführt. +Bei erfolgreicher Durchführung wird der jeweils zurückgelieferte `distinguished name` ins Log geschrieben. + +[red]#ACHTUNG:# + +Wenn ein Modify Directory Entry durchgeführt wird, werden alle veränderbaren Attribute, die in dem Kommando nicht gesetzt wurden auf null gesetzt. +Sollte nur ein Attribut überschrieben werden, kann die Funktion <<Save Modify Directory Entry>> verwendet werden. + +=== Delete Directory Entry / Certificate +==== Validitätsprüfung +Bei einem Delete Directory Entry Kommando wird die Angabe einer uid vom `VZD-Client` überprüft. Anschließend wird der Löschbefehl gesendet. + +Bei einem Delete Directory Entry Certificate Kommando wird die uid aus dem `UserCertificate` ausgelesen. Dieses muss mit der uid im `BaseDirectorEntry` +überein stimmen, sofern angegeben. Außerdem muss ein `cn` im `UserCertificate` angegeben werden. Sollte eine dieser Voraussetzungen nicht zutreffen, +bricht der VZD die Bearbeitung ab. + +==== Ablauf +Bevor ein Delete Directory Entry ausgeführt überprüft der Client, ob bereits ein Eintrag zu der `telematikID` existiert. Sollte dies die Löschanfrage +nicht gesendet. + +Sollte der Request erfolgreich sein, so wird die gelöschte uid als Bestätigung in das Log geschrieben. + +=== Save Modify Directory Entry +Dies ist eine ergänzende Funktion die nicht in der Spezifikation festgehalten ist. Sie soll den Umgang erleichtern und die Fehleranfälligkeit +verringern. Sie kann dazu genutzt werden einzelne Attribute eines Eintrages zu überschreiben ohne die restlichen Attribute zu löschen. + +==== Validitätsprüfung +Die Validitätsprüfung ist deckungsgleich zu der unter <<Modify Directory Entry / Certificate>> + +==== Ablauf +Im gegensatz zu dem Modify-Directory-Entry-Befehl wird der Eintrag bei dieser Operation nicht komplett mit den angegebenen Daten ersetzt. Der +`VZD-Client` führt vorher eine Readoperation durch und vergleicht die Daten die unterschiedlich sind und ersetzt die im Command angegebenen Daten. \ No newline at end of file diff --git a/doc/userguide/VZDCL_Introduction.adoc b/doc/userguide/VZDCL_Introduction.adoc new file mode 100644 index 0000000..3702a2f --- /dev/null +++ b/doc/userguide/VZDCL_Introduction.adoc @@ -0,0 +1,8 @@ +ifndef::javadoc[] +include::config.adoc[] +endif::javadoc[] + +== Introduction + +Der VZD-Client dient als Werkzeug um einen Verzeichnisdienst mit Einträgen +so wie Zertifikaten zu füllen, zu bearbeiten, zu löschen oder auszulesen. \ No newline at end of file diff --git a/doc/userguide/VZDCL_License.adoc b/doc/userguide/VZDCL_License.adoc new file mode 100644 index 0000000..30947bf --- /dev/null +++ b/doc/userguide/VZDCL_License.adoc @@ -0,0 +1,4 @@ +include::config.adoc[] +== License + +Licensed under the https://www.apache.org/licenses/LICENSE-2.0[Apache License, Version 2.0]. diff --git a/doc/userguide/VZDCL_Main.adoc b/doc/userguide/VZDCL_Main.adoc new file mode 100644 index 0000000..b194f60 --- /dev/null +++ b/doc/userguide/VZDCL_Main.adoc @@ -0,0 +1,7 @@ +include::config.adoc[] + +== VZD-Client + +include::VZDCL_Introduction.adoc[] +include::VZDCL_Overview.adoc[] +include::VZDCL_GettingStarted.adoc[] diff --git a/doc/userguide/VZDCL_Overview.adoc b/doc/userguide/VZDCL_Overview.adoc new file mode 100644 index 0000000..b76cdc2 --- /dev/null +++ b/doc/userguide/VZDCL_Overview.adoc @@ -0,0 +1,4 @@ +include::config.adoc[] + +== Overview + diff --git a/doc/userguide/config.adoc b/doc/userguide/config.adoc new file mode 100644 index 0000000..48039a5 --- /dev/null +++ b/doc/userguide/config.adoc @@ -0,0 +1,27 @@ +ifndef::globalConfig[] +// asciidoc settings for EN (English) +// ================================== + + +:toc-title: Table of Contents + +// enable table-of-contents +:toc: +:toclevels: 4 + +:classdia-caption: Class diagram +:seqdia-caption: Sequence diagram + +:source-highlighter: prettify + +// where are images located? +:imagesdir: ../images +:imagesoutdir: ../images +:testdir: ../../src/test/java/de/gematik/ti +:sourcedir: ../../src/main/java/de/gematik/ti +:plantumldir: ../plantuml + + + + +endif::globalConfig[] \ No newline at end of file diff --git a/docs/AdministrationApi.md b/docs/AdministrationApi.md new file mode 100644 index 0000000..546f8b1 --- /dev/null +++ b/docs/AdministrationApi.md @@ -0,0 +1,134 @@ +# AdministrationApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**changeProvider1**](AdministrationApi.md#changeProvider1) | **POST** /changeProvider | Anbieter wechseln +[**putNotificationInformation1**](AdministrationApi.md#putNotificationInformation1) | **POST** /NotificationInformation | Benachrichtigungsadresse fuer Geraeteautorisierung aktualisieren + + +<a name="changeProvider1"></a> +# **changeProvider1** +> ResponseDTO changeProvider1(changeProviderRequestDTO) + +Anbieter wechseln + +Umsetzung Operation I_FdV::changeProvicer (A_18047) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.AdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + AdministrationApi apiInstance = new AdministrationApi(defaultClient); + ChangeProviderRequestDTO changeProviderRequestDTO = new ChangeProviderRequestDTO(); // ChangeProviderRequestDTO | + try { + ResponseDTO result = apiInstance.changeProvider1(changeProviderRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AdministrationApi#changeProvider1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **changeProviderRequestDTO** | [**ChangeProviderRequestDTO**](ChangeProviderRequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="putNotificationInformation1"></a> +# **putNotificationInformation1** +> ResponseDTO putNotificationInformation1(notificationInformationRequestDTO) + +Benachrichtigungsadresse fuer Geraeteautorisierung aktualisieren + +Umsetzung Operation I_FdV::putNotificationInformation (A_18063); Hinterlegt eine Benachrichtigungsadresse fuer das Aktenkonto. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.AdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + AdministrationApi apiInstance = new AdministrationApi(defaultClient); + NotificationInformationRequestDTO notificationInformationRequestDTO = new NotificationInformationRequestDTO(); // NotificationInformationRequestDTO | + try { + ResponseDTO result = apiInstance.putNotificationInformation1(notificationInformationRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AdministrationApi#putNotificationInformation1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **notificationInformationRequestDTO** | [**NotificationInformationRequestDTO**](NotificationInformationRequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/Author.md b/docs/Author.md new file mode 100644 index 0000000..6f38a23 --- /dev/null +++ b/docs/Author.md @@ -0,0 +1,21 @@ + + +# Author + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**identifier** | **String** | authorPerson, fuer Leistungserbringer Lebenslange Identifikationsnummer eines Arztes, fuer Versicherte Versicherten-ID (unveraenderliche Teil der KVNR) | [optional] +**familyName** | **String** | authorPerson, Nachname | [optional] +**givenName** | **String** | authorPerson, Vorname | [optional] +**otherName** | **String** | authorPerson, weiterer Vorname | [optional] +**nameAffix** | **String** | authorPerson, Nameszusatz | [optional] +**title** | **String** | authorPerson, Titel | [optional] +**authorInstitution** | [**List<AuthorInstitution>**](AuthorInstitution.md) | | [optional] +**authorRole** | **List<String>** | | [optional] +**authorSpecialty** | **List<String>** | | [optional] +**authorTelecommunication** | **List<String>** | | [optional] + + + diff --git a/docs/AuthorInstitution.md b/docs/AuthorInstitution.md new file mode 100644 index 0000000..508a80e --- /dev/null +++ b/docs/AuthorInstitution.md @@ -0,0 +1,13 @@ + + +# AuthorInstitution + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | Name der Leistungserbringerinstitution oder Name des Kostentraegers | [optional] +**identifier** | **String** | Institutionskennzeichen der Leistungserbringerinstitution oder Betriebsnummer des Kostentraegers | [optional] + + + diff --git a/docs/BaseDirectoryEntry.md b/docs/BaseDirectoryEntry.md new file mode 100644 index 0000000..6162c7d --- /dev/null +++ b/docs/BaseDirectoryEntry.md @@ -0,0 +1,27 @@ + + +# BaseDirectoryEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dn** | [**DistinguishedName**](DistinguishedName.md) | | +**givenName** | **String** | HBA: Vorname, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet | [optional] [readonly] +**sn** | **String** | HBA: Name, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet | [optional] [readonly] +**cn** | **String** | HBA: Vorname und Nachname / SMC-B: Bezeichner: Name Wird vom VZD aus dem Zertifikatsattribut commonName übernommen. | [readonly] +**displayName** | **String** | Anzeigename, kann geändert werden. Dieses Attribut wird genutzt um den Namen der Organisation gegenüber dem Anwender darzustellen (Verwendung als Filter-Attribut um die Suche einzuschränken und bei der Darstellung des Ergebnisses). Der Wert wird von der pflegenden Stelle festgelegt. | [optional] +**streetAddress** | **String** | Straße und Hausnummer Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**postalCode** | **String** | Postleitzahl Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**localityName** | **String** | Ort Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**stateOrProvienceName** | **String** | Bundesland Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**title** | **String** | HBA: Titel, optional / SMC-B: nicht verwendet | [optional] +**organization** | **String** | Organisation Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**otherName** | **String** | Anderer Name. Wird vom VZD aus dem Zertifikatsattribut otherName übernommen. | [optional] +**specialization** | **List<String>** | Fachgebiet Der Wert wird von der pflegenden Stelle festgelegt | [optional] +**domainID** | **List<String>** | Ärzte: Betriebsstättennummer Der Wert wird aus dem Zertifikat übernommen (Attribut organizationName) | [optional] +**personalEntry** | **Boolean** | Wird vom VZD eingetragen / Wert == TRUE, wenn alle Zertifikate den entryType 1 haben (Berufsgruppe), Wert == FALSE sonst | [optional] [readonly] +**dataFromAuthority** | **Boolean** | Wird vom VZD eingetragen / Wert == TRUE, wenn der Verzeichnisdienst_Eintrag von dem Kartenherausgeber geschrieben wurde, Wert == FALSE sonst | [optional] [readonly] + + + diff --git a/docs/CertificateAdministrationApi.md b/docs/CertificateAdministrationApi.md new file mode 100644 index 0000000..35f56ca --- /dev/null +++ b/docs/CertificateAdministrationApi.md @@ -0,0 +1,307 @@ +# CertificateAdministrationApi + +All URIs are relative to *https://to.be.defined* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addDirectoryEntryCertificate**](CertificateAdministrationApi.md#addDirectoryEntryCertificate) | **POST** /DirectoryEntries/{uid}/Certificates | Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. +[**deleteDirectoryEntryCertificate**](CertificateAdministrationApi.md#deleteDirectoryEntryCertificate) | **DELETE** /DirectoryEntries/{uid}/Certificates/{certificateEntryID} | Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. +[**modifyDirectoryEntryCertificate**](CertificateAdministrationApi.md#modifyDirectoryEntryCertificate) | **PUT** /DirectoryEntries/{uid}/Certificates/{certificateEntryID} | Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. +[**readDirectoryCertificates**](CertificateAdministrationApi.md#readDirectoryCertificates) | **GET** /DirectoryEntries/Certificates | Zertifikat lesen + + +<a name="addDirectoryEntryCertificate"></a> +# **addDirectoryEntryCertificate** +> DistinguishedName addDirectoryEntryCertificate(uid, userCertificate) + +Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.CertificateAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + CertificateAdministrationApi apiInstance = new CertificateAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID (dn.uid) vom übergeordneten Verzeichniseintrag + UserCertificate userCertificate = new UserCertificate(); // UserCertificate | Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein description Kann optional belegt werden + try { + DistinguishedName result = apiInstance.addDirectoryEntryCertificate(uid, userCertificate); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling CertificateAdministrationApi#addDirectoryEntryCertificate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID (dn.uid) vom übergeordneten Verzeichniseintrag | + **userCertificate** | [**UserCertificate**](UserCertificate.md)| Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein description Kann optional belegt werden | + +### Return type + +[**DistinguishedName**](DistinguishedName.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Created Der Zertifikatseintrag wurde hinzugefügt. Zurückgegeben wird der distinguishedName des erzeugten Eintrags. | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**405** | Invalid input | - | + +<a name="deleteDirectoryEntryCertificate"></a> +# **deleteDirectoryEntryCertificate** +> deleteDirectoryEntryCertificate(uid, certificateEntryID) + +Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.CertificateAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + CertificateAdministrationApi apiInstance = new CertificateAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID vom übergeordneten Verzeichniseintrag + String certificateEntryID = "certificateEntryID_example"; // String | ID von dem zu löschenden Zertifikatseintrag + try { + apiInstance.deleteDirectoryEntryCertificate(uid, certificateEntryID); + } catch (ApiException e) { + System.err.println("Exception when calling CertificateAdministrationApi#deleteDirectoryEntryCertificate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID vom übergeordneten Verzeichniseintrag | + **certificateEntryID** | **String**| ID von dem zu löschenden Zertifikatseintrag | + +### Return type + +null (empty response body) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**400** | Invalid ID supplied | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**404** | Certificate not found | - | + +<a name="modifyDirectoryEntryCertificate"></a> +# **modifyDirectoryEntryCertificate** +> UserCertificate modifyDirectoryEntryCertificate(uid, certificateEntryID, userCertificate) + +Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.CertificateAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + CertificateAdministrationApi apiInstance = new CertificateAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID vom übergeordneten Verzeichniseintrag + String certificateEntryID = "certificateEntryID_example"; // String | ID von dem Zertifikat + UserCertificate userCertificate = new UserCertificate(); // UserCertificate | Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & certificateEntryID in Path). telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate unverändert gegenüber VZD description Kann optional belegt werden. + try { + UserCertificate result = apiInstance.modifyDirectoryEntryCertificate(uid, certificateEntryID, userCertificate); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling CertificateAdministrationApi#modifyDirectoryEntryCertificate"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID vom übergeordneten Verzeichniseintrag | + **certificateEntryID** | **String**| ID von dem Zertifikat | + **userCertificate** | [**UserCertificate**](UserCertificate.md)| Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & certificateEntryID in Path). telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate unverändert gegenüber VZD description Kann optional belegt werden. | + +### Return type + +[**UserCertificate**](UserCertificate.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Der aktualisierte Zertifikatseintrag wird zurückgegeben. | - | +**400** | Invalid ID supplied or userCertificate changed | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**404** | Certificate not found | - | +**405** | Invalid input | - | + +<a name="readDirectoryCertificates"></a> +# **readDirectoryCertificates** +> List<UserCertificate> readDirectoryCertificates(uid, certificateEntryID, entryType, telematikID, professionOID, usage) + +Zertifikat lesen + +Liefert alle Zertifikate, die dem Filter (siehe 'parameters') entsprechen. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.CertificateAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + CertificateAdministrationApi apiInstance = new CertificateAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID vom übergeordneten Verzeichniseintrag + String certificateEntryID = "certificateEntryID_example"; // String | ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. + String entryType = "entryType_example"; // String | Erlaubt die Suche mit Hilfe des Attributs entryType. + String telematikID = "telematikID_example"; // String | telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. + String professionOID = "professionOID_example"; // String | Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. + String usage = "usage_example"; // String | Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im Attribut usage (array) des Zertifikatseintrags enthalten ist. + try { + List<UserCertificate> result = apiInstance.readDirectoryCertificates(uid, certificateEntryID, entryType, telematikID, professionOID, usage); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling CertificateAdministrationApi#readDirectoryCertificates"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID vom übergeordneten Verzeichniseintrag | + **certificateEntryID** | **String**| ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. | [optional] + **entryType** | **String**| Erlaubt die Suche mit Hilfe des Attributs entryType. | [optional] + **telematikID** | **String**| telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. | [optional] + **professionOID** | **String**| Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. | [optional] + **usage** | **String**| Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im Attribut usage (array) des Zertifikatseintrags enthalten ist. | [optional] + +### Return type + +[**List<UserCertificate>**](UserCertificate.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation Es werden alle gefundenen Zertifikatseinträge zurückgegeben. | - | +**400** | Bad Request Wird zurückgegeben wenn mehr als 100 Einträge gefunden wurden. In diesem Fall müssen die Filter Parameter vom Client genauer belegt werden. | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**404** | Certificate not found | - | + diff --git a/docs/ChangeProviderRequestDTO.md b/docs/ChangeProviderRequestDTO.md new file mode 100644 index 0000000..a60e123 --- /dev/null +++ b/docs/ChangeProviderRequestDTO.md @@ -0,0 +1,15 @@ + + +# ChangeProviderRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**fqdnNewProvider** | **String** | FQDN des neuen Anbieters | +**transferPermission** | **Boolean** | legt fest, ob die Berechtigungen mit uebertragen werden sollen | [optional] +**representativeNotificationInfo** | [**List<NotificationInformationWithId>**](NotificationInformationWithId.md) | | [optional] + + + diff --git a/docs/ConfigurationApi.md b/docs/ConfigurationApi.md new file mode 100644 index 0000000..b500c31 --- /dev/null +++ b/docs/ConfigurationApi.md @@ -0,0 +1,136 @@ +# ConfigurationApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getConfigurationEntries1**](ConfigurationApi.md#getConfigurationEntries1) | **GET** /configuration | Gesamte Konfiguration lesen +[**updateConfigurationEntries1**](ConfigurationApi.md#updateConfigurationEntries1) | **PUT** /configuration | Konfigurationseintrag aendern + + +<a name="getConfigurationEntries1"></a> +# **getConfigurationEntries1** +> List<ConfigurationEntry> getConfigurationEntries1(uid) + +Gesamte Konfiguration lesen + +Umsetzung Operation I_FdV_Management::getConfiguration (A_18067); Liefert alle Konfigurationseintraege, die dem Filter entsprechen. Als Filter ist configurationEntryId moeglich. Wird kein Filter angegeben, dann werden alle Eintraege aus der Konfiguration zurueckgegeben. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.ConfigurationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + ConfigurationApi apiInstance = new ConfigurationApi(defaultClient); + String uid = "uid_example"; // String | Bezeichner eines Konfigurationseintrages (configurationEntryId) + try { + List<ConfigurationEntry> result = apiInstance.getConfigurationEntries1(uid); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ConfigurationApi#getConfigurationEntries1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| Bezeichner eines Konfigurationseintrages (configurationEntryId) | [optional] + +### Return type + +[**List<ConfigurationEntry>**](ConfigurationEntry.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation; Es werden alle Konfigurationseintraege zurueckgegeben.; Wenn nach einer uid gesucht wurde, wird genau dieser Eintrag zurueckgegeben.; Falls der Konfigurationseintrag vorab nicht gesetzt wurde, wird ein Leerstring zurückgegeben. | - | +**400** | Invalid ID supplied | - | +**404** | Entry not found | - | + +<a name="updateConfigurationEntries1"></a> +# **updateConfigurationEntries1** +> ResponseDTO updateConfigurationEntries1(configurationEntry) + +Konfigurationseintrag aendern + +Umsetzung Operation I_FdV_Management::setConfiguration (A_18066); Setzt einen Konfigurationseintrag + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.ConfigurationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + ConfigurationApi apiInstance = new ConfigurationApi(defaultClient); + ConfigurationEntry configurationEntry = new ConfigurationEntry(); // ConfigurationEntry | + try { + ResponseDTO result = apiInstance.updateConfigurationEntries1(configurationEntry); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ConfigurationApi#updateConfigurationEntries1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **configurationEntry** | [**ConfigurationEntry**](ConfigurationEntry.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/ConfigurationEntry.md b/docs/ConfigurationEntry.md new file mode 100644 index 0000000..ebded38 --- /dev/null +++ b/docs/ConfigurationEntry.md @@ -0,0 +1,33 @@ + + +# ConfigurationEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**configurationEntryId** | [**ConfigurationEntryIdEnum**](#ConfigurationEntryIdEnum) | Schluesselwerte fuer die in A_15292 definierten Parameter, die durch den Nutzer fuer die Konfiguration des FdV eingegeben werden.; OwnerInsurantId - Versicherten-ID des Aktenkontoinhabers, Teil der Akten-ID; OwnerFqdnProvider - FQDN Anbieter ePA-Aktensystem des Aktenkontoinhabers; OwnerDeviceName - Gerätename des GdV; In der Testtreiber-Konfiguration können 2 Vertretungen eingerichtet werden.; Representation1Name - Name des zu Vertretenden; Representation1InsurantId - Versicherten-ID des zu Vertretenden, Teil der Akten-ID; Representation1FqdnProvider - FQDN Anbieter ePA-Aktensystem des zu Vertretenden; Notifcation - Benachrichtigungen aktivieren; NotificationPeriod - Benachrichtigungszeitraum; ShowPermissionOnAddDocuments - Dokumente einstellen Berechtigte anzeigen; UseEGK (boolean) - gibt an, ob fuer die Authentisierung die eGK oder die alternative kryptographische Versichertenidentitaet genutzt wird. | +**configurationEntryValue** | **String** | Wert fuer den Konfigurationsparameter | + + + +## Enum: ConfigurationEntryIdEnum + +Name | Value +---- | ----- +OWNERINSURANTID | "OwnerInsurantId" +OWNERFQDNPROVIDER | "OwnerFqdnProvider" +OWNERDEVICENAME | "OwnerDeviceName" +REPRESENTATION1NAME | "Representation1Name" +REPRESENTATION1INSURANTID | "Representation1InsurantId" +REPRESENTATION1FQDNPROVIDER | "Representation1FqdnProvider" +REPRESENTATION2NAME | "Representation2Name" +REPRESENTATION2INSURANTID | "Representation2InsurantId" +REPRESENTATION2FQDNPROVIDER | "Representation2FqdnProvider" +NOTIFCATION | "Notifcation" +NOTIFICATIONPERIOD | "NotificationPeriod" +SHOWPERMISSIONONADDDOCUMENTS | "ShowPermissionOnAddDocuments" +USEEGK | "UseEGK" + + + diff --git a/docs/CreateDirectoryEntry.md b/docs/CreateDirectoryEntry.md new file mode 100644 index 0000000..2e16fe8 --- /dev/null +++ b/docs/CreateDirectoryEntry.md @@ -0,0 +1,13 @@ + + +# CreateDirectoryEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**directoryEntryBase** | [**BaseDirectoryEntry**](BaseDirectoryEntry.md) | | [optional] +**userCertificates** | [**List<UserCertificate>**](UserCertificate.md) | | [optional] + + + diff --git a/docs/DefaultApi.md b/docs/DefaultApi.md new file mode 100644 index 0000000..24c2cca --- /dev/null +++ b/docs/DefaultApi.md @@ -0,0 +1,126 @@ +# DefaultApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getProductInformation1**](DefaultApi.md#getProductInformation1) | **POST** /productinformation | Gibt die Informationen zur Produktinformation zurueck +[**ping1**](DefaultApi.md#ping1) | **POST** /ping | Prueft die Erreichbarkeit der Schnittstelle auf Anwendungsebene + + +<a name="getProductInformation1"></a> +# **getProductInformation1** +> ResponseProductInformationDTO getProductInformation1() + +Gibt die Informationen zur Produktinformation zurueck + +Umsetzung Operation I_FdV_Management::getProductInformation (A_18068) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + ResponseProductInformationDTO result = apiInstance.getProductInformation1(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#getProductInformation1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**ResponseProductInformationDTO**](ResponseProductInformationDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="ping1"></a> +# **ping1** +> ResponsePingDTO ping1() + +Prueft die Erreichbarkeit der Schnittstelle auf Anwendungsebene + +Ping prueft die Erreichbarkeit der Schnittstelle auf Anwendungsebene. In der Response wird die Schnittstellenversion zurueckgegeben, was der Pruefung der Interoberabilitaet dient. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DefaultApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + try { + ResponsePingDTO result = apiInstance.ping1(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#ping1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**ResponsePingDTO**](ResponsePingDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/DeletePermissionDTO.md b/docs/DeletePermissionDTO.md new file mode 100644 index 0000000..df1d12c --- /dev/null +++ b/docs/DeletePermissionDTO.md @@ -0,0 +1,13 @@ + + +# DeletePermissionDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**telematikOrInsurantId** | **String** | Versicherten-ID für Vertreter oder Telematik-ID für LEI bzw. KTR | + + + diff --git a/docs/DirectoryApi.md b/docs/DirectoryApi.md new file mode 100644 index 0000000..2f81e82 --- /dev/null +++ b/docs/DirectoryApi.md @@ -0,0 +1,134 @@ +# DirectoryApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**findHcpos1**](DirectoryApi.md#findHcpos1) | **POST** /findHcpos | Suche nach Leistungserbringerinstitutionen im Verzeichnisdienst +[**findInsurances1**](DirectoryApi.md#findInsurances1) | **POST** /findInsurances | Suche nach Kostentraegern im Verzeichnisdienst + + +<a name="findHcpos1"></a> +# **findHcpos1** +> FindDirectoryResponseDTO findHcpos1(findDirectoryRequestDTO) + +Suche nach Leistungserbringerinstitutionen im Verzeichnisdienst + +Umsetzung Operation I_FdV::findHcp (A_18048) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DirectoryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DirectoryApi apiInstance = new DirectoryApi(defaultClient); + FindDirectoryRequestDTO findDirectoryRequestDTO = new FindDirectoryRequestDTO(); // FindDirectoryRequestDTO | + try { + FindDirectoryResponseDTO result = apiInstance.findHcpos1(findDirectoryRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryApi#findHcpos1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **findDirectoryRequestDTO** | [**FindDirectoryRequestDTO**](FindDirectoryRequestDTO.md)| | [optional] + +### Return type + +[**FindDirectoryResponseDTO**](FindDirectoryResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="findInsurances1"></a> +# **findInsurances1** +> FindDirectoryResponseDTO findInsurances1(findDirectoryRequestDTO) + +Suche nach Kostentraegern im Verzeichnisdienst + +Umsetzung Operation I_FdV::findInsurance (A_18051) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DirectoryApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DirectoryApi apiInstance = new DirectoryApi(defaultClient); + FindDirectoryRequestDTO findDirectoryRequestDTO = new FindDirectoryRequestDTO(); // FindDirectoryRequestDTO | + try { + FindDirectoryResponseDTO result = apiInstance.findInsurances1(findDirectoryRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryApi#findInsurances1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **findDirectoryRequestDTO** | [**FindDirectoryRequestDTO**](FindDirectoryRequestDTO.md)| | [optional] + +### Return type + +[**FindDirectoryResponseDTO**](FindDirectoryResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/DirectoryEntry.md b/docs/DirectoryEntry.md new file mode 100644 index 0000000..c7834b8 --- /dev/null +++ b/docs/DirectoryEntry.md @@ -0,0 +1,14 @@ + + +# DirectoryEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**directoryEntryBase** | [**BaseDirectoryEntry**](BaseDirectoryEntry.md) | | [optional] +**userCertificates** | [**List<UserCertificate>**](UserCertificate.md) | | [optional] +**fachdaten** | [**List<Fachdaten>**](Fachdaten.md) | | [optional] + + + diff --git a/docs/DirectoryEntryAdministrationApi.md b/docs/DirectoryEntryAdministrationApi.md new file mode 100644 index 0000000..e42a9ba --- /dev/null +++ b/docs/DirectoryEntryAdministrationApi.md @@ -0,0 +1,321 @@ +# DirectoryEntryAdministrationApi + +All URIs are relative to *https://to.be.defined* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addDirectoryEntry**](DirectoryEntryAdministrationApi.md#addDirectoryEntry) | **POST** /DirectoryEntries | Einen Eintrag zum Verzeichnisdienst hinzufügen +[**deleteDirectoryEntry**](DirectoryEntryAdministrationApi.md#deleteDirectoryEntry) | **DELETE** /DirectoryEntries/{uid} | Gesamten Verzeichniseintrag löschen +[**modifyDirectoryEntry**](DirectoryEntryAdministrationApi.md#modifyDirectoryEntry) | **PUT** /DirectoryEntries/{uid}/baseDirectoryEntries | Der Verzeichniseintrag (ohne Zertifikate und Fachdaten) wird mit den übergebenen Daten aktualisiert. +[**readDirectoryEntry**](DirectoryEntryAdministrationApi.md#readDirectoryEntry) | **GET** /DirectoryEntries | Gesamten Verzeichniseintrag lesen + + +<a name="addDirectoryEntry"></a> +# **addDirectoryEntry** +> DistinguishedName addDirectoryEntry(createDirectoryEntry) + +Einen Eintrag zum Verzeichnisdienst hinzufügen + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.DirectoryEntryAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + DirectoryEntryAdministrationApi apiInstance = new DirectoryEntryAdministrationApi(defaultClient); + CreateDirectoryEntry createDirectoryEntry = new CreateDirectoryEntry(); // CreateDirectoryEntry | Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvienceName Kann optional belegt werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Muss vorhanden sein (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden kann). + try { + DistinguishedName result = apiInstance.addDirectoryEntry(createDirectoryEntry); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryEntryAdministrationApi#addDirectoryEntry"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **createDirectoryEntry** | [**CreateDirectoryEntry**](CreateDirectoryEntry.md)| Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvienceName Kann optional belegt werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Nicht vorhanden (wird vom Verzeichnisdienst belegt) entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Muss vorhanden sein (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden kann). | + +### Return type + +[**DistinguishedName**](DistinguishedName.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Created Der Verzeichniseintrag wurde angelegt. Zurückgegeben wird der distinguishedName des erzeugten Eintrags. | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**405** | Invalid input | - | + +<a name="deleteDirectoryEntry"></a> +# **deleteDirectoryEntry** +> deleteDirectoryEntry(uid) + +Gesamten Verzeichniseintrag löschen + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.DirectoryEntryAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + DirectoryEntryAdministrationApi apiInstance = new DirectoryEntryAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate und Fachdaten. + try { + apiInstance.deleteDirectoryEntry(uid); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryEntryAdministrationApi#deleteDirectoryEntry"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate und Fachdaten. | + +### Return type + +null (empty response body) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Successful operation | - | +**400** | Invalid ID supplied | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**404** | DirectoryEntry not found | - | + +<a name="modifyDirectoryEntry"></a> +# **modifyDirectoryEntry** +> DistinguishedName modifyDirectoryEntry(uid, baseDirectoryEntry) + +Der Verzeichniseintrag (ohne Zertifikate und Fachdaten) wird mit den übergebenen Daten aktualisiert. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.DirectoryEntryAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + DirectoryEntryAdministrationApi apiInstance = new DirectoryEntryAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID von dem Verzeichniseintrag + BaseDirectoryEntry baseDirectoryEntry = new BaseDirectoryEntry(); // BaseDirectoryEntry | Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvienceName Kann optional belegt werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht vorhanden. dataFromAuthority Nicht vorhanden + try { + DistinguishedName result = apiInstance.modifyDirectoryEntry(uid, baseDirectoryEntry); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryEntryAdministrationApi#modifyDirectoryEntry"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID von dem Verzeichniseintrag | + **baseDirectoryEntry** | [**BaseDirectoryEntry**](BaseDirectoryEntry.md)| Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvienceName Kann optional belegt werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht vorhanden. dataFromAuthority Nicht vorhanden | + +### Return type + +[**DistinguishedName**](DistinguishedName.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Der Verzeichniseintrag wurde aktualisiert. | - | +**400** | Invalid ID supplied | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response muss auf OAuth gesetzt werden. | - | +**403** | Forbidden | - | +**404** | DirectoryEntry not found | - | +**405** | Invalid input | - | + +<a name="readDirectoryEntry"></a> +# **readDirectoryEntry** +> List<DirectoryEntry> readDirectoryEntry(uid, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, stateOrProvienceName, title, organization, otherName, specialization, domainID, personalEntry, dataFromAuthority) + +Gesamten Verzeichniseintrag lesen + +Liefert alle zum Filter passenden Verzeichniseinträge. Die angegebenen Parameter werden mit logischen UND verknüpft. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.auth.*; +import de.gematik.ti.epa.vzd.client.invoker.models.*; +import de.gematik.ti.epa.vzd.client.api.DirectoryEntryAdministrationApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://to.be.defined"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + DirectoryEntryAdministrationApi apiInstance = new DirectoryEntryAdministrationApi(defaultClient); + String uid = "uid_example"; // String | ID von dem Verzeichniseintrag (distinguishedName.uid) + String givenName = "givenName_example"; // String | Erlaubt die Suche mit Hilfe des Attributs givenName. + String sn = "sn_example"; // String | Erlaubt die Suche mit Hilfe des Attributs sn. + String cn = "cn_example"; // String | Erlaubt die Suche mit Hilfe des Attributs cn. + String displayName = "displayName_example"; // String | Erlaubt die Suche mit Hilfe des Attributs displayName. + String streetAddress = "streetAddress_example"; // String | Erlaubt die Suche mit Hilfe des Attributs streetAddress. + String postalCode = "postalCode_example"; // String | Erlaubt die Suche mit Hilfe des Attributs postalCode. + String localityName = "localityName_example"; // String | Erlaubt die Suche mit Hilfe des Attributs localityName. + String stateOrProvienceName = "stateOrProvienceName_example"; // String | Erlaubt die Suche mit Hilfe des Attributs stateOrProvienceName. + String title = "title_example"; // String | Erlaubt die Suche mit Hilfe des Attributs title. + String organization = "organization_example"; // String | Erlaubt die Suche mit Hilfe des Attributs organization. + String otherName = "otherName_example"; // String | Erlaubt die Suche mit Hilfe des Attributs otherName. + String specialization = "specialization_example"; // String | Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. + String domainID = "domainID_example"; // String | Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. + String personalEntry = "personalEntry_example"; // String | Erlaubt die Suche mit Hilfe des Attributs personalEntry. + String dataFromAuthority = "dataFromAuthority_example"; // String | Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. + try { + List<DirectoryEntry> result = apiInstance.readDirectoryEntry(uid, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, stateOrProvienceName, title, organization, otherName, specialization, domainID, personalEntry, dataFromAuthority); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DirectoryEntryAdministrationApi#readDirectoryEntry"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **uid** | **String**| ID von dem Verzeichniseintrag (distinguishedName.uid) | [optional] + **givenName** | **String**| Erlaubt die Suche mit Hilfe des Attributs givenName. | [optional] + **sn** | **String**| Erlaubt die Suche mit Hilfe des Attributs sn. | [optional] + **cn** | **String**| Erlaubt die Suche mit Hilfe des Attributs cn. | [optional] + **displayName** | **String**| Erlaubt die Suche mit Hilfe des Attributs displayName. | [optional] + **streetAddress** | **String**| Erlaubt die Suche mit Hilfe des Attributs streetAddress. | [optional] + **postalCode** | **String**| Erlaubt die Suche mit Hilfe des Attributs postalCode. | [optional] + **localityName** | **String**| Erlaubt die Suche mit Hilfe des Attributs localityName. | [optional] + **stateOrProvienceName** | **String**| Erlaubt die Suche mit Hilfe des Attributs stateOrProvienceName. | [optional] + **title** | **String**| Erlaubt die Suche mit Hilfe des Attributs title. | [optional] + **organization** | **String**| Erlaubt die Suche mit Hilfe des Attributs organization. | [optional] + **otherName** | **String**| Erlaubt die Suche mit Hilfe des Attributs otherName. | [optional] + **specialization** | **String**| Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. | [optional] + **domainID** | **String**| Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. | [optional] + **personalEntry** | **String**| Erlaubt die Suche mit Hilfe des Attributs personalEntry. | [optional] + **dataFromAuthority** | **String**| Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. | [optional] + +### Return type + +[**List<DirectoryEntry>**](DirectoryEntry.md) + +### Authorization + +[OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation Es werden alle zu dem Filter Parametern passenden Verzeichniseinträge - inklusive Zertifikaten und Fachdaten - zurückgegeben. | - | +**400** | Bad Request Wird zurückgegeben wenn mehr als 100 Einträge gefunden wurden. In diesem Fall müssen die Filter Parameter vom Client genauer belegt werden. | - | +**401** | Unauthorized Der WWW-Authenticate Header im Response wird auf OAuth gesetzt. | - | +**403** | Forbidden | - | +**404** | DirectoryEntry not found | - | + diff --git a/docs/DirectoryEntryWithCertificates.md b/docs/DirectoryEntryWithCertificates.md new file mode 100644 index 0000000..e752564 --- /dev/null +++ b/docs/DirectoryEntryWithCertificates.md @@ -0,0 +1,13 @@ + + +# DirectoryEntryWithCertificates + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**directoryEntry** | [**DirectoryEntry**](DirectoryEntry.md) | | +**certificates** | **List<byte[]>** | | + + + diff --git a/docs/DistinguishedName.md b/docs/DistinguishedName.md new file mode 100644 index 0000000..cb79422 --- /dev/null +++ b/docs/DistinguishedName.md @@ -0,0 +1,15 @@ + + +# DistinguishedName + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**uid** | **String** | entryID: Name/ID, den den Eintrag eindeutig identifiziert. Hat für den Verzeichnisdienst_Eintrag, Certificate, KOM-LE_Fachdaten und FAD1 eines Verzeichniseintrags den gleichen Wert. | +**dc** | **List<String>** | | [optional] +**ou** | **List<String>** | | [optional] +**cn** | **String** | Common Name | [optional] + + + diff --git a/docs/Document.md b/docs/Document.md new file mode 100644 index 0000000..cf1c61c --- /dev/null +++ b/docs/Document.md @@ -0,0 +1,12 @@ + + +# Document + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**doc** | **byte[]** | Dokument (Base64 kodiert) | [optional] + + + diff --git a/docs/DocumentWithMetadata.md b/docs/DocumentWithMetadata.md new file mode 100644 index 0000000..269aa49 --- /dev/null +++ b/docs/DocumentWithMetadata.md @@ -0,0 +1,51 @@ + + +# DocumentWithMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**author** | [**List<Author>**](Author.md) | | [optional] +**classCode** | **String** | Grobe Klassifizierung des Dokuments, einem Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.classCode | [optional] +**comments** | **String** | Ergaenzende Hinweise in Freitext | [optional] +**confidentialityCode** | **List<String>** | | [optional] +**creationTime** | [**OffsetDateTime**](OffsetDateTime.md) | Erstellungszeitpunkt des Dokuments; date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z | [optional] +**eventCodeList** | **List<String>** | Ereignisse, die zur Erstellung des Dokuments geführt haben.; ein Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.eventCodeList oder aus der Tabelle in A_17540 | [optional] +**formatCode** | **List<String>** | | [optional] +**hash** | **String** | | [optional] +**healthcareFacilityTypeCode** | **String** | Art der Einrichtung, in der das dokumentierte Ereignis stattgefunden hat.; ein Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.healthcareFacilityTypeCode | [optional] +**languageCode** | **String** | Sprache, in der das Dokument abgefasst ist.; ein Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.languageCode | [optional] +**legalAuthenticator** | **String** | Rechtlich Verantwortlicher fuer das Dokument | [optional] +**mimeType** | [**MimeTypeEnum**](#MimeTypeEnum) | MIME-Type des Dokuments | [optional] +**practiceSettingCode** | **String** | Art der Fachrichtung der erstellenden Einrichtung, in der das dokumentiere Ereignis stattgefunden hat.; ein Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.practiceSettingCode oder aus der Tabelle in A_16944 | [optional] +**referenceIdList** | **List<String>** | Liste von IDs, mit denen das Dokument assoziiert wird | [optional] +**serviceStartTime** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis begonnen wurde.; date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z | [optional] +**serviceStopTime** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis beendet wurde.; date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z | [optional] +**size** | **Integer** | Groesse des Dokuments in Bytes | [optional] +**title** | **String** | Titel des Dokuments | [optional] +**typeCode** | **String** | Art des Dokumentes; ein Code des in [IHE-ITI-VS] definierten Value Sets fuer DocumentEntry.typeCode | [optional] +**uniqueId** | **String** | Eindeutige, aktenweite Kennung des Dokuments | [optional] +**uri** | **String** | Dateiname | [optional] +**doc** | **byte[]** | Dokument (Base64 kodiert) | [optional] + + + +## Enum: MimeTypeEnum + +Name | Value +---- | ----- +APPLICATION_PDF | "application/pdf" +IMAGE_JPEG | "image/jpeg" +IMAGE_TIFF | "image/tiff" +TEXT_PLAIN | "text/plain" +TEXT_RTF | "text/rtf" +APPLICATION_MSWORD | "application/msword" +APPLICATION_MSEXCEL | "application/msexcel" +APPLICATION_VND_OASIS_OPENDOCUMENT_TEXT | "application/vnd.oasis.opendocument.text" +APPLICATION_VND_OASIS_OPENDOCUMENT_SPREADSHEET | "application/vnd.oasis.opendocument.spreadsheet" +APPLICATION_XML | "application/xml" +APPLICATION_HL7_V3 | "application/hl7-v3" + + + diff --git a/docs/DocumentsApi.md b/docs/DocumentsApi.md new file mode 100644 index 0000000..ab47529 --- /dev/null +++ b/docs/DocumentsApi.md @@ -0,0 +1,260 @@ +# DocumentsApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteDocuments1**](DocumentsApi.md#deleteDocuments1) | **POST** /deleteDocuments | Dokumente aus dem Aktenkonto loeschen +[**findDocuments1**](DocumentsApi.md#findDocuments1) | **POST** /findDocuments | Dokumente und Submission Sets in einem Aktenkonto finden +[**retrieveDocuments1**](DocumentsApi.md#retrieveDocuments1) | **POST** /retrieveDocuments | Dokumente aus Aktenkonto herunterladen +[**storeDocuments1**](DocumentsApi.md#storeDocuments1) | **POST** /storeDocuments | Dokumente in ein Aktenkonto laden + + +<a name="deleteDocuments1"></a> +# **deleteDocuments1** +> ResponseDTO deleteDocuments1(documentsRequestDTO) + +Dokumente aus dem Aktenkonto loeschen + +Umsetzung Operation I_FdV::deleteDocuments (A_18061); Loescht die Dokumente mit dem im Request angegebenen Ids aus dem Aktenkonto. Die Ids werden mittels findDocuments ermittelt. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DocumentsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DocumentsApi apiInstance = new DocumentsApi(defaultClient); + DocumentsRequestDTO documentsRequestDTO = new DocumentsRequestDTO(); // DocumentsRequestDTO | + try { + ResponseDTO result = apiInstance.deleteDocuments1(documentsRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DocumentsApi#deleteDocuments1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **documentsRequestDTO** | [**DocumentsRequestDTO**](DocumentsRequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="findDocuments1"></a> +# **findDocuments1** +> FindDocumentsResponseDTO findDocuments1(findDocumentsRequestDTO) + +Dokumente und Submission Sets in einem Aktenkonto finden + +Umsetzung Operation I_FdV::findDocuments (A_18059); Die fuer die Suchoperation zu verwendende Stored Query wird durch den Parameter vorgegeben. Falls dieser nicht angegeben ist, muss eine geeignete Stored Query gewaehlt werden.; Wenn die Suchparameter ein SubmissionSet adressieren, dann soll der Response die Metadaten der im SubmissionSet enthaltenen Dokumente (unter Beachtung ggf. zusätzlich angegebenener Suchkriterien zu Dokumenten) beinhalten.; Der Response enthält Metadaten zu Dokumenten aber nicht die Dokumente selbst. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DocumentsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DocumentsApi apiInstance = new DocumentsApi(defaultClient); + FindDocumentsRequestDTO findDocumentsRequestDTO = new FindDocumentsRequestDTO(); // FindDocumentsRequestDTO | + try { + FindDocumentsResponseDTO result = apiInstance.findDocuments1(findDocumentsRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DocumentsApi#findDocuments1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **findDocumentsRequestDTO** | [**FindDocumentsRequestDTO**](FindDocumentsRequestDTO.md)| | [optional] + +### Return type + +[**FindDocumentsResponseDTO**](FindDocumentsResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="retrieveDocuments1"></a> +# **retrieveDocuments1** +> RetrieveDocumentsResponseDTO retrieveDocuments1(documentsRequestDTO) + +Dokumente aus Aktenkonto herunterladen + +Umsetzung Operation I_FdV::getDocuments (A_18060); Laedt die Dokumente mit den im Request angegebenen Ids aus dem Aktenkonto. Die Ids werden mittels findDocuments ermittelt. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DocumentsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DocumentsApi apiInstance = new DocumentsApi(defaultClient); + DocumentsRequestDTO documentsRequestDTO = new DocumentsRequestDTO(); // DocumentsRequestDTO | + try { + RetrieveDocumentsResponseDTO result = apiInstance.retrieveDocuments1(documentsRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DocumentsApi#retrieveDocuments1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **documentsRequestDTO** | [**DocumentsRequestDTO**](DocumentsRequestDTO.md)| | [optional] + +### Return type + +[**RetrieveDocumentsResponseDTO**](RetrieveDocumentsResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="storeDocuments1"></a> +# **storeDocuments1** +> ResponseDTO storeDocuments1(storeDocumentRequestDTO) + +Dokumente in ein Aktenkonto laden + +Umsetzung Operation I_FdV::putDocuments (A_18058) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.DocumentsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + DocumentsApi apiInstance = new DocumentsApi(defaultClient); + StoreDocumentRequestDTO storeDocumentRequestDTO = new StoreDocumentRequestDTO(); // StoreDocumentRequestDTO | + try { + ResponseDTO result = apiInstance.storeDocuments1(storeDocumentRequestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DocumentsApi#storeDocuments1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **storeDocumentRequestDTO** | [**StoreDocumentRequestDTO**](StoreDocumentRequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/DocumentsRequestDTO.md b/docs/DocumentsRequestDTO.md new file mode 100644 index 0000000..5d2f5d3 --- /dev/null +++ b/docs/DocumentsRequestDTO.md @@ -0,0 +1,13 @@ + + +# DocumentsRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**documentIds** | **List<String>** | | + + + diff --git a/docs/Error.md b/docs/Error.md new file mode 100644 index 0000000..a188609 --- /dev/null +++ b/docs/Error.md @@ -0,0 +1,13 @@ + + +# Error + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**attributeName** | **String** | Name des Attributs, in dem ein Fehler erkannt wurde | [optional] +**attributeError** | **String** | Beschreibung des erkannten Fehlers | [optional] + + + diff --git a/docs/FAD1.md b/docs/FAD1.md new file mode 100644 index 0000000..12f686a --- /dev/null +++ b/docs/FAD1.md @@ -0,0 +1,13 @@ + + +# FAD1 + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dn** | [**DistinguishedName**](DistinguishedName.md) | | +**mail** | **List<String>** | | [optional] [readonly] + + + diff --git a/docs/Fachdaten.md b/docs/Fachdaten.md new file mode 100644 index 0000000..fcec795 --- /dev/null +++ b/docs/Fachdaten.md @@ -0,0 +1,13 @@ + + +# Fachdaten + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dn** | [**DistinguishedName**](DistinguishedName.md) | | +**FAD1** | [**List<FAD1>**](FAD1.md) | | [optional] + + + diff --git a/docs/FindDirectoryRequestDTO.md b/docs/FindDirectoryRequestDTO.md new file mode 100644 index 0000000..95e7b71 --- /dev/null +++ b/docs/FindDirectoryRequestDTO.md @@ -0,0 +1,13 @@ + + +# FindDirectoryRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**directoryEntry** | [**DirectoryEntry**](DirectoryEntry.md) | | + + + diff --git a/docs/FindDirectoryResponseDTO.md b/docs/FindDirectoryResponseDTO.md new file mode 100644 index 0000000..f5ab8c6 --- /dev/null +++ b/docs/FindDirectoryResponseDTO.md @@ -0,0 +1,14 @@ + + +# FindDirectoryResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**directoryEntries** | [**List<DirectoryEntryWithCertificates>**](DirectoryEntryWithCertificates.md) | | [optional] + + + diff --git a/docs/FindDocumentMetaData.md b/docs/FindDocumentMetaData.md new file mode 100644 index 0000000..8477d13 --- /dev/null +++ b/docs/FindDocumentMetaData.md @@ -0,0 +1,33 @@ + + +# FindDocumentMetaData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**xdSSubmissionSetEntryUUID** | **List<String>** | | [optional] +**xdSSubmissionSetUniqueId** | **List<String>** | | [optional] +**xdSSubmissionSetSubmissionTimeFrom** | [**OffsetDateTime**](OffsetDateTime.md) | Beginn Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSSubmissionSetSubmissionTimeTo** | [**OffsetDateTime**](OffsetDateTime.md) | XDSDocumentEntryCreationTimeTo, Ende Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryEntryUUID** | **List<String>** | | [optional] +**xdSDocumentEntryUniqueId** | **List<String>** | | [optional] +**xdSDocumentEntryClassCode** | **List<String>** | | [optional] +**xdSDocumentEntryPracticeSettingCode** | **List<String>** | | [optional] +**xdSDocumentEntryCreationTimeFrom** | [**OffsetDateTime**](OffsetDateTime.md) | Beginn Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryCreationTimeTo** | [**OffsetDateTime**](OffsetDateTime.md) | Ende Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryServiceStartTimeFrom** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis begonnen wurde. Beginn Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryServiceStartTimeTo** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis begonnen wurde. Ende Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryServiceStopTimeFrom** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis beendet wurde. Beginn Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryServiceStopTimeTo** | [**OffsetDateTime**](OffsetDateTime.md) | Zeitpunkt, an dem das im Dokument dokumentierte (Behandlungs-)Ereignis beendet wurde. Ende Zeitraum fuer Suche; date-time notation as defined by RFC 3339, section 5.6 | [optional] +**xdSDocumentEntryHealthcareFacilityTypeCode** | **List<String>** | | [optional] +**xdSDocumentEntryEventCodeList** | **List<String>** | | [optional] +**xdSDocumentEntryConfidentialityCode** | **List<String>** | | [optional] +**xdSDocumentEntryAuthorPerson** | **List<String>** | | [optional] +**xdSDocumentEntryFormatCode** | **List<String>** | | [optional] +**xdSDocumentEntryTypeCode** | **List<String>** | | [optional] +**xdSDocumentEntryTitle** | **List<String>** | | [optional] +**xdSDocumentAuthorInstitution** | **List<String>** | | [optional] + + + diff --git a/docs/FindDocumentsRequestDTO.md b/docs/FindDocumentsRequestDTO.md new file mode 100644 index 0000000..cb8faf6 --- /dev/null +++ b/docs/FindDocumentsRequestDTO.md @@ -0,0 +1,29 @@ + + +# FindDocumentsRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**doc** | [**FindDocumentMetaData**](FindDocumentMetaData.md) | | [optional] +**query** | [**QueryEnum**](#QueryEnum) | optional; falls angegeben, ist die entsprechende Stored Query anzuwenden; falls nicht angegeben, ist eine entsprechend der Suchparameter geeignete Stored Query anzuwenden | [optional] + + + +## Enum: QueryEnum + +Name | Value +---- | ----- +FINDDOCUMENTS | "FindDocuments" +FINDSUBMISSIONSETS | "FindSubmissionSets" +FINDDOCUMENTSBYTITLE | "FindDocumentsByTitle" +GETALL | "GetAll" +GETDOCUMENTS | "GetDocuments" +GETSUBMISSIONSETS | "GetSubmissionSets" +GETSUBMISSIONSETANDCONTENTS | "GetSubmissionSetAndContents" +FINDDOCUMENTSBYREFERENCEID | "FindDocumentsByReferenceId" + + + diff --git a/docs/FindDocumentsResponseDTO.md b/docs/FindDocumentsResponseDTO.md new file mode 100644 index 0000000..89ac6a3 --- /dev/null +++ b/docs/FindDocumentsResponseDTO.md @@ -0,0 +1,14 @@ + + +# FindDocumentsResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**docs** | [**List<SubmissionSetWithDocumentWithMetadata>**](SubmissionSetWithDocumentWithMetadata.md) | | [optional] + + + diff --git a/docs/Login.md b/docs/Login.md new file mode 100644 index 0000000..66b004a --- /dev/null +++ b/docs/Login.md @@ -0,0 +1,16 @@ + + +# Login + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | **String** | referenziert eine Aktensession, in der die Operation ausgefuehrt werden soll; Wenn keine Aktensession besteht, dann muss fuer dieses Aktenkonto (entspricht OwnerInsurantId oder RepresentationXInsurantId in der Konfiguration) eine Aktensession eroeffnet werden (implizites Login). | +**insurantId** | **String** | Versicherten-ID des Nutzers (Aktenkontoinhaber oder Vertreter) des FdV; Wenn dieser Parameter gesetzt ist, dann wird für die Authentisierung entsprechend dem Konfigurationsparameter useEGK eine angebundene eGK oder der Signaturdienst genutzt.; Wenn dieser Parameter gesetzt ist, dann werden die Parameter pkcs12, passwordPrivateKey und passwordKeyStore ignoriert. | [optional] +**pkcs12** | **byte[]** | C.CH.AUT-Zertifikat des Nutzers mit private Key im pkcs12 Format; Aus dem C.CH.AUT-Zertifikat wird die Versicherten-ID des Nutzers (Aktenkontoinhaber oder Vertreter) bestimmt.; Mit dem private Key werden die Signaturen bei der Authentisierung und der Schluesselerzeugung (SGD) erstellt | [optional] +**passwordPrivateKey** | **String** | Passwort für private Key in pkcs12 | [optional] +**passwordKeyStore** | **String** | | [optional] + + + diff --git a/docs/NotificationInformationRequestDTO.md b/docs/NotificationInformationRequestDTO.md new file mode 100644 index 0000000..ed6b47f --- /dev/null +++ b/docs/NotificationInformationRequestDTO.md @@ -0,0 +1,13 @@ + + +# NotificationInformationRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**notificationInformation** | **String** | Benachrichtigungsadresse (E-Mail) fuer die Geraeteautorisierung | + + + diff --git a/docs/NotificationInformationWithId.md b/docs/NotificationInformationWithId.md new file mode 100644 index 0000000..5674ae8 --- /dev/null +++ b/docs/NotificationInformationWithId.md @@ -0,0 +1,13 @@ + + +# NotificationInformationWithId + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**insurantId** | **String** | Versicherten-ID (unveraenderliche Teil der KVNR) | +**notificationInformation** | **String** | Benachrichtigungsadresse (E-Mail) fuer die Geraeteautorisierung | + + + diff --git a/docs/PermissionEntry.md b/docs/PermissionEntry.md new file mode 100644 index 0000000..0c8f7e2 --- /dev/null +++ b/docs/PermissionEntry.md @@ -0,0 +1,14 @@ + + +# PermissionEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**telematikOrInsurantId** | **String** | Telematik-ID bzw. Versicherten-ID des Berechtigten | +**name** | **String** | Name des Berechtigten | +**permissionLeiProperties** | [**PermissionLeiProp**](PermissionLeiProp.md) | | [optional] + + + diff --git a/docs/PermissionHcpoDTO.md b/docs/PermissionHcpoDTO.md new file mode 100644 index 0000000..f378532 --- /dev/null +++ b/docs/PermissionHcpoDTO.md @@ -0,0 +1,16 @@ + + +# PermissionHcpoDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**hcpoTelematikId** | **String** | Telematik-ID der Leistungserbringerinstitution (LEI) | +**hcpoName** | **String** | Name der LEI | +**certificate** | **byte[]** | aus dem Verzeichnisdienst ermittelte Zertifikat der LEI (Format DER, Base64 kodiert) | +**permissionLeiProperties** | [**PermissionLeiProp**](PermissionLeiProp.md) | | + + + diff --git a/docs/PermissionInsuranceDTO.md b/docs/PermissionInsuranceDTO.md new file mode 100644 index 0000000..32afb6f --- /dev/null +++ b/docs/PermissionInsuranceDTO.md @@ -0,0 +1,15 @@ + + +# PermissionInsuranceDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**insuranceTelematikId** | **String** | Telematik-ID des Kostentraegers (KTR) | +**insuranceName** | **String** | Name des KTR | +**certificate** | **byte[]** | aus dem Verzeichnisdienst ermittelte Zertifikat des KTR (Format DER, Base64 kodiert) | + + + diff --git a/docs/PermissionLeiProp.md b/docs/PermissionLeiProp.md new file mode 100644 index 0000000..cad4a10 --- /dev/null +++ b/docs/PermissionLeiProp.md @@ -0,0 +1,15 @@ + + +# PermissionLeiProp + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**permissionAccessHcpoDocuments** | **Boolean** | Option Zugriff auf durch LEI eingestellte Dokumente erlaubt | [optional] +**permissionAccessInsuranceDocuments** | **Boolean** | Option Zugriff auf durch Kostentraeger eingestellte Dokumente erlaubt | [optional] +**permissionAccessInsurantDocuments** | **Boolean** | Option Zugriff auf durch Versicherte eingestellte Dokumente erlaubt | [optional] +**validity** | [**LocalDate**](LocalDate.md) | Zugriff gueltig bis; full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21 | + + + diff --git a/docs/PermissionRepresentativeDTO.md b/docs/PermissionRepresentativeDTO.md new file mode 100644 index 0000000..ab5844c --- /dev/null +++ b/docs/PermissionRepresentativeDTO.md @@ -0,0 +1,15 @@ + + +# PermissionRepresentativeDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**represantativeInsurantId** | **String** | Versicherten-ID des Vertreters (unveraenderliche Teil der KVNR) | +**represantativeName** | **String** | Name des Vertreters | +**representativeNotificationInfo** | **String** | Benachrichtigungsadresse (E-Mail) fuer die Geraeteautorisierung | + + + diff --git a/docs/PermissionsApi.md b/docs/PermissionsApi.md new file mode 100644 index 0000000..05d5599 --- /dev/null +++ b/docs/PermissionsApi.md @@ -0,0 +1,515 @@ +# PermissionsApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPermissionHcpo1**](PermissionsApi.md#addPermissionHcpo1) | **POST** /permissionHcpo | Berechtigung fuer LEI erteilen +[**addPermissionInsurance1**](PermissionsApi.md#addPermissionInsurance1) | **POST** /permissionInsurance | Berechtigung fuer einen Kostentraeger erteilen +[**addPermissionRepresentative1**](PermissionsApi.md#addPermissionRepresentative1) | **POST** /permissionRepresentative | Berechtigung fuer einen Vertreter erteilen +[**changePermissionHcpo1**](PermissionsApi.md#changePermissionHcpo1) | **PUT** /permissionHcpo | Berechtigung fuer eine LEI aendern +[**deletePermissionHcpo1**](PermissionsApi.md#deletePermissionHcpo1) | **DELETE** /permissionHcpo | Berechtigung fuer eine LEI loeschen +[**deletePermissionInsurance1**](PermissionsApi.md#deletePermissionInsurance1) | **DELETE** /permissionInsurance | Berechtigung fuer einen Kostentraeger loeschen +[**deletePermissionRepresentative1**](PermissionsApi.md#deletePermissionRepresentative1) | **DELETE** /permissionRepresentative | Berechtigung fuer einen Vertreter loeschen +[**getPermissions1**](PermissionsApi.md#getPermissions1) | **POST** /permissions | Alle Berechtigungen lesen + + +<a name="addPermissionHcpo1"></a> +# **addPermissionHcpo1** +> ResponseDTO addPermissionHcpo1(permissionHcpoDTO) + +Berechtigung fuer LEI erteilen + +Umsetzung Operation I_FdV::grantPermissionHcp (A_18049) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + PermissionHcpoDTO permissionHcpoDTO = new PermissionHcpoDTO(); // PermissionHcpoDTO | + try { + ResponseDTO result = apiInstance.addPermissionHcpo1(permissionHcpoDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#addPermissionHcpo1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **permissionHcpoDTO** | [**PermissionHcpoDTO**](PermissionHcpoDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="addPermissionInsurance1"></a> +# **addPermissionInsurance1** +> ResponseDTO addPermissionInsurance1(permissionInsuranceDTO) + +Berechtigung fuer einen Kostentraeger erteilen + +Umsetzung Operation I_FdV::grantPermissionInsurance (A_18052) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + PermissionInsuranceDTO permissionInsuranceDTO = new PermissionInsuranceDTO(); // PermissionInsuranceDTO | + try { + ResponseDTO result = apiInstance.addPermissionInsurance1(permissionInsuranceDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#addPermissionInsurance1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **permissionInsuranceDTO** | [**PermissionInsuranceDTO**](PermissionInsuranceDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="addPermissionRepresentative1"></a> +# **addPermissionRepresentative1** +> ResponseDTO addPermissionRepresentative1(permissionRepresentativeDTO) + +Berechtigung fuer einen Vertreter erteilen + +Umsetzung Operation I_FdV::grantPermissionRepresentative (A_18050) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + PermissionRepresentativeDTO permissionRepresentativeDTO = new PermissionRepresentativeDTO(); // PermissionRepresentativeDTO | + try { + ResponseDTO result = apiInstance.addPermissionRepresentative1(permissionRepresentativeDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#addPermissionRepresentative1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **permissionRepresentativeDTO** | [**PermissionRepresentativeDTO**](PermissionRepresentativeDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="changePermissionHcpo1"></a> +# **changePermissionHcpo1** +> ResponseDTO changePermissionHcpo1(permissionHcpoDTO) + +Berechtigung fuer eine LEI aendern + +Umsetzung Operation I_FdV::changePermissionHcp (A_18054) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + PermissionHcpoDTO permissionHcpoDTO = new PermissionHcpoDTO(); // PermissionHcpoDTO | + try { + ResponseDTO result = apiInstance.changePermissionHcpo1(permissionHcpoDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#changePermissionHcpo1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **permissionHcpoDTO** | [**PermissionHcpoDTO**](PermissionHcpoDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="deletePermissionHcpo1"></a> +# **deletePermissionHcpo1** +> deletePermissionHcpo1(body) + +Berechtigung fuer eine LEI loeschen + +Umsetzung Operation I_FdV::deletePermissionHcp (A_18055) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + DeletePermissionDTO body = new DeletePermissionDTO(); // DeletePermissionDTO | + try { + apiInstance.deletePermissionHcpo1(body); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#deletePermissionHcpo1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**DeletePermissionDTO**](.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Entry not found | - | + +<a name="deletePermissionInsurance1"></a> +# **deletePermissionInsurance1** +> deletePermissionInsurance1(body) + +Berechtigung fuer einen Kostentraeger loeschen + +Umsetzung Operation I_FdV::deletePermissionInsurance (A_18057) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + DeletePermissionDTO body = new DeletePermissionDTO(); // DeletePermissionDTO | + try { + apiInstance.deletePermissionInsurance1(body); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#deletePermissionInsurance1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**DeletePermissionDTO**](.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Entry not found | - | + +<a name="deletePermissionRepresentative1"></a> +# **deletePermissionRepresentative1** +> deletePermissionRepresentative1(body) + +Berechtigung fuer einen Vertreter loeschen + +Umsetzung Operation I_FdV::deletePermissionRepresentative (A_18056) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + DeletePermissionDTO body = new DeletePermissionDTO(); // DeletePermissionDTO | + try { + apiInstance.deletePermissionRepresentative1(body); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#deletePermissionRepresentative1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**DeletePermissionDTO**](.md)| | + +### Return type + +null (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | successful operation | - | +**400** | Invalid ID supplied | - | +**404** | Entry not found | - | + +<a name="getPermissions1"></a> +# **getPermissions1** +> PermissionsResponseDTO getPermissions1(requestDTO) + +Alle Berechtigungen lesen + +Umsetzung Operation I_FdV::getPermissions (A_18053) + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.PermissionsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + PermissionsApi apiInstance = new PermissionsApi(defaultClient); + RequestDTO requestDTO = new RequestDTO(); // RequestDTO | + try { + PermissionsResponseDTO result = apiInstance.getPermissions1(requestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling PermissionsApi#getPermissions1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestDTO** | [**RequestDTO**](RequestDTO.md)| | [optional] + +### Return type + +[**PermissionsResponseDTO**](PermissionsResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/PermissionsResponseDTO.md b/docs/PermissionsResponseDTO.md new file mode 100644 index 0000000..ed7baed --- /dev/null +++ b/docs/PermissionsResponseDTO.md @@ -0,0 +1,14 @@ + + +# PermissionsResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**permissions** | [**List<PermissionEntry>**](PermissionEntry.md) | | [optional] + + + diff --git a/docs/ProtocolApi.md b/docs/ProtocolApi.md new file mode 100644 index 0000000..27f670c --- /dev/null +++ b/docs/ProtocolApi.md @@ -0,0 +1,71 @@ +# ProtocolApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getProtocol1**](ProtocolApi.md#getProtocol1) | **POST** /protocol | Zugriffsprotokoll lesen + + +<a name="getProtocol1"></a> +# **getProtocol1** +> ProtocolResponseDTO getProtocol1(requestDTO) + +Zugriffsprotokoll lesen + +Umsetzung Operation I_FdV::getProtocol (A_18062); Liefert alle Eintraege aus dem §291a und Verwaltungsprotokoll fuer das Aktenkonto. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.ProtocolApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + ProtocolApi apiInstance = new ProtocolApi(defaultClient); + RequestDTO requestDTO = new RequestDTO(); // RequestDTO | + try { + ProtocolResponseDTO result = apiInstance.getProtocol1(requestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ProtocolApi#getProtocol1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestDTO** | [**RequestDTO**](RequestDTO.md)| | [optional] + +### Return type + +[**ProtocolResponseDTO**](ProtocolResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/ProtocolEntry.md b/docs/ProtocolEntry.md new file mode 100644 index 0000000..827d855 --- /dev/null +++ b/docs/ProtocolEntry.md @@ -0,0 +1,22 @@ + + +# ProtocolEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**eventId** | **String** | Aufgerufene Operation gemass A_14505 | +**eventDisplayName** | **String** | Anzeigename der aufgerufenen Operation | +**eventDateTime** | [**OffsetDateTime**](OffsetDateTime.md) | Datum und Uhrzeit des Zugriffs; date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z | +**eventResult** | **String** | Ergebnis der aufgerufenen Operation | +**userId** | **String** | | +**userName** | **String** | | +**objectId** | **String** | | [optional] +**objectName** | **String** | | [optional] +**deviceId** | **String** | Device-ID bei Zugriff durch Versicherte | [optional] +**providerId** | **String** | Home-Community-ID des ePA-Aktensystems | +**providerName** | **String** | Name des Anbieters ePA-Aktensystem | + + + diff --git a/docs/ProtocolResponseDTO.md b/docs/ProtocolResponseDTO.md new file mode 100644 index 0000000..bdb7998 --- /dev/null +++ b/docs/ProtocolResponseDTO.md @@ -0,0 +1,14 @@ + + +# ProtocolResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**protocolEntries** | [**List<ProtocolEntry>**](ProtocolEntry.md) | | [optional] + + + diff --git a/docs/RequestDTO.md b/docs/RequestDTO.md new file mode 100644 index 0000000..339ab6e --- /dev/null +++ b/docs/RequestDTO.md @@ -0,0 +1,12 @@ + + +# RequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | + + + diff --git a/docs/ResponseDTO.md b/docs/ResponseDTO.md new file mode 100644 index 0000000..269e829 --- /dev/null +++ b/docs/ResponseDTO.md @@ -0,0 +1,13 @@ + + +# ResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] + + + diff --git a/docs/ResponsePingDTO.md b/docs/ResponsePingDTO.md new file mode 100644 index 0000000..f1517a2 --- /dev/null +++ b/docs/ResponsePingDTO.md @@ -0,0 +1,14 @@ + + +# ResponsePingDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**version** | **String** | | + + + diff --git a/docs/ResponseProductInformationDTO.md b/docs/ResponseProductInformationDTO.md new file mode 100644 index 0000000..5215f11 --- /dev/null +++ b/docs/ResponseProductInformationDTO.md @@ -0,0 +1,14 @@ + + +# ResponseProductInformationDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**producerId** | **String** | Hersteller-ID | +**code** | **String** | Produktkuerzel | +**version** | **String** | Produktversion | + + + diff --git a/docs/RetrieveDocumentsResponseDTO.md b/docs/RetrieveDocumentsResponseDTO.md new file mode 100644 index 0000000..1e72859 --- /dev/null +++ b/docs/RetrieveDocumentsResponseDTO.md @@ -0,0 +1,14 @@ + + +# RetrieveDocumentsResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**success** | **Boolean** | | +**error** | **String** | | [optional] +**docs** | [**List<Document>**](Document.md) | | [optional] + + + diff --git a/docs/StoreDocumentRequestDTO.md b/docs/StoreDocumentRequestDTO.md new file mode 100644 index 0000000..746fdf8 --- /dev/null +++ b/docs/StoreDocumentRequestDTO.md @@ -0,0 +1,14 @@ + + +# StoreDocumentRequestDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**account** | [**Login**](Login.md) | | +**title** | **String** | Titel des Submission Sets | [optional] +**docs** | [**List<DocumentWithMetadata>**](DocumentWithMetadata.md) | | + + + diff --git a/docs/SubmissionSetMetaData.md b/docs/SubmissionSetMetaData.md new file mode 100644 index 0000000..6be1280 --- /dev/null +++ b/docs/SubmissionSetMetaData.md @@ -0,0 +1,18 @@ + + +# SubmissionSetMetaData + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**author** | [**Author**](Author.md) | | [optional] +**comments** | **String** | Ergaenzende Hinweise zum Submission Set in Freitext | [optional] +**contentTypeCode** | **String** | | [optional] +**intendedRecipient** | **List<String>** | | [optional] +**submissionTime** | [**OffsetDateTime**](OffsetDateTime.md) | date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z | [optional] +**title** | **String** | Titel des Submission Sets | [optional] +**uniqueId** | **String** | Eindeutige Kennung des Submission Sets | [optional] + + + diff --git a/docs/SubmissionSetWithDocumentWithMetadata.md b/docs/SubmissionSetWithDocumentWithMetadata.md new file mode 100644 index 0000000..35484e1 --- /dev/null +++ b/docs/SubmissionSetWithDocumentWithMetadata.md @@ -0,0 +1,13 @@ + + +# SubmissionSetWithDocumentWithMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**submissionSet** | [**SubmissionSetMetaData**](SubmissionSetMetaData.md) | | [optional] +**documentMetadata** | [**List<DocumentWithMetadata>**](DocumentWithMetadata.md) | | [optional] + + + diff --git a/docs/UserApi.md b/docs/UserApi.md new file mode 100644 index 0000000..bb58991 --- /dev/null +++ b/docs/UserApi.md @@ -0,0 +1,134 @@ +# UserApi + +All URIs are relative to *https://gematik.de/fdv* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**login1**](UserApi.md#login1) | **POST** /login | Login Aktensession +[**logout1**](UserApi.md#logout1) | **POST** /logout | Logout Aktensession + + +<a name="login1"></a> +# **login1** +> ResponseDTO login1(requestDTO) + +Login Aktensession + +Umsetzung Operation I_FdV::login A_18045; Login in zwei Varianten; Falls die insurantID uebergeben wird, dann referenziert die insurantID die AUT-Identitaet des Nutzers, welche ueber eine eGK oder einen Signaturdienst (Konfigurationsparameter UseEGK) verfuegbar ist. Falls keine insurantID übergeben wird, dann wird eine PKCS12-Datei uebergeben. Das C.CH.AUT Zertifikat und der private Schluessel aus der PKCS12-Datei werden im Testtreiber genutzt (bspw. Signatur bei der Authentisierung und der Schluesselerzeugung mit SGD). + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + UserApi apiInstance = new UserApi(defaultClient); + RequestDTO requestDTO = new RequestDTO(); // RequestDTO | + try { + ResponseDTO result = apiInstance.login1(requestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#login1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestDTO** | [**RequestDTO**](RequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + +<a name="logout1"></a> +# **logout1** +> ResponseDTO logout1(requestDTO) + +Logout Aktensession + +Umsetzung Operation I_FdV::logout A_18046; Logout wird fuer eine per InsurantID (KVNR) referenzierte Identitaet ausgeloest. + +### Example +```java +// Import classes: +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiClient; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.ApiException; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.Configuration; +import de.gematik.ti.epa.fdv.testtreiber.client.invoker.models.*; +import de.gematik.ti.epa.fdv.testtreiber.client.api.UserApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://gematik.de/fdv"); + + UserApi apiInstance = new UserApi(defaultClient); + RequestDTO requestDTO = new RequestDTO(); // RequestDTO | + try { + ResponseDTO result = apiInstance.logout1(requestDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling UserApi#logout1"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **requestDTO** | [**RequestDTO**](RequestDTO.md)| | [optional] + +### Return type + +[**ResponseDTO**](ResponseDTO.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**0** | default response | - | + diff --git a/docs/UserCertificate.md b/docs/UserCertificate.md new file mode 100644 index 0000000..9b7d76c --- /dev/null +++ b/docs/UserCertificate.md @@ -0,0 +1,28 @@ + + +# UserCertificate + +Jeder Verzeichniseintrag muss mindestens ein Zertifikat enthalten. +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**dn** | [**DistinguishedName**](DistinguishedName.md) | | +**entryType** | **String** | Eintragstyp Wird vom VZD anhand der in dem Zertifikat enthaltenen OID (Extension Admission, Attribut ProfessionOID) und der Spalte Eintragstyp in Tab_VZD_Mapping_Eintragstyp_und_ProfessionOID automatisch eingetragen. Siehe auch [gemSpecOID]# Tab_PKI_402 und Tab_PKI_403 | [optional] [readonly] +**telematikID** | **String** | TelematikID Wird beim Anlegen des Eintrags vom VZD aus dem Zertifikat übernommen (Feld registrationNumber der Extension Admission). | [optional] [readonly] +**professionOID** | **List<String>** | | [optional] [readonly] +**usage** | [**List<UsageEnum>**](#List<UsageEnum>) | Nutzungskennzeichnung kann pro Zertifikat mehrfach vergeben werden. Vorgegebener Wertebereich [KOM-LE, ePA]. Obligatorisch für LEI und KTR mit vorgegebenem Wert usage=ePA | [optional] +**userCertificate** | **String** | Zertifikat im DER Format. Base64 kodiert. Die pflegende Stelle erhält das Zertifikat vom TSP oder falls das nicht möglich ist wird ein Ersatzverfahren abgestimmt. | [optional] +**description** | **String** | Dieses Attribut ermöglicht das Zertifikat zu beschreiben, um die Administration des VZD Eintrags zu vereinfachen. | [optional] + + + +## Enum: List<UsageEnum> + +Name | Value +---- | ----- +KOM_LE | "KOM-LE" +EPA | "ePA" + + + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..05644f0 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +# Uncomment to build for Android +#target = android \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..78e52e2 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "VZD-Client" \ No newline at end of file diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApi.java b/src/main/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApi.java new file mode 100644 index 0000000..9a092fb --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApi.java @@ -0,0 +1,742 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.api; + +import com.google.gson.reflect.TypeToken; +import de.gematik.ti.epa.vzd.client.invoker.ApiCallback; +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CertificateAdministrationApi { + + private ApiClient localVarApiClient; + + public CertificateAdministrationApi() { + this(Configuration.getDefaultApiClient()); + } + + public CertificateAdministrationApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for addDirectoryEntryCertificate + * + * @param uid ID (dn.uid) vom übergeordneten Verzeichniseintrag (required) + * @param userCertificate Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) + * telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode 422 + * abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird + * vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein + * description Kann optional belegt werden (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call addDirectoryEntryCertificateCall(String uid, UserCertificate userCertificate, final ApiCallback _callback) + throws ApiException { + Object localVarPostBody = userCertificate; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addDirectoryEntryCertificateValidateBeforeCall(String uid, UserCertificate userCertificate, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'uid' is set + if (uid == null) { + throw new ApiException("Missing the required parameter 'uid' when calling addDirectoryEntryCertificate(Async)"); + } + + // verify the required parameter 'userCertificate' is set + if (userCertificate == null) { + throw new ApiException("Missing the required parameter 'userCertificate' when calling addDirectoryEntryCertificate(Async)"); + } + + okhttp3.Call localVarCall = addDirectoryEntryCertificateCall(uid, userCertificate, _callback); + return localVarCall; + + } + + /** + * Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. + * + * @param uid ID (dn.uid) vom übergeordneten Verzeichniseintrag (required) + * @param userCertificate Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) + * telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode 422 + * abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird + * vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein + * description Kann optional belegt werden (required) + * @return DistinguishedName + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public DistinguishedName addDirectoryEntryCertificate(String uid, UserCertificate userCertificate) throws ApiException { + ApiResponse<DistinguishedName> localVarResp = addDirectoryEntryCertificateWithHttpInfo(uid, userCertificate); + return localVarResp.getData(); + } + + /** + * Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. + * + * @param uid ID (dn.uid) vom übergeordneten Verzeichniseintrag (required) + * @param userCertificate Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) + * telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode 422 + * abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird + * vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein + * description Kann optional belegt werden (required) + * @return ApiResponse<DistinguishedName> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public ApiResponse<DistinguishedName> addDirectoryEntryCertificateWithHttpInfo(String uid, UserCertificate userCertificate) throws ApiException { + okhttp3.Call localVarCall = addDirectoryEntryCertificateValidateBeforeCall(uid, userCertificate, null); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. + * (asynchronously) + * + * @param uid ID (dn.uid) vom übergeordneten Verzeichniseintrag (required) + * @param userCertificate Datensatz für die Erzeugung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid in Path) + * telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode 422 + * abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden (wird + * vom Verzeichnisdienst belegt) usage Kann optional belegt werden userCertificate Muss vorhanden sein + * description Kann optional belegt werden (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call addDirectoryEntryCertificateAsync(String uid, UserCertificate userCertificate, final ApiCallback<DistinguishedName> _callback) + throws ApiException { + + okhttp3.Call localVarCall = addDirectoryEntryCertificateValidateBeforeCall(uid, userCertificate, _callback); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteDirectoryEntryCertificate + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem zu löschenden Zertifikatseintrag (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call deleteDirectoryEntryCertificateCall(String uid, String certificateEntryID, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates/{certificateEntryID}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())) + .replaceAll("\\{" + "certificateEntryID" + "\\}", localVarApiClient.escapeString(certificateEntryID.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteDirectoryEntryCertificateValidateBeforeCall(String uid, String certificateEntryID, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'uid' is set + if (uid == null) { + throw new ApiException("Missing the required parameter 'uid' when calling deleteDirectoryEntryCertificate(Async)"); + } + + // verify the required parameter 'certificateEntryID' is set + if (certificateEntryID == null) { + throw new ApiException("Missing the required parameter 'certificateEntryID' when calling deleteDirectoryEntryCertificate(Async)"); + } + + okhttp3.Call localVarCall = deleteDirectoryEntryCertificateCall(uid, certificateEntryID, _callback); + return localVarCall; + + } + + /** + * Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat + * mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem zu löschenden Zertifikatseintrag (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public void deleteDirectoryEntryCertificate(String uid, String certificateEntryID) throws ApiException { + deleteDirectoryEntryCertificateWithHttpInfo(uid, certificateEntryID); + } + + /** + * Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat + * mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem zu löschenden Zertifikatseintrag (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public ApiResponse<Void> deleteDirectoryEntryCertificateWithHttpInfo(String uid, String certificateEntryID) throws ApiException { + okhttp3.Call localVarCall = deleteDirectoryEntryCertificateValidateBeforeCall(uid, certificateEntryID, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat + * mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. (asynchronously) + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem zu löschenden Zertifikatseintrag (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call deleteDirectoryEntryCertificateAsync(String uid, String certificateEntryID, final ApiCallback<Void> _callback) + throws ApiException { + + okhttp3.Call localVarCall = deleteDirectoryEntryCertificateValidateBeforeCall(uid, certificateEntryID, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for modifyDirectoryEntryCertificate + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem Zertifikat (required) + * @param userCertificate Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & + * certificateEntryID in Path). telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss + * diese telematikID mit der telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die + * Operation mit Fehlercode 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. + * userCertificate unverändert gegenüber VZD description Kann optional belegt werden. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call modifyDirectoryEntryCertificateCall(String uid, String certificateEntryID, UserCertificate userCertificate, + final ApiCallback _callback) throws ApiException { + Object localVarPostBody = userCertificate; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates/{certificateEntryID}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())) + .replaceAll("\\{" + "certificateEntryID" + "\\}", localVarApiClient.escapeString(certificateEntryID.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyDirectoryEntryCertificateValidateBeforeCall(String uid, String certificateEntryID, UserCertificate userCertificate, + final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'uid' is set + if (uid == null) { + throw new ApiException("Missing the required parameter 'uid' when calling modifyDirectoryEntryCertificate(Async)"); + } + + // verify the required parameter 'certificateEntryID' is set + if (certificateEntryID == null) { + throw new ApiException("Missing the required parameter 'certificateEntryID' when calling modifyDirectoryEntryCertificate(Async)"); + } + + // verify the required parameter 'userCertificate' is set + if (userCertificate == null) { + throw new ApiException("Missing the required parameter 'userCertificate' when calling modifyDirectoryEntryCertificate(Async)"); + } + + okhttp3.Call localVarCall = modifyDirectoryEntryCertificateCall(uid, certificateEntryID, userCertificate, _callback); + return localVarCall; + + } + + /** + * Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem Zertifikat (required) + * @param userCertificate Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & + * certificateEntryID in Path). telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss + * diese telematikID mit der telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die + * Operation mit Fehlercode 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. + * userCertificate unverändert gegenüber VZD description Kann optional belegt werden. (required) + * @return UserCertificate + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public UserCertificate modifyDirectoryEntryCertificate(String uid, String certificateEntryID, UserCertificate userCertificate) + throws ApiException { + ApiResponse<UserCertificate> localVarResp = modifyDirectoryEntryCertificateWithHttpInfo(uid, certificateEntryID, userCertificate); + return localVarResp.getData(); + } + + /** + * Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem Zertifikat (required) + * @param userCertificate Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & + * certificateEntryID in Path). telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss + * diese telematikID mit der telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die + * Operation mit Fehlercode 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. + * userCertificate unverändert gegenüber VZD description Kann optional belegt werden. (required) + * @return ApiResponse<UserCertificate> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public ApiResponse<UserCertificate> modifyDirectoryEntryCertificateWithHttpInfo(String uid, String certificateEntryID, + UserCertificate userCertificate) throws ApiException { + okhttp3.Call localVarCall = modifyDirectoryEntryCertificateValidateBeforeCall(uid, certificateEntryID, userCertificate, null); + Type localVarReturnType = new TypeToken<UserCertificate>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. (asynchronously) + * + * @param uid ID vom übergeordneten Verzeichniseintrag (required) + * @param certificateEntryID ID von dem Zertifikat (required) + * @param userCertificate Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein Attribut Wert + * ------------------------------------------- dn.* Nicht vorhanden (Adressierung erfolgt über uid & + * certificateEntryID in Path). telematikID Kann optional belegt werden. Wird telematikID angegeben, dann muss + * diese telematikID mit der telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die + * Operation mit Fehlercode 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * professionOID Nicht vorhanden (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. + * userCertificate unverändert gegenüber VZD description Kann optional belegt werden. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call modifyDirectoryEntryCertificateAsync(String uid, String certificateEntryID, UserCertificate userCertificate, + final ApiCallback<UserCertificate> _callback) throws ApiException { + + okhttp3.Call localVarCall = modifyDirectoryEntryCertificateValidateBeforeCall(uid, certificateEntryID, userCertificate, _callback); + Type localVarReturnType = new TypeToken<UserCertificate>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for readDirectoryCertificates + * + * @param uid ID vom übergeordneten Verzeichniseintrag (optional) + * @param certificateEntryID ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) + * Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. + * (optional) + * @param entryType Erlaubt die Suche mit Hilfe des Attributs entryType. (optional) + * @param telematikID telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. (optional) + * @param professionOID Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. (optional) + * @param usage Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im + * Attribut usage (array) des Zertifikatseintrags enthalten ist. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call readDirectoryCertificatesCall(String uid, String certificateEntryID, String entryType, String telematikID, + String professionOID, String usage, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/Certificates"; + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + if (uid != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("uid", uid)); + } + + if (certificateEntryID != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("certificateEntryID", certificateEntryID)); + } + + if (entryType != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("entryType", entryType)); + } + + if (telematikID != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("telematikID", telematikID)); + } + + if (professionOID != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("professionOID", professionOID)); + } + + if (usage != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("usage", usage)); + } + + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call readDirectoryCertificatesValidateBeforeCall(String uid, String certificateEntryID, String entryType, String telematikID, + String professionOID, String usage, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = readDirectoryCertificatesCall(uid, certificateEntryID, entryType, telematikID, professionOID, usage, _callback); + return localVarCall; + + } + + /** + * Zertifikat lesen Liefert alle Zertifikate, die dem Filter (siehe 'parameters') entsprechen. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (optional) + * @param certificateEntryID ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) + * Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. + * (optional) + * @param entryType Erlaubt die Suche mit Hilfe des Attributs entryType. (optional) + * @param telematikID telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. (optional) + * @param professionOID Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. (optional) + * @param usage Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im + * Attribut usage (array) des Zertifikatseintrags enthalten ist. (optional) + * @return List<UserCertificate> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public List<UserCertificate> readDirectoryCertificates(String uid, String certificateEntryID, String entryType, String telematikID, + String professionOID, String usage) throws ApiException { + ApiResponse<List<UserCertificate>> localVarResp = readDirectoryCertificatesWithHttpInfo(uid, certificateEntryID, entryType, telematikID, + professionOID, usage); + return localVarResp.getData(); + } + + /** + * Zertifikat lesen Liefert alle Zertifikate, die dem Filter (siehe 'parameters') entsprechen. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (optional) + * @param certificateEntryID ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) + * Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. + * (optional) + * @param entryType Erlaubt die Suche mit Hilfe des Attributs entryType. (optional) + * @param telematikID telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. (optional) + * @param professionOID Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. (optional) + * @param usage Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im + * Attribut usage (array) des Zertifikatseintrags enthalten ist. (optional) + * @return ApiResponse<List<UserCertificate>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public ApiResponse<List<UserCertificate>> readDirectoryCertificatesWithHttpInfo(String uid, String certificateEntryID, String entryType, + String telematikID, String professionOID, String usage) throws ApiException { + okhttp3.Call localVarCall = readDirectoryCertificatesValidateBeforeCall(uid, certificateEntryID, entryType, telematikID, professionOID, usage, + null); + Type localVarReturnType = new TypeToken<List<UserCertificate>>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Zertifikat lesen (asynchronously) Liefert alle Zertifikate, die dem Filter (siehe 'parameters') entsprechen. + * + * @param uid ID vom übergeordneten Verzeichniseintrag (optional) + * @param certificateEntryID ID von dem Zertifikat (dn.cn vom Zertifikatseintrag) Wenn angegeben wird das adressierte (certificateEntryID) + * Zertifikat geliefert. Wenn nicht angegeben werden alle Zertifikate des übergeordneten Verzeichniseintrags geliefert. + * (optional) + * @param entryType Erlaubt die Suche mit Hilfe des Attributs entryType. (optional) + * @param telematikID telematikID von dem Zertifikat Erlaubt die Suche nach Zertifikatseinträgen einer telematikID. (optional) + * @param professionOID Erlaubt die Suche mit Hilfe des Attributs professionOID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * professionOID im Attribut professionOID (array) des Zertifikatseintrags enthalten ist. (optional) + * @param usage Erlaubt die Suche mit Hilfe des Attributs usage. Der Verzeichniseintrag wird selektiert, wenn die angegebene usage im + * Attribut usage (array) des Zertifikatseintrags enthalten ist. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call readDirectoryCertificatesAsync(String uid, String certificateEntryID, String entryType, String telematikID, + String professionOID, String usage, final ApiCallback<List<UserCertificate>> _callback) throws ApiException { + + okhttp3.Call localVarCall = readDirectoryCertificatesValidateBeforeCall(uid, certificateEntryID, entryType, telematikID, professionOID, usage, + _callback); + Type localVarReturnType = new TypeToken<List<UserCertificate>>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/api/DirectoryEntryAdministrationApi.java b/src/main/java/de/gematik/ti/epa/vzd/client/api/DirectoryEntryAdministrationApi.java new file mode 100644 index 0000000..10dd6a9 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/api/DirectoryEntryAdministrationApi.java @@ -0,0 +1,839 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.api; + +import com.google.gson.reflect.TypeToken; +import de.gematik.ti.epa.vzd.client.invoker.ApiCallback; +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.invoker.Configuration; +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DirectoryEntryAdministrationApi { + + private ApiClient localVarApiClient; + + public DirectoryEntryAdministrationApi() { + this(Configuration.getDefaultApiClient()); + } + + public DirectoryEntryAdministrationApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for addDirectoryEntry + * + * @param createDirectoryEntry Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden + * (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional + * belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt werden. title + * Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. + * specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst + * belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom + * Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Kann + * optional belegt werden. Wird telematikID und userCertificate angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode + * 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden + * (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Kann optional + * belegt werden (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird + * ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in + * dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im + * Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden + * kann). (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call addDirectoryEntryCall(CreateDirectoryEntry createDirectoryEntry, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = createDirectoryEntry; + + // create path and map variables + String localVarPath = "/DirectoryEntries"; + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addDirectoryEntryValidateBeforeCall(CreateDirectoryEntry createDirectoryEntry, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'createDirectoryEntry' is set + if (createDirectoryEntry == null) { + throw new ApiException("Missing the required parameter 'createDirectoryEntry' when calling addDirectoryEntry(Async)"); + } + + okhttp3.Call localVarCall = addDirectoryEntryCall(createDirectoryEntry, _callback); + return localVarCall; + + } + + /** + * Einen Eintrag zum Verzeichnisdienst hinzufügen + * + * @param createDirectoryEntry Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden + * (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional + * belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt werden. title + * Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. + * specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst + * belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom + * Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Kann + * optional belegt werden. Wird telematikID und userCertificate angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode + * 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden + * (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Kann optional + * belegt werden (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird + * ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in + * dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im + * Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden + * kann). (required) + * @return DistinguishedName + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public DistinguishedName addDirectoryEntry(CreateDirectoryEntry createDirectoryEntry) throws ApiException { + ApiResponse<DistinguishedName> localVarResp = addDirectoryEntryWithHttpInfo(createDirectoryEntry); + return localVarResp.getData(); + } + + /** + * Einen Eintrag zum Verzeichnisdienst hinzufügen + * + * @param createDirectoryEntry Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden + * (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional + * belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt werden. title + * Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. + * specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst + * belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom + * Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Kann + * optional belegt werden. Wird telematikID und userCertificate angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode + * 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden + * (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Kann optional + * belegt werden (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird + * ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in + * dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im + * Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden + * kann). (required) + * @return ApiResponse<DistinguishedName> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public ApiResponse<DistinguishedName> addDirectoryEntryWithHttpInfo(CreateDirectoryEntry createDirectoryEntry) throws ApiException { + okhttp3.Call localVarCall = addDirectoryEntryValidateBeforeCall(createDirectoryEntry, null); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Einen Eintrag zum Verzeichnisdienst hinzufügen (asynchronously) + * + * @param createDirectoryEntry Datensatz für den neuen Eintrag. Die Attribute müssen wie folgt belegt sein dn.* Leer/nicht vorhanden + * (wird vom Verzeichnisdienst belegt) givenName Nicht vorhanden (wird vom Verzeichnisdienst belegt) sn Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) cn Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode Kann optional + * belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt werden. title + * Kann optional belegt werden. organization Kann optional belegt werden. otherName Kann optional belegt werden. + * specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry Nicht + * vorhanden (wird vom Verzeichnisdienst belegt) dataFromAuthority Nicht vorhanden (wird vom Verzeichnisdienst belegt) + * userCertificates Kann optional belegt werden. dn.uid Leer/nicht vorhanden (wird vom Verzeichnisdienst + * belegt) dn.dc Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) dn.ou Leer/nicht vorhanden (wird vom + * Verzeichnisdienst belegt) dn.cn Leer/nicht vorhanden (wird vom Verzeichnisdienst belegt) telematikID Kann + * optional belegt werden. Wird telematikID und userCertificate angegeben, dann muss diese telematikID mit der + * telematikID im userCertificate übereinstimmen. Bei unterschiedlichen telematikID wird die Operation mit Fehlercode + * 422 abgelehnt. entryType Nicht vorhanden (wird vom Verzeichnisdienst belegt) professionOID Nicht vorhanden + * (wird vom Verzeichnisdienst belegt) usage Kann optional belegt werden. userCertificate Kann optional + * belegt werden (Format DER, Base64 kodiert) description Kann optional belegt werden. Entsprechend gemSpec_VZD wird + * ein Teil der Attribute durch den Verzeichnisdienst automatisch mit Werten aus dem Zertifikat gefüllt. Wenn in + * dieser Operation Attribute - für die dies erlaubt ist - mit einem Wert belegt werden, wird dieser Wert im + * Verzeichniseintrag gespeichert (auch wenn der Wert durch den Verzeichnisdienst aus dem Zertifikat entnommen werden + * kann). (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 201 </td><td> Created </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call addDirectoryEntryAsync(CreateDirectoryEntry createDirectoryEntry, final ApiCallback<DistinguishedName> _callback) + throws ApiException { + + okhttp3.Call localVarCall = addDirectoryEntryValidateBeforeCall(createDirectoryEntry, _callback); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteDirectoryEntry + * + * @param uid ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate + * und Fachdaten. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call deleteDirectoryEntryCall(String uid, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteDirectoryEntryValidateBeforeCall(String uid, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'uid' is set + if (uid == null) { + throw new ApiException("Missing the required parameter 'uid' when calling deleteDirectoryEntry(Async)"); + } + + okhttp3.Call localVarCall = deleteDirectoryEntryCall(uid, _callback); + return localVarCall; + + } + + /** + * Gesamten Verzeichniseintrag löschen + * + * @param uid ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate und + * Fachdaten. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public void deleteDirectoryEntry(String uid) throws ApiException { + deleteDirectoryEntryWithHttpInfo(uid); + } + + /** + * Gesamten Verzeichniseintrag löschen + * + * @param uid ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate und + * Fachdaten. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public ApiResponse<Void> deleteDirectoryEntryWithHttpInfo(String uid) throws ApiException { + okhttp3.Call localVarCall = deleteDirectoryEntryValidateBeforeCall(uid, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Gesamten Verzeichniseintrag löschen (asynchronously) + * + * @param uid ID von dem zu löschenden Verzeichniseintrag Gelöscht werden der Basis Verzeichniseintrag sowie alle dazugehörenden Zertifikate + * und Fachdaten. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call deleteDirectoryEntryAsync(String uid, final ApiCallback<Void> _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteDirectoryEntryValidateBeforeCall(uid, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for modifyDirectoryEntry + * + * @param uid ID von dem Verzeichniseintrag (required) + * @param baseDirectoryEntry Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht + * vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn + * Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode + * Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt + * werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht + * vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry + * Nicht vorhanden. dataFromAuthority Nicht vorhanden (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call modifyDirectoryEntryCall(String uid, BaseDirectoryEntry baseDirectoryEntry, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = baseDirectoryEntry; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/baseDirectoryEntries" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call modifyDirectoryEntryValidateBeforeCall(String uid, BaseDirectoryEntry baseDirectoryEntry, final ApiCallback _callback) + throws ApiException { + + // verify the required parameter 'uid' is set + if (uid == null) { + throw new ApiException("Missing the required parameter 'uid' when calling modifyDirectoryEntry(Async)"); + } + + // verify the required parameter 'baseDirectoryEntry' is set + if (baseDirectoryEntry == null) { + throw new ApiException("Missing the required parameter 'baseDirectoryEntry' when calling modifyDirectoryEntry(Async)"); + } + + okhttp3.Call localVarCall = modifyDirectoryEntryCall(uid, baseDirectoryEntry, _callback); + return localVarCall; + + } + + /** + * Der Verzeichniseintrag (ohne Zertifikate und Fachdaten) wird mit den übergebenen Daten aktualisiert. + * + * @param uid ID von dem Verzeichniseintrag (required) + * @param baseDirectoryEntry Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht + * vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn + * Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode + * Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt + * werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht + * vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry + * Nicht vorhanden. dataFromAuthority Nicht vorhanden (required) + * @return DistinguishedName + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * </table> + */ + public DistinguishedName modifyDirectoryEntry(String uid, BaseDirectoryEntry baseDirectoryEntry) throws ApiException { + ApiResponse<DistinguishedName> localVarResp = modifyDirectoryEntryWithHttpInfo(uid, baseDirectoryEntry); + return localVarResp.getData(); + } + + /** + * Der Verzeichniseintrag (ohne Zertifikate und Fachdaten) wird mit den übergebenen Daten aktualisiert. + * + * @param uid ID von dem Verzeichniseintrag (required) + * @param baseDirectoryEntry Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht + * vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn + * Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode + * Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt + * werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht + * vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry + * Nicht vorhanden. dataFromAuthority Nicht vorhanden (required) + * @return ApiResponse<DistinguishedName> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * </table> + */ + public ApiResponse<DistinguishedName> modifyDirectoryEntryWithHttpInfo(String uid, BaseDirectoryEntry baseDirectoryEntry) throws ApiException { + okhttp3.Call localVarCall = modifyDirectoryEntryValidateBeforeCall(uid, baseDirectoryEntry, null); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Der Verzeichniseintrag (ohne Zertifikate und Fachdaten) wird mit den übergebenen Daten aktualisiert. (asynchronously) + * + * @param uid ID von dem Verzeichniseintrag (required) + * @param baseDirectoryEntry Datensatz für die Aktualisierung des Eintrags Die Attribute müssen wie folgt belegt sein dn.* Nicht + * vorhanden (Adressierung erfolgt über uid in Path). givenName Nicht vorhanden. sn Nicht vorhanden. cn + * Nicht vorhanden. displayName Kann optional belegt werden. streetAddress Kann optional belegt werden. postalCode + * Kann optional belegt werden. localityName Kann optional belegt werden. stateOrProvinceName Kann optional belegt + * werden. title Kann optional belegt werden. organization Kann optional belegt werden. otherName Nicht + * vorhanden. specialization Kann optional belegt werden. domainID Kann optional belegt werden. personalEntry + * Nicht vorhanden. dataFromAuthority Nicht vorhanden (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * <tr><td> 405 </td><td> Method Not Allowed </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call modifyDirectoryEntryAsync(String uid, BaseDirectoryEntry baseDirectoryEntry, final ApiCallback<DistinguishedName> _callback) + throws ApiException { + + okhttp3.Call localVarCall = modifyDirectoryEntryValidateBeforeCall(uid, baseDirectoryEntry, _callback); + Type localVarReturnType = new TypeToken<DistinguishedName>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for readDirectoryEntry + * + * @param uid ID von dem Verzeichniseintrag (distinguishedName.uid) (optional) + * @param givenName Erlaubt die Suche mit Hilfe des Attributs givenName. (optional) + * @param sn Erlaubt die Suche mit Hilfe des Attributs sn. (optional) + * @param cn Erlaubt die Suche mit Hilfe des Attributs cn. (optional) + * @param displayName Erlaubt die Suche mit Hilfe des Attributs displayName. (optional) + * @param streetAddress Erlaubt die Suche mit Hilfe des Attributs streetAddress. (optional) + * @param postalCode Erlaubt die Suche mit Hilfe des Attributs postalCode. (optional) + * @param localityName Erlaubt die Suche mit Hilfe des Attributs localityName. (optional) + * @param stateOrProvinceName Erlaubt die Suche mit Hilfe des Attributs stateOrProvinceName. (optional) + * @param title Erlaubt die Suche mit Hilfe des Attributs title. (optional) + * @param organization Erlaubt die Suche mit Hilfe des Attributs organization. (optional) + * @param otherName Erlaubt die Suche mit Hilfe des Attributs otherName. (optional) + * @param specialization Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die + * angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param domainID Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param personalEntry Erlaubt die Suche mit Hilfe des Attributs personalEntry. (optional) + * @param dataFromAuthority Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call readDirectoryEntryCall(String uid, String givenName, String sn, String cn, String displayName, String streetAddress, + String postalCode, String localityName, String stateOrProvinceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries"; + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + if (uid != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("uid", uid)); + } + + if (givenName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("givenName", givenName)); + } + + if (sn != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sn", sn)); + } + + if (cn != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cn", cn)); + } + + if (displayName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("displayName", displayName)); + } + + if (streetAddress != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("streetAddress", streetAddress)); + } + + if (postalCode != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("postalCode", postalCode)); + } + + if (localityName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("localityName", localityName)); + } + + if (stateOrProvinceName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("stateOrProvinceName", stateOrProvinceName)); + } + + if (title != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("title", title)); + } + + if (organization != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("organization", organization)); + } + + if (otherName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("otherName", otherName)); + } + + if (specialization != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("specialization", specialization)); + } + + if (domainID != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("domainID", domainID)); + } + + if (personalEntry != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("personalEntry", personalEntry)); + } + + if (dataFromAuthority != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("dataFromAuthority", dataFromAuthority)); + } + + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call readDirectoryEntryValidateBeforeCall(String uid, String givenName, String sn, String cn, String displayName, + String streetAddress, String postalCode, String localityName, String stateOrProvinceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = readDirectoryEntryCall(uid, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, + stateOrProvinceName, title, organization, otherName, specialization, domainID, personalEntry, dataFromAuthority, _callback); + return localVarCall; + + } + + /** + * Gesamten Verzeichniseintrag lesen Liefert alle zum Filter passenden Verzeichniseinträge. Die angegebenen Parameter werden mit logischen UND + * verknüpft. + * + * @param uid ID von dem Verzeichniseintrag (distinguishedName.uid) (optional) + * @param givenName Erlaubt die Suche mit Hilfe des Attributs givenName. (optional) + * @param sn Erlaubt die Suche mit Hilfe des Attributs sn. (optional) + * @param cn Erlaubt die Suche mit Hilfe des Attributs cn. (optional) + * @param displayName Erlaubt die Suche mit Hilfe des Attributs displayName. (optional) + * @param streetAddress Erlaubt die Suche mit Hilfe des Attributs streetAddress. (optional) + * @param postalCode Erlaubt die Suche mit Hilfe des Attributs postalCode. (optional) + * @param localityName Erlaubt die Suche mit Hilfe des Attributs localityName. (optional) + * @param stateOrProvinceName Erlaubt die Suche mit Hilfe des Attributs stateOrProvinceName. (optional) + * @param title Erlaubt die Suche mit Hilfe des Attributs title. (optional) + * @param organization Erlaubt die Suche mit Hilfe des Attributs organization. (optional) + * @param otherName Erlaubt die Suche mit Hilfe des Attributs otherName. (optional) + * @param specialization Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die + * angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param domainID Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param personalEntry Erlaubt die Suche mit Hilfe des Attributs personalEntry. (optional) + * @param dataFromAuthority Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. (optional) + * @return List<DirectoryEntry> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public List<DirectoryEntry> readDirectoryEntry(String uid, String givenName, String sn, String cn, String displayName, String streetAddress, + String postalCode, String localityName, String stateOrProvinceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority) throws ApiException { + ApiResponse<List<DirectoryEntry>> localVarResp = readDirectoryEntryWithHttpInfo(uid, givenName, sn, cn, displayName, streetAddress, + postalCode, localityName, stateOrProvinceName, title, organization, otherName, specialization, domainID, personalEntry, + dataFromAuthority); + return localVarResp.getData(); + } + + /** + * Gesamten Verzeichniseintrag lesen Liefert alle zum Filter passenden Verzeichniseinträge. Die angegebenen Parameter werden mit logischen UND + * verknüpft. + * + * @param uid ID von dem Verzeichniseintrag (distinguishedName.uid) (optional) + * @param givenName Erlaubt die Suche mit Hilfe des Attributs givenName. (optional) + * @param sn Erlaubt die Suche mit Hilfe des Attributs sn. (optional) + * @param cn Erlaubt die Suche mit Hilfe des Attributs cn. (optional) + * @param displayName Erlaubt die Suche mit Hilfe des Attributs displayName. (optional) + * @param streetAddress Erlaubt die Suche mit Hilfe des Attributs streetAddress. (optional) + * @param postalCode Erlaubt die Suche mit Hilfe des Attributs postalCode. (optional) + * @param localityName Erlaubt die Suche mit Hilfe des Attributs localityName. (optional) + * @param stateOrProvinceName Erlaubt die Suche mit Hilfe des Attributs stateOrProvinceName. (optional) + * @param title Erlaubt die Suche mit Hilfe des Attributs title. (optional) + * @param organization Erlaubt die Suche mit Hilfe des Attributs organization. (optional) + * @param otherName Erlaubt die Suche mit Hilfe des Attributs otherName. (optional) + * @param specialization Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die + * angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param domainID Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param personalEntry Erlaubt die Suche mit Hilfe des Attributs personalEntry. (optional) + * @param dataFromAuthority Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. (optional) + * @return ApiResponse<List<DirectoryEntry>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public ApiResponse<List<DirectoryEntry>> readDirectoryEntryWithHttpInfo(String uid, String givenName, String sn, String cn, String displayName, + String streetAddress, String postalCode, String localityName, String stateOrProvinceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority) throws ApiException { + okhttp3.Call localVarCall = readDirectoryEntryValidateBeforeCall(uid, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, + stateOrProvinceName, title, organization, otherName, specialization, domainID, personalEntry, dataFromAuthority, null); + Type localVarReturnType = new TypeToken<List<DirectoryEntry>>() { + }.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Gesamten Verzeichniseintrag lesen (asynchronously) Liefert alle zum Filter passenden Verzeichniseinträge. Die angegebenen Parameter werden mit + * logischen UND verknüpft. + * + * @param uid ID von dem Verzeichniseintrag (distinguishedName.uid) (optional) + * @param givenName Erlaubt die Suche mit Hilfe des Attributs givenName. (optional) + * @param sn Erlaubt die Suche mit Hilfe des Attributs sn. (optional) + * @param cn Erlaubt die Suche mit Hilfe des Attributs cn. (optional) + * @param displayName Erlaubt die Suche mit Hilfe des Attributs displayName. (optional) + * @param streetAddress Erlaubt die Suche mit Hilfe des Attributs streetAddress. (optional) + * @param postalCode Erlaubt die Suche mit Hilfe des Attributs postalCode. (optional) + * @param localityName Erlaubt die Suche mit Hilfe des Attributs localityName. (optional) + * @param stateOrProvinceName Erlaubt die Suche mit Hilfe des Attributs stateOrProvinceName. (optional) + * @param title Erlaubt die Suche mit Hilfe des Attributs title. (optional) + * @param organization Erlaubt die Suche mit Hilfe des Attributs organization. (optional) + * @param otherName Erlaubt die Suche mit Hilfe des Attributs otherName. (optional) + * @param specialization Erlaubt die Suche mit Hilfe des Attributs specialization. Der Verzeichniseintrag wird selektiert, wenn die + * angegebene domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param domainID Erlaubt die Suche mit Hilfe des Attributs domainID. Der Verzeichniseintrag wird selektiert, wenn die angegebene + * domainID im Attribut domainID (array) des Verzeichniseintrags enthalten ist. (optional) + * @param personalEntry Erlaubt die Suche mit Hilfe des Attributs personalEntry. (optional) + * @param dataFromAuthority Erlaubt die Suche mit Hilfe des Attributs dataFromAuthority. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details <table summary="Response Details" border="1"> + * <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr> + * <tr><td> 200 </td><td> OK </td><td> - </td></tr> + * <tr><td> 400 </td><td> Bad Request </td><td> - </td></tr> + * <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr> + * <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr> + * <tr><td> 404 </td><td> Not Found </td><td> - </td></tr> + * </table> + */ + public okhttp3.Call readDirectoryEntryAsync(String uid, String givenName, String sn, String cn, String displayName, String streetAddress, + String postalCode, String localityName, String stateOrProvinceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority, final ApiCallback<List<DirectoryEntry>> _callback) + throws ApiException { + + okhttp3.Call localVarCall = readDirectoryEntryValidateBeforeCall(uid, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, + stateOrProvinceName, title, organization, otherName, specialization, domainID, personalEntry, dataFromAuthority, _callback); + Type localVarReturnType = new TypeToken<List<DirectoryEntry>>() { + }.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiCallback.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiCallback.java new file mode 100644 index 0000000..ff13de2 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiCallback.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.util.List; +import java.util.Map; + +/** + * Callback for asynchronous API call. + * + * @param <T> The return type + */ +public interface ApiCallback<T> { + + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map<String, List<String>> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map<String, List<String>> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API downlond processing. + * + * @param bytesRead bytes Read + * @param contentLength content lenngth of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiClient.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiClient.java new file mode 100644 index 0000000..b15443b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiClient.java @@ -0,0 +1,1391 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import de.gematik.ti.epa.vzd.client.invoker.auth.ApiKeyAuth; +import de.gematik.ti.epa.vzd.client.invoker.auth.Authentication; +import de.gematik.ti.epa.vzd.client.invoker.auth.HttpBasicAuth; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuth; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuthFlow; +import de.gematik.ti.epa.vzd.client.invoker.auth.RetryingOAuth; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.KeyManager; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.MultipartBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.BufferedSink; +import okio.Okio; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; + +public class ApiClient { + + private String basePath = "https://to.be.defined"; + private boolean debugging = false; + private Map<String, String> defaultHeaderMap = new HashMap<String, String>(); + private Map<String, String> defaultCookieMap = new HashMap<String, String>(); + private String tempFolderPath = null; + + private Map<String, Authentication> authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /* + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + + // Setup authentications (key: authentication name, value: authentication). + authentications.put("OAuth2", new OAuth()); + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID + */ + public ApiClient(String clientId) { + this(clientId, null, null); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters + */ + public ApiClient(String clientId, Map<String, String> parameters) { + this(clientId, null, parameters); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters + */ + public ApiClient(String clientId, String clientSecret, Map<String, String> parameters) { + init(); + + RetryingOAuth retryingOAuth = new RetryingOAuth("https://to.be.defined/oauth/token", clientId, OAuthFlow.application, clientSecret, + parameters); + authentications.put( + "OAuth2", + retryingOAuth + ); + httpClient.interceptors().add(retryingOAuth); + + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void init() { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + httpClient = builder.build(); + + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/1.1.1/java"); + + authentications = new HashMap<String, Authentication>(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://to.be.defined + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. Default to true. NOTE: Do NOT set to false in production code, + * otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + public DateFormat getDateFormat() { + return dateFormat; + } + + public ApiClient setDateFormat(DateFormat dateFormat) { + this.json.setDateFormat(dateFormat); + return this; + } + + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + this.json.setSqlDateFormat(dateFormat); + return this; + } + + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + this.json.setOffsetDateTimeFormat(dateFormat); + return this; + } + + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + this.json.setLocalDateFormat(dateFormat); + return this; + } + + public ApiClient setLenientOnJson(boolean lenientOnJson) { + this.json.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map<String, Authentication> getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + for (Authentication auth : authentications.values()) { + if (auth instanceof OAuth) { + ((OAuth) auth).setAccessToken(accessToken); + return; + } + } + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + httpClient.interceptors().remove(loggingInterceptor); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints with file response. The default value is <code>null</code>, i.e. + * using the system's default tempopary folder. + * + * @return Temporary folder path + * @see <a href="https://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile">createTempFile</a> + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and {@link Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and {@link Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and {@link Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Helper method to configure the token endpoint of the first oauth found in the apiAuthorizations (there should be only one) + * + * @return Token request builder + */ + public TokenRequestBuilder getTokenEndPoint() { + for (Authentication apiAuth : authentications.values()) { + if (apiAuth instanceof RetryingOAuth) { + RetryingOAuth retryingOAuth = (RetryingOAuth) apiAuth; + return retryingOAuth.getTokenRequestBuilder(); + } + } + return null; + } + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = json.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(o)); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * <p> + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List<Pair> parameterToPair(String name, Object value) { + List<Pair> params = new ArrayList<Pair>(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * <p> + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List<Pair> parameterToPairs(String collectionFormat, String name, Collection value) { + List<Pair> params = new ArrayList<Pair>(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceAll(".*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON + * application/vnd.company+json "* / *" is also default to JSON + * + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining + * into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given array, use it; otherwise use the first one of the + * array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, or matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) { + return "application/json"; + } + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and the Content-Type response header. + * + * @param <T> Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws ApiException If fail to deserialize response body, i.e. cannot read response body or the Content-Type of the response is not + * supported. + */ + @SuppressWarnings("unchecked") + public <T> T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + String respBody; + try { + if (response.body() != null) { + respBody = response.body().string(); + } else { + respBody = null; + } + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return json.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * Serialize the given Java object into request body according to the object's class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create(MediaType.parse(contentType), (byte[]) obj); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create(MediaType.parse(contentType), (File) obj); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = json.serialize(obj); + } else { + content = null; + } + return RequestBody.create(MediaType.parse(contentType), content); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @return Downloaded file + * @throws ApiException If fail to read file content from response and write to disk + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // File.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) { + prefix = "download-"; + } + } + + if (tempFolderPath == null) { + return File.createTempFile(prefix, suffix); + } else { + return File.createTempFile(prefix, suffix, new File(tempFolderPath)); + } + } + + /** + * {@link #execute(Call, Type)} + * + * @param <T> Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws ApiException If fail to execute the call + */ + public <T> ApiResponse<T> execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param <T> The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and data, which is a Java object deserialized from response body and would be + * null when returnType is null. + * @throws ApiException If fail to execute the call + */ + public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param <T> Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public <T> void executeAsync(Call call, ApiCallback<T> callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param <T> Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public <T> void executeAsync(Call call, final Type returnType, final ApiCallback<T> callback) { + call.enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } + callback.onSuccess(result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param <T> Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws ApiException If the response has an unsuccessful status code or fail to deserialize the response body + */ + public <T> T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); + } + } + throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws ApiException If fail to serialize the request body object + */ + public Call buildCall(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, + Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) + throws ApiException { + Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, + callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, + Map<String, String> headerParams, Map<String, String> cookieParams, Map<String, Object> formParams, String[] authNames, ApiCallback callback) + throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + + final String url = buildUrl(path, queryParams, collectionQueryParams); + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + String contentType = (String) headerParams.get("Content-Type"); + // ensuring a default content type + if (contentType == null) { + contentType = "application/json"; + } + + RequestBody reqBody; + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentType)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = RequestBody.create(MediaType.parse(contentType), ""); + } + } else { + reqBody = serialize(body, contentType); + } + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String path, List<Pair> queryParams, List<Pair> collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + url.append(basePath).append(path); + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map<String, String> headerParams, Request.Builder reqBuilder) { + for (Entry<String, String> param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry<String, String> header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map<String, String> cookieParams, Request.Builder reqBuilder) { + for (Entry<String, String> param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry<String, String> param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + */ + public void updateParamsForAuth(String[] authNames, List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map<String, Object> formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry<String, Object> param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map<String, Object> formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry<String, Object> param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + Headers partHeaders = Headers + .of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file)); + } else { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); + mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue()))); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for async requests. + */ + public Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of verifyingSsl and sslCaCert. + */ + private void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + Integer.toString(index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiException.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiException.java new file mode 100644 index 0000000..a6e1124 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiException.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.util.List; +import java.util.Map; + + +public class ApiException extends Exception { + + private int code = 0; + private Map<String, List<String>> responseHeaders = null; + private String responseBody = null; + + public ApiException() { + } + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, Map<String, List<String>> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, Map<String, List<String>> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, Map<String, List<String>> responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, Map<String, List<String>> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map<String, List<String>> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiResponse.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiResponse.java new file mode 100644 index 0000000..ed295dc --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param <T> The type of data that is deserialized from response body + */ +public class ApiResponse<T> { + + final private int statusCode; + final private Map<String, List<String>> headers; + final private T data; + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map<String, List<String>> headers) { + this(statusCode, headers, null); + } + + /** + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map<String, List<String>> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Configuration.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Configuration.java new file mode 100644 index 0000000..75e91c9 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Configuration.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + + +public class Configuration { + + private static ApiClient defaultApiClient = new ApiClient(); + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/GzipRequestInterceptor.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/GzipRequestInterceptor.java new file mode 100644 index 0000000..ad7ee42 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/GzipRequestInterceptor.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.io.IOException; +import okhttp3.Interceptor; +import okhttp3.MediaType; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +/** + * Encodes request bodies using gzip. + * <p> + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/JSON.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/JSON.java new file mode 100644 index 0000000..eb88c7b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/JSON.java @@ -0,0 +1,406 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.gsonfire.GsonFireBuilder; +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import okio.ByteString; + +public class JSON { + + private Gson gson; + private boolean isLenientOnJson = false; + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder(); + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase(Locale.ROOT)); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + public JSON() { + gson = createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + .registerTypeAdapter(byte[].class, byteArrayAdapter) + .create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param <T> Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public <T> T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public class ByteArrayAdapter extends TypeAdapter<byte[]> { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter<OffsetDateTime> { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length() - 5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter<LocalDate> { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + /** + * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd" format will be used (more efficient than + * SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter<java.sql.Date> { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() { + } + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter<Date> { + + private DateFormat dateFormat; + + public DateTypeAdapter() { + } + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Pair.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Pair.java new file mode 100644 index 0000000..f48eeef --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/Pair.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + + +public class Pair { + + private String name = ""; + private String value = ""; + + public Pair(String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + if (arg.trim().isEmpty()) { + return false; + } + + return true; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressRequestBody.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressRequestBody.java new file mode 100644 index 0000000..dafa1e7 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressRequestBody.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressResponseBody.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressResponseBody.java new file mode 100644 index 0000000..1769d7a --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/ProgressResponseBody.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.ResponseBody; +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} + + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/StringUtil.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/StringUtil.java new file mode 100644 index 0000000..5fd8f1d --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/StringUtil.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker; + + +public class StringUtil { + + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + * <p> + * Note: This might be replaced by utility method from commons-lang or guava someday if one of those libraries is added as dependency. + * </p> + * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/ApiKeyAuth.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/ApiKeyAuth.java new file mode 100644 index 0000000..e612615 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/ApiKeyAuth.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.util.List; +import java.util.Map; + + +public class ApiKeyAuth implements Authentication { + + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/Authentication.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/Authentication.java new file mode 100644 index 0000000..bfac6ec --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/Authentication.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.util.List; +import java.util.Map; + +public interface Authentication { + + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + */ + void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams); +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBasicAuth.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBasicAuth.java new file mode 100644 index 0000000..9d0d59e --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBasicAuth.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.util.List; +import java.util.Map; +import okhttp3.Credentials; + +public class HttpBasicAuth implements Authentication { + + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBearerAuth.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBearerAuth.java new file mode 100644 index 0000000..af1dfd6 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/HttpBearerAuth.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.util.List; +import java.util.Map; + + +public class HttpBearerAuth implements Authentication { + + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuth.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuth.java new file mode 100644 index 0000000..8647004 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuth.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.util.List; +import java.util.Map; + + +public class OAuth implements Authentication { + + private String accessToken; + + public String getAccessToken() { + return accessToken; + } + + public void setAccessToken(String accessToken) { + this.accessToken = accessToken; + } + + @Override + public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + if (accessToken != null) { + headerParams.put("Authorization", "Bearer " + accessToken); + } + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthFlow.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthFlow.java new file mode 100644 index 0000000..7936549 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthFlow.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.invoker.auth; + +public enum OAuthFlow { + accessCode, implicit, password, application +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthOkHttpClient.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthOkHttpClient.java new file mode 100644 index 0000000..077bcd3 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/OAuthOkHttpClient.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.client.invoker.auth; + +import java.io.IOException; +import java.util.Map; +import java.util.Map.Entry; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import org.apache.oltu.oauth2.client.HttpClient; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest; +import org.apache.oltu.oauth2.client.response.OAuthClientResponse; +import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory; +import org.apache.oltu.oauth2.common.exception.OAuthProblemException; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; + +public class OAuthOkHttpClient implements HttpClient { + + private OkHttpClient client; + + public OAuthOkHttpClient() { + this.client = new OkHttpClient(); + } + + public OAuthOkHttpClient(OkHttpClient client) { + this.client = client; + } + + @Override + public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers, + String requestMethod, Class<T> responseClass) + throws OAuthSystemException, OAuthProblemException { + + MediaType mediaType = MediaType.parse("application/json"); + Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri()); + + if (headers != null) { + for (Entry<String, String> entry : headers.entrySet()) { + if (entry.getKey().equalsIgnoreCase("Content-Type")) { + mediaType = MediaType.parse(entry.getValue()); + } else { + requestBuilder.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null; + requestBuilder.method(requestMethod, body); + + try { + Response response = client.newCall(requestBuilder.build()).execute(); + return OAuthClientResponseFactory.createCustomResponse( + response.body().string(), + response.body().contentType().toString(), + response.code(), + response.headers().toMultimap(), + responseClass); + } catch (IOException e) { + throw new OAuthSystemException(e); + } + } + + @Override + public void shutdown() { + // Nothing to do here + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/RetryingOAuth.java b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/RetryingOAuth.java new file mode 100644 index 0000000..14af54f --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/invoker/auth/RetryingOAuth.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.client.invoker.auth; + +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.util.List; +import java.util.Map; +import okhttp3.Interceptor; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.apache.oltu.oauth2.client.OAuthClient; +import org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; +import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse; +import org.apache.oltu.oauth2.common.exception.OAuthProblemException; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; +import org.apache.oltu.oauth2.common.message.types.GrantType; + +public class RetryingOAuth extends OAuth implements Interceptor { + + private OAuthClient oAuthClient; + + private TokenRequestBuilder tokenRequestBuilder; + + public RetryingOAuth(OkHttpClient client, TokenRequestBuilder tokenRequestBuilder) { + this.oAuthClient = new OAuthClient(new OAuthOkHttpClient(client)); + this.tokenRequestBuilder = tokenRequestBuilder; + } + + public RetryingOAuth(TokenRequestBuilder tokenRequestBuilder) { + this(new OkHttpClient(), tokenRequestBuilder); + } + + public RetryingOAuth( + String tokenUrl, + String clientId, + OAuthFlow flow, + String clientSecret, + Map<String, String> parameters + ) { + this(OAuthClientRequest.tokenLocation(tokenUrl) + .setClientId(clientId) + .setClientSecret(clientSecret)); + setFlow(flow); + if (parameters != null) { + for (String paramName : parameters.keySet()) { + tokenRequestBuilder.setParameter(paramName, parameters.get(paramName)); + } + } + } + + public void setFlow(OAuthFlow flow) { + switch (flow) { + case accessCode: + tokenRequestBuilder.setGrantType(GrantType.AUTHORIZATION_CODE); + break; + case implicit: + tokenRequestBuilder.setGrantType(GrantType.IMPLICIT); + break; + case password: + tokenRequestBuilder.setGrantType(GrantType.PASSWORD); + break; + case application: + tokenRequestBuilder.setGrantType(GrantType.CLIENT_CREDENTIALS); + break; + default: + break; + } + } + + @Override + public Response intercept(Chain chain) throws IOException { + return retryingIntercept(chain, true); + } + + private Response retryingIntercept(Chain chain, boolean updateTokenAndRetryOnAuthorizationFailure) throws IOException { + Request request = chain.request(); + + // If the request already has an authorization (e.g. Basic auth), proceed with the request as is + if (request.header("Authorization") != null) { + return chain.proceed(request); + } + + // Get the token if it has not yet been acquired + if (getAccessToken() == null) { + updateAccessToken(null); + } + + OAuthClientRequest oAuthRequest; + if (getAccessToken() != null) { + // Build the request + Request.Builder requestBuilder = request.newBuilder(); + + String requestAccessToken = getAccessToken(); + try { + oAuthRequest = + new OAuthBearerClientRequest(request.url().toString()). + setAccessToken(requestAccessToken). + buildHeaderMessage(); + } catch (OAuthSystemException e) { + throw new IOException(e); + } + + Map<String, String> headers = oAuthRequest.getHeaders(); + for (String headerName : headers.keySet()) { + requestBuilder.addHeader(headerName, headers.get(headerName)); + } + requestBuilder.url(oAuthRequest.getLocationUri()); + + // Execute the request + Response response = chain.proceed(requestBuilder.build()); + + // 401/403 response codes most likely indicate an expired access token, unless it happens two times in a row + if ( + response != null && + (response.code() == HttpURLConnection.HTTP_UNAUTHORIZED || + response.code() == HttpURLConnection.HTTP_FORBIDDEN) && + updateTokenAndRetryOnAuthorizationFailure + ) { + try { + if (updateAccessToken(requestAccessToken)) { + response.body().close(); + return retryingIntercept(chain, false); + } + } catch (Exception e) { + response.body().close(); + throw e; + } + } + return response; + } else { + return chain.proceed(chain.request()); + } + } + + /* + * Returns true if the access token has been updated + */ + public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException { + if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) { + try { + OAuthJSONAccessTokenResponse accessTokenResponse = + oAuthClient.accessToken(tokenRequestBuilder.buildBodyMessage()); + if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) { + setAccessToken(accessTokenResponse.getAccessToken()); + return !getAccessToken().equals(requestAccessToken); + } + } catch (OAuthSystemException | OAuthProblemException e) { + throw new IOException(e); + } + } + + return false; + } + + public TokenRequestBuilder getTokenRequestBuilder() { + return tokenRequestBuilder; + } + + public void setTokenRequestBuilder(TokenRequestBuilder tokenRequestBuilder) { + this.tokenRequestBuilder = tokenRequestBuilder; + } + + // Applying authorization to parameters is performed in the retryingIntercept method + @Override + public void applyToParams(List<Pair> queryParams, Map<String, String> headerParams, Map<String, String> cookieParams) { + // No implementation necessary + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntry.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntry.java new file mode 100644 index 0000000..b6f22fa --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntry.java @@ -0,0 +1,531 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * BaseDirectoryEntry + */ + +public class BaseDirectoryEntry { + + public static final String SERIALIZED_NAME_DN = "dn"; + @SerializedName(SERIALIZED_NAME_DN) + private DistinguishedName dn; + + public static final String SERIALIZED_NAME_GIVEN_NAME = "givenName"; + @SerializedName(SERIALIZED_NAME_GIVEN_NAME) + private String givenName; + + public static final String SERIALIZED_NAME_SN = "sn"; + @SerializedName(SERIALIZED_NAME_SN) + private String sn; + + public static final String SERIALIZED_NAME_CN = "cn"; + @SerializedName(SERIALIZED_NAME_CN) + private String cn; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + private String displayName; + + public static final String SERIALIZED_NAME_STREET_ADDRESS = "streetAddress"; + @SerializedName(SERIALIZED_NAME_STREET_ADDRESS) + private String streetAddress; + + public static final String SERIALIZED_NAME_POSTAL_CODE = "postalCode"; + @SerializedName(SERIALIZED_NAME_POSTAL_CODE) + private String postalCode; + + public static final String SERIALIZED_NAME_LOCALITY_NAME = "localityName"; + @SerializedName(SERIALIZED_NAME_LOCALITY_NAME) + private String localityName; + + public static final String SERIALIZED_NAME_STATE_OR_PROVINCE_NAME = "stateOrProvinceName"; + @SerializedName(SERIALIZED_NAME_STATE_OR_PROVINCE_NAME) + private String stateOrProvinceName; + + public static final String SERIALIZED_NAME_TITLE = "title"; + @SerializedName(SERIALIZED_NAME_TITLE) + private String title; + + public static final String SERIALIZED_NAME_ORGANIZATION = "organization"; + @SerializedName(SERIALIZED_NAME_ORGANIZATION) + private String organization; + + public static final String SERIALIZED_NAME_OTHER_NAME = "otherName"; + @SerializedName(SERIALIZED_NAME_OTHER_NAME) + private String otherName; + + public static final String SERIALIZED_NAME_SPECIALIZATION = "specialization"; + @SerializedName(SERIALIZED_NAME_SPECIALIZATION) + private List<String> specialization = null; + + public static final String SERIALIZED_NAME_DOMAIN_I_D = "domainID"; + @SerializedName(SERIALIZED_NAME_DOMAIN_I_D) + private List<String> domainID = null; + + public static final String SERIALIZED_NAME_PERSONAL_ENTRY = "personalEntry"; + @SerializedName(SERIALIZED_NAME_PERSONAL_ENTRY) + private Boolean personalEntry; + + public static final String SERIALIZED_NAME_DATA_FROM_AUTHORITY = "dataFromAuthority"; + @SerializedName(SERIALIZED_NAME_DATA_FROM_AUTHORITY) + private Boolean dataFromAuthority; + + + public BaseDirectoryEntry dn(DistinguishedName dn) { + + this.dn = dn; + return this; + } + + /** + * Get dn + * + * @return dn + **/ + @ApiModelProperty(required = true, value = "") + + public DistinguishedName getDn() { + return dn; + } + + + public void setDn(DistinguishedName dn) { + this.dn = dn; + } + + + /** + * HBA: Vorname, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet + * + * @return givenName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Vorname", value = "HBA: Vorname, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet") + + public String getGivenName() { + return givenName; + } + + + /** + * HBA: Name, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet + * + * @return sn + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Nachname", value = "HBA: Name, obligatorisch, wird aus dem Zertifikat übernommen / SMC-B: nicht verwendet") + + public String getSn() { + return sn; + } + + + /** + * HBA: Vorname und Nachname / SMC-B: Bezeichner: Name Wird vom VZD aus dem Zertifikatsattribut commonName übernommen. + * + * @return cn + **/ + @ApiModelProperty(example = "Vorname Nachname", required = true, value = "HBA: Vorname und Nachname / SMC-B: Bezeichner: Name Wird vom VZD aus dem Zertifikatsattribut commonName übernommen.") + + public String getCn() { + return cn; + } + + public void setCn(String cn) { + this.cn = cn; + } + + + public BaseDirectoryEntry displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + /** + * Anzeigename, kann geändert werden. Dieses Attribut wird genutzt um den Namen der Organisation gegenüber dem Anwender darzustellen (Verwendung + * als Filter-Attribut um die Suche einzuschränken und bei der Darstellung des Ergebnisses). Der Wert wird von der pflegenden Stelle festgelegt. + * + * @return displayName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Vorname Nachname", value = "Anzeigename, kann geändert werden. Dieses Attribut wird genutzt um den Namen der Organisation gegenüber dem Anwender darzustellen (Verwendung als Filter-Attribut um die Suche einzuschränken und bei der Darstellung des Ergebnisses). Der Wert wird von der pflegenden Stelle festgelegt.") + + public String getDisplayName() { + return displayName; + } + + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + public BaseDirectoryEntry streetAddress(String streetAddress) { + + this.streetAddress = streetAddress; + return this; + } + + /** + * Straße und Hausnummer Der Wert wird von der pflegenden Stelle festgelegt + * + * @return streetAddress + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Friedrichstraße 136", value = "Straße und Hausnummer Der Wert wird von der pflegenden Stelle festgelegt") + + public String getStreetAddress() { + return streetAddress; + } + + + public void setStreetAddress(String streetAddress) { + this.streetAddress = streetAddress; + } + + + public BaseDirectoryEntry postalCode(String postalCode) { + + this.postalCode = postalCode; + return this; + } + + /** + * Postleitzahl Der Wert wird von der pflegenden Stelle festgelegt + * + * @return postalCode + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "10117", value = "Postleitzahl Der Wert wird von der pflegenden Stelle festgelegt") + + public String getPostalCode() { + return postalCode; + } + + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + + public BaseDirectoryEntry localityName(String localityName) { + + this.localityName = localityName; + return this; + } + + /** + * Ort Der Wert wird von der pflegenden Stelle festgelegt + * + * @return localityName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Berlin", value = "Ort Der Wert wird von der pflegenden Stelle festgelegt") + + public String getLocalityName() { + return localityName; + } + + + public void setLocalityName(String localityName) { + this.localityName = localityName; + } + + + public BaseDirectoryEntry stateOrProvinceName(String stateOrProvinceName) { + + this.stateOrProvinceName = stateOrProvinceName; + return this; + } + + /** + * Bundesland Der Wert wird von der pflegenden Stelle festgelegt + * + * @return stateOrProvinceName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Berlin", value = "Bundesland Der Wert wird von der pflegenden Stelle festgelegt") + + public String getStateOrProvinceName() { + return stateOrProvinceName; + } + + + public void setStateOrProvinceName(String stateOrProvinceName) { + this.stateOrProvinceName = stateOrProvinceName; + } + + + public BaseDirectoryEntry title(String title) { + + this.title = title; + return this; + } + + /** + * HBA: Titel, optional / SMC-B: nicht verwendet + * + * @return title + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "HBA: Titel, optional / SMC-B: nicht verwendet") + + public String getTitle() { + return title; + } + + + public void setTitle(String title) { + this.title = title; + } + + + public BaseDirectoryEntry organization(String organization) { + + this.organization = organization; + return this; + } + + /** + * Organisation Der Wert wird von der pflegenden Stelle festgelegt + * + * @return organization + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "12345670", value = "Organisation Der Wert wird von der pflegenden Stelle festgelegt") + + public String getOrganization() { + return organization; + } + + + public void setOrganization(String organization) { + this.organization = organization; + } + + + public BaseDirectoryEntry otherName(String otherName) { + + this.otherName = otherName; + return this; + } + + /** + * Anderer Name. Wird vom VZD aus dem Zertifikatsattribut otherName übernommen. + * + * @return otherName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Anderer Name. Wird vom VZD aus dem Zertifikatsattribut otherName übernommen.") + + public String getOtherName() { + return otherName; + } + + + public void setOtherName(String otherName) { + this.otherName = otherName; + } + + + public BaseDirectoryEntry specialization(List<String> specialization) { + + this.specialization = specialization; + return this; + } + + public BaseDirectoryEntry addSpecializationItem(String specializationItem) { + if (this.specialization == null) { + this.specialization = new ArrayList<>(); + } + this.specialization.add(specializationItem); + return this; + } + + /** + * Fachgebiet Der Wert wird von der pflegenden Stelle festgelegt + * + * @return specialization + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Fachgebiet Der Wert wird von der pflegenden Stelle festgelegt") + + public List<String> getSpecialization() { + return specialization; + } + + + public void setSpecialization(List<String> specialization) { + this.specialization = specialization; + } + + + public BaseDirectoryEntry domainID(List<String> domainID) { + + this.domainID = domainID; + return this; + } + + public BaseDirectoryEntry addDomainIDItem(String domainIDItem) { + if (this.domainID == null) { + this.domainID = new ArrayList<>(); + } + this.domainID.add(domainIDItem); + return this; + } + + /** + * Ärzte: Betriebsstättennummer Der Wert wird aus dem Zertifikat übernommen (Attribut organizationName) + * + * @return domainID + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Ärzte: Betriebsstättennummer Der Wert wird aus dem Zertifikat übernommen (Attribut organizationName)") + + public List<String> getDomainID() { + return domainID; + } + + + public void setDomainID(List<String> domainID) { + this.domainID = domainID; + } + + + /** + * Wird vom VZD eingetragen / Wert == TRUE, wenn alle Zertifikate den entryType 1 haben (Berufsgruppe), Wert == FALSE sonst + * + * @return personalEntry + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "true", value = "Wird vom VZD eingetragen / Wert == TRUE, wenn alle Zertifikate den entryType 1 haben (Berufsgruppe), Wert == FALSE sonst") + + public Boolean getPersonalEntry() { + return personalEntry; + } + + + /** + * Wird vom VZD eingetragen / Wert == TRUE, wenn der Verzeichnisdienst_Eintrag von dem Kartenherausgeber geschrieben wurde, Wert + * == FALSE sonst + * + * @return dataFromAuthority + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "true", value = "Wird vom VZD eingetragen / Wert == TRUE, wenn der Verzeichnisdienst_Eintrag von dem Kartenherausgeber geschrieben wurde, Wert == FALSE sonst") + + public Boolean getDataFromAuthority() { + return dataFromAuthority; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseDirectoryEntry baseDirectoryEntry = (BaseDirectoryEntry) o; + return Objects.equals(this.dn, baseDirectoryEntry.dn) && + Objects.equals(this.givenName, baseDirectoryEntry.givenName) && + Objects.equals(this.sn, baseDirectoryEntry.sn) && + Objects.equals(this.cn, baseDirectoryEntry.cn) && + Objects.equals(this.displayName, baseDirectoryEntry.displayName) && + Objects.equals(this.streetAddress, baseDirectoryEntry.streetAddress) && + Objects.equals(this.postalCode, baseDirectoryEntry.postalCode) && + Objects.equals(this.localityName, baseDirectoryEntry.localityName) && + Objects.equals(this.stateOrProvinceName, baseDirectoryEntry.stateOrProvinceName) && + Objects.equals(this.title, baseDirectoryEntry.title) && + Objects.equals(this.organization, baseDirectoryEntry.organization) && + Objects.equals(this.otherName, baseDirectoryEntry.otherName) && + Objects.equals(this.specialization, baseDirectoryEntry.specialization) && + Objects.equals(this.domainID, baseDirectoryEntry.domainID) && + Objects.equals(this.personalEntry, baseDirectoryEntry.personalEntry) && + Objects.equals(this.dataFromAuthority, baseDirectoryEntry.dataFromAuthority); + } + + @Override + public int hashCode() { + return Objects + .hash(dn, givenName, sn, cn, displayName, streetAddress, postalCode, localityName, + stateOrProvinceName, title, organization, otherName, specialization, domainID, + personalEntry, dataFromAuthority); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseDirectoryEntry {\n"); + sb.append(" dn: ").append(toIndentedString(dn)).append("\n"); + sb.append(" givenName: ").append(toIndentedString(givenName)).append("\n"); + sb.append(" sn: ").append(toIndentedString(sn)).append("\n"); + sb.append(" cn: ").append(toIndentedString(cn)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" streetAddress: ").append(toIndentedString(streetAddress)).append("\n"); + sb.append(" postalCode: ").append(toIndentedString(postalCode)).append("\n"); + sb.append(" localityName: ").append(toIndentedString(localityName)).append("\n"); + sb.append(" stateOrProvinceName: ").append(toIndentedString(stateOrProvinceName)) + .append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" organization: ").append(toIndentedString(organization)).append("\n"); + sb.append(" otherName: ").append(toIndentedString(otherName)).append("\n"); + sb.append(" specialization: ").append(toIndentedString(specialization)).append("\n"); + sb.append(" domainID: ").append(toIndentedString(domainID)).append("\n"); + sb.append(" personalEntry: ").append(toIndentedString(personalEntry)).append("\n"); + sb.append(" dataFromAuthority: ").append(toIndentedString(dataFromAuthority)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntry.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntry.java new file mode 100644 index 0000000..35cb1df --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntry.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * CreateDirectoryEntry + */ + +public class CreateDirectoryEntry { + + public static final String SERIALIZED_NAME_DIRECTORY_ENTRY_BASE = "DirectoryEntryBase"; + @SerializedName(SERIALIZED_NAME_DIRECTORY_ENTRY_BASE) + private BaseDirectoryEntry directoryEntryBase; + + public static final String SERIALIZED_NAME_USER_CERTIFICATES = "userCertificates"; + @SerializedName(SERIALIZED_NAME_USER_CERTIFICATES) + private List<UserCertificate> userCertificates = null; + + + public CreateDirectoryEntry directoryEntryBase(BaseDirectoryEntry directoryEntryBase) { + + this.directoryEntryBase = directoryEntryBase; + return this; + } + + /** + * Get directoryEntryBase + * + * @return directoryEntryBase + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public BaseDirectoryEntry getDirectoryEntryBase() { + return directoryEntryBase; + } + + + public void setDirectoryEntryBase(BaseDirectoryEntry directoryEntryBase) { + this.directoryEntryBase = directoryEntryBase; + } + + + public CreateDirectoryEntry userCertificates(List<UserCertificate> userCertificates) { + + this.userCertificates = userCertificates; + return this; + } + + public CreateDirectoryEntry addUserCertificatesItem(UserCertificate userCertificatesItem) { + if (this.userCertificates == null) { + this.userCertificates = new ArrayList<>(); + } + this.userCertificates.add(userCertificatesItem); + return this; + } + + /** + * Get userCertificates + * + * @return userCertificates + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<UserCertificate> getUserCertificates() { + return userCertificates; + } + + + public void setUserCertificates(List<UserCertificate> userCertificates) { + this.userCertificates = userCertificates; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateDirectoryEntry createDirectoryEntry = (CreateDirectoryEntry) o; + return Objects.equals(this.directoryEntryBase, createDirectoryEntry.directoryEntryBase) && + Objects.equals(this.userCertificates, createDirectoryEntry.userCertificates); + } + + @Override + public int hashCode() { + return Objects.hash(directoryEntryBase, userCertificates); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateDirectoryEntry {\n"); + sb.append(" directoryEntryBase: ").append(toIndentedString(directoryEntryBase)).append("\n"); + sb.append(" userCertificates: ").append(toIndentedString(userCertificates)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntry.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntry.java new file mode 100644 index 0000000..2392c6b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntry.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * DirectoryEntry + */ + +public class DirectoryEntry { + + public static final String SERIALIZED_NAME_DIRECTORY_ENTRY_BASE = "DirectoryEntryBase"; + @SerializedName(SERIALIZED_NAME_DIRECTORY_ENTRY_BASE) + private BaseDirectoryEntry directoryEntryBase; + + public static final String SERIALIZED_NAME_USER_CERTIFICATES = "userCertificates"; + @SerializedName(SERIALIZED_NAME_USER_CERTIFICATES) + private List<UserCertificate> userCertificates = null; + + public static final String SERIALIZED_NAME_FACHDATEN = "Fachdaten"; + @SerializedName(SERIALIZED_NAME_FACHDATEN) + private List<Fachdaten> fachdaten = null; + + + public DirectoryEntry directoryEntryBase(BaseDirectoryEntry directoryEntryBase) { + + this.directoryEntryBase = directoryEntryBase; + return this; + } + + /** + * Get directoryEntryBase + * + * @return directoryEntryBase + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public BaseDirectoryEntry getDirectoryEntryBase() { + return directoryEntryBase; + } + + + public void setDirectoryEntryBase(BaseDirectoryEntry directoryEntryBase) { + this.directoryEntryBase = directoryEntryBase; + } + + + public DirectoryEntry userCertificates(List<UserCertificate> userCertificates) { + + this.userCertificates = userCertificates; + return this; + } + + public DirectoryEntry addUserCertificatesItem(UserCertificate userCertificatesItem) { + if (this.userCertificates == null) { + this.userCertificates = new ArrayList<>(); + } + this.userCertificates.add(userCertificatesItem); + return this; + } + + /** + * Get userCertificates + * + * @return userCertificates + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<UserCertificate> getUserCertificates() { + return userCertificates; + } + + + public void setUserCertificates(List<UserCertificate> userCertificates) { + this.userCertificates = userCertificates; + } + + + public DirectoryEntry fachdaten(List<Fachdaten> fachdaten) { + + this.fachdaten = fachdaten; + return this; + } + + public DirectoryEntry addFachdatenItem(Fachdaten fachdatenItem) { + if (this.fachdaten == null) { + this.fachdaten = new ArrayList<>(); + } + this.fachdaten.add(fachdatenItem); + return this; + } + + /** + * Get fachdaten + * + * @return fachdaten + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<Fachdaten> getFachdaten() { + return fachdaten; + } + + + public void setFachdaten(List<Fachdaten> fachdaten) { + this.fachdaten = fachdaten; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DirectoryEntry directoryEntry = (DirectoryEntry) o; + return Objects.equals(this.directoryEntryBase, directoryEntry.directoryEntryBase) && + Objects.equals(this.userCertificates, directoryEntry.userCertificates) && + Objects.equals(this.fachdaten, directoryEntry.fachdaten); + } + + @Override + public int hashCode() { + return Objects.hash(directoryEntryBase, userCertificates, fachdaten); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DirectoryEntry {\n"); + sb.append(" directoryEntryBase: ").append(toIndentedString(directoryEntryBase)).append("\n"); + sb.append(" userCertificates: ").append(toIndentedString(userCertificates)).append("\n"); + sb.append(" fachdaten: ").append(toIndentedString(fachdaten)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/DistinguishedName.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/DistinguishedName.java new file mode 100644 index 0000000..d5feb1f --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/DistinguishedName.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * DistinguishedName + */ + +public class DistinguishedName { + + public static final String SERIALIZED_NAME_UID = "uid"; + @SerializedName(SERIALIZED_NAME_UID) + private String uid; + + public static final String SERIALIZED_NAME_DC = "dc"; + @SerializedName(SERIALIZED_NAME_DC) + private List<String> dc = null; + + public static final String SERIALIZED_NAME_OU = "ou"; + @SerializedName(SERIALIZED_NAME_OU) + private List<String> ou = null; + + public static final String SERIALIZED_NAME_CN = "cn"; + @SerializedName(SERIALIZED_NAME_CN) + private String cn; + + + public DistinguishedName uid(String uid) { + + this.uid = uid; + return this; + } + + /** + * entryID: Name/ID, den den Eintrag eindeutig identifiziert. Hat für den Verzeichnisdienst_Eintrag, Certificate, KOM-LE_Fachdaten und FAD1 eines + * Verzeichniseintrags den gleichen Wert. + * + * @return uid + **/ + @ApiModelProperty(required = true, value = "entryID: Name/ID, den den Eintrag eindeutig identifiziert. Hat für den Verzeichnisdienst_Eintrag, Certificate, KOM-LE_Fachdaten und FAD1 eines Verzeichniseintrags den gleichen Wert.") + + public String getUid() { + return uid; + } + + + public void setUid(String uid) { + this.uid = uid; + } + + + public DistinguishedName dc(List<String> dc) { + + this.dc = dc; + return this; + } + + public DistinguishedName addDcItem(String dcItem) { + if (this.dc == null) { + this.dc = new ArrayList<>(); + } + this.dc.add(dcItem); + return this; + } + + /** + * Get dc + * + * @return dc + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<String> getDc() { + return dc; + } + + + public void setDc(List<String> dc) { + this.dc = dc; + } + + + public DistinguishedName ou(List<String> ou) { + + this.ou = ou; + return this; + } + + public DistinguishedName addOuItem(String ouItem) { + if (this.ou == null) { + this.ou = new ArrayList<>(); + } + this.ou.add(ouItem); + return this; + } + + /** + * Get ou + * + * @return ou + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<String> getOu() { + return ou; + } + + + public void setOu(List<String> ou) { + this.ou = ou; + } + + + public DistinguishedName cn(String cn) { + + this.cn = cn; + return this; + } + + /** + * Common Name + * + * @return cn + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Common Name") + + public String getCn() { + return cn; + } + + + public void setCn(String cn) { + this.cn = cn; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DistinguishedName distinguishedName = (DistinguishedName) o; + return Objects.equals(this.uid, distinguishedName.uid) && + Objects.equals(this.dc, distinguishedName.dc) && + Objects.equals(this.ou, distinguishedName.ou) && + Objects.equals(this.cn, distinguishedName.cn); + } + + @Override + public int hashCode() { + return Objects.hash(uid, dc, ou, cn); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DistinguishedName {\n"); + sb.append(" uid: ").append(toIndentedString(uid)).append("\n"); + sb.append(" dc: ").append(toIndentedString(dc)).append("\n"); + sb.append(" ou: ").append(toIndentedString(ou)).append("\n"); + sb.append(" cn: ").append(toIndentedString(cn)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/Error.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/Error.java new file mode 100644 index 0000000..600d23d --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/Error.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** + * Error + */ + +public class Error { + + public static final String SERIALIZED_NAME_ATTRIBUTE_NAME = "attributeName"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_NAME) + private String attributeName; + + public static final String SERIALIZED_NAME_ATTRIBUTE_ERROR = "attributeError"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_ERROR) + private String attributeError; + + + public Error attributeName(String attributeName) { + + this.attributeName = attributeName; + return this; + } + + /** + * Name des Attributs, in dem ein Fehler erkannt wurde + * + * @return attributeName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Name des Attributs, in dem ein Fehler erkannt wurde") + + public String getAttributeName() { + return attributeName; + } + + + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } + + + public Error attributeError(String attributeError) { + + this.attributeError = attributeError; + return this; + } + + /** + * Beschreibung des erkannten Fehlers + * + * @return attributeError + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Beschreibung des erkannten Fehlers") + + public String getAttributeError() { + return attributeError; + } + + + public void setAttributeError(String attributeError) { + this.attributeError = attributeError; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.attributeName, error.attributeName) && + Objects.equals(this.attributeError, error.attributeError); + } + + @Override + public int hashCode() { + return Objects.hash(attributeName, attributeError); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" attributeName: ").append(toIndentedString(attributeName)).append("\n"); + sb.append(" attributeError: ").append(toIndentedString(attributeError)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/FAD1.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/FAD1.java new file mode 100644 index 0000000..0a72dd3 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/FAD1.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.List; +import java.util.Objects; + +/** + * FAD1 + */ + +public class FAD1 { + + public static final String SERIALIZED_NAME_DN = "dn"; + @SerializedName(SERIALIZED_NAME_DN) + private DistinguishedName dn; + + public static final String SERIALIZED_NAME_MAIL = "mail"; + @SerializedName(SERIALIZED_NAME_MAIL) + private List<String> mail = null; + + + public FAD1 dn(DistinguishedName dn) { + + this.dn = dn; + return this; + } + + /** + * Get dn + * + * @return dn + **/ + @ApiModelProperty(required = true, value = "") + + public DistinguishedName getDn() { + return dn; + } + + + public void setDn(DistinguishedName dn) { + this.dn = dn; + } + + + /** + * Get mail + * + * @return mail + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<String> getMail() { + return mail; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FAD1 FAD1 = (FAD1) o; + return Objects.equals(this.dn, FAD1.dn) && + Objects.equals(this.mail, FAD1.mail); + } + + @Override + public int hashCode() { + return Objects.hash(dn, mail); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FAD1 {\n"); + sb.append(" dn: ").append(toIndentedString(dn)).append("\n"); + sb.append(" mail: ").append(toIndentedString(mail)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/Fachdaten.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/Fachdaten.java new file mode 100644 index 0000000..0620740 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/Fachdaten.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Fachdaten + */ + +public class Fachdaten { + + public static final String SERIALIZED_NAME_DN = "dn"; + @SerializedName(SERIALIZED_NAME_DN) + private DistinguishedName dn; + + public static final String SERIALIZED_NAME_F_A_D1 = "FAD1"; + @SerializedName(SERIALIZED_NAME_F_A_D1) + private List<FAD1> FAD1 = null; + + + public Fachdaten dn(DistinguishedName dn) { + + this.dn = dn; + return this; + } + + /** + * Get dn + * + * @return dn + **/ + @ApiModelProperty(required = true, value = "") + + public DistinguishedName getDn() { + return dn; + } + + + public void setDn(DistinguishedName dn) { + this.dn = dn; + } + + + public Fachdaten FAD1(List<FAD1> FAD1) { + + this.FAD1 = FAD1; + return this; + } + + public Fachdaten addFAD1Item(FAD1 FAD1Item) { + if (this.FAD1 == null) { + this.FAD1 = new ArrayList<>(); + } + this.FAD1.add(FAD1Item); + return this; + } + + /** + * Get FAD1 + * + * @return FAD1 + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<FAD1> getFAD1() { + return FAD1; + } + + + public void setFAD1(List<FAD1> FAD1) { + this.FAD1 = FAD1; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Fachdaten fachdaten = (Fachdaten) o; + return Objects.equals(this.dn, fachdaten.dn) && + Objects.equals(this.FAD1, fachdaten.FAD1); + } + + @Override + public int hashCode() { + return Objects.hash(dn, FAD1); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Fachdaten {\n"); + sb.append(" dn: ").append(toIndentedString(dn)).append("\n"); + sb.append(" FAD1: ").append(toIndentedString(FAD1)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/client/model/UserCertificate.java b/src/main/java/de/gematik/ti/epa/vzd/client/model/UserCertificate.java new file mode 100644 index 0000000..c2cc51b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/client/model/UserCertificate.java @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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. + */ + +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.1.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Jeder Verzeichniseintrag muss mindestens ein Zertifikat enthalten. + */ +@ApiModel(description = "Jeder Verzeichniseintrag muss mindestens ein Zertifikat enthalten.") + +public class UserCertificate { + + public static final String SERIALIZED_NAME_DN = "dn"; + @SerializedName(SERIALIZED_NAME_DN) + private DistinguishedName dn; + + public static final String SERIALIZED_NAME_ENTRY_TYPE = "entryType"; + @SerializedName(SERIALIZED_NAME_ENTRY_TYPE) + private String entryType; + + public static final String SERIALIZED_NAME_TELEMATIK_I_D = "telematikID"; + @SerializedName(SERIALIZED_NAME_TELEMATIK_I_D) + private String telematikID; + + public static final String SERIALIZED_NAME_PROFESSION_O_I_D = "professionOID"; + @SerializedName(SERIALIZED_NAME_PROFESSION_O_I_D) + private List<String> professionOID = null; + + /** + * Gets or Sets usage + */ + @JsonAdapter(UsageEnum.Adapter.class) + public enum UsageEnum { + KOM_LE("KOM-LE"), + + EPA("ePA"); + + private String value; + + UsageEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static UsageEnum fromValue(String value) { + for (UsageEnum b : UsageEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter<UsageEnum> { + + @Override + public void write(final JsonWriter jsonWriter, final UsageEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public UsageEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return UsageEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_USAGE = "usage"; + @SerializedName(SERIALIZED_NAME_USAGE) + private List<UsageEnum> usage = null; + + public static final String SERIALIZED_NAME_USER_CERTIFICATE = "userCertificate"; + @SerializedName(SERIALIZED_NAME_USER_CERTIFICATE) + private String userCertificate; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + + public UserCertificate dn(DistinguishedName dn) { + + this.dn = dn; + return this; + } + + /** + * Get dn + * + * @return dn + **/ + @ApiModelProperty(required = true, value = "") + + public DistinguishedName getDn() { + return dn; + } + + + public void setDn(DistinguishedName dn) { + this.dn = dn; + } + + + /** + * Eintragstyp Wird vom VZD anhand der in dem Zertifikat enthaltenen OID (Extension Admission, Attribut ProfessionOID) und der Spalte Eintragstyp + * in Tab_VZD_Mapping_Eintragstyp_und_ProfessionOID automatisch eingetragen. Siehe auch [gemSpecOID]# Tab_PKI_402 und Tab_PKI_403 + * + * @return entryType + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Eintragstyp Wird vom VZD anhand der in dem Zertifikat enthaltenen OID (Extension Admission, Attribut ProfessionOID) und der Spalte Eintragstyp in Tab_VZD_Mapping_Eintragstyp_und_ProfessionOID automatisch eingetragen. Siehe auch [gemSpecOID]# Tab_PKI_402 und Tab_PKI_403") + + public String getEntryType() { + return entryType; + } + + + public UserCertificate telematikID(String telematikID) { + + this.telematikID = telematikID; + return this; + } + + /** + * Wird beim Anlegen des Eintrags vom VZD aus dem Zertifikat übernommen (Feld registrationNumber der Extension Admission). Falls der Basiseintrag + * (baseDirectoryEntry) ohne Zertifikat angelegt wird, kann in Operation add_Directory_Entry die telematikID angegeben werden. Damit ist der + * Verzeichniseintrag bereits über die telematikID auffindbar. + * + * @return telematikID + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Wird beim Anlegen des Eintrags vom VZD aus dem Zertifikat übernommen (Feld registrationNumber der Extension Admission). Falls der Basiseintrag (baseDirectoryEntry) ohne Zertifikat angelegt wird, kann in Operation add_Directory_Entry die telematikID angegeben werden. Damit ist der Verzeichniseintrag bereits über die telematikID auffindbar.") + + public String getTelematikID() { + return telematikID; + } + + + public void setTelematikID(String telematikID) { + this.telematikID = telematikID; + } + + + /** + * Get professionOID + * + * @return professionOID + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List<String> getProfessionOID() { + return professionOID; + } + + + public UserCertificate usage(List<UsageEnum> usage) { + + this.usage = usage; + return this; + } + + public UserCertificate addUsageItem(UsageEnum usageItem) { + if (this.usage == null) { + this.usage = new ArrayList<>(); + } + this.usage.add(usageItem); + return this; + } + + /** + * Nutzungskennzeichnung kann pro Zertifikat mehrfach vergeben werden. Vorgegebener Wertebereich [KOM-LE, ePA]. Obligatorisch für LEI und KTR mit + * vorgegebenem Wert usage=ePA + * + * @return usage + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Nutzungskennzeichnung kann pro Zertifikat mehrfach vergeben werden. Vorgegebener Wertebereich [KOM-LE, ePA]. Obligatorisch für LEI und KTR mit vorgegebenem Wert usage=ePA") + + public List<UsageEnum> getUsage() { + return usage; + } + + + public void setUsage(List<UsageEnum> usage) { + this.usage = usage; + } + + + public UserCertificate userCertificate(String userCertificate) { + + this.userCertificate = userCertificate; + return this; + } + + /** + * Zertifikat im DER Format. Base64 kodiert. Die pflegende Stelle erhält das Zertifikat vom TSP oder falls das nicht möglich ist wird ein + * Ersatzverfahren abgestimmt. + * + * @return userCertificate + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Zertifikat im DER Format. Base64 kodiert. Die pflegende Stelle erhält das Zertifikat vom TSP oder falls das nicht möglich ist wird ein Ersatzverfahren abgestimmt.") + + public String getUserCertificate() { + return userCertificate; + } + + + public void setUserCertificate(String userCertificate) { + this.userCertificate = userCertificate; + } + + + public UserCertificate description(String description) { + + this.description = description; + return this; + } + + /** + * Dieses Attribut ermöglicht das Zertifikat zu beschreiben, um die Administration des VZD Eintrags zu vereinfachen. + * + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Dieses Attribut ermöglicht das Zertifikat zu beschreiben, um die Administration des VZD Eintrags zu vereinfachen.") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserCertificate userCertificate = (UserCertificate) o; + return Objects.equals(this.dn, userCertificate.dn) && + Objects.equals(this.entryType, userCertificate.entryType) && + Objects.equals(this.telematikID, userCertificate.telematikID) && + Objects.equals(this.professionOID, userCertificate.professionOID) && + Objects.equals(this.usage, userCertificate.usage) && + Objects.equals(this.userCertificate, userCertificate.userCertificate) && + Objects.equals(this.description, userCertificate.description); + } + + @Override + public int hashCode() { + return Objects.hash(dn, entryType, telematikID, professionOID, usage, userCertificate, description); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UserCertificate {\n"); + sb.append(" dn: ").append(toIndentedString(dn)).append("\n"); + sb.append(" entryType: ").append(toIndentedString(entryType)).append("\n"); + sb.append(" telematikID: ").append(toIndentedString(telematikID)).append("\n"); + sb.append(" professionOID: ").append(toIndentedString(professionOID)).append("\n"); + sb.append(" usage: ").append(toIndentedString(usage)).append("\n"); + sb.append(" userCertificate: ").append(toIndentedString(userCertificate)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/CommandNamesEnum.java b/src/main/java/de/gematik/ti/epa/vzd/gem/CommandNamesEnum.java new file mode 100644 index 0000000..efd548b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/CommandNamesEnum.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem; + +public enum CommandNamesEnum { + + ADD_DIR_ENTRY("addDirectoryEntries"), + READ_DIR_ENTRY("readDirectoryEntries"), + MOD_DIR_ENTRY("modifyDirectoryEntries"), + SMOD_DIR_ENTRY("safeModifyDirectoryEntries"), + DEL_DIR_ENTRY("deleteDirectoryEntries"), + ADD_DIR_CERT("addDirectoryEntryCertificate"), + READ_DIR_CERT("readDirectoryEntryCertificate"), + MOD_DIR_CERT("modifyDirectoryEntryCertificate"), + DEL_DIR_CERT("deleteDirectoryEntryCertificate"); + + private final String name; + + CommandNamesEnum(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } + + public static CommandNamesEnum getEntry(String name) { + for (CommandNamesEnum cn : CommandNamesEnum.values()) { + if (name.equals(cn.getName())) { + return cn; + } + } + return null; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/GemStringUtils.java b/src/main/java/de/gematik/ti/epa/vzd/gem/GemStringUtils.java new file mode 100644 index 0000000..a353496 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/GemStringUtils.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem; + +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +public class GemStringUtils { + + private static final String GOTHINC = "____ ______________________ _________ .__ .__ __ \n\\ \\ / /\\____ /\\______ \\ \\_ ___ \\| | |__| ____ _____/ |_ \n \\ Y / / / | | \\ ______ / \\ \\/| | | |/ __ \\ / \\ __\\ \n \\ / / /_ | ` \\ /_____/ \\ \\___| |_| \\ ___/| | \\ |\n \\___/ /_______ \\/_______ / \\______ /____/__|\\___ >___| /__|\n \\/ \\/ \\/ \\/ \\/ \n"; + private static final String GOOFY = " __ __ __ ___________ __ _____ __ __ ___ __ __\n| | | | (___ ) | \\ / __) \\ | (_ _) \\ ___) | \\ | | (__ __) \n| | | | / / | | ___ | / | | | | | (__ | | \\ | | | \n| | | | / / | | (___) | | | | | | | __) | | \\ \\| | | | \n \\ \\/ / / /__ | | | \\__ | |__ _| |_ | (___ | | \\ | | | \n__\\ /___( )_| /_________\\ )_/ )_( )_/ )_ | |___\\ |____| |____\n"; + private static final String FUZZY = ".-..-..----..---. .--. .-. _ .-. \n: :: :`--. :: . : : .--': : :_; .' `.\n: :: : ,',': :: : _____ : : : : .-. .--. ,-.,-.`. .'\n: `' ;.'.'_ : :; ::_____:: :__ : :_ : :' '_.': ,. : : : \n `.,' :____;:___.' `.__.'`.__;:_;`.__.':_;:_; :_;\n"; + private static final String FOURTOPS = "| |~~/|~~\\ /~~|' | \n \\ / / | |---| ||/~/|/~\\~|~\n \\/ /__|__/ \\__||\\/_| || \n"; + private static final String FENDER = "\\\\ // |'''''/ '||'''|. .|'''', '||` || \n \\\\ // // || || || || '' || \n \\\\ // // || || --- || || || .|''|, `||''|, ''||'' \n \\\\// // || || || || || ||..|| || || || \n \\/ /.....| .||...|' `|....' .||. .||. `|... .|| ||. `|..' \n"; + private static final String UNIVERS = "8b d8 888888888888 88888888ba, ,ad8888ba, 88 88 \n`8b d8' ,88 88 `\"8b d8\"' `\"8b 88 \"\" ,d \n `8b d8' ,88\" 88 `8b d8' 88 88 \n `8b d8' ,88\" 88 88 88 88 88 ,adPPYba, 8b,dPPYba, MM88MMM \n `8b d8' ,88\" 88 88 aaaaaaaa 88 88 88 a8P_____88 88P' `\"8a 88 \n `8b d8' ,88\" 88 8P \"\"\"\"\"\"\"\" Y8, 88 88 8PP\"\"\"\"\"\"\" 88 88 88 \n `888' 88\" 88 .a8P Y8a. .a8P 88 88 \"8b, ,aa 88 88 88, \n `8' 888888888888 88888888Y\"' `\"Y8888Y\"' 88 88 `\\\"Ybbd8\\\"'88 88 \\\"Y888 \"\n"; + private static final String SLANT = " _ _______ ____ ________ ___________ ________\n| | / /__ / / __ \\ / ____/ / / _/ ____/ | / /_ __/\n| | / / / / / / / /_____/ / / / / // __/ / |/ / / / \n| |/ / / /__/ /_/ /_____/ /___/ /____/ // /___/ /| / / / \n|___/ /____/_____/ \\____/_____/___/_____/_/ |_/ /_/ \n"; + private static final String MERLIN = " ___ ___ ________ ________- ______ ___ __ _______ _____ ___ ___________ \n|\" \\ /\" |(\" \"\\ |\" \"\\ /\" _ \"\\ |\" | |\" \\ /\" \"|(\\\" \\|\" \\(\" _ \") \n \\ \\ // / \\___/ :)(. ___ :)(: ( \\___)|| | || | (: ______)|.\\\\ \\ |)__/ \\\\__/ \n \\\\ \\/. ./ / ___/ |: \\ ) || \\/ \\ |: | |: | \\/ | |: \\. \\\\ | \\\\_ / \n \\. // // \\__ (| (___\\ || // \\ _ \\ |___ |. | // ___)_ |. \\ \\. | |. | \n \\\\ / (: / \"\\ |: :)(: _) \\ ( \\_|: \\ /\\ |\\(: \"|| \\ \\ | \\: | \n \\__/ \\_______)(________/ \\_______) \\_______)(__\\_|_)\\_______) \\___|\\____\\) \\__| \n"; + private static final String DIMENSION3 = "** ** ******** ******* ****** ** ** ******** **** ** **********\n/** /**//////** /**////** **////**/** /**/**///// /**/** /**/////**/// \n/** /** ** /** /** ** // /** /**/** /**//** /** /** \n//** ** ** /** /** *****/** /** /**/******* /** //** /** /** \n //** ** ** /** /**///// /** /** /**/**//// /** //**/** /** \n //**** ** /** ** //** **/** /**/** /** //**** /** \n //** ********/******* //****** /********/**/********/** //*** /** \n // //////// /////// ////// //////// // //////// // /// // "; + private static final String ISOMETRIC = " ___ ___ ___ ___ ___ ___ ___ ___ \n /\\__\\ /\\ \\ /\\ \\ /\\ \\ /\\__\\ ___ /\\ \\ /\\__\\ /\\ \\ \n /:/ / \\:\\ \\ /::\\ \\ /::\\ \\ /:/ / /\\ \\ /::\\ \\ /::| | \\:\\ \\ \n /:/ / \\:\\ \\ /:/\\:\\ \\ /:/\\:\\ \\ /:/ / \\:\\ \\ /:/\\:\\ \\ /:|:| | \\:\\ \\ \n /:/__/ ___ \\:\\ \\ /:/ \\:\\__\\ /:/ \\:\\ \\ /:/ / /::\\__\\ /::\\~\\:\\ \\ /:/|:| |__ /::\\ \\ \n |:| | /\\__\\ _______\\:\\__\\ /:/__/ \\:|__| /:/__/ \\:\\__\\ /:/__/ __/:/\\/__/ /:/\\:\\ \\:\\__\\ /:/ |:| /\\__\\ /:/\\:\\__\\\n |:| |/:/ / \\::::::::/__/ \\:\\ \\ /:/ / \\:\\ \\ \\/__/ \\:\\ \\ /\\/:/ / \\:\\~\\:\\ \\/__/ \\/__|:|/:/ / /:/ \\/__/\n |:|__/:/ / \\:\\~~\\~~ \\:\\ /:/ / \\:\\ \\ \\:\\ \\ \\::/__/ \\:\\ \\:\\__\\ |:/:/ / /:/ / \n \\::::/__/ \\:\\ \\ \\:\\/:/ / \\:\\ \\ \\:\\ \\ \\:\\__\\ \\:\\ \\/__/ |::/ / \\/__/ \n ~~~~ \\:\\__\\ \\::/__/ \\:\\__\\ \\:\\__\\ \\/__/ \\:\\__\\ /:/ / \n \\/__/ ~~ \\/__/ \\/__/ \\/__/ \\/__/ "; + private static final List<String> PICS = Arrays + .asList(GOTHINC, GOOFY, FUZZY, FOURTOPS, FENDER, UNIVERS, SLANT, MERLIN, DIMENSION3, ISOMETRIC); + public static final String LINE = "\n=====================================================================\n\t\t\t=========================================================\n=====================================================================\n"; + + public static String listToString(List<String> list) { + StringBuilder sb = new StringBuilder(); + for (String s : list) { + sb.append(s + ","); + } + if (sb.length() > 0) { + sb.setLength(sb.length() - 1); + } + return sb.toString(); + } + + public static String getPic() { + StringBuffer asciPic = new StringBuffer(); + asciPic.append(LINE); + asciPic.append(PICS.get(new Random().nextInt(GemStringUtils.PICS.size()))); + asciPic.append(LINE); + return asciPic.toString(); + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/Main.java b/src/main/java/de/gematik/ti/epa/vzd/gem/Main.java new file mode 100644 index 0000000..c88fc3f --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/Main.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem; + +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.command.ExecutionController; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class Main { + + private static final Logger LOG = LoggerFactory.getLogger(Main.class); + + public static void main(final String[] args) { + LOG.info("VZD-Client started"); + LOG.info(GemStringUtils.getPic()); + ConfigHandler.init(args); + start(); + } + + private static void start() { + List<CommandType> commands = new CommandsBuilder().buildCommands(); + ConfigHandler configHandler = ConfigHandler.getInstance(); + configHandler.adjustConnectionCount(commands); + LOG.debug("============ Execution parameter ============"); + LOG.debug("Server: " + configHandler.getBasePath()); + LOG.debug("OAuth Server: " + configHandler.getRetryingOAuthPath()); + LOG.debug("Command data: " + configHandler.getCommandsPath()); + LOG.debug("Commands in progress: " + commands.size()); + LOG.debug("============================================="); + ExecutionCollection.init(ConnectionPool.createConnectionPool(ConfigHandler.getInstance().getConnectionCount())); + new ExecutionController().execute(commands); + } + + // <editor-fold desc="Private Constructor"> + private Main() { + super(); + } + // </editor-fold> +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemCertificateAdministrationApi.java b/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemCertificateAdministrationApi.java new file mode 100644 index 0000000..5ebe760 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemCertificateAdministrationApi.java @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.api; + +import de.gematik.ti.epa.vzd.client.api.CertificateAdministrationApi; +import de.gematik.ti.epa.vzd.client.invoker.ApiCallback; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuth; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Overrides all functions of CertificateAdministration api that build calls for the different commands to add the OAuth2 Token to the header + */ +public class GemCertificateAdministrationApi extends CertificateAdministrationApi { + + private GemApiClient localVarApiClient; + + public GemCertificateAdministrationApi(GemApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + @Override + public okhttp3.Call readDirectoryCertificatesCall(String uid, String certificateEntryID, + String entryType, String telematikID, String professionOID, String usage, + final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/Certificates"; + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + if (uid != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("uid", uid)); + } + + if (certificateEntryID != null) { + localVarQueryParams.addAll( + localVarApiClient.parameterToPair("certificateEntryID", certificateEntryID)); + } + + if (entryType != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("entryType", entryType)); + } + + if (telematikID != null) { + localVarQueryParams + .addAll(localVarApiClient.parameterToPair("telematikID", telematikID)); + } + + if (professionOID != null) { + localVarQueryParams + .addAll(localVarApiClient.parameterToPair("professionOID", professionOID)); + } + + if (usage != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("usage", usage)); + } + + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = {"application/json"}; + + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + //Setze Auth token + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } + + @Override + public okhttp3.Call addDirectoryEntryCertificateCall(String uid, + UserCertificate userCertificate, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = userCertificate; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + //Setze Auth token + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } + + @Override + public okhttp3.Call deleteDirectoryEntryCertificateCall(String uid, String certificateEntryID, + final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates/{certificateEntryID}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())) + .replaceAll("\\{" + "certificateEntryID" + "\\}", + localVarApiClient.escapeString(certificateEntryID.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + //Set OAuth2 token + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } + + @Override + public okhttp3.Call modifyDirectoryEntryCertificateCall(String uid, String certificateEntryID, + UserCertificate userCertificate, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = userCertificate; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/Certificates/{certificateEntryID}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())) + .replaceAll("\\{" + "certificateEntryID" + "\\}", + localVarApiClient.escapeString(certificateEntryID.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + //Set OAuth2 token + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemDirectoryEntryAdministrationApi.java b/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemDirectoryEntryAdministrationApi.java new file mode 100644 index 0000000..c9a278d --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/api/GemDirectoryEntryAdministrationApi.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.api; + +import de.gematik.ti.epa.vzd.client.api.DirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.client.invoker.ApiCallback; +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.Pair; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuth; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.Call; + +/** + * Overrides all functions of DirectoryEntryAdministration api that build calls for the different commands to add the OAuth2 Token to the header + */ +public class GemDirectoryEntryAdministrationApi extends DirectoryEntryAdministrationApi { + + private GemApiClient localVarApiClient; + + public GemDirectoryEntryAdministrationApi(GemApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + @Override + public Call addDirectoryEntryCall(CreateDirectoryEntry createDirectoryEntry, + ApiCallback _callback) throws ApiException { + Object localVarPostBody = createDirectoryEntry; + + // create path and map variables + String localVarPath = "/DirectoryEntries"; + + List<Pair> localVarQueryParams = new ArrayList<>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<>(); + Map<String, String> localVarHeaderParams = new HashMap<>(); + Map<String, String> localVarCookieParams = new HashMap<>(); + Map<String, Object> localVarFormParams = new HashMap<>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + // add OAuth2 token for authorization + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } + + @Override + public Call deleteDirectoryEntryCall(String uid, ApiCallback _callback) + throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json;charset=UTF-8" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + // add OAuth2 token for authorization + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient + .selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, + localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, + localVarAuthNames, _callback); + } + + @Override + public Call modifyDirectoryEntryCall(String uid, BaseDirectoryEntry baseDirectoryEntry, + ApiCallback _callback) throws ApiException { + Object localVarPostBody = baseDirectoryEntry; + + // create path and map variables + String localVarPath = "/DirectoryEntries/{uid}/baseDirectoryEntries" + .replaceAll("\\{" + "uid" + "\\}", localVarApiClient.escapeString(uid.toString())); + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + // add OAuth2 token for authorization + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Override + public Call readDirectoryEntryCall(String uid, String givenName, String sn, String cn, + String displayName, String streetAddress, String postalCode, String localityName, + String stateOrProvienceName, String title, String organization, String otherName, + String specialization, String domainID, String personalEntry, String dataFromAuthority, + ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/DirectoryEntries"; + + List<Pair> localVarQueryParams = new ArrayList<Pair>(); + List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>(); + if (uid != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("uid", uid)); + } + + if (givenName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("givenName", givenName)); + } + + if (sn != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("sn", sn)); + } + + if (cn != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("cn", cn)); + } + + if (displayName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("displayName", displayName)); + } + + if (streetAddress != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("streetAddress", streetAddress)); + } + + if (postalCode != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("postalCode", postalCode)); + } + + if (localityName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("localityName", localityName)); + } + + if (stateOrProvienceName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("stateOrProvienceName", stateOrProvienceName)); + } + + if (title != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("title", title)); + } + + if (organization != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("organization", organization)); + } + + if (otherName != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("otherName", otherName)); + } + + if (specialization != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("specialization", specialization)); + } + + if (domainID != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("domainID", domainID)); + } + + if (personalEntry != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("personalEntry", personalEntry)); + } + + if (dataFromAuthority != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("dataFromAuthority", dataFromAuthority)); + } + + Map<String, String> localVarHeaderParams = new HashMap<String, String>(); + Map<String, String> localVarCookieParams = new HashMap<String, String>(); + Map<String, Object> localVarFormParams = new HashMap<String, Object>(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + // add OAuth2 token for authorization + final OAuth oAuth2Token = (OAuth) localVarApiClient.getAuthentication("OAuth"); + localVarHeaderParams.put("Authorization", "Bearer " + oAuth2Token.getAccessToken()); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[]{"OAuth2"}; + return localVarApiClient + .buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, + localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilder.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilder.java new file mode 100644 index 0000000..9afcf0f --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilder.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command; + +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.exceptions.ReadException; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import generated.CommandListType; +import generated.CommandType; +import generated.ObjectFactory; +import java.io.File; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * This class is responsible for reading the commands out of the .xml File. Before the commands can be build the ConfigHandler have to be initialized + */ +public class CommandsBuilder { + + private JAXBContext jaxbContext; + private Logger LOG = LoggerFactory.getLogger(CommandsBuilder.class); + + private static DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); + + /** + * Standard constructor initialize an jaxbContext + */ + public CommandsBuilder() { + try { + jaxbContext = JAXBContext.newInstance(ObjectFactory.class); + } catch (JAXBException e) { + throw new ReadException("Error occurred by creating JAXBContext"); + } + } + + /** + * Reads the given command file and creates a list of commands to execute + * + * @return CommandListType - List of all commands to execute + */ + public List<CommandType> buildCommands() { + CommandListType commandList; + ConfigHandler configHandler = ConfigHandler.getInstance(); + try { + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + Document doc = builderFactory.newDocumentBuilder() + .parse(new File(configHandler.getCommandsPath())); + Object obj = unmarshaller.unmarshal(doc); + Object commands = ((JAXBElement) obj).getValue(); + if (commands instanceof CommandListType) { + commandList = (CommandListType) commands; + if (addId(commandList)) { + writeCommandDataWithIds(commandList); + } + LOG.debug("Commands have been build"); + return commandList.getCommand(); + } + } catch (ParserConfigurationException | SAXException | JAXBException e) { + throw new ReadException( + "An error have been occurred while reading your command file. Please check if this file is a valid .xml file"); + } catch (IOException e) { + throw new ReadException( + "A problem with your named file have occurred. Please if check " + configHandler.getCommandsPath() + " exist"); + } + return null; + } + + private boolean addId(CommandListType commandList) { + int counter = 1; + boolean idsSet = false; + Set<String> givenIds = new HashSet<>(); + for (CommandType command : commandList.getCommand()) { + if (!StringUtils.isBlank(command.getCommandId()) && !givenIds.add(command.getCommandId())) { + LOG.error("The predefined ID \"" + command.getCommandId() + "\" occurs twice"); + throw new CommandException("The predefined ID \"" + command.getCommandId() + "\" occurs twice"); + } + } + for (CommandType command : commandList.getCommand()) { + while (givenIds.contains(String.valueOf(counter))) { + counter++; + } + if (StringUtils.isBlank(command.getCommandId())) { + command.setCommandId(String.valueOf(counter)); + counter++; + idsSet = true; + } + } + if (idsSet) { + LOG.debug("IDs have been set automatically"); + } + return idsSet; + } + + private void writeCommandDataWithIds(CommandListType commandList) throws JAXBException { + JAXBElement<CommandListType> element = new ObjectFactory().createCommandList(commandList); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.marshal(element, new File(ConfigHandler.getInstance().getCommandsPath())); + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollection.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollection.java new file mode 100644 index 0000000..e2ba7b5 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollection.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command; + +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryCertExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryCertExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ExecutionBase; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ModifyDirEntryCertExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ModifyDirEntryExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryCertExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryExecution; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.SaveModifyDirEntryExecution; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Class that maintains all the specific Executions, have to be initialisized once with a GemApiClient + */ +public class ExecutionCollection { + + private static ExecutionCollection executionCollection; + + private final ReadDirEntryExecution readDirEntryExecution; + private final ReadDirEntryCertExecution readDirEntryCertExecution; + private final AddDirEntryExecution addDirEntryExecution; + private final AddDirEntryCertExecution addDirEntryCertExecution; + private final ModifyDirEntryExecution modifyDirEntryExecution; + private final ModifyDirEntryCertExecution modifyDirEntryCertExecution; + + private static Logger LOG = LoggerFactory.getLogger(ExecutionCollection.class); + + private ArrayList<ExecutionBase> executors = new ArrayList<>(); + + + /** + * Gives the instance as long as it exists. + * + * @return + */ + public static ExecutionCollection getInstance() { + if (executionCollection == null) { + throw new InstantiationError("Please instance a executor first. It needs an ConnectionPool"); + } + return executionCollection; + } + + /** + * Instances the executions + * + * @param connectionPool + * @return + */ + public static ExecutionCollection init(IConnectionPool connectionPool) { + if (executionCollection != null) { + LOG.error("Error occurred while initializing executions. Executor is already instanced"); + throw new InstantiationError("Executor is already instanced"); + } + executionCollection = new ExecutionCollection(connectionPool); + LOG.debug("Executiors have been initialized correctly"); + + return executionCollection; + } + + private ExecutionCollection(IConnectionPool connectionPool) { + this.readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + this.readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + this.addDirEntryExecution = new AddDirEntryExecution(connectionPool); + this.addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + this.modifyDirEntryExecution = new ModifyDirEntryExecution(connectionPool); + this.modifyDirEntryCertExecution = new ModifyDirEntryCertExecution(connectionPool); + + executors.add(readDirEntryExecution); + executors.add(addDirEntryExecution); + executors.add(modifyDirEntryExecution); + executors.add(new DeleteDirEntryExecution(connectionPool)); + executors.add(readDirEntryCertExecution); + executors.add(addDirEntryCertExecution); + executors.add(modifyDirEntryCertExecution); + executors.add(new DeleteDirEntryCertExecution(connectionPool)); + executors.add(new SaveModifyDirEntryExecution(connectionPool)); + } + + + //<editor-fold desc="Getter"> + public void setExecutionCollection(ExecutionCollection executionCollection) { + this.executionCollection = executionCollection; + } + + public List<ExecutionBase> getExecutors() { + return this.executors; + } + + public ReadDirEntryExecution getReadDirEntryExecution() { + return this.readDirEntryExecution; + } + + public ReadDirEntryCertExecution getReadDirEntryCertExecution() { + return this.readDirEntryCertExecution; + } + + public AddDirEntryExecution getAddDirEntryExecution() { + return this.addDirEntryExecution; + } + + public AddDirEntryCertExecution getAddDirEntryCertExecution() { + return this.addDirEntryCertExecution; + } + + public ModifyDirEntryExecution getModifyDirEntry() { + return this.modifyDirEntryExecution; + } + + public ModifyDirEntryCertExecution getModifyDirEntryCertExecution() { + return this.modifyDirEntryCertExecution; + } + //</editor-fold> +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionController.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionController.java new file mode 100644 index 0000000..9d63786 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/ExecutionController.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command; + +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ExecutionBase; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import generated.CommandType; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * This class handles the execution process. It orders the commands to the specific executors where they belong and calls the + */ +public class ExecutionController { + + private Logger LOG = LoggerFactory.getLogger(ExecutionController.class); + + + /** + * Order the commands to the specific executions where they belong and than call the execution functions of the specific executors + * + * @param commandList + */ + public void execute(List<CommandType> commandList) { + Map<String, Boolean> report = new HashMap<>(); + loadCommands(commandList); + LOG.debug("Execution -> Run executions"); + Optional<Boolean> correctExecution; + + ExecutorService executorService = Executors.newFixedThreadPool(ConfigHandler.getInstance().getMaxParallelExecutor()); + + try { + correctExecution = executorService + .invokeAll(ExecutionCollection.getInstance().getExecutors()) + .parallelStream() + .map( + executor -> { + try { + report.put(executor.get().getName(), executor.get().getResult()); + if (!executor.get().getResult()) { + LOG.error("Error while execute commands in " + executor.get().getName()); + } else { + LOG.debug( + "All commands of " + executor.get().getName() + " operated correctly"); + } + return executor.get().getResult(); + } catch (Exception e) { + LOG.error("Something went wrong. " + e.getMessage()); + } + return false; + }) + .filter(b -> !b) + .findAny(); + } catch (InterruptedException e) { + correctExecution = Optional.of(false); + Thread.currentThread().interrupt(); + } finally { + executorService.shutdown(); + } + logReport(report, correctExecution); + + } + + private void logReport(Map<String, Boolean> report, Optional<Boolean> correctExecution) { + Iterator<String> keys = report.keySet().iterator(); + while (keys.hasNext()) { + String key = keys.next(); + LOG.info(report.get(key) + " <-- All executions for " + key + " run correctly"); + } + String path = System.getProperties().getProperty("l4j.logDir") == null ? + System.getProperties().getProperty("java.io.tmpdir") + "logs" + : System.getProperties().getProperty("l4j.logDir"); + LOG.info("Execution -> All executions done" + (correctExecution.isEmpty() ? " correctly" + : ". Some commands failed. Please look at the logfile at " + path)); + } + + private void loadCommands(List<CommandType> commandList) { + LOG.debug("Execution -> Precheck started"); + boolean commandError = false; + for (CommandType command : commandList) { + boolean unknownCommand = true; + for (ExecutionBase specificExecutor : ExecutionCollection.getInstance().getExecutors()) { + if (specificExecutor.canHandleCommand(CommandNamesEnum.getEntry(command.getName()))) { + unknownCommand = false; + if (!specificExecutor.preCheck(command)) { + commandError = true; + } + } + } + if (unknownCommand) { + LOG.error("Unknown command " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + commandError = true; + } + } + if (commandError) { + throw new CommandException("Commands not executed, preCheck failed!"); + } + LOG.debug("Execution -> Precheck successful"); + } +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/Transformer.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/Transformer.java new file mode 100644 index 0000000..7728afe --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/Transformer.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command; + +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import java.util.ArrayList; +import org.apache.commons.lang3.StringUtils; + +/** + * This helper class helps to transform the input data (CommandType) to objects the API needs + */ +public class Transformer { + + /** + * Transforms CommandType to BaseDirectorEntry + * + * @param command <type>CommandType</type> + * @return baseDirectoryEntry <type>BaseDirectoryEntry</type> + */ + public static BaseDirectoryEntry getBaseDirectoryEntryFromCommandType(CommandType command) { + BaseDirectoryEntry baseDirectoryEntry = new BaseDirectoryEntry(); + + if (command.getDn() != null) { + baseDirectoryEntry.setDn(getDnFromDnType(command.getDn())); + } + baseDirectoryEntry.setDisplayName(command.getDisplayName()); + baseDirectoryEntry.setStreetAddress(command.getStreetAddress()); + baseDirectoryEntry.setPostalCode(command.getPostalCode()); + baseDirectoryEntry.setLocalityName(command.getLocalityName()); + baseDirectoryEntry.setStateOrProvinceName(command.getStateOrProvinceName()); + // This setter is manually added to the generated class BaseDirectoryEntry + baseDirectoryEntry.setCn(command.getCn()); + baseDirectoryEntry.setTitle(command.getTitle()); + baseDirectoryEntry.setOrganization(command.getOrganization()); + baseDirectoryEntry.setOtherName(command.getOtherName()); + if (!command.getSpecialization().isEmpty()) { + baseDirectoryEntry.setSpecialization(command.getSpecialization()); + } + if (!command.getDomainID().isEmpty()) { + baseDirectoryEntry.setDomainID(command.getDomainID()); + } + return baseDirectoryEntry; + } + + private static DistinguishedName getDnFromDnType(DistinguishedNameType dn) { + DistinguishedName distinguishedName = new DistinguishedName(); + distinguishedName.setUid(dn.getUid()); + distinguishedName.setCn(dn.getCn()); + if (!dn.getDc().isEmpty()) { + distinguishedName.setDc(dn.getDc()); + } + if (!dn.getOu().isEmpty()) { + distinguishedName.setOu(dn.getOu()); + } + return distinguishedName; + } + + /** + * Transforms CommandType to CreateDirectoryEntry + * + * @param command <type>CommandType</type> + * @return baseDirectoryEntry <type>BaseDirectoryEntry</type> + */ + public static CreateDirectoryEntry getCreateDirectoryEntry(CommandType command) { + CreateDirectoryEntry createDirectoryEntry = new CreateDirectoryEntry(); + createDirectoryEntry.setDirectoryEntryBase(getBaseDirectoryEntryFromCommandType(command)); + if (!command.getUserCertificate().isEmpty()) { + createDirectoryEntry.setUserCertificates(new ArrayList<>()); + for (UserCertificateType cert : command.getUserCertificate()) { + createDirectoryEntry.getUserCertificates().add(getUserCertificate(cert)); + } + } + return createDirectoryEntry; + } + + private static UserCertificate getUserCertificate( + UserCertificateType userCertificateType) { + + UserCertificate userCertificate = new UserCertificate(); + + if (userCertificateType.getDn() != null) { + userCertificate.setDn(getDnFromDnType(userCertificateType.getDn())); + } + userCertificate.setTelematikID(userCertificateType.getTelematikID()); + if (!userCertificateType.getUsage().isEmpty()) { + for (String usage : userCertificateType.getUsage()) { + userCertificate.addUsageItem(UserCertificate.UsageEnum.fromValue(usage)); + } + } + userCertificate.setDescription(userCertificateType.getDescription()); + if (StringUtils.isNoneBlank(userCertificateType.getUserCertificate())) { + String cert = userCertificateType.getUserCertificate().replaceAll("[\n\r]", "").trim(); + userCertificate.setUserCertificate(cert); + } + + return userCertificate; + } + + public static CommandType getCommandTypeFromDirectoryEntry(DirectoryEntry entry) { + BaseDirectoryEntry baseEntry = entry.getDirectoryEntryBase(); + CommandType commandType = new CommandType(); + + commandType.setDn(getDnFromDnBase(baseEntry.getDn())); + commandType.setGivenName(baseEntry.getGivenName()); + commandType.setSn(baseEntry.getSn()); + commandType.setCn(baseEntry.getCn()); + commandType.setDisplayName(baseEntry.getDisplayName()); + commandType.setStreetAddress(baseEntry.getStreetAddress()); + commandType.setPostalCode(baseEntry.getPostalCode()); + commandType.setLocalityName(baseEntry.getLocalityName()); + commandType.setStateOrProvinceName(baseEntry.getStateOrProvinceName()); + commandType.setTitle(baseEntry.getTitle()); + commandType.setOrganization(baseEntry.getOrganization()); + commandType.setOtherName(baseEntry.getOtherName()); + commandType.getSpecialization().addAll(baseEntry.getSpecialization()); + commandType.getDomainID().addAll(baseEntry.getDomainID()); + commandType.setPersonalEntry(baseEntry.getPersonalEntry().toString()); + commandType.setDataFromAuthority(baseEntry.getDataFromAuthority().toString()); + + return commandType; + } + + private static DistinguishedNameType getDnFromDnBase(DistinguishedName dn) { + DistinguishedNameType dnType = new DistinguishedNameType(); + dnType.setUid(dn.getUid()); + dnType.setCn(dn.getCn()); + return dnType; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecution.java new file mode 100644 index 0000000..7d2bb5c --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecution.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemCertificateAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.ExecutionResult; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "AddDirectoryEntryCertificate" + */ +public class AddDirEntryCertExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(AddDirEntryCertExecution.class); + + public AddDirEntryCertExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.ADD_DIR_CERT); + } + + @Override + public boolean checkValidation(CommandType command) { + if (command.getUserCertificate().isEmpty()) { + LOG.error("No certificate element found"); + return false; + } + String uid = null; + if (command.getDn() != null) { + uid = command.getDn().getUid(); + } + for (UserCertificateType cert : command.getUserCertificate()) { + if (StringUtils.isBlank(cert.getUserCertificate())) { + LOG.error("No user certificate for element found"); + return false; + } + if (cert.getDn() != null) { + DistinguishedNameType certDn = cert.getDn(); + if (uid == null) { + uid = certDn.getUid(); + } + if (StringUtils.isNotBlank(certDn.getUid())) { + if (!uid.equals(certDn.getUid())) { + LOG.error("Mismatching uid delivered"); + return false; + } + } + } + } + if (StringUtils.isBlank(uid)) { + LOG.error("No or mismatching uid delivered"); + return false; + } + return true; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + ExecutionResult result = executeCommand(command, apiClient); + sb.append(result.getMessage()); + sb.append("--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return result.getResult(); + } catch (ApiException ex) { + sb.append(ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + protected ExecutionResult executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + StringBuffer sb = new StringBuffer(); + boolean runSuccessful = true; + int errorCode = 0; + + CreateDirectoryEntry createDirectoryEntry = Transformer.getCreateDirectoryEntry(command); + + ApiResponse<DistinguishedName> response; + for (UserCertificate userCertificate : createDirectoryEntry.getUserCertificates()) { + try { + String uid = getUid(createDirectoryEntry.getDirectoryEntryBase(), userCertificate); + response = addSingleCertificate(uid, userCertificate, apiClient); + if (response.getStatusCode() == HttpStatus.SC_CREATED) { + sb.append("\nCertificate successful added: \n" + response.getData()); + } + } catch (ApiException ex) { + runSuccessful = false; + errorCode = ex.getCode(); + sb.append("\nSomething went wrong will adding certificate. Responsecode: " + ex.getCode() + + " certificate: " + userCertificate.getUserCertificate()); + } + } + if (!runSuccessful) { + throw new ApiException(errorCode, sb.toString() + "\n" + + "At least one certificate could not be added in:" + "\n" + Transformer + .getCreateDirectoryEntry(command)); + } + return new ExecutionResult(sb.toString(), true); + } + + private String getUid(BaseDirectoryEntry directoryEntryBase, UserCertificate userCertificate) { + String uidCert = null; + String uidEntry = null; + + if (userCertificate.getDn() != null) { + uidCert = userCertificate.getDn().getUid(); + } + + if (directoryEntryBase != null) { + DistinguishedName dn = directoryEntryBase.getDn(); + if (dn != null) { + uidEntry = dn.getUid(); + } + } + return uidCert == null ? uidEntry : uidCert; + } + + private ApiResponse<DistinguishedName> addSingleCertificate(String uid, UserCertificate userCertificate, GemApiClient apiClient) + throws ApiException { + return new GemCertificateAdministrationApi(apiClient) + .addDirectoryEntryCertificateWithHttpInfo(uid, userCertificate); + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecution.java new file mode 100644 index 0000000..14b5e10 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecution.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemDirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.ExecutionResult; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "AddDirectoryEntry" + */ +public class AddDirEntryExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(AddDirEntryExecution.class); + + public AddDirEntryExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.ADD_DIR_ENTRY); + } + + @Override + public boolean checkValidation(CommandType command) { + boolean check = true; + if (command.getUserCertificate().isEmpty()) { + LOG.error("Missing certificate"); + check = false; + } else { + for (UserCertificateType userCertificateType : command.getUserCertificate()) { + String telematikId = userCertificateType.getTelematikID(); + String userCertificate = userCertificateType.getUserCertificate(); + if ((StringUtils.isBlank(telematikId) && StringUtils + .isBlank(userCertificate))) { + check = false; + } + } + } + if (!check) { + LOG.error("Missing argument -> telematikId or userCertificate in every entry have to be set." + + command.getName() + "\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + return check; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + if (isEntryPresent(command, apiClient)) { + sb.append("\nEntry is already present in VZD. Will Proceed with modify directory entry command\n"); + ExecutionResult modifyExecutionResult = doModify(command, apiClient); + sb.append(modifyExecutionResult.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end (proceeded as modify) ---"); + LOG.debug(sb.toString()); + return modifyExecutionResult.getResult(); + } else { + sb.append(executeCommand(command, apiClient).getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return true; + } + } catch (ApiException ex) { + sb.append("\nAdd directory entry execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command) + "\n" + ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + /** + * Function that execute one command and logs the result + * + * @param command + * @return + * @throws ApiException + */ + protected ExecutionResult executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + + CreateDirectoryEntry createDirectoryEntry = Transformer.getCreateDirectoryEntry(command); + ApiResponse<DistinguishedName> response = new GemDirectoryEntryAdministrationApi(apiClient) + .addDirectoryEntryWithHttpInfo(createDirectoryEntry); + if (response.getStatusCode() == HttpStatus.SC_CREATED) { + return new ExecutionResult("\nAdd directory entry execution successful operated\n" + response.getData(), true); + } else { + throw new CommandException( + "Add directory entry execution failed. Response-Status was: " + response + .getStatusCode() + "\n" + Transformer.getCreateDirectoryEntry(command)); + } + } + + private ExecutionResult doModify(CommandType command, GemApiClient apiClient) { + try { + return ExecutionCollection.getInstance().getModifyDirEntry().executeCommand(command, apiClient); + } catch (Exception ex) { + return new ExecutionResult(ex.getMessage(), false); + } + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecution.java new file mode 100644 index 0000000..697ca41 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecution.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemCertificateAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.ExecutionResult; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "DeleteDirectoryEntryCertificate" + */ +public class DeleteDirEntryCertExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(DeleteDirEntryCertExecution.class); + + + public DeleteDirEntryCertExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.DEL_DIR_CERT); + } + + @Override + public boolean checkValidation(CommandType command) { + String uid = null; + String cn; + if (command.getDn() != null) { + uid = command.getDn().getUid(); + } + List<String> listCn = new ArrayList<>(); + for (UserCertificateType userCertificateType : command.getUserCertificate()) { + if (userCertificateType.getDn() != null) { + if (uid == null) { + uid = userCertificateType.getDn().getUid(); + } + if (!userCertificateType.getDn().getUid().equals(uid)) { + LOG.error("Different Uid delivered (" + userCertificateType.getDn().getUid() + " / " + uid + " at command " + command + .getCommandId()); + return false; + } + if (StringUtils.isBlank(userCertificateType.getDn().getCn())) { + LOG.error("Missing cn"); + return false; + } + if (listCn.contains(userCertificateType.getDn().getCn())) { + LOG.error("Some cn is named twice"); + return false; + } else { + listCn.add(userCertificateType.getDn().getCn()); + } + + } + } + if (StringUtils.isBlank(uid)) { + LOG.error("Missing UId or Cn"); + return false; + } + return true; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + sb.append(executeCommand(command, apiClient).getMessage()); + sb.append("--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return true; + } catch (ApiException ex) { + sb.append(ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + protected ExecutionResult executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + StringBuffer sb = new StringBuffer(); + boolean runSuccessfull = true; + int errorCode = 0; + + CreateDirectoryEntry createDirectoryEntry = Transformer.getCreateDirectoryEntry(command); + + for (UserCertificate userCertificate : createDirectoryEntry.getUserCertificates()) { + try { + String uid = getUid(createDirectoryEntry.getDirectoryEntryBase(), userCertificate); + String cn = userCertificate.getDn().getCn(); + ApiResponse<Void> response = deleteSingleCertificate(uid, cn, apiClient); + if (response.getStatusCode() == HttpStatus.SC_OK) { + sb.append("\nCertificate successful deleted: \n" + userCertificate); + } + } catch (ApiException ex) { + runSuccessfull = false; + errorCode = ex.getCode(); + sb.append("\nSomething went wrong will deleting certificate. Responsecode: " + ex.getCode() + + " certificate: " + userCertificate.getUserCertificate()); + } + } + if (!runSuccessfull) { + throw new ApiException(errorCode, sb.toString() + "\n" + + "At least one certificate could not be deleted in:" + "\n" + Transformer + .getCreateDirectoryEntry(command)); + } + return new ExecutionResult(sb.toString(), true); + } + + private String getUid(BaseDirectoryEntry directoryEntryBase, UserCertificate userCertificate) { + String uidCert = userCertificate.getDn().getUid(); + String uidEntry = null; + + if (directoryEntryBase != null) { + DistinguishedName dn = directoryEntryBase.getDn(); + if (dn != null) { + uidEntry = dn.getUid(); + } + } + return uidCert == null ? uidEntry : uidCert; + } + + private ApiResponse<Void> deleteSingleCertificate(String uid, String certificateEntryId, GemApiClient apiClient) + throws ApiException { + return new GemCertificateAdministrationApi(apiClient) + .deleteDirectoryEntryCertificateWithHttpInfo(uid, certificateEntryId); + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecution.java new file mode 100644 index 0000000..0b0d384 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecution.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemDirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "DeleteDirectoryEntry" + */ +public class DeleteDirEntryExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(DeleteDirEntryExecution.class); + + public DeleteDirEntryExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.DEL_DIR_ENTRY); + } + + @Override + public boolean checkValidation(CommandType command) { + boolean check = true; + if (command.getDn() != null) { + if (StringUtils.isBlank(command.getDn().getUid())) { + LOG.error( + "Missing argument -> uid for command " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + check = false; + } + } else { + LOG.error("Missing element \"dn\" " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + check = false; + } + return check; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---\n"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + sb.append(executeCommand(command, apiClient)); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + } catch (ApiException ex) { + sb.append("Delete directory entry execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command) + "\n" + ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + return true; + } + }; + } + + private String executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + + ApiResponse<Void> response = new GemDirectoryEntryAdministrationApi(apiClient) + .deleteDirectoryEntryWithHttpInfo(command.getDn().getUid()); + if (response.getStatusCode() == HttpStatus.SC_OK) { + return "Delete directory entry execution successful operated for " + command.getDn().getUid(); + } else if (response.getStatusCode() == HttpStatus.SC_NOT_FOUND) { + return (command.getDn().getUid() + " could not be found"); + } else { + throw new CommandException( + "Delete directory entry execution failed. Response-Status was: " + + response.getStatusCode() + "\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBase.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBase.java new file mode 100644 index 0000000..93a7956 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBase.java @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.DirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemCertificateAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.BaseExecutionResult; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.exceptions.GemClientException; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Represents the base for every specific execution + */ +public abstract class ExecutionBase implements Callable<BaseExecutionResult> { + + private Logger LOG = LoggerFactory.getLogger(ExecutionBase.class); + protected static final int FIRST_INDEX = 0; + + protected final IConnectionPool connectionPool; + protected CommandNamesEnum execCommand; + protected List<CommandType> commands; + + public ExecutionBase(IConnectionPool connectionPool, CommandNamesEnum cmd) { + this.connectionPool = connectionPool; + this.execCommand = cmd; + this.commands = new ArrayList<>(); + } + + /** + * Every single executor validates their commands and log the missing or wrong values + * + * @param command + * @return + */ + public abstract boolean checkValidation(CommandType command); + + /** + * Creates Callable to execute one command + * + * @param command + * @return + */ + protected abstract Callable<Boolean> createCallable(CommandType command); + + /** + * Checks if the Executor can progress the named Command + * + * @param cmd + * @return + */ + public boolean canHandleCommand(CommandNamesEnum cmd) { + return this.execCommand.equals(cmd); + } + + /** + * Checks the given command for validation and adds it to the queue of commands to execute + * + * @param command + * @return + */ + public boolean preCheck(CommandType command) { + try { + if (!checkValidation(command)) { + throw new CommandException( + "Command invalid. Please check " + command.getName()); + } + commands.add(command); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + return false; + } + } + + /** + * Gets the name of the specific executor for logging + * + * @param executor + * @return + */ + protected String extractExecutorName(ExecutionBase executor) { + String[] splitClass = executor.getClass().getName().split("\\."); + return splitClass[splitClass.length - 1]; + } + + /** + * Checks if the execution was successful and logs the result + * + * @return + */ + public boolean postCheck() { + try { + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + return false; + } + + /** + * This function proceed a read command, to check if a entry without cert is already present + * + * @param command + * @return + */ + protected boolean isEntryPresent(CommandType command, GemApiClient apiClient) throws ApiException { + if (command.getDn() != null) { + CommandType searchCommand = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid(getUid(command, apiClient)); + searchCommand.setDn(dn); + try { + ApiResponse<List<DirectoryEntry>> response = ExecutionCollection.getInstance().getReadDirEntryExecution() + .executeCommand(searchCommand, apiClient); + return response.getStatusCode() == HttpStatus.SC_OK ? true : false; + } catch (ApiException ex) { + if (ex.getCode() == 0) { + throw new GemClientException( + "The server you address is probably not reachable at the moment"); + } + LOG.error(ex.getMessage()); + return false; + } + } else { + return serachByTelematikId(command, apiClient); + } + } + + /** + * This function proceed a read command, to check if a entry without cert is already present + * + * @param command + * @return + */ + private boolean serachByTelematikId(CommandType command, GemApiClient apiClient) { + UserCertificateType userCertificate = command.getUserCertificate().get(FIRST_INDEX); + if (userCertificate != null) { + try { + CommandType searchCommand = new CommandType(); + searchCommand.getUserCertificate().add(new UserCertificateType()); + searchCommand.getUserCertificate().get(FIRST_INDEX).setTelematikID(userCertificate.getTelematikID()); + ApiResponse<List<UserCertificate>> response = ExecutionCollection + .getInstance().getReadDirEntryCertExecution().executeCommand(searchCommand, apiClient); + return response.getStatusCode() == HttpStatus.SC_OK && response.getData().size() == 1 ? true : false; + } catch (ApiException ex) { + if (ex.getCode() == 0) { + throw new GemClientException( + "The server you address is probably not reachable at the moment"); + } + return false; + } + } + throw new GemClientException("No valid parameter found for present check" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + } + + public boolean searchByUserCertificate(CommandType command, GemApiClient apiClient) { + ApiResponse<List<UserCertificate>> response; + try { + response = ExecutionCollection.getInstance().getReadDirEntryCertExecution() + .executeCommand(command, apiClient); + } catch (ApiException ex) { + if (ex.getCode() == 0) { + throw new GemClientException( + "The server you address is probably not reachable at the moment"); + } + LOG.error(ex.getMessage()); + return false; + } + if (response.getData().size() == command.getUserCertificate().size()) { + return true; + } + return false; + } + + public String getUidByTelematikId(String telematikId, GemApiClient apiClient) throws ApiException { + ApiResponse<List<UserCertificate>> response = null; + try { + response = new GemCertificateAdministrationApi(apiClient) + .readDirectoryCertificatesWithHttpInfo(null, null, null, + telematikId, null, null); + if (!response.getData().isEmpty()) { + return response.getData().get(FIRST_INDEX).getDn().getUid(); + } + } catch (ApiException ex) { + if (ex.getCode() == 0) { + throw new GemClientException( + "The server you address is probably not reachable at the moment"); + } + if (ex.getCode() == 404) { + return null; + } + } + throw new ApiException("Problem occurred while finding uid via telematikId"); + } + + + @Override + public BaseExecutionResult call() { + LOG.debug("CALL " + extractExecutorName(this)); + + if (commands.size() == 0) { + LOG.debug("CALL END " + extractExecutorName(this)); + return new BaseExecutionResult(extractExecutorName(this), true); + } + List<Callable<Boolean>> callables = new ArrayList<>(); + ExecutorService executorService = Executors.newFixedThreadPool(ConfigHandler.getInstance().getMaxParaExecutionsPerExecutor()); + for (CommandType command : commands) { + callables.add(createCallable(command)); + } + try { + List<Future<Boolean>> futures = executorService.invokeAll(callables); + Optional<Future<Boolean>> first = + futures.stream() + .filter( + booleanFuture -> { + try { + return !booleanFuture.get(); + } catch (InterruptedException | ExecutionException e) { + Thread.currentThread().interrupt(); + return false; + } + }) + .findFirst(); + if (first.isPresent()) { + return new BaseExecutionResult(extractExecutorName(this), false); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return new BaseExecutionResult(extractExecutorName(this), false); + } finally { + LOG.debug("CALL END " + extractExecutorName(this)); + executorService.shutdown(); + } + + return new BaseExecutionResult(extractExecutorName(this), true); + } + + + protected String getUid(CommandType command, GemApiClient apiClient) throws ApiException { + String uidFromTelematikID = null; + String uidFromCommand = null; + + if (command.getDn() != null) { + uidFromCommand = command.getDn().getUid(); + } + if (!command.getUserCertificate().isEmpty()) { + if (command.getUserCertificate().get(FIRST_INDEX).getDn() != null && StringUtils.isBlank(uidFromCommand)) { + uidFromCommand = command.getUserCertificate().get(FIRST_INDEX).getDn().getUid(); + } + if (StringUtils.isNotBlank(command.getUserCertificate().get(FIRST_INDEX).getTelematikID())) { + uidFromTelematikID = getUidByTelematikId(command.getUserCertificate().get(FIRST_INDEX).getTelematikID(), apiClient); + } + } + if (StringUtils.isNotBlank(uidFromCommand) && StringUtils.isNotBlank(uidFromTelematikID)) { + if (!uidFromCommand.equals(uidFromTelematikID)) { + throw new ApiException("UID delivered by TelematikId does not match the UID in command file"); + } + } + return StringUtils.isBlank(uidFromCommand) ? uidFromTelematikID : uidFromCommand; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryCertExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryCertExecution.java new file mode 100644 index 0000000..f6e3684 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryCertExecution.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.CreateDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemCertificateAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "ModifyDirectoryEntryCertificate" + */ +public class ModifyDirEntryCertExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(ModifyDirEntryCertExecution.class); + + public ModifyDirEntryCertExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.MOD_DIR_CERT); + } + + @Override + public boolean checkValidation(CommandType command) { + if (command.getUserCertificate() != null) { + for (UserCertificateType cert : command.getUserCertificate()) { + if (checkSingleUserCertificate(cert)) { + return false; + } + } + } + return true; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + LOG.info("The execution for ModifyCertificate is exposed"); + return new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + return true; + } + }; + } + + private boolean checkSingleUserCertificate(UserCertificateType cert) { + if (cert.getDn() != null) { + DistinguishedNameType dn = cert.getDn(); + if (StringUtils.isBlank(dn.getUid()) || StringUtils.isBlank(dn.getCn())) { + return false; + } + } + return true; + } + + + protected ApiResponse<UserCertificate> executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + CreateDirectoryEntry createDirectoryEntry = Transformer.getCreateDirectoryEntry(command); + ApiResponse<UserCertificate> response = null; + + for (UserCertificate userCertificate : createDirectoryEntry.getUserCertificates()) { + try { + response = new GemCertificateAdministrationApi(apiClient) + .modifyDirectoryEntryCertificateWithHttpInfo(userCertificate.getDn().getUid(), + userCertificate.getDn().getCn(), userCertificate); + if (response.getStatusCode() == HttpStatus.SC_OK) { + LOG.debug( + "Modify directory entry execution successful operated\n" + response.getData()); + } else { + throw new CommandException( + "Modify directory entry execution failed. Response-Status was: " + response + .getStatusCode() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + } + } catch (ApiException e) { + LOG.error("ModifyCertExecution could not be proceed. " + e.getMessage()); + } + } + return response; + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecution.java new file mode 100644 index 0000000..4fabbcf --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecution.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemDirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.ExecutionResult; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "ModifyDirectoryEntry" + */ +public class ModifyDirEntryExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(ModifyDirEntryExecution.class); + + public ModifyDirEntryExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.MOD_DIR_ENTRY); + } + + @Override + public boolean checkValidation(CommandType command) { + if (command.getDn() != null) { + if (StringUtils.isBlank(command.getDn().getUid())) { + LOG.error( + "Missing argument -> uid for command " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + return false; + } + return true; + } + if (!command.getUserCertificate().isEmpty()) { + String telematikId = command.getUserCertificate().get(0).getTelematikID(); + for (UserCertificateType userCertificateType : command.getUserCertificate()) { + if (!telematikId.equals(userCertificateType.getTelematikID())) { + return false; + } + } + return true; + } + LOG.error("Missing element \"dn\" " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + return false; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---\n"); + + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + if (isEntryPresent(command, apiClient)) { + ExecutionResult modifyExecutionResult = executeCommand(command, apiClient); + sb.append(modifyExecutionResult.getMessage()); + sb.append("--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return modifyExecutionResult.getResult(); + } else { + sb.append("\nEntry is not present in VZD. Will Proceed with add directory entry command\n"); + ExecutionResult addExecutionResult = doAdd(command, apiClient); + sb.append(addExecutionResult.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end (proceeded as add) ---"); + return addExecutionResult.getResult(); + } + } catch (ApiException ex) { + sb.append("Modify directory entry execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)+ "\n" + ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + /** + * Function that execute one command and logs the result + * + * @param command + * @return + * @throws ApiException + */ + protected ExecutionResult executeCommand(CommandType command, GemApiClient apiClient) + throws ApiException { + + BaseDirectoryEntry baseDirectoryEntry = Transformer + .getBaseDirectoryEntryFromCommandType(command); + if (baseDirectoryEntry.getDn() == null) { + baseDirectoryEntry.setDn(new DistinguishedName()); + } + if (StringUtils.isBlank(baseDirectoryEntry.getDn().getUid())) { + baseDirectoryEntry.getDn().setUid(getUid(command, apiClient)); + } + ApiResponse<DistinguishedName> response = new GemDirectoryEntryAdministrationApi(apiClient) + .modifyDirectoryEntryWithHttpInfo(baseDirectoryEntry.getDn().getUid(), baseDirectoryEntry); + if (response.getStatusCode() == HttpStatus.SC_OK) { + return (new ExecutionResult( + "Modify directory entry execution successful operated\n" + response.getData(), true)); + } else { + throw new CommandException( + "Modify directory entry execution failed. Response status was: " + + response.getStatusCode() + "\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + } + + private ExecutionResult doAdd(CommandType command, GemApiClient apiClient) throws ApiException { + LOG.debug("Entry not present at VZD. Will proceed with add directory entry command"); + return ExecutionCollection.getInstance().getAddDirEntryExecution().executeCommand(command, apiClient); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecution.java new file mode 100644 index 0000000..cc64554 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecution.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.GemStringUtils; +import de.gematik.ti.epa.vzd.gem.api.GemCertificateAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Specific execution for Command "ReadDirectoryEntryCertificate" + */ +public class ReadDirEntryCertExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(ReadDirEntryCertExecution.class); + + public ReadDirEntryCertExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.READ_DIR_CERT); + } + + @Override + public boolean checkValidation(CommandType command) { + if (command.getUserCertificate().isEmpty()) { + LOG.error("No certificate delivered for command " + Transformer.getCreateDirectoryEntry(command)); + return false; + } + for (UserCertificateType cert : command.getUserCertificate()) { + if (checkSingleCertificate(cert) == false) { + return false; + } + } + return true; + } + + private boolean checkSingleCertificate(UserCertificateType cert) { + List<String> params = new ArrayList<>(); + if (cert.getDn() != null) { + params.add(cert.getDn().getUid()); + } + params.add(cert.getEntryType()); + params.add(cert.getTelematikID()); + params.add(cert.getProfessionOID()); + if (!cert.getUsage().isEmpty()) { + params.add("usage Vorhanden"); + } + for (String param : params) { + if (!StringUtils.isBlank(param)) { + return true; + } + } + return false; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---\n"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + executeCommand(command, apiClient).getData().forEach(directoryEntry -> sb.append("Entry found: " + directoryEntry)); + sb.append("--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + } catch (ApiException ex) { + sb.append("Read directory entry cert execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command) + "\n" + ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + return true; + } + }; + } + + protected ApiResponse<List<UserCertificate>> executeCommand(CommandType command, GemApiClient apiClient) + throws ApiException { + + ApiResponse<List<UserCertificate>> result = null; + for (UserCertificateType cert : command.getUserCertificate()) { + + String uid = null; + String cn = null; + if (cert.getDn() != null) { + uid = cert.getDn().getUid(); + cn = cert.getDn().getCn(); + } + String entryType = cert.getEntryType(); + String telematikID = cert.getTelematikID(); + String professionOID = cert.getProfessionOID(); + String usage = null; + if (cert.getUsage().isEmpty()) { + usage = GemStringUtils.listToString(cert.getUsage()); + } + ApiResponse<List<UserCertificate>> tempResult = new GemCertificateAdministrationApi(apiClient) + .readDirectoryCertificatesWithHttpInfo(uid, cn, entryType, + telematikID, professionOID, usage); + if (result == null) { + result = tempResult; + } else { + result.getData().addAll(tempResult.getData()); + } + } + return result; + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + return false; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecution.java new file mode 100644 index 0000000..3d198ed --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecution.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.DirectoryEntry; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.GemStringUtils; +import de.gematik.ti.epa.vzd.gem.api.GemDirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Specific execution for Command "ReadDirectoryEntry" + */ +public class ReadDirEntryExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(ReadDirEntryExecution.class); + + public ReadDirEntryExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.READ_DIR_ENTRY); + } + + @Override + public boolean checkValidation(CommandType command) { + boolean check = certificateCheck(command.getUserCertificate()); + if (!check) { + List<String> params = new ArrayList<>(); + if (command.getDn() != null) { + params.add(command.getDn().getUid()); + } + params.add(command.getGivenName()); + params.add(command.getSn()); + params.add(command.getCn()); + params.add(command.getDisplayName()); + params.add(command.getStreetAddress()); + params.add(command.getPostalCode()); + params.add(command.getLocalityName()); + params.add(command.getStateOrProvinceName()); + params.add(command.getTitle()); + params.add(command.getOrganization()); + params.add(command.getOtherName()); + params.add(GemStringUtils.listToString(command.getSpecialization())); + params.add(GemStringUtils.listToString(command.getDomainID())); + params.add(command.getPersonalEntry()); + params.add(command.getDataFromAuthority()); + + for (String parameter : params) { + if (!StringUtils.isBlank(parameter)) { + check = true; + } + } + } + if (!check) { + LOG.error("Missing argument -> The given command have no argument to search for or given different TelematikIds delivered " + command + .getName() + + "\n" + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + return check; + } + + private boolean certificateCheck(List<UserCertificateType> userCertificate) { + if (!userCertificate.isEmpty()) { + String telematikId = userCertificate.get(FIRST_INDEX).getTelematikID(); + for (UserCertificateType cert : userCertificate) { + if (!cert.getTelematikID().equals(telematikId) || StringUtils.isBlank(cert.getTelematikID())) { + return false; + } + } + return true; + } + return false; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + return new Callable<Boolean>() { + + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---\n"); + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + executeCommand(command, apiClient).getData().forEach(directoryEntry -> sb.append("Entry found: " + directoryEntry)); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return true; + } catch (ApiException ex) { + sb.append("\nRead directory entry execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command) + "\n" + ex.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + public ApiResponse<List<DirectoryEntry>> executeCommand(CommandType command, GemApiClient apiClient) throws ApiException { + + String uid = getUid(command, apiClient); + String givenName = command.getGivenName(); + String sn = command.getSn(); + String cn = command.getCn(); + String displayName = command.getDisplayName(); + String streetAddress = command.getStreetAddress(); + String postalCode = command.getPostalCode(); + String localityName = command.getLocalityName(); + String stateOrProvinceName = command.getStateOrProvinceName(); + String title = command.getTitle(); + String organization = command.getOrganization(); + String otherName = command.getOtherName(); + String specialization = GemStringUtils.listToString(command.getSpecialization()); + String domainID = GemStringUtils.listToString(command.getDomainID()); + String personalEntry = command.getPersonalEntry(); + String dataFromAuthority = command.getDataFromAuthority(); + + if (!command.getUserCertificate().isEmpty()) { + if (StringUtils.isBlank(uid) && StringUtils.isNotBlank(command.getUserCertificate().get(0).getTelematikID())) { + throw new ApiException("No entry present for telematikID: " + command.getUserCertificate().get(0).getTelematikID()); + } + } + ApiResponse<List<DirectoryEntry>> response = + new GemDirectoryEntryAdministrationApi(apiClient).readDirectoryEntryWithHttpInfo(uid, givenName, sn, cn, + displayName, streetAddress, postalCode, localityName, stateOrProvinceName, title, + organization, otherName, specialization, domainID, personalEntry, + dataFromAuthority); + if (response.getStatusCode() == HttpStatus.SC_OK) { + return response; + } else { + throw new CommandException( + "Read directory entry execution failed. Response status was: " + + response.getStatusCode() + "\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + } + + @Override + public boolean postCheck() { + try { + super.postCheck(); + return true; + } catch (Exception ex) { + LOG.error(ex.getMessage()); + } + + return false; + } +} + diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirEntryExecution.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirEntryExecution.java new file mode 100644 index 0000000..1d06ce2 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirEntryExecution.java @@ -0,0 +1,184 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.ApiResponse; +import de.gematik.ti.epa.vzd.client.model.BaseDirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DirectoryEntry; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.gem.CommandNamesEnum; +import de.gematik.ti.epa.vzd.gem.api.GemDirectoryEntryAdministrationApi; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.command.Transformer; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto.ExecutionResult; +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import java.util.List; +import java.util.concurrent.Callable; +import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SaveModifyDirEntryExecution extends ExecutionBase { + + private Logger LOG = LoggerFactory.getLogger(SaveModifyDirEntryExecution.class); + private static final int FIRST_INDEX = 0; + + public SaveModifyDirEntryExecution(IConnectionPool connectionPool) { + super(connectionPool, CommandNamesEnum.SMOD_DIR_ENTRY); + } + + @Override + public boolean checkValidation(CommandType command) { + if (command.getDn() != null) { + if (StringUtils.isBlank(command.getDn().getUid())) { + LOG.error( + "Missing argument -> uid for command " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + return false; + } + return true; + } + if (!command.getUserCertificate().isEmpty()) { + String telematikId = command.getUserCertificate().get(FIRST_INDEX).getTelematikID(); + for (UserCertificateType userCertificateType : command.getUserCertificate()) { + if (!telematikId.equals(userCertificateType.getTelematikID())) { + return false; + } + } + return true; + } + LOG.error("Missing element \"dn\" " + command.getName() + "\n" + Transformer + .getBaseDirectoryEntryFromCommandType(command)); + return false; + } + + @Override + protected Callable<Boolean> createCallable(CommandType command) { + + return new Callable<Boolean>() { + @Override + public Boolean call() throws Exception { + StringBuffer sb = new StringBuffer(); + sb.append("\n--- Command " + command.getCommandId() + " ---\n"); + + try (GemApiClient apiClient = connectionPool.getConnection()) { + apiClient.validateToken(); + if (isEntryPresent(command, apiClient)) { + CommandType safeCommand = getSaveCommand(command, apiClient); + ExecutionResult modifyExecutionResult = executeCommand(safeCommand, apiClient); + sb.append(modifyExecutionResult.getMessage()); + sb.append("--- Command " + safeCommand.getCommandId() + " end ---"); + LOG.debug(sb.toString()); + return modifyExecutionResult.getResult(); + } else { + sb.append("\nEntry is not present in VZD. Will Proceed with add directory entry command\n"); + ExecutionResult addExecutionResult = doAdd(command, apiClient); + sb.append(addExecutionResult.getMessage()); + sb.append("\n--- Command " + command.getCommandId() + " end (proceeded as add) ---"); + return addExecutionResult.getResult(); + } + } catch (ApiException ex) { + sb.append("Save modify directory entry execution failed\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + sb.append("\n--- Command " + command.getCommandId() + " end ---"); + LOG.error(sb.toString()); + return false; + } + } + }; + } + + private CommandType getSaveCommand(CommandType command, GemApiClient apiClient) throws ApiException { + ApiResponse<List<DirectoryEntry>> response = new GemDirectoryEntryAdministrationApi(apiClient) + .readDirectoryEntryWithHttpInfo(command.getDn().getUid(), null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null); + CommandType saveCommand = Transformer.getCommandTypeFromDirectoryEntry(response.getData().get(0)); + + saveCommand.setCommandId(command.getCommandId()); + saveCommand.setName(command.getName()); + + if (command.getDn() != null) { + saveCommand.setDn(command.getDn()); + } + if (StringUtils.isNotBlank(command.getGivenName())) { + saveCommand.setGivenName(command.getGivenName()); + } + if (StringUtils.isNotBlank(command.getSn())) { + saveCommand.setSn(command.getSn()); + } + if (StringUtils.isNotBlank(command.getStreetAddress())) { + saveCommand.setStreetAddress(command.getStreetAddress()); + } + if (StringUtils.isNotBlank(command.getPostalCode())) { + saveCommand.setPostalCode(command.getPostalCode()); + } + if (StringUtils.isNotBlank(command.getLocalityName())) { + saveCommand.setLocalityName(command.getLocalityName()); + } + if (StringUtils.isNotBlank(command.getStateOrProvinceName())) { + saveCommand.setStateOrProvinceName(command.getStateOrProvinceName()); + } + if (StringUtils.isNotBlank(command.getCn())) { + saveCommand.setCn(command.getCn()); + } + if (StringUtils.isNotBlank(command.getDisplayName())) { + saveCommand.setDisplayName(command.getDisplayName()); + } + if (StringUtils.isNotBlank(command.getTitle())) { + saveCommand.setTitle(command.getTitle()); + } + if (StringUtils.isNotBlank(command.getOrganization())) { + saveCommand.setOrganization(command.getOrganization()); + } + if (StringUtils.isNotBlank(command.getOtherName())) { + saveCommand.setOtherName(command.getOtherName()); + } + if (!command.getSpecialization().isEmpty()) { + while (!saveCommand.getSpecialization().isEmpty()) { + saveCommand.getSpecialization().remove(FIRST_INDEX); + } + saveCommand.getSpecialization().addAll(command.getSpecialization()); + } + if (!command.getDomainID().isEmpty()) { + while (!saveCommand.getDomainID().isEmpty()) { + saveCommand.getDomainID().remove(FIRST_INDEX); + } + saveCommand.getDomainID().addAll(command.getDomainID()); + } + + return saveCommand; + } + + protected ExecutionResult executeCommand(CommandType command, GemApiClient apiClient) + throws ApiException { + + BaseDirectoryEntry baseDirectoryEntry = Transformer + .getBaseDirectoryEntryFromCommandType(command); + if (baseDirectoryEntry.getDn() == null) { + baseDirectoryEntry.setDn(new DistinguishedName()); + } + if (StringUtils.isBlank(baseDirectoryEntry.getDn().getUid())) { + baseDirectoryEntry.getDn().setUid(getUid(command, apiClient)); + } + ApiResponse<DistinguishedName> response = new GemDirectoryEntryAdministrationApi(apiClient) + .modifyDirectoryEntryWithHttpInfo(baseDirectoryEntry.getDn().getUid(), baseDirectoryEntry); + if (response.getStatusCode() == HttpStatus.SC_OK) { + return (new ExecutionResult( + "Modify directory entry execution successful operated\n" + response.getData(), true)); + } else { + throw new CommandException( + "Modify directory entry execution failed. Response status was: " + + response.getStatusCode() + "\n" + + Transformer.getBaseDirectoryEntryFromCommandType(command)); + } + } + + private ExecutionResult doAdd(CommandType command, GemApiClient apiClient) throws ApiException { + LOG.debug("Entry not present at VZD. Will proceed with add directory entry command"); + return ExecutionCollection.getInstance().getAddDirEntryExecution().executeCommand(command, apiClient); + } +} \ No newline at end of file diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/BaseExecutionResult.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/BaseExecutionResult.java new file mode 100644 index 0000000..b7d356e --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/BaseExecutionResult.java @@ -0,0 +1,20 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto; + +public class BaseExecutionResult { + + private final String name; + private final Boolean result; + + public BaseExecutionResult(String name, Boolean result) { + this.name = name; + this.result = result; + } + + public String getName() { + return name; + } + + public Boolean getResult() { + return result; + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/ExecutionResult.java b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/ExecutionResult.java new file mode 100644 index 0000000..bcf8885 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/dto/ExecutionResult.java @@ -0,0 +1,21 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions.dto; + +public class ExecutionResult { + + private final String message; + private final Boolean result; + + public ExecutionResult(String message, Boolean result) { + this.message = message; + this.result = result; + } + + public String getMessage() { + return message; + } + + public Boolean getResult() { + return result; + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/CommandException.java b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/CommandException.java new file mode 100644 index 0000000..7f8cc6b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/CommandException.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.exceptions; + +/** + * Exception that should be thrown if something went wrong during executing commands + */ +public class CommandException extends RuntimeException { + + public CommandException() { + } + + public CommandException(String message) { + super(message); + } + + public CommandException(String message, Throwable cause) { + super(message, cause); + } + + public CommandException(Throwable cause) { + super(cause); + } + + protected CommandException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ConnectionAlreadyReleased.java b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ConnectionAlreadyReleased.java new file mode 100644 index 0000000..97fea9b --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ConnectionAlreadyReleased.java @@ -0,0 +1,8 @@ +package de.gematik.ti.epa.vzd.gem.exceptions; + +public class ConnectionAlreadyReleased extends RuntimeException { + + public ConnectionAlreadyReleased() { + super("The Connection is already released!"); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/GemClientException.java b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/GemClientException.java new file mode 100644 index 0000000..f663647 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/GemClientException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.exceptions; + +public class GemClientException extends RuntimeException { + + public GemClientException() { + } + + public GemClientException(String message) { + super(message); + } + + public GemClientException(String message, Throwable cause) { + super(message, cause); + } + + public GemClientException(Throwable cause) { + super(cause); + } + + protected GemClientException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ReadException.java b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ReadException.java new file mode 100644 index 0000000..6bf858a --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/ReadException.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.exceptions; + +/** + * Exception that should be thrown when something while reading files went wrong + */ +public class ReadException extends RuntimeException { + + public ReadException() { + } + + public ReadException(String message) { + super(message); + } + + public ReadException(String message, Throwable cause) { + super(message, cause); + } + + public ReadException(Throwable cause) { + super(cause); + } + + protected ReadException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/WrongConnection.java b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/WrongConnection.java new file mode 100644 index 0000000..73fd0f1 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/exceptions/WrongConnection.java @@ -0,0 +1,8 @@ +package de.gematik.ti.epa.vzd.gem.exceptions; + +public class WrongConnection extends RuntimeException { + + public WrongConnection() { + super("Connection is not associated with this ConnectionPool"); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/AccessHandler.java b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/AccessHandler.java new file mode 100644 index 0000000..359b760 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/AccessHandler.java @@ -0,0 +1,167 @@ +package de.gematik.ti.epa.vzd.gem.invoker; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import de.gematik.ti.epa.vzd.client.invoker.auth.HttpBasicAuth; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuth; +import de.gematik.ti.epa.vzd.gem.exceptions.GemClientException; +import de.gematik.ti.epa.vzd.oauth2.URLConnectionClient; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.time.LocalDateTime; +import org.apache.oltu.oauth2.client.OAuthClient; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest; +import org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse; +import org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse; +import org.apache.oltu.oauth2.common.exception.OAuthProblemException; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; +import org.apache.oltu.oauth2.common.message.types.GrantType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AccessHandler { + + private static final Logger LOG = LoggerFactory.getLogger(AccessHandler.class); + private static AccessHandler tokenCreator; + private OAuth oAuth2Token; + private LocalDateTime tokenvalidationDate; + private HttpBasicAuth baseAuth; + + private AccessHandler() { + baseAuth = getHttpBasicAuthFromFile(); + } + + public static AccessHandler getInstance() { + if (tokenCreator == null) { + tokenCreator = new AccessHandler(); + } + return tokenCreator; + } + + public OAuth getOAuth2Token() throws OAuthSystemException, OAuthProblemException { + if (oAuth2Token == null) { + oAuth2Token = getNewOAuth2Token(); + } + validateToken(); + return oAuth2Token; + } + + /** + * Requests an OAuth2 Token with Username and Password + * + * @return + * @throws OAuthSystemException + * @throws OAuthProblemException + */ + public OAuth getNewOAuth2Token() throws OAuthProblemException, OAuthSystemException { + LOG.debug("Trying to get new access token"); + + OAuthClientRequest request = OAuthClientRequest + .tokenLocation(ConfigHandler.getInstance().getRetryingOAuthPath()) + .setClientId(baseAuth.getUsername()) + .setClientSecret(baseAuth.getPassword()) + .setGrantType(GrantType.CLIENT_CREDENTIALS) + .buildBodyMessage(); + + request.setHeader("Accept", "application/json"); + + OAuthClient oAuthClient; + + ConfigHandler configHandler = ConfigHandler.getInstance(); + if (configHandler.isProxySet()) { + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(configHandler.getProxyHost(), configHandler.getProxyPort())); + oAuthClient = new OAuthClient(new URLConnectionClient(proxy)); + } else { + oAuthClient = new OAuthClient(new URLConnectionClient()); + } + + OAuthAccessTokenResponse oAuthResponse = oAuthClient + .accessToken(request, OAuthJSONAccessTokenResponse.class); + + JsonObject jObj = new JsonParser().parse(oAuthResponse.getBody()).getAsJsonObject(); + OAuth oAuth = new OAuth(); + oAuth.setAccessToken(jObj.get("access_token").toString().replaceAll("\"", "")); + setTokenValidation(jObj.get("expires_in").toString()); + LOG.debug("Requesting new OAuth2 token successful"); + return oAuth; + } + + /** + * Sets the time - 10% until the token expires. This ensures that the token is every time valid + * + * @param expires_in is an String with numbers. For example 3600 equals 1 hour. + */ + private void setTokenValidation(String expires_in) { + int seconds = Integer.parseInt(expires_in); + int secureSeconds = (int) (seconds * 0.90); + tokenvalidationDate = LocalDateTime.now().plusSeconds(secureSeconds); + } + + /** + * Checks if the token is still valid. If not request a new one + * + * @return + */ + private boolean validateToken() { + if (LocalDateTime.now().isBefore(tokenvalidationDate)) { + return true; + } + try { + getNewOAuth2Token(); + } catch (OAuthProblemException | OAuthSystemException e) { + throw new GemClientException("Requesting a new OAuth2 token failed.", e); + } + return LocalDateTime.now().isBefore(tokenvalidationDate); + } + + public HttpBasicAuth getBaseAuth() { + if (baseAuth == null) { + baseAuth = getHttpBasicAuthFromFile(); + } + return baseAuth; + } + + /** + * Reads the credentialFile and stores the client_id and client_secret + * + * @return + */ + private HttpBasicAuth getHttpBasicAuthFromFile() { + String client_id = ""; + String client_secret = ""; + File file = new File(ConfigHandler.getInstance().getCredentialPath()); + + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String line = br.readLine(); + while (line != null) { + String[] param = line.split("="); + switch (param[0]) { + case "id": + client_id = param[1]; + break; + case "secret": + client_secret = param[1]; + break; + default: + break; + } + line = br.readLine(); + } + HttpBasicAuth basicAuth = new HttpBasicAuth(); + basicAuth.setPassword(client_secret); + basicAuth.setUsername(client_id); + return basicAuth; + } catch (IOException e) { + LOG.error( + "The named file on path " + file.getAbsolutePath() + " could not be accessed"); + throw new IllegalArgumentException( + "The named file on path " + file.getAbsolutePath() + " could not be accessed"); + } + } + + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandler.java b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandler.java new file mode 100644 index 0000000..8047966 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandler.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.invoker; + +import de.gematik.ti.epa.vzd.gem.exceptions.GemClientException; +import generated.CommandType; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class reads the user input and store all the locations and configurations the user did + * <p> + * Implemented as singelton + */ +public final class ConfigHandler { + + private static final Logger LOG = LoggerFactory.getLogger(ConfigHandler.class); + private static final String BASE_PATH = "base"; + private static final String RETRY_OAUTH = "retryingOAuth"; + private static final String COMMANDS = "commands"; + private static final String PARA_EXECUTIONS = "maxExecutionsPerOperation"; + private static final String PARA_EXECUTORS = "maxOperations"; + private static final String PROXY_HOST = "proxyHost"; + private static final String PROXY_PORT = "proxyPort"; + private static final int MAX_EXECUTORS = 9; + private static final int MAX_EXECUTIONS_PER_EXECUTOR = 20; + + private static ConfigHandler configHandler = null; + private String configPath; + private String basePath; + private String credentialPath; + private String commandsPath; + private String retryingOAuthPath; + private String proxyHost; + private int maxParallelExecutor = 1; + private int maxParaExecutionsPerExecutor = 1; + private int connectionCount; + private int proxyPort = -1; + private boolean proxySet; + + private ConfigHandler() { + } + + /** + * This function returns the instance of the ConfigHandler as long as it is initialized + * + * @return + */ + public static ConfigHandler getInstance() { + if (configHandler == null) { + throw new GemClientException("A ConfigHandler have to be initialized first"); + } + return configHandler; + } + + /** + * Create an instance of a ConfigHandler while reading the commandline + * + * @param args input parameter from commandline + */ + public static ConfigHandler init(String[] args) { + if (configHandler == null) { + configHandler = new ConfigHandler(); + for (int iIndex = 0; iIndex < args.length; iIndex++) { + switch (args[iIndex]) { + case "-p": + configHandler.configPath = new File(args[iIndex + 1]).getAbsolutePath(); + configHandler.setParams(configHandler.configPath); + break; + case "-c": + configHandler.credentialPath = new File(args[iIndex + 1]).getAbsolutePath(); + break; + case "-b": + configHandler.commandsPath = new File(args[iIndex + 1]).getAbsolutePath(); + break; + case "-h": + configHandler.proxyHost = args[iIndex + 1]; + break; + case "-d": + try { + configHandler.proxyPort = Integer.parseInt(args[iIndex + 1]); + } catch (NumberFormatException ex) { + LOG.error("Your named proxy port is not valid." + args[iIndex + 1]); + throw new IllegalArgumentException("Your named proxy port is not valid." + args[iIndex + 1]); + } + break; + default: + break; + } + } + } else { + throw new GemClientException("Configurations are only allowed to set once"); + } + if (StringUtils.isBlank(configHandler.credentialPath) || StringUtils + .isBlank(configHandler.configPath)) { + LOG.error("At least CredentialPath or ConfigPath is missing and have to be set"); + throw new GemClientException( + "At least CredentialPath or ConfigPath is missing and have to be set"); + } + LOG.debug("Configurations have been set"); + return configHandler; + } + + private void setParams(String arg) { + File file = new File(arg); + try (BufferedReader br = new BufferedReader(new FileReader(file))) { + String line = br.readLine(); + while (line != null) { + if (StringUtils.isNotBlank(line) && line.contains("=")) { + String[] param = line.split("="); + String name = param[0]; + String value = param[1]; + switch (name) { + case BASE_PATH: + configHandler.basePath = value; + break; + case RETRY_OAUTH: + configHandler.retryingOAuthPath = value; + break; + case COMMANDS: + if (StringUtils.isBlank(configHandler.commandsPath)) { + configHandler.commandsPath = new File(value).getAbsolutePath(); + } + break; + case PARA_EXECUTORS: + try { + maxParallelExecutor = Integer.parseInt(value.trim()); + if (maxParallelExecutor > MAX_EXECUTORS) { + maxParallelExecutor = MAX_EXECUTORS; + } else if (maxParallelExecutor <= 0) { + maxParallelExecutor = 1; + } + } catch (NumberFormatException ex) { + LOG.error("maxExecutors have to be a number"); + } + break; + case PARA_EXECUTIONS: + try { + maxParaExecutionsPerExecutor = Integer.parseInt(value.trim()); + if (maxParaExecutionsPerExecutor > MAX_EXECUTIONS_PER_EXECUTOR) { + maxParaExecutionsPerExecutor = MAX_EXECUTIONS_PER_EXECUTOR; + } else if (maxParaExecutionsPerExecutor <= 0) { + maxParaExecutionsPerExecutor = 1; + } + } catch (NumberFormatException ex) { + LOG.error("maxExecutionsPerExecutor have to be a number"); + } + break; + case PROXY_HOST: + if (StringUtils.isBlank(configHandler.proxyHost)) { + configHandler.proxyHost = value; + } + break; + case PROXY_PORT: + if (configHandler.proxyPort == -1) { + try { + configHandler.proxyPort = Integer.parseInt(value.trim()); + } catch (NumberFormatException ex) { + LOG.error("Your named proxy port is not valid." + value); + throw new IllegalArgumentException("Your named proxy port is not valid." + value); + } + } + break; + default: + break; + } + } + line = br.readLine(); + } + connectionCount = maxParaExecutionsPerExecutor * maxParallelExecutor; + } catch (IOException e) { + LOG.error("File not found at " + file.getAbsolutePath()); + throw new IllegalArgumentException("No access to given file " + file.getAbsolutePath()); + } + + if (StringUtils.isNotBlank(proxyHost) && (proxyPort != -1)) { + proxySet = true; + } + + if (StringUtils.isBlank(configHandler.retryingOAuthPath)) { + LOG.error("No authorization server named"); + throw new GemClientException("No authorization server named"); + } + if (StringUtils.isBlank(configHandler.basePath)) { + LOG.error("No vzd server named"); + throw new GemClientException("No server named"); + } + } + + public void adjustConnectionCount(List<CommandType> commands) { + Map<String, List<CommandType>> commandMap = commands.stream().collect(Collectors.groupingBy(CommandType::getName)); + int count = 0; + for (var entry : commandMap.entrySet()) { + if (entry.getValue().size() >= MAX_EXECUTIONS_PER_EXECUTOR) { + count += MAX_EXECUTIONS_PER_EXECUTOR; + } else { + count += entry.getValue().size(); + } + } + this.connectionCount = count < this.connectionCount ? count : this.connectionCount; + } + + // <editor-fold desc="Getter & Setter"> + + public static void setConfigHandler(ConfigHandler setConfigHandler) { + configHandler = setConfigHandler; + } + + public String getRetryingOAuthPath() { + return retryingOAuthPath; + } + + public String getConfigPath() { + return configPath; + } + + public String getCredentialPath() { + return credentialPath; + } + + public String getBasePath() { + return basePath; + } + + public String getCommandsPath() { + return commandsPath; + } + + public String getProxyHost() { + return proxyHost; + } + + public int getProxyPort() { + return proxyPort; + } + + public boolean isProxySet() { + return proxySet; + } + + public int getMaxParallelExecutor() { + return maxParallelExecutor; + } + + public int getMaxParaExecutionsPerExecutor() { + return maxParaExecutionsPerExecutor; + } + + public int getConnectionCount() { + return connectionCount; + } + + // </editor-fold> +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConnectionPool.java b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConnectionPool.java new file mode 100644 index 0000000..1ac9e33 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/ConnectionPool.java @@ -0,0 +1,74 @@ +package de.gematik.ti.epa.vzd.gem.invoker; + +import de.gematik.ti.epa.vzd.gem.exceptions.ConnectionAlreadyReleased; +import de.gematik.ti.epa.vzd.gem.exceptions.WrongConnection; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.LinkedBlockingQueue; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ConnectionPool implements IConnectionPool { + + private static final Logger LOG = LoggerFactory.getLogger(ConnectionPool.class); + + private final LinkedBlockingQueue<GemApiClient> connections; + private final List<GemApiClient> usedConnections; + + private ConnectionPool(int size) { + connections = new LinkedBlockingQueue<>(size); + usedConnections = new ArrayList<>(); + for (int i = 0; i < size; i++) { + connections.add(new GemApiClient(this)); + } + } + + public static IConnectionPool createConnectionPool(final int size) { + return new ConnectionPool(size); + } + + @Override + public synchronized GemApiClient getConnection() throws InterruptedException { + LOG.trace("Try to get Connection (" + getUsedConnectionSize() + " / " + getConnectionSize() + ")"); + GemApiClient connection = connections.take(); + usedConnections.add(connection); + LOG.trace("Connection found and return (" + getUsedConnectionSize() + " / " + getConnectionSize() + ")"); + return connection; + } + + @Override + public synchronized void releaseConnection(GemApiClient gemApiClient) { + LOG.trace("Try to releaseConnection (" + getUsedConnectionSize() + " / " + getConnectionSize() + ")"); + if (usedConnections.contains(gemApiClient)) { + usedConnections.remove(gemApiClient); + connections.add(gemApiClient); + LOG.trace("Connection released (" + getUsedConnectionSize() + " / " + getConnectionSize() + ")"); + } else if (!connections.contains(gemApiClient)) { + throw new WrongConnection(); + } else { + throw new ConnectionAlreadyReleased(); + } + } + + @Override + public void reset() { + connections.addAll(usedConnections); + usedConnections.clear(); + LOG.trace("Connection reset done (" + getUsedConnectionSize() + " / " + getConnectionSize() + ")"); + } + + @Override + public int getConnectionSize() { + return connections.size() + connections.remainingCapacity(); + } + + @Override + public int getAvailableConnectionSize() { + return connections.size(); + } + + @Override + public int getUsedConnectionSize() { + return usedConnections.size(); + } +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/GemApiClient.java b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/GemApiClient.java new file mode 100644 index 0000000..5e16168 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/GemApiClient.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.invoker; + +import de.gematik.ti.epa.vzd.client.invoker.ApiClient; +import de.gematik.ti.epa.vzd.client.invoker.JSON; +import de.gematik.ti.epa.vzd.client.invoker.auth.Authentication; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuthFlow; +import de.gematik.ti.epa.vzd.client.invoker.auth.RetryingOAuth; +import de.gematik.ti.epa.vzd.gem.exceptions.GemClientException; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import okhttp3.OkHttpClient; +import org.apache.oltu.oauth2.common.exception.OAuthProblemException; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GemApiClient extends ApiClient implements AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(GemApiClient.class); + + private String retryingOAuthPath = ConfigHandler.getInstance().getRetryingOAuthPath(); + private Map<String, Authentication> authentications; + private IConnectionPool connectionPool; + + + public GemApiClient(IConnectionPool connectionPool) { + + this.connectionPool = connectionPool; + modifiedWithOAuth(); + authentications = Collections.unmodifiableMap(authentications); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID + */ + public GemApiClient(final String clientId) { + this(clientId, null, null); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID and additional parameters + */ + public GemApiClient(final String clientId, final Map<String, String> parameters) { + this(clientId, null, parameters); + } + + /* + * Constructor for ApiClient to support access token retry on 401/403 configured with client ID, secret, and additional parameters + */ + public GemApiClient(final String clientId, final String clientSecret, + final Map<String, String> parameters) { + modifiedWithOAuth(); + + final RetryingOAuth retryingOAuth = new RetryingOAuth(retryingOAuthPath, clientId, + OAuthFlow.application, clientSecret, parameters); + authentications.put("OAuth2", retryingOAuth); + getHttpClient().interceptors().add(retryingOAuth); + + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * The function <code> getProgressInterceptor </code> comes from the generated class ApiClient and maybe have to be set on public again. + * <p> + * The OAuth2 token is stored in authentications.get("OAuth") + */ + private void modifiedWithOAuth() { + ConfigHandler configHandler = ConfigHandler.getInstance(); + setBasePath(configHandler.getBasePath()); + + OkHttpClient.Builder builder; + if (configHandler.isProxySet()) { + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(configHandler.getProxyHost(), configHandler.getProxyPort())); + builder = new OkHttpClient.Builder().proxy(proxy); + } else { + builder = new OkHttpClient.Builder(); + } + + // Function have to be set public when client is regenerated + builder.addNetworkInterceptor(getProgressInterceptor()); + setHttpClient(builder.build()); + + setVerifyingSsl(true); + + setJSON(new JSON()); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/1.0.0/java"); + + authentications = new HashMap<>(); + authentications + .put("HttpBasicAuth", AccessHandler.getInstance().getBaseAuth()); + try { + authentications.put("OAuth", AccessHandler.getInstance().getOAuth2Token()); + } catch (OAuthSystemException | OAuthProblemException e) { + LOG.error("Error while getting Token"); + throw new ExceptionInInitializerError("Error while getting Token"); + } + } + + public void validateToken() { + try { + AccessHandler.getInstance().getOAuth2Token(); + } catch (OAuthSystemException | OAuthProblemException e) { + LOG.error("Error while refreshing OAuthToken"); + throw new GemClientException("Error while refreshing OAuthToken"); + } + } + + // <editor-fold desc="Getter & Setter"> + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + @Override + public Map<String, Authentication> getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + @Override + public Authentication getAuthentication(final String authName) { + return authentications.get(authName); + } + + @Override + public void close() throws Exception { + if (connectionPool != null) { + connectionPool.releaseConnection(this); + } + } + + // </editor-fold> +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/IConnectionPool.java b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/IConnectionPool.java new file mode 100644 index 0000000..3791fd8 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/gem/invoker/IConnectionPool.java @@ -0,0 +1,17 @@ +package de.gematik.ti.epa.vzd.gem.invoker; + +public interface IConnectionPool { + + GemApiClient getConnection() throws InterruptedException; + + void releaseConnection(GemApiClient gemApiClient); + + void reset(); + + int getConnectionSize(); + + int getAvailableConnectionSize(); + + int getUsedConnectionSize(); + +} diff --git a/src/main/java/de/gematik/ti/epa/vzd/oauth2/URLConnectionClient.java b/src/main/java/de/gematik/ti/epa/vzd/oauth2/URLConnectionClient.java new file mode 100644 index 0000000..8541657 --- /dev/null +++ b/src/main/java/de/gematik/ti/epa/vzd/oauth2/URLConnectionClient.java @@ -0,0 +1,136 @@ +/** + * Copyright 2010 Newcastle University + * <p> + * http://research.ncl.ac.uk/smart/ + * <p> + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work + * for additional information regarding copyright ownership. The ASF licenses this file to You 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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 de.gematik.ti.epa.vzd.oauth2; + +import static org.apache.http.HttpStatus.SC_BAD_REQUEST; +import static org.apache.http.HttpStatus.SC_UNAUTHORIZED; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.HttpURLConnection; +import java.net.Proxy; +import java.net.URL; +import java.net.URLConnection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.oltu.oauth2.client.HttpClient; +import org.apache.oltu.oauth2.client.request.OAuthClientRequest; +import org.apache.oltu.oauth2.client.response.OAuthClientResponse; +import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory; +import org.apache.oltu.oauth2.common.OAuth; +import org.apache.oltu.oauth2.common.exception.OAuthProblemException; +import org.apache.oltu.oauth2.common.exception.OAuthSystemException; +import org.apache.oltu.oauth2.common.utils.OAuthUtils; + + +/** + * Implementation of the Oltu OAuth HttpClient using URL Connection + */ +public class URLConnectionClient implements HttpClient { + + private Proxy proxy = Proxy.NO_PROXY; + + public URLConnectionClient() { + } + + public URLConnectionClient(final Proxy proxy) { + this.proxy = proxy; + } + + @Override + public <T extends OAuthClientResponse> T execute(final OAuthClientRequest request, final Map<String, String> headers, + final String requestMethod, final Class<T> responseClass) + throws OAuthSystemException, OAuthProblemException { + + InputStream responseBody = null; + URLConnection c; + Map<String, List<String>> responseHeaders = new HashMap<String, List<String>>(); + int responseCode; + try { + URL url = new URL(request.getLocationUri()); + + c = url.openConnection(proxy); + responseCode = -1; + if (c instanceof HttpURLConnection) { + HttpURLConnection httpURLConnection = (HttpURLConnection) c; + + if (headers != null && !headers.isEmpty()) { + for (Map.Entry<String, String> header : headers.entrySet()) { + httpURLConnection.addRequestProperty(header.getKey(), header.getValue()); + } + } + + if (request.getHeaders() != null) { + for (Map.Entry<String, String> header : request.getHeaders().entrySet()) { + httpURLConnection.addRequestProperty(header.getKey(), header.getValue()); + } + } + + if (OAuthUtils.isEmpty(requestMethod)) { + httpURLConnection.setRequestMethod(OAuth.HttpMethod.GET); + } else { + httpURLConnection.setRequestMethod(requestMethod); + setRequestBody(request, requestMethod, httpURLConnection); + } + + httpURLConnection.connect(); + + InputStream inputStream; + responseCode = httpURLConnection.getResponseCode(); + if (responseCode == SC_BAD_REQUEST || responseCode == SC_UNAUTHORIZED) { + inputStream = httpURLConnection.getErrorStream(); + } else { + inputStream = httpURLConnection.getInputStream(); + } + + responseHeaders = httpURLConnection.getHeaderFields(); + responseBody = inputStream; + } + } catch (IOException e) { + throw new OAuthSystemException(e); + } + + return OAuthClientResponseFactory + .createCustomResponse(responseBody, c.getContentType(), responseCode, responseHeaders, responseClass); + } + + private void setRequestBody(OAuthClientRequest request, String requestMethod, HttpURLConnection httpURLConnection) + throws IOException { + String requestBody = request.getBody(); + if (OAuthUtils.isEmpty(requestBody)) { + return; + } + + if (OAuth.HttpMethod.POST.equals(requestMethod) || OAuth.HttpMethod.PUT.equals(requestMethod)) { + httpURLConnection.setDoOutput(true); + OutputStream ost = httpURLConnection.getOutputStream(); + PrintWriter pw = new PrintWriter(ost); + pw.print(requestBody); + pw.flush(); + pw.close(); + } + } + + @Override + public void shutdown() { + // Nothing to do here + } + +} \ No newline at end of file diff --git a/src/main/resources/jaxb-binding/binding.xml b/src/main/resources/jaxb-binding/binding.xml new file mode 100644 index 0000000..d129ad7 --- /dev/null +++ b/src/main/resources/jaxb-binding/binding.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" + version="2.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <jaxb:bindings schemaLocation="../xsd/commands.xsd" node="/xs:schema"> + <jaxb:globalBindings fixedAttributeAsConstantProperty="true"/> + </jaxb:bindings> + +</jaxb:bindings> \ No newline at end of file diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 0000000..3aa1690 --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="INFO"> + <Properties> + <Property name="toolname">VZD-Client</Property> + <Property name="l4j.lvl">${sys:l4j.lvl:-INFO}</Property> + <Property name="l4j.logDir">${sys:l4j.logDir:-${sys:java.io.tmpdir}/logs}</Property> + </Properties> + <Appenders> + <File name="file-log" fileName="${l4j.logDir}/VZD-Client_${date:yyyy-MM-dd_HH-mm-ss.SSSS}.log" append="false"> + <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1}: %L - %m%n"/> + </File> + <Console name="console-log"> + <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1}: %L - %m%n"/> + </Console> + </Appenders> + + <Loggers> + <Logger name="de.gematik.ti.epa" level="TRACE" additivity="false"> + <appender-ref ref="file-log" level="DEBUG"/> + <appender-ref ref="console-log" level="${l4j.lvl}"/> + </Logger> + <Root level="TRACE" additivity="false"> + <AppenderRef ref="file-log" level="DEBUG"/> + <AppenderRef ref="console-log" level="${l4j.lvl}"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/src/main/resources/xsd/commands.xsd b/src/main/resources/xsd/commands.xsd new file mode 100644 index 0000000..fcce750 --- /dev/null +++ b/src/main/resources/xsd/commands.xsd @@ -0,0 +1,59 @@ +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + + <xs:element name="CommandList" type="CommandListType"/> + + <xs:complexType name="CommandListType"> + <xs:sequence> + <xs:element name="Command" type="CommandType" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="CommandType"> + <xs:sequence> + <xs:element name="commandId" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="name" type="xs:string" minOccurs="1" maxOccurs="1"/> + <xs:element name="dn" type="DistinguishedNameType" minOccurs="0" maxOccurs="1"/> + <xs:element name="givenName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="sn" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="streetAddress" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="postalCode" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="localityName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="stateOrProvinceName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="cn" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="displayName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="organization" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="otherName" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="specialization" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="domainID" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="mail" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="UserCertificate" type="UserCertificateType" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="personalEntry" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="dataFromAuthority" type="xs:string" minOccurs="0" maxOccurs="1"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="DistinguishedNameType"> + <xs:sequence> + <xs:element name="cn" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="uid" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="dc" type="xs:string" minOccurs="0" maxOccurs="2"/> + <xs:element name="ou" type="xs:string" minOccurs="0" maxOccurs="2"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="UserCertificateType"> + <xs:sequence> + <xs:element name="dn" type="DistinguishedNameType" minOccurs="0" maxOccurs="1"/> + <xs:element name="entryType" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="telematikID" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="professionOID" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="usage" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="userCertificate" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"/> + + </xs:sequence> + </xs:complexType> + +</xs:schema> \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApiTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApiTest.java new file mode 100644 index 0000000..afa65a0 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/api/CertificateAdministrationApiTest.java @@ -0,0 +1,96 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.api; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.model.DistinguishedName; +import de.gematik.ti.epa.vzd.client.model.UserCertificate; +import java.util.List; +import org.junit.Ignore; +import org.junit.Test; + +/** + * API tests for CertificateAdministrationApi + */ +@Ignore +public class CertificateAdministrationApiTest { + + private final CertificateAdministrationApi api = new CertificateAdministrationApi(); + + + /** + * Der Zertifikatseintrag wird im Verzeichnisdienst hinzugefügt und ist logisch über dn.uid mit dem übergeordneten Verzeichniseintrag verknüpft. + * + * @throws ApiException if the Api call fails + */ + @Test + public void addDirectoryEntryCertificateTest() throws ApiException { + String uid = null; + UserCertificate userCertificate = null; + DistinguishedName response = api.addDirectoryEntryCertificate(uid, userCertificate); + + // TODO: test validations + } + + /** + * Zertifikatseintrag löschen Dem Verzeichniseintrag muss immer mindestens ein Zertifikat zugeordnet sein. Wenn nach dem Löschen kein Zertifikat + * mehr dem Verzeichniseintrag zugeordnet wäre, muss die delete Operation abgelehnt werden. + * + * @throws ApiException if the Api call fails + */ + @Test + public void deleteDirectoryEntryCertificateTest() throws ApiException { + String uid = null; + String certificateEntryID = null; + api.deleteDirectoryEntryCertificate(uid, certificateEntryID); + + // TODO: test validations + } + + /** + * Der Zertifikatseintrag wird mit den übergebenen Daten aktualisiert. + * + * @throws ApiException if the Api call fails + */ + @Test + public void modifyDirectoryEntryCertificateTest() throws ApiException { + String uid = null; + String certificateEntryID = null; + UserCertificate userCertificate = null; + UserCertificate response = api.modifyDirectoryEntryCertificate(uid, certificateEntryID, userCertificate); + + // TODO: test validations + } + + /** + * Zertifikat lesen + * <p> + * Liefert alle Zertifikate, die dem Filter (siehe 'parameters') entsprechen. + * + * @throws ApiException if the Api call fails + */ + @Test + public void readDirectoryCertificatesTest() throws ApiException { + String uid = null; + String certificateEntryID = null; + String entryType = null; + String telematikID = null; + String professionOID = null; + String usage = null; + List<UserCertificate> response = api.readDirectoryCertificates(uid, certificateEntryID, entryType, telematikID, professionOID, usage); + + // TODO: test validations + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntryTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntryTest.java new file mode 100644 index 0000000..04959c0 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/BaseDirectoryEntryTest.java @@ -0,0 +1,162 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for BaseDirectoryEntry + */ +public class BaseDirectoryEntryTest { + + private final BaseDirectoryEntry model = new BaseDirectoryEntry(); + + /** + * Model tests for BaseDirectoryEntry + */ + @Test + public void testBaseDirectoryEntry() { + // TODO: test BaseDirectoryEntry + } + + /** + * Test the property 'dn' + */ + @Test + public void dnTest() { + // TODO: test dn + } + + /** + * Test the property 'givenName' + */ + @Test + public void givenNameTest() { + // TODO: test givenName + } + + /** + * Test the property 'sn' + */ + @Test + public void snTest() { + // TODO: test sn + } + + /** + * Test the property 'cn' + */ + @Test + public void cnTest() { + // TODO: test cn + } + + /** + * Test the property 'displayName' + */ + @Test + public void displayNameTest() { + // TODO: test displayName + } + + /** + * Test the property 'streetAddress' + */ + @Test + public void streetAddressTest() { + // TODO: test streetAddress + } + + /** + * Test the property 'postalCode' + */ + @Test + public void postalCodeTest() { + // TODO: test postalCode + } + + /** + * Test the property 'localityName' + */ + @Test + public void localityNameTest() { + // TODO: test localityName + } + + /** + * Test the property 'stateOrProvienceName' + */ + @Test + public void stateOrProvienceNameTest() { + // TODO: test stateOrProvienceName + } + + /** + * Test the property 'title' + */ + @Test + public void titleTest() { + // TODO: test title + } + + /** + * Test the property 'organization' + */ + @Test + public void organizationTest() { + // TODO: test organization + } + + /** + * Test the property 'otherName' + */ + @Test + public void otherNameTest() { + // TODO: test otherName + } + + /** + * Test the property 'specialization' + */ + @Test + public void specializationTest() { + // TODO: test specialization + } + + /** + * Test the property 'domainID' + */ + @Test + public void domainIDTest() { + // TODO: test domainID + } + + /** + * Test the property 'personalEntry' + */ + @Test + public void personalEntryTest() { + // TODO: test personalEntry + } + + /** + * Test the property 'dataFromAuthority' + */ + @Test + public void dataFromAuthorityTest() { + // TODO: test dataFromAuthority + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntryTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntryTest.java new file mode 100644 index 0000000..ace3793 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/CreateDirectoryEntryTest.java @@ -0,0 +1,50 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for CreateDirectoryEntry + */ +public class CreateDirectoryEntryTest { + + private final CreateDirectoryEntry model = new CreateDirectoryEntry(); + + /** + * Model tests for CreateDirectoryEntry + */ + @Test + public void testCreateDirectoryEntry() { + // TODO: test CreateDirectoryEntry + } + + /** + * Test the property 'directoryEntryBase' + */ + @Test + public void directoryEntryBaseTest() { + // TODO: test directoryEntryBase + } + + /** + * Test the property 'userCertificates' + */ + @Test + public void userCertificatesTest() { + // TODO: test userCertificates + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntryTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntryTest.java new file mode 100644 index 0000000..0643483 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/DirectoryEntryTest.java @@ -0,0 +1,58 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for DirectoryEntry + */ +public class DirectoryEntryTest { + + private final DirectoryEntry model = new DirectoryEntry(); + + /** + * Model tests for DirectoryEntry + */ + @Test + public void testDirectoryEntry() { + // TODO: test DirectoryEntry + } + + /** + * Test the property 'directoryEntryBase' + */ + @Test + public void directoryEntryBaseTest() { + // TODO: test directoryEntryBase + } + + /** + * Test the property 'userCertificates' + */ + @Test + public void userCertificatesTest() { + // TODO: test userCertificates + } + + /** + * Test the property 'fachdaten' + */ + @Test + public void fachdatenTest() { + // TODO: test fachdaten + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/DistinguishedNameTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/DistinguishedNameTest.java new file mode 100644 index 0000000..7e0d7a9 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/DistinguishedNameTest.java @@ -0,0 +1,66 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for DistinguishedName + */ +public class DistinguishedNameTest { + + private final DistinguishedName model = new DistinguishedName(); + + /** + * Model tests for DistinguishedName + */ + @Test + public void testDistinguishedName() { + // TODO: test DistinguishedName + } + + /** + * Test the property 'uid' + */ + @Test + public void uidTest() { + // TODO: test uid + } + + /** + * Test the property 'dc' + */ + @Test + public void dcTest() { + // TODO: test dc + } + + /** + * Test the property 'ou' + */ + @Test + public void ouTest() { + // TODO: test ou + } + + /** + * Test the property 'cn' + */ + @Test + public void cnTest() { + // TODO: test cn + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/ErrorTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/ErrorTest.java new file mode 100644 index 0000000..0009326 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/ErrorTest.java @@ -0,0 +1,50 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for Error + */ +public class ErrorTest { + + private final Error model = new Error(); + + /** + * Model tests for Error + */ + @Test + public void testError() { + // TODO: test Error + } + + /** + * Test the property 'attributeName' + */ + @Test + public void attributeNameTest() { + // TODO: test attributeName + } + + /** + * Test the property 'attributeError' + */ + @Test + public void attributeErrorTest() { + // TODO: test attributeError + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/FAD1Test.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/FAD1Test.java new file mode 100644 index 0000000..3eb0129 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/FAD1Test.java @@ -0,0 +1,50 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for FAD1 + */ +public class FAD1Test { + + private final FAD1 model = new FAD1(); + + /** + * Model tests for FAD1 + */ + @Test + public void testFAD1() { + // TODO: test FAD1 + } + + /** + * Test the property 'dn' + */ + @Test + public void dnTest() { + // TODO: test dn + } + + /** + * Test the property 'mail' + */ + @Test + public void mailTest() { + // TODO: test mail + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/FachdatenTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/FachdatenTest.java new file mode 100644 index 0000000..0fc5e1e --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/FachdatenTest.java @@ -0,0 +1,50 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for Fachdaten + */ +public class FachdatenTest { + + private final Fachdaten model = new Fachdaten(); + + /** + * Model tests for Fachdaten + */ + @Test + public void testFachdaten() { + // TODO: test Fachdaten + } + + /** + * Test the property 'dn' + */ + @Test + public void dnTest() { + // TODO: test dn + } + + /** + * Test the property 'FAD1' + */ + @Test + public void FAD1Test() { + // TODO: test FAD1 + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/client/model/UserCertificateTest.java b/src/test/java/de/gematik/ti/epa/vzd/client/model/UserCertificateTest.java new file mode 100644 index 0000000..959fd9f --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/client/model/UserCertificateTest.java @@ -0,0 +1,90 @@ +/* + * I_Directory_Administration + * REST Schnittstelle zur Pflege der Verzeichniseinträge. Über diese Schnittstelle können Verzeichniseinträge inklusive Zertifikaten erzeugt, aktualisiert und gelöscht werden. Die Administration von Fachdaten erfolgt über Schnittstelle I_Directory_Application_Maintenance und wird durch die Fachanwendungen durchgeführt. Lesender Zugriff auf die Fachdaten ist mit Operation getDirectoryEntries in vorliegender Schnittstelle möglich. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package de.gematik.ti.epa.vzd.client.model; + +import org.junit.Test; + + +/** + * Model tests for UserCertificate + */ +public class UserCertificateTest { + + private final UserCertificate model = new UserCertificate(); + + /** + * Model tests for UserCertificate + */ + @Test + public void testUserCertificate() { + // TODO: test UserCertificate + } + + /** + * Test the property 'dn' + */ + @Test + public void dnTest() { + // TODO: test dn + } + + /** + * Test the property 'entryType' + */ + @Test + public void entryTypeTest() { + // TODO: test entryType + } + + /** + * Test the property 'telematikID' + */ + @Test + public void telematikIDTest() { + // TODO: test telematikID + } + + /** + * Test the property 'professionOID' + */ + @Test + public void professionOIDTest() { + // TODO: test professionOID + } + + /** + * Test the property 'usage' + */ + @Test + public void usageTest() { + // TODO: test usage + } + + /** + * Test the property 'userCertificate' + */ + @Test + public void userCertificateTest() { + // TODO: test userCertificate + } + + /** + * Test the property 'description' + */ + @Test + public void descriptionTest() { + // TODO: test description + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilderTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilderTest.java new file mode 100644 index 0000000..879cc34 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/CommandsBuilderTest.java @@ -0,0 +1,62 @@ +package de.gematik.ti.epa.vzd.gem.command; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import de.gematik.ti.epa.vzd.gem.exceptions.CommandException; +import de.gematik.ti.epa.vzd.gem.exceptions.ReadException; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import java.io.File; +import org.junit.Before; +import org.junit.Test; + +public class CommandsBuilderTest { + + private static final String[] ARGS_Wrong_Formatted = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "ConfigWrongFormattedCommands.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "bspCredentials.txt"}; + private static final String[] ARGS_MISSING_COMMANDS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "ConfigMissingCommands.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "bspCredentials.txt"}; + private static final String[] DUBLED_COMMAND_ID = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "DoubledCommandId.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "bspCredentials.txt"}; + + @Before + public void createConfigHandler() { + ConfigHandler.setConfigHandler(null); + } + + @Test + public void checkParsingError() { + ConfigHandler.init(ARGS_Wrong_Formatted); + ReadException exception = assertThrows(ReadException.class, + () -> new CommandsBuilder().buildCommands()); + assertEquals( + "An error have been occurred while reading your command file. Please check if this file is a valid .xml file", + exception.getMessage()); + } + + @Test + public void checkFileNotFoundError() { + ConfigHandler.init(ARGS_MISSING_COMMANDS); + ReadException exception = assertThrows(ReadException.class, + () -> new CommandsBuilder().buildCommands()); + assertEquals( + "A problem with your named file have occurred. Please if check " + new File("doesNotExist.xml").getAbsolutePath() + " exist", + exception.getMessage()); + } + + @Test + public void doubledCommandIdDefinedTest() { + ConfigHandler.init(DUBLED_COMMAND_ID); + CommandException exception = assertThrows(CommandException.class, () -> new CommandsBuilder().buildCommands()); + assertEquals("The predefined ID \"thisShouldOccureAnError\" occurs twice", exception.getMessage()); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollectionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollectionTest.java new file mode 100644 index 0000000..95bd9f1 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/ExecutionCollectionTest.java @@ -0,0 +1,28 @@ +package de.gematik.ti.epa.vzd.gem.command; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import org.junit.Test; + +public class ExecutionCollectionTest { + + private static ConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void getInstanceWithoutInit() { + InstantiationError ex = assertThrows(InstantiationError.class, () -> ExecutionCollection.getInstance()); + assertEquals("Please instance a executor first. It needs an ConnectionPool", ex.getMessage()); + } + + @Test + public void initWithoutConnectionPool() { + ExecutionCollection.init(connectionPool); + InstantiationError ex = assertThrows(InstantiationError.class, () -> ExecutionCollection.init(connectionPool)); + + assertEquals("Executor is already instanced", ex.getMessage()); + } +} \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionIntegrationTest.java new file mode 100644 index 0000000..d495153 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionIntegrationTest.java @@ -0,0 +1,63 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class AddDirEntryCertExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "addCert.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void addCommandSuccessTest() throws Exception { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(addDirEntryCertExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void addCommandFailTest() throws Exception { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(addDirEntryCertExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandExceptionTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> addDirEntryCertExecution.executeCommand(commands.get(1), addDirEntryCertExecution.connectionPool.getConnection())); + assertEquals(422, exception.getCode()); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionTest.java new file mode 100644 index 0000000..b619b07 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryCertExecutionTest.java @@ -0,0 +1,121 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import org.junit.Test; + +public class AddDirEntryCertExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void missingUserCertificateElementTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + assertFalse(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void missingUidTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setUserCertificate("SomeUserCertificate"); + command.getUserCertificate().add(userCertificateType); + assertFalse(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void missingUserCertificateTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + UserCertificateType userCertificateType = new UserCertificateType(); + + command.getUserCertificate().add(userCertificateType); + command.setDn(dn); + + assertFalse(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void uidInDnTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setUserCertificate("SomeUserCertificate"); + + command.getUserCertificate().add(userCertificateType); + command.setDn(dn); + + assertTrue(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void uidInCertTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setUserCertificate("SomeUserCertificate"); + + userCertificateType.setDn(dn); + command.getUserCertificate().add(userCertificateType); + + assertTrue(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void uidInCertAndDnTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + DistinguishedNameType dn2 = new DistinguishedNameType(); + dn2.setUid("SomeUid"); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setUserCertificate("SomeUserCertificate"); + + userCertificateType.setDn(dn); + command.getUserCertificate().add(userCertificateType); + command.setDn(dn2); + + assertTrue(addDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void mismatchingUidTest() { + AddDirEntryCertExecution addDirEntryCertExecution = new AddDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + DistinguishedNameType dn2 = new DistinguishedNameType(); + dn2.setUid("SomeOtherUid"); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setUserCertificate("SomeUserCertificate"); + + userCertificateType.setDn(dn); + command.getUserCertificate().add(userCertificateType); + command.setDn(dn2); + + assertFalse(addDirEntryCertExecution.checkValidation(command)); + } + + +} \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionIntegrationTest.java new file mode 100644 index 0000000..60d28d0 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionIntegrationTest.java @@ -0,0 +1,78 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class AddDirEntryExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "addDir.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void addCommandSuccessTest() throws Exception { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(addDirEntryExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void addCommandFailTest() throws Exception { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(addDirEntryExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandExceptionTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> addDirEntryExecution.executeCommand(commands.get(1), addDirEntryExecution.connectionPool.getConnection())); + assertEquals(405, exception.getCode()); + } + + @Test + public void addCommandDifferentTelematikIdTest() throws Exception { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(addDirEntryExecution.createCallable(commands.get(2)).call()); + } + + @Test + public void executeCommandDifferentTelematikIdTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> addDirEntryExecution.executeCommand(commands.get(2), addDirEntryExecution.connectionPool.getConnection())); + assertEquals(405, exception.getCode()); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionTest.java new file mode 100644 index 0000000..2d73e7e --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/AddDirEntryExecutionTest.java @@ -0,0 +1,55 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.UserCertificateType; +import org.junit.Test; + +public class AddDirEntryExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void checkValidationMissingCertificateObjectTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + assertFalse(addDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationMissingTelematikIdAndCertificateTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate = new UserCertificateType(); + command.getUserCertificate().add(certificate); + assertFalse(addDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationTelematikIdTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setCn("Test"); + UserCertificateType certificate = new UserCertificateType(); + certificate.setUserCertificate("Certificate"); + command.getUserCertificate().add(certificate); + assertTrue(addDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationCertificateTest() { + AddDirEntryExecution addDirEntryExecution = new AddDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setCn("Test"); + UserCertificateType certificate = new UserCertificateType(); + certificate.setTelematikID("TelematikId"); + command.getUserCertificate().add(certificate); + assertTrue(addDirEntryExecution.checkValidation(command)); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionIntegrationTest.java new file mode 100644 index 0000000..9b527eb --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionIntegrationTest.java @@ -0,0 +1,64 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class DeleteDirEntryCertExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "delCert.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void delCertCommandSuccessTest() throws Exception { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(deleteDirEntryCertExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void delCertCommandFailTest() throws Exception { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(deleteDirEntryCertExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandExceptionTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> deleteDirEntryCertExecution.executeCommand(commands.get(1), deleteDirEntryCertExecution.connectionPool.getConnection())); + assertEquals(400, exception.getCode()); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionTest.java new file mode 100644 index 0000000..9dfd9e1 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryCertExecutionTest.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2020 gematik GmbH + * + * 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 de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import org.junit.Test; + +public class DeleteDirEntryCertExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + + @Test + public void checkValidationDifferentUidsTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate1 = new UserCertificateType(); + UserCertificateType certificate2 = new UserCertificateType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + DistinguishedNameType dn2 = new DistinguishedNameType(); + dn1.setUid("something"); + dn2.setUid("somethingelse"); + certificate1.setDn(dn1); + certificate2.setDn(dn2); + command.getUserCertificate().add(certificate1); + command.getUserCertificate().add(certificate2); + command.setCn("SomeCn"); + assertFalse(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void checkValidationMissingCnTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate1 = new UserCertificateType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + dn1.setUid("SomeUid"); + certificate1.setDn(dn1); + command.getUserCertificate().add(certificate1); + assertFalse(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void checkValidationMissingUidTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + command.setCn("SomeCn"); + assertFalse(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void checkValidationSameUidsTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate1 = new UserCertificateType(); + UserCertificateType certificate2 = new UserCertificateType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + DistinguishedNameType dn2 = new DistinguishedNameType(); + DistinguishedNameType dn3 = new DistinguishedNameType(); + dn1.setUid("SomeUid"); + dn1.setCn("SomeCn"); + dn2.setUid("SomeUid"); + dn2.setCn("SomeOtherCn"); + dn3.setUid("SomeUid"); + certificate1.setDn(dn1); + certificate2.setDn(dn2); + command.setDn(dn3); + command.getUserCertificate().add(certificate1); + command.getUserCertificate().add(certificate2); + assertTrue(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void doubledCnTest(){ + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate1 = new UserCertificateType(); + UserCertificateType certificate2 = new UserCertificateType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + DistinguishedNameType dn2 = new DistinguishedNameType(); + DistinguishedNameType dn3 = new DistinguishedNameType(); + dn1.setUid("SomeUid"); + dn1.setCn("SameCn"); + dn2.setUid("SomeUid"); + dn2.setCn("SameCn"); + dn3.setUid("SomeUid"); + certificate1.setDn(dn1); + certificate2.setDn(dn2); + command.setDn(dn3); + command.getUserCertificate().add(certificate1); + command.getUserCertificate().add(certificate2); + assertFalse(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void checkValidationUidInCertTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType certificate1 = new UserCertificateType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + dn1.setUid("SomeUid"); + dn1.setCn("SomeCn"); + certificate1.setDn(dn1); + command.setCn("SomeUid"); + dn1.setCn("SomeOtherCn"); + command.getUserCertificate().add(certificate1); + assertTrue(deleteDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void checkValidationUidInDnTest() { + DeleteDirEntryCertExecution deleteDirEntryCertExecution = new DeleteDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn1 = new DistinguishedNameType(); + dn1.setUid("SomeUid"); + command.setDn(dn1); + command.setCn("SomeUid"); + assertTrue(deleteDirEntryCertExecution.checkValidation(command)); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionIntegrationTest.java new file mode 100644 index 0000000..fe56e85 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionIntegrationTest.java @@ -0,0 +1,64 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class DeleteDirEntryExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "delDir.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void delCommandSuccessTest() throws Exception { + DeleteDirEntryExecution deleteDirEntryExecution = new DeleteDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(deleteDirEntryExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void delCommandFailTest() throws Exception { + DeleteDirEntryExecution deleteDirEntryExecution = new DeleteDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(deleteDirEntryExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandEntryNotPresentTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> readDirEntryExecution.executeCommand(commands.get(1), readDirEntryExecution.connectionPool.getConnection())); + assertEquals(404, exception.getCode()); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionTest.java new file mode 100644 index 0000000..c1fb39e --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/DeleteDirEntryExecutionTest.java @@ -0,0 +1,33 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import org.junit.Test; + +public class DeleteDirEntryExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void checkValidationMissingArgumentTest() { + DeleteDirEntryExecution deleteDirEntryExecution = new DeleteDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + assertFalse(deleteDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveUID() { + DeleteDirEntryExecution deleteDirEntryExecution = new DeleteDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("cbca60fe-8ca7-4960-990d-ec526a200582"); + command.setDn(dn); + assertTrue(deleteDirEntryExecution.checkValidation(command)); + } +} \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseIntegrationTest.java new file mode 100644 index 0000000..8818dea --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseIntegrationTest.java @@ -0,0 +1,54 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ExecutionBaseIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "executionBase.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void getUidTestMissMatchUid() throws InterruptedException, ApiException { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + + readDirEntryCertExecution.executeCommand(commands.get(0),readDirEntryCertExecution.connectionPool.getConnection()); + + ApiException exception = assertThrows(ApiException.class, + () -> readDirEntryExecution.executeCommand(commands.get(0), readDirEntryExecution.connectionPool.getConnection())); + assertEquals("UID delivered by TelematikId does not match the UID in command file", exception.getMessage()); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseTest.java new file mode 100644 index 0000000..e233ef5 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ExecutionBaseTest.java @@ -0,0 +1,64 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.client.invoker.auth.OAuth; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.GemApiClient; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import org.junit.Test; + +public class ExecutionBaseTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + private static GemApiClient apiClient = mock(GemApiClient.class); + private static OAuth token = mock(OAuth.class); + + @Test + public void getUidTestUidInDn() throws ApiException { + + ExecutionBase readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + command.setDn(dn); + + String result = readDirEntryExecution.getUid(command, apiClient); + + assertEquals("SomeUid", result); + } + + @Test + public void getUidTestUidCert() throws ApiException { + + ExecutionBase readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType cert = new UserCertificateType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + cert.setDn(dn); + command.getUserCertificate().add(cert); + + String result = readDirEntryExecution.getUid(command, apiClient); + + assertEquals("SomeUid", result); + } + + @Test + public void getUidTestNoUid() throws ApiException { + + ExecutionBase readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + + String result = readDirEntryExecution.getUid(command, apiClient); + + assertEquals(null, result); + } + +} \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionIntegrationTest.java new file mode 100644 index 0000000..a99f9f0 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionIntegrationTest.java @@ -0,0 +1,63 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ModifyDirEntryExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "modDir.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void modCommandSuccessTest() throws Exception { + ModifyDirEntryExecution modifyDirEntryExecution = new ModifyDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(modifyDirEntryExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void modCommandDoAddTest() throws Exception { + ModifyDirEntryExecution modifyDirEntryExecution = new ModifyDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(modifyDirEntryExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandNotFoundTest() { + ModifyDirEntryExecution modifyDirEntryExecution = new ModifyDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> modifyDirEntryExecution.executeCommand(commands.get(1), modifyDirEntryExecution.connectionPool.getConnection())); + assertEquals(400, exception.getCode()); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionTest.java new file mode 100644 index 0000000..e943493 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ModifyDirEntryExecutionTest.java @@ -0,0 +1,50 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import org.junit.Test; + +public class ModifyDirEntryExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void preCheckFalseWhenUidIsEmptyString() { + ModifyDirEntryExecution modDirEnt = new ModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid(""); + command.setDn(dn); + + assertTrue(!modDirEnt.preCheck(command)); + } + + @Test + public void preCheckIsTrue() { + ModifyDirEntryExecution modDirEnt = new ModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("Test"); + command.setDn(dn); + + assertTrue(modDirEnt.preCheck(command)); + } + + @Test + public void preCheckFalseWhenUidIsMissing() { + ModifyDirEntryExecution modDirEnt = new ModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setCn("Test"); + command.setDn(dn); + + assertTrue(!modDirEnt.preCheck(command)); + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionIntegrationTest.java new file mode 100644 index 0000000..c485c8f --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionIntegrationTest.java @@ -0,0 +1,63 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ReadDirEntryCertExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "readCert.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void readCommandSuccessTest() throws Exception { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(readDirEntryCertExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void readCommandFailTest() throws Exception { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(readDirEntryCertExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandIdNotPresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> readDirEntryCertExecution.executeCommand(commands.get(1), readDirEntryCertExecution.connectionPool.getConnection())); + assertEquals(404, exception.getCode()); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionTest.java new file mode 100644 index 0000000..2557ad5 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryCertExecutionTest.java @@ -0,0 +1,86 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import generated.UserCertificateType; +import org.junit.Test; + +public class ReadDirEntryCertExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void noCertificatePresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + assertFalse(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void emptyCertificateTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + command.getUserCertificate().add(userCertificateType); + assertFalse(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void uidPresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("SomeUid"); + userCertificateType.setDn(dn); + command.getUserCertificate().add(userCertificateType); + assertTrue(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void entryTypePresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setEntryType("1"); + command.getUserCertificate().add(userCertificateType); + assertTrue(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void telematikIDPresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setTelematikID("SomeTelematikId"); + command.getUserCertificate().add(userCertificateType); + assertTrue(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void professionOIDPresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.setProfessionOID("SomeProfessionOID"); + command.getUserCertificate().add(userCertificateType); + assertTrue(readDirEntryCertExecution.checkValidation(command)); + } + + @Test + public void usagePresentTest() { + ReadDirEntryCertExecution readDirEntryCertExecution = new ReadDirEntryCertExecution(connectionPool); + CommandType command = new CommandType(); + UserCertificateType userCertificateType = new UserCertificateType(); + userCertificateType.getUsage().add("SomeUsage"); + command.getUserCertificate().add(userCertificateType); + assertTrue(readDirEntryCertExecution.checkValidation(command)); + } + +} \ No newline at end of file diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionIntegrationTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionIntegrationTest.java new file mode 100644 index 0000000..e30ec7e --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionIntegrationTest.java @@ -0,0 +1,72 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import de.gematik.ti.epa.vzd.client.invoker.ApiException; +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilder; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollection; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandler; +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import generated.CommandType; +import java.io.File; +import java.util.List; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ReadDirEntryExecutionIntegrationTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "IntegrationConfig.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "commands" + File.separator + "readDir.xml"}; + public static List<CommandType> commands; + + @Before + public void initConfigHandler() { + ConfigHandler.setConfigHandler(null); + ConfigHandler.init(TEST_ARGS); + ExecutionCollection.init(ConnectionPool.createConnectionPool(1)); + commands = new CommandsBuilder().buildCommands(); + } + + @After + public void unsetConfigHandler() { + ConfigHandler.setConfigHandler(null); + ExecutionCollection.getInstance().setExecutionCollection(null); + } + + @Test + public void readCommandSuccessTest() throws Exception { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertTrue(readDirEntryExecution.createCallable(commands.get(0)).call()); + } + + @Test + public void readCommandFailTest() throws Exception { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + assertFalse(readDirEntryExecution.createCallable(commands.get(1)).call()); + } + + @Test + public void executeCommandIdNotPresentTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> readDirEntryExecution.executeCommand(commands.get(1), readDirEntryExecution.connectionPool.getConnection())); + assertEquals(404, exception.getCode()); + } + + @Test + public void notExsistingTelematikIDTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(ConnectionPool.createConnectionPool(1)); + ApiException exception = assertThrows(ApiException.class, + () -> readDirEntryExecution.executeCommand(commands.get(2), readDirEntryExecution.connectionPool.getConnection())); + assertEquals("No entry present for telematikID: SomeNotExistingTelematikID", exception.getMessage()); + assertEquals(0, exception.getCode()); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionTest.java new file mode 100644 index 0000000..e86d74a --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/ReadDirEntryExecutionTest.java @@ -0,0 +1,153 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import org.junit.Test; + +public class ReadDirEntryExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void checkValidationMissingArgumentTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + assertFalse(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveDnTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("cbca60fe-8ca7-4960-990d-ec526a200582"); + command.setDn(dn); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveGivenNameTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setGivenName("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveSnTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setSn("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveCnTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setCn("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveDisplayNameTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setDisplayName("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveStreetAddressTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setStreetAddress("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHavePostalCodeTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setPostalCode("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveLocalityNameTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setLocalityName("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveStateOrProvinceNameTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setGivenName("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveTitleTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setTitle("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveOrganizationTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setOrganization("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveOtherNameTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setOtherName("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveSpecializationTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.getSpecialization().add("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveDomainIDTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.getDomainID().add("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHavePersonalEntryTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setPersonalEntry("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } + + @Test + public void checkValidationHaveDataFromAuthorityTest() { + ReadDirEntryExecution readDirEntryExecution = new ReadDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + command.setDataFromAuthority("TestString"); + assertTrue(readDirEntryExecution.checkValidation(command)); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirExecutionTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirExecutionTest.java new file mode 100644 index 0000000..329f5bc --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/command/commandExecutions/SaveModifyDirExecutionTest.java @@ -0,0 +1,48 @@ +package de.gematik.ti.epa.vzd.gem.command.commandExecutions; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import de.gematik.ti.epa.vzd.gem.invoker.ConnectionPool; +import de.gematik.ti.epa.vzd.gem.invoker.IConnectionPool; +import generated.CommandType; +import generated.DistinguishedNameType; +import org.junit.Test; + +public class SaveModifyDirExecutionTest { + + private static IConnectionPool connectionPool = mock(ConnectionPool.class); + + @Test + public void preCheckFalseWhenUidIsEmptyString() { + SaveModifyDirEntryExecution sModDirEnt = new SaveModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid(""); + command.setDn(dn); + + assertTrue(!sModDirEnt.preCheck(command)); + } + + @Test + public void preCheckIsTrue() { + SaveModifyDirEntryExecution sModDirEnt = new SaveModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setUid("Test"); + command.setDn(dn); + + assertTrue(sModDirEnt.preCheck(command)); + } + + @Test + public void preCheckFalseWhenUidIsMissing() { + SaveModifyDirEntryExecution sModDirEnt = new SaveModifyDirEntryExecution(connectionPool); + CommandType command = new CommandType(); + DistinguishedNameType dn = new DistinguishedNameType(); + dn.setCn("Test"); + command.setDn(dn); + + assertTrue(!sModDirEnt.preCheck(command)); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandlerTest.java b/src/test/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandlerTest.java new file mode 100644 index 0000000..106b24b --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/invoker/ConfigHandlerTest.java @@ -0,0 +1,187 @@ +package de.gematik.ti.epa.vzd.gem.invoker; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; + +import de.gematik.ti.epa.vzd.gem.exceptions.GemClientException; +import generated.CommandType; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + +public class ConfigHandlerTest { + + private static final String[] TEST_ARGS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Config.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "rightPath"}; + private static final String[] TEST_ARGS_MAX_CONNECTIONS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "ConnectionWithMaxConnectionDefined.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "rightPath"}; + private static final String[] TEST_ARGS_LIMIT_CONNECTIONS = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "ConnectionWithLimitConnectionDefined.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-b", "rightPath"}; + private static final String[] TEST_ARGS_WITH_COMMANDPATH_AND_PROXY_IN_FILE = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Config.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt"}; + private static final String[] TEST_ARGS_WITH_COMMANDPATH_AND_PROXY_IN_CLI = new String[]{"-p", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Config.txt", "-c", + "src" + File.separator + "test" + File.separator + "resources" + File.separator + + "config" + File.separator + "Credentials.txt", "-d", "4321", "-h", "anotherHost.com"}; + + @Before + public void resetConfigHandler() { + ConfigHandler.setConfigHandler(null); + } + + @Test + public void testGetInstanceBeforeInit() { + GemClientException exception = assertThrows(GemClientException.class, + ConfigHandler::getInstance); + assertEquals("A ConfigHandler have to be initialized first", exception.getMessage()); + } + + @Test + public void doubleInitConfigHandlerTest() { + ConfigHandler.init(TEST_ARGS); + GemClientException exception = assertThrows(GemClientException.class, () -> + ConfigHandler.init(TEST_ARGS)); + assertEquals("Configurations are only allowed to set once", exception.getMessage()); + } + + @Test + public void checkRightCommandsWithCliPath() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS); + + assertEquals(new File("rightPath").getAbsolutePath(), configHandler.getCommandsPath()); + } + + @Test + public void checkRightCommandsWithFilePath() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_WITH_COMMANDPATH_AND_PROXY_IN_FILE); + + assertEquals(new File("src\\test\\resources\\config\\Commands.xml").getAbsolutePath(), configHandler.getCommandsPath()); + } + + @Test + public void checkRightRetryOAuthPath() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS); + + assertEquals("https://to.be.defined/oauth/token", configHandler.getRetryingOAuthPath()); + } + + @Test + public void checkRightBasePath() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS); + + assertEquals("http://[::1]:8080/OAuth2Token", configHandler.getBasePath()); + } + + @Test + public void testGetProxyFromFile() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_WITH_COMMANDPATH_AND_PROXY_IN_FILE); + + assertEquals("Wrong proxy", 1234, configHandler.getProxyPort()); + assertEquals("Wrong host", "testHost.de", configHandler.getProxyHost()); + } + + @Test + public void testGetProxyOverrideFile() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_WITH_COMMANDPATH_AND_PROXY_IN_CLI); + + assertEquals("Wrong proxy", 4321, configHandler.getProxyPort()); + assertEquals("Wrong host", "anotherHost.com", configHandler.getProxyHost()); + } + + @Test + public void testMoreConnectionNeededThanSpecified() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS); + List<CommandType> list = new ArrayList<>(); + CommandType command = new CommandType(); + command.setName("CommandType1"); + list.add(command); + list.add(command); + list.add(command); + CommandType command2 = new CommandType(); + command2.setName("CommandType2"); + list.add(command2); + list.add(command2); + list.add(command2); + configHandler.adjustConnectionCount(list); + assertEquals(4, configHandler.getConnectionCount()); + } + + @Test + public void testLesConnectionNeededThanSpecified() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS); + List<CommandType> list = new ArrayList<>(); + CommandType command = new CommandType(); + command.setName("CommandType1"); + list.add(command); + CommandType command2 = new CommandType(); + command2.setName("CommandType2"); + list.add(command2); + configHandler.adjustConnectionCount(list); + assertEquals(2, configHandler.getConnectionCount()); + } + + @Test + public void testMoreThan20Commands() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_MAX_CONNECTIONS); + List<CommandType> list = new ArrayList<>(); + CommandType command = new CommandType(); + command.setName("CommandType1"); + for (int i = 0; i < 30; i++) { + list.add(command); + } + CommandType command2 = new CommandType(); + command2.setName("CommandType2"); + for (int i = 0; i < 25; i++) { + list.add(command2); + } + CommandType command3 = new CommandType(); + command3.setName("CommandType3"); + list.add(command3); + CommandType command4 = new CommandType(); + command4.setName("CommandType4"); + list.add(command4); + list.add(command4); + list.add(command4); + CommandType command5 = new CommandType(); + command5.setName("CommandType5"); + list.add(command5); + list.add(command5); + list.add(command5); + configHandler.adjustConnectionCount(list); + assertEquals(47, configHandler.getConnectionCount()); + } + + @Test + public void testConnectionLimitByCommands() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_LIMIT_CONNECTIONS); + List<CommandType> commands = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + CommandType command = new CommandType(); + command.setName("CommandType"); + commands.add(command); + } + configHandler.adjustConnectionCount(commands); + assertEquals(2, configHandler.getInstance().getConnectionCount()); + } + + @Test + public void testMoreThanPossibleConnectionDefined() { + ConfigHandler configHandler = ConfigHandler.init(TEST_ARGS_MAX_CONNECTIONS); + assertEquals(180, configHandler.getConnectionCount()); + } +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/AllTestsuite.java b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/AllTestsuite.java new file mode 100644 index 0000000..5584243 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/AllTestsuite.java @@ -0,0 +1,12 @@ +package de.gematik.ti.epa.vzd.gem.testSuites; + + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({IntegrationTestsuite.class, UnitTestsuite.class}) +public class AllTestsuite { + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/IntegrationTestsuite.java b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/IntegrationTestsuite.java new file mode 100644 index 0000000..7d9abe0 --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/IntegrationTestsuite.java @@ -0,0 +1,82 @@ +package de.gematik.ti.epa.vzd.gem.testSuites; + +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryCertExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryCertExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ExecutionBaseIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ModifyDirEntryExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryCertExecutionIntegrationTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryExecutionIntegrationTest; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(Suite.class) +@SuiteClasses({ + AddDirEntryCertExecutionIntegrationTest.class, + AddDirEntryExecutionIntegrationTest.class, + DeleteDirEntryCertExecutionIntegrationTest.class, + DeleteDirEntryExecutionIntegrationTest.class, + ModifyDirEntryExecutionIntegrationTest.class, + ReadDirEntryCertExecutionIntegrationTest.class, + ReadDirEntryExecutionIntegrationTest.class, + ExecutionBaseIntegrationTest.class}) +public class IntegrationTestsuite { + + private static final Logger LOG = LoggerFactory.getLogger(IntegrationTestsuite.class); + public static Process serverProcess; + + @BeforeClass + public static void startServer() throws InterruptedException { + ExecutorService service = Executors.newFixedThreadPool(2); + service.execute(new StartServer()); + Thread.currentThread().sleep(10000); + service.shutdown(); + } + + @AfterClass + public static void tearDownServer() { + serverProcess.destroy(); + } + + static class StartServer implements Runnable { + + @Override + public void run() { + File f = new File("src/test/resources/exec/Testserver.jar"); + ProcessBuilder pb = new ProcessBuilder( + "java", + "-jar", + f.getAbsolutePath() + ); + try { + System.out.println("startServer"); + serverProcess = pb.start(); + System.out.println("Server started by " + Thread.currentThread().getName()); + BufferedReader input = new BufferedReader(new InputStreamReader(serverProcess.getInputStream())); + String line; + try { + while ((line = input.readLine()) != null) { + System.out.println(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + } catch (IOException ioException) { + LOG.error("Server could not be started"); + } + } + } + +} diff --git a/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/UnitTestsuite.java b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/UnitTestsuite.java new file mode 100644 index 0000000..425b2fd --- /dev/null +++ b/src/test/java/de/gematik/ti/epa/vzd/gem/testSuites/UnitTestsuite.java @@ -0,0 +1,36 @@ +package de.gematik.ti.epa.vzd.gem.testSuites; + +import de.gematik.ti.epa.vzd.gem.command.CommandsBuilderTest; +import de.gematik.ti.epa.vzd.gem.command.ExecutionCollectionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryCertExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.AddDirEntryExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryCertExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.DeleteDirEntryExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ExecutionBaseTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ModifyDirEntryExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryCertExecutionTest; +import de.gematik.ti.epa.vzd.gem.command.commandExecutions.ReadDirEntryExecutionTest; +import de.gematik.ti.epa.vzd.gem.invoker.ConfigHandlerTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ + // CommandExecutions + AddDirEntryCertExecutionTest.class, + AddDirEntryExecutionTest.class, + DeleteDirEntryCertExecutionTest.class, + DeleteDirEntryExecutionTest.class, + ModifyDirEntryExecutionTest.class, + ReadDirEntryCertExecutionTest.class, + ReadDirEntryExecutionTest.class, + ExecutionBaseTest.class, + // Command + CommandsBuilderTest.class, + ExecutionCollectionTest.class, + // Invoker + ConfigHandlerTest.class}) +public class UnitTestsuite { + +} diff --git a/src/test/resources/config/Commands.xml b/src/test/resources/config/Commands.xml new file mode 100644 index 0000000..76ab26b --- /dev/null +++ b/src/test/resources/config/Commands.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<CommandList> + <Command> + <name>modifyDirectoryEntries</name> + <dn> + <uid>Blub</uid> + </dn> + <displayName>displayName</displayName> + <otherName>otherName</otherName> + <streetAddress>streetAddress</streetAddress> + <postalCode>postalCode</postalCode> + <localityName>localityName</localityName> + <stateOrProvinceName>stateOrProvinceName</stateOrProvinceName> + <title>title + organization + specialization + domainID + + + modifyDirectoryEntries + + Blub2 + + displayName2 + otherName2 + streetAddress2 + postalCode2 + localityName2 + stateOrProvinceName2 + title2 + organization2 + specialization2 + domainID2 + + \ No newline at end of file diff --git a/src/test/resources/config/CommandsMissingOperationName.xml b/src/test/resources/config/CommandsMissingOperationName.xml new file mode 100644 index 0000000..b55a5e4 --- /dev/null +++ b/src/test/resources/config/CommandsMissingOperationName.xml @@ -0,0 +1,34 @@ + + + + + Blub + + displayName + otherName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + specialization + domainID + + + modifyDirectoryEntries + + Blub2 + + displayName2 + otherName2 + streetAddress2 + postalCode2 + localityName2 + stateOrProvinceName2 + title2 + organization2 + specialization2 + domainID2 + + \ No newline at end of file diff --git a/src/test/resources/config/CommandsWrongFormated.xml b/src/test/resources/config/CommandsWrongFormated.xml new file mode 100644 index 0000000..6b832aa --- /dev/null +++ b/src/test/resources/config/CommandsWrongFormated.xml @@ -0,0 +1,35 @@ + + + + modifyDirectoryEntries + + Blub + + displayName + otherName + streetAddress + postalCode + localityName + stateOrProvinceNametitle + organization + specialization + domainID + + + modifyDirectoryEntries + + Blub2 + + displayName2 + otherName2 + streetAddress2 + postalCode2 + localityName2 + stateOrProvinceName2 + title2 + organization2 + specialization2 + domainID2 + + \ No newline at end of file diff --git a/src/test/resources/config/Config.txt b/src/test/resources/config/Config.txt new file mode 100644 index 0000000..eb11a0f --- /dev/null +++ b/src/test/resources/config/Config.txt @@ -0,0 +1,7 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\Commands.xml +proxyPort=1234 +proxyHost=testHost.de +maxExecutionsPerOperation=2 +maxOperations=2 \ No newline at end of file diff --git a/src/test/resources/config/ConfigMissingCommands.txt b/src/test/resources/config/ConfigMissingCommands.txt new file mode 100644 index 0000000..7bfcf81 --- /dev/null +++ b/src/test/resources/config/ConfigMissingCommands.txt @@ -0,0 +1,3 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=doesNotExist.xml \ No newline at end of file diff --git a/src/test/resources/config/ConfigMissingOperationname.txt b/src/test/resources/config/ConfigMissingOperationname.txt new file mode 100644 index 0000000..71eecf8 --- /dev/null +++ b/src/test/resources/config/ConfigMissingOperationname.txt @@ -0,0 +1,3 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\CommandsMissingOperationName.xml \ No newline at end of file diff --git a/src/test/resources/config/ConfigWrongFormattedCommands.txt b/src/test/resources/config/ConfigWrongFormattedCommands.txt new file mode 100644 index 0000000..e6900b1 --- /dev/null +++ b/src/test/resources/config/ConfigWrongFormattedCommands.txt @@ -0,0 +1,3 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\CommandsWrongFormated.xml \ No newline at end of file diff --git a/src/test/resources/config/ConnectionWithLimitConnectionDefined.txt b/src/test/resources/config/ConnectionWithLimitConnectionDefined.txt new file mode 100644 index 0000000..98e326b --- /dev/null +++ b/src/test/resources/config/ConnectionWithLimitConnectionDefined.txt @@ -0,0 +1,7 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\Commands.xml +proxyPort=1234 +proxyHost=testHost.de +maxExecutionsPerOperation=5 +maxOperations=9 \ No newline at end of file diff --git a/src/test/resources/config/ConnectionWithMaxConnectionDefined.txt b/src/test/resources/config/ConnectionWithMaxConnectionDefined.txt new file mode 100644 index 0000000..9016259 --- /dev/null +++ b/src/test/resources/config/ConnectionWithMaxConnectionDefined.txt @@ -0,0 +1,7 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\Commands.xml +proxyPort=1234 +proxyHost=testHost.de +maxExecutionsPerOperation=999 +maxOperations=99 \ No newline at end of file diff --git a/src/test/resources/config/Credentials.txt b/src/test/resources/config/Credentials.txt new file mode 100644 index 0000000..0ce6b34 --- /dev/null +++ b/src/test/resources/config/Credentials.txt @@ -0,0 +1,2 @@ +id=someId +secret=someSecret \ No newline at end of file diff --git a/src/test/resources/config/DoubleIdCommands.xml b/src/test/resources/config/DoubleIdCommands.xml new file mode 100644 index 0000000..e942d5d --- /dev/null +++ b/src/test/resources/config/DoubleIdCommands.xml @@ -0,0 +1,37 @@ + + + + thisShouldOccureAnError + modifyDirectoryEntries + + Blub + + displayName + otherName + streetAddress + postalCode + localityName + stateOrProvinceName + title + organization + specialization + domainID + + + thisShouldOccureAnError + modifyDirectoryEntries + + Blub2 + + displayName2 + otherName2 + streetAddress2 + postalCode2 + localityName2 + stateOrProvinceName2 + title2 + organization2 + specialization2 + domainID2 + + \ No newline at end of file diff --git a/src/test/resources/config/DoubledCommandId.txt b/src/test/resources/config/DoubledCommandId.txt new file mode 100644 index 0000000..bb6ee13 --- /dev/null +++ b/src/test/resources/config/DoubledCommandId.txt @@ -0,0 +1,3 @@ +base=http://[::1]:8080/OAuth2Token +retryingOAuth=https://to.be.defined/oauth/token +commands=src\test\resources\config\DoubleIdCommands.xml \ No newline at end of file diff --git a/src/test/resources/config/IntegrationConfig.txt b/src/test/resources/config/IntegrationConfig.txt new file mode 100644 index 0000000..303edad --- /dev/null +++ b/src/test/resources/config/IntegrationConfig.txt @@ -0,0 +1,2 @@ +base=http://[::1]:4041 +retryingOAuth=http://[::1]:4041/oauth/token \ No newline at end of file diff --git a/src/test/resources/config/commands/addCert.xml b/src/test/resources/config/commands/addCert.xml new file mode 100644 index 0000000..6a45712 --- /dev/null +++ b/src/test/resources/config/commands/addCert.xml @@ -0,0 +1,33 @@ + + + + TestSuccess + addDirectoryEntryCertificate + + SuccessUId + + + SuccessTelematikId + ePA + + MIIFHjCCBAagAwIBAgIHA+5BCCCEfTANBgkqhkiG9w0BAQsFADCBmjELMAkGA1UEBhMCREUxHzAdBgNVBAoMFmdlbWF0aWsgR21iSCBOT1QtVkFMSUQxRjBEBgNVBAsMPUhCQS1xQ0EgZGVyIFRlbGVtYXRpa2luZnJhc3RydWt0dXIgbWl0IEFuYmlldGVyYWtrcmVkaXRpZXJ1bmcxIjAgBgNVBAMMGUdFTS5IQkEtcUNBNTpQTiBURVNULU9OTFkwHhcNMjAwNTEzMDAwMDAwWhcNMjUwNTEyMjM1OTU5WjBtMQswCQYDVQQGEwJERTFeMA0GA1UEKgwGTWFydGluMA8GA1UEBAwIR2VpYsO2bGwwGwYDVQQFExQ4MDI3Njg4MzExMDAwMDIxODU3MjAfBgNVBAMMGE1hcnRpbiBHZWliw7ZsbFRFU1QtT05MWTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMPTJsw7AHirJcBnS8Jbuf6pjBasQTH7NTcNUDyyOwh35QUdCWgO83kbipxv8yJLrF6Rgb5qw2hbNEsUiNsrwuwn/CF65HiyXMajbNo1etAb23sWHeQt2XLuInJGuT9oM8VWh5rfVTbQL+Bp2VbeoEoqyMLufojL3S/Hal2HDIEd5OWiiTr3i5ECLZX9iHOe8+9c0Q8X1AjeISQLCyuJ3iR67UCpSQBUaMiJaaiVzKaf6kNeRBsAvX78pThkv1oTT7apoQ9l3+x1yjhfF5BQXrigD78W7SYLdRYP/40xj5PUAMD73Cfwij/c4VcqowDRBctRZtP1OyU9FZ6+lgaogoMCAwEAAaOCAZMwggGPMB0GA1UdDgQWBBQTf/qksNlSX3Q1RAcuoXKWLlsZRjA5BgNVHSAEMjAwMAkGByqCFABMBEgwCQYHBACL7EABAjAKBggqghQATASBETAMBgorBgEEAYLNMwEBMCIGCCsGAQUFBwEDBBYwFDAIBgYEAI5GAQEwCAYGBACORgEEMA4GA1UdDwEB/wQEAwIGQDA4BggrBgEFBQcBAQQsMCowKAYIKwYBBQUHMAGGHGh0dHA6Ly9laGNhLmdlbWF0aWsuZGUvb2NzcC8wDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBShOjUzorMhCb0AWpKm55d2xFD7tzAbBgkrBgEEAcBtAwUEDjAMBgorBgEEAcBtAwUBMHkGBSskCAMDBHAwbqQoMCYxCzAJBgNVBAYTAkRFMRcwFQYDVQQKDA5nZW1hdGlrIEJlcmxpbjBCMEAwPjA8MA4MDMOEcnp0aW4vQXJ6dDAJBgcqghQATAQeEx8xLUhCQS1UZXN0a2FydGUtODgzMTEwMDAwMjE4NTcyMA0GCSqGSIb3DQEBCwUAA4IBAQA6wy8SHuB3O2m9xT5WZU7krCBbTjAqVpK8Prmq/eqCXp0c7JHp8tZMiflEzckO01divk9FvtsDEHjwnTEFKYrquPbU9BBsfcLM2u/NugWLqhc6DlH/cxfjhL/e5wgFcBKhJ0UC/3mLCO9EImsuS8qMMBvh4giY/BdHLM7xHZWHxAnknieqSFoutLmFbSSV8ggW1sxPKVGKfh1QYOL1cDz8MbOUKnMTKQGFTSwiJ4lfPq7TkevCBlGYvZQPlodL8xTVWcJLhTjuoLuWcrmkMe/aF4WKd4MwMsmHhgGN4yV2YY56D3L6OV/Np0UJ7A918E9E7iLqLkyVKJcCRTltk+35 + + crazyStuff + + + + TestFail + addDirectoryEntryCertificate + + SuccessUId + + + TelematikId + ePA + + does not fit to TelematikId + + crazyStuff + + + diff --git a/src/test/resources/config/commands/addDir.xml b/src/test/resources/config/commands/addDir.xml new file mode 100644 index 0000000..1503763 --- /dev/null +++ b/src/test/resources/config/commands/addDir.xml @@ -0,0 +1,55 @@ + + + + TestSuccess + addDirectoryEntries + GivenName + SN + streetAddress + postalCode + localityName + stateOrProvinceName + CN + displayName + title + organization + otherName + specialization + domainID + asdf@gmx.net + + SuccessTelematikId + + + + TestFail + addDirectoryEntries + GivenName + SN + streetAddress + postalCode + localityName + stateOrProvinceName + CN + displayName + title + organization + otherName + specialization + domainID + asdf@gmx.net + + FailTelematikId + + + + TestTelematikIdFail + addDirectoryEntries + + FailTelematikId + + + OtherFailTelematikId + + + \ No newline at end of file diff --git a/src/test/resources/config/commands/delCert.xml b/src/test/resources/config/commands/delCert.xml new file mode 100644 index 0000000..faeabda --- /dev/null +++ b/src/test/resources/config/commands/delCert.xml @@ -0,0 +1,25 @@ + + + + TestSuccess + deleteDirectoryEntryCertificate + + + e6483730-6788-4e4b-8ac2-19e858dbae64 + fdb30aad-5f37-4af6-970a-1d4c643ce36a + + 1-HBA-Testkarte-883110000218572 + + + + TestFail + deleteDirectoryEntryCertificate + + + noValidCn + fdb30aad-5f37-4af6-970a-1d4c643ce36a + + 1-HBA-Testkarte-883110000218572 + + + \ No newline at end of file diff --git a/src/test/resources/config/commands/delDir.xml b/src/test/resources/config/commands/delDir.xml new file mode 100644 index 0000000..a8d1b13 --- /dev/null +++ b/src/test/resources/config/commands/delDir.xml @@ -0,0 +1,17 @@ + + + + TestSuccess + deleteDirectoryEntries + + d0752991-d822-48a5-aba9-9af73cbe8f1c + + + + TestFail + deleteDirectoryEntries + + failUid + + + diff --git a/src/test/resources/config/commands/executionBase.xml b/src/test/resources/config/commands/executionBase.xml new file mode 100644 index 0000000..2fd8239 --- /dev/null +++ b/src/test/resources/config/commands/executionBase.xml @@ -0,0 +1,13 @@ + + + + RealTelematik + readDirectoryEntries + + SomeUid + + + Some-TelematikID-that-does-not-fit-the-uid + + + \ No newline at end of file diff --git a/src/test/resources/config/commands/modDir.xml b/src/test/resources/config/commands/modDir.xml new file mode 100644 index 0000000..3ee4cde --- /dev/null +++ b/src/test/resources/config/commands/modDir.xml @@ -0,0 +1,40 @@ + + + + TestSuccess + modifyDirectoryEntries + + 469fd210-b2f8-4d8e-b7ef-c0434303c26d + Hallo hier ist ein Test + + Hero + Whut? + Nirvana + 12345 + Luluhausen + Vereiniges Spaßhausen + Thut + Holla die Waldfee + Denk dir was eigenes lustiges aus + Gagfabrik + Hups I did it again + Spaßmachen + Malen + Lachen + Vereiern + Immer + noch + keinen + Schimmer + was + das + ist + + + ModNotExistentDoModifyTest + modifyDirectoryEntries + + FailModifyUId + + + \ No newline at end of file diff --git a/src/test/resources/config/commands/readCert.xml b/src/test/resources/config/commands/readCert.xml new file mode 100644 index 0000000..a8c8d58 --- /dev/null +++ b/src/test/resources/config/commands/readCert.xml @@ -0,0 +1,26 @@ + + + + TestSuccess + readDirectoryEntryCertificate + + UIdSuccess + + + + UIdSuccess + + 1-HBA-Testkarte-883110000218572 + + + + TestFail + readDirectoryEntryCertificate + + + UIdFail + + SomeTelematikid + + + diff --git a/src/test/resources/config/commands/readDir.xml b/src/test/resources/config/commands/readDir.xml new file mode 100644 index 0000000..9e5ede7 --- /dev/null +++ b/src/test/resources/config/commands/readDir.xml @@ -0,0 +1,24 @@ + + + + 1 + readDirectoryEntries + + 469fd210-b2f8-4d8e-b7ef-c0434303c26d + + + + 2 + readDirectoryEntries + + failUid + + + + 3 + readDirectoryEntries + + SomeNotExistingTelematikID + + + \ No newline at end of file diff --git a/src/test/resources/exec/Testserver.jar b/src/test/resources/exec/Testserver.jar new file mode 100644 index 0000000..da161b7 Binary files /dev/null and b/src/test/resources/exec/Testserver.jar differ diff --git a/version.txt b/version.txt new file mode 100644 index 0000000..b71a88e --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +1.1.1