From 2fba3e5addd6c588761fde9e0d5dae079662e2a5 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 13 Nov 2020 13:33:35 +0100 Subject: [PATCH] Feature/authentication (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Basic Authentication für den Client implementiert (fixes #13) * Version 1.1.0 * neueres Gradle BND Plugin verwenden * Authenifizierung im Betriebshandbuch beschrieben --- build.gradle | 6 +- de.bitctrl.dav.rest.api/.classpath | 20 ---- de.bitctrl.dav.rest.api/config/checkstyle.xml | 106 +++++++++--------- .../Betriebshandbuch.md | 2 + .../de/bitctrl/dav/rest/client/Client.java | 9 +- de.bitctrl.dav.rest.server/.classpath | 6 - 6 files changed, 66 insertions(+), 83 deletions(-) diff --git a/build.gradle b/build.gradle index 02039ce..87d830b 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { } dependencies { classpath "org.raml.jaxrs:raml-to-jaxrs-gradle-plugin:3.0.5" - classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:4.1.0" + classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:5.2.0" classpath "gradle.plugin.de.fntsoftware.gradle:markdown-to-pdf:1.1.0" } } @@ -25,11 +25,11 @@ allprojects { mavenLocal() maven { url "https://dl.bintray.com/bitctrl/maven" } mavenCentral() - maven { url "http://h2727649.stratoserver.net:8081/repository/nerz-maven-public/" } + maven { url "https://repo.nerz-ev.de" } } group = 'de.bitctrl.dav.rest' - version = '1.0.2-SNAPSHOT' + version = '1.1.0-SNAPSHOT' } markdownToPdf{ diff --git a/de.bitctrl.dav.rest.api/.classpath b/de.bitctrl.dav.rest.api/.classpath index 7a907fa..df0c7b8 100644 --- a/de.bitctrl.dav.rest.api/.classpath +++ b/de.bitctrl.dav.rest.api/.classpath @@ -1,31 +1,11 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/de.bitctrl.dav.rest.api/config/checkstyle.xml b/de.bitctrl.dav.rest.api/config/checkstyle.xml index 6819c37..6ba4dec 100644 --- a/de.bitctrl.dav.rest.api/config/checkstyle.xml +++ b/de.bitctrl.dav.rest.api/config/checkstyle.xml @@ -1,58 +1,58 @@ - - - + + + +--> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +--> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/de.bitctrl.dav.rest.client/Betriebshandbuch.md b/de.bitctrl.dav.rest.client/Betriebshandbuch.md index 115889a..060b44f 100644 --- a/de.bitctrl.dav.rest.client/Betriebshandbuch.md +++ b/de.bitctrl.dav.rest.client/Betriebshandbuch.md @@ -97,6 +97,8 @@ Die SWE verwendet die Datenverteiler - Applikationsfunktionen zur Kommunikation * `-objekt=` : Die PID des Applikationsobjektes (vom Typ `typ.archiv`) * `-url=http://localhost` : Die URL des REST Servers, der Standardwert ist `http://localhost`. * `-port=80` : Der Port des REST Servers, der Standardwert ist `9998`. +* `-authUser=` : Nutzername für die Authentifizierung am REST Server (optional). +* `-authPassword=` : Passwort für die Authentifizierung am REST Server (optional). #### Unterstützte Datenspezifikationen diff --git a/de.bitctrl.dav.rest.client/src/main/java/de/bitctrl/dav/rest/client/Client.java b/de.bitctrl.dav.rest.client/src/main/java/de/bitctrl/dav/rest/client/Client.java index 79266b7..31ee779 100644 --- a/de.bitctrl.dav.rest.client/src/main/java/de/bitctrl/dav/rest/client/Client.java +++ b/de.bitctrl.dav.rest.client/src/main/java/de/bitctrl/dav/rest/client/Client.java @@ -27,6 +27,7 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; +import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.jackson.JacksonFeature; import de.bsvrz.dav.daf.main.ClientDavInterface; @@ -56,12 +57,16 @@ public static void main(final String[] args) { private String serverUrl; private String port; private javax.ws.rs.client.Client client; + private String authUser; + private String authPassword; @Override public void parseArguments(ArgumentList argumentList) throws Exception { archivObjektPid = argumentList.fetchArgument("-objekt=").asString(); serverUrl = argumentList.fetchArgument("-url=http://localhost").asString(); port = argumentList.fetchArgument("-port=9998").asString(); + authUser = argumentList.fetchArgument("-authUser=").asString(); + authPassword = argumentList.fetchArgument("-authPassword=").asString(); } @@ -84,6 +89,9 @@ public void initialize(ClientDavInterface connection) throws Exception { final ClientConfig config = new ClientConfig(); config.register(JacksonFeature.class); + if (!authPassword.isEmpty()) { + config.register(HttpAuthenticationFeature.basic(authUser, authPassword)); + } config.property(ClientProperties.READ_TIMEOUT, 60000); // ClientBuilder.newBuilder().sslContext(ctx); @@ -98,7 +106,6 @@ public void initialize(ClientDavInterface connection) throws Exception { @Override public void connectionClosed(ClientDavInterface connection) { client.close(); - } } diff --git a/de.bitctrl.dav.rest.server/.classpath b/de.bitctrl.dav.rest.server/.classpath index f73487b..42f073e 100644 --- a/de.bitctrl.dav.rest.server/.classpath +++ b/de.bitctrl.dav.rest.server/.classpath @@ -13,12 +13,6 @@ - - - - - -