diff --git a/iris-public-server/.mvn/wrapper/MavenWrapperDownloader.java b/iris-public-server/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index e76d1f32..00000000 --- a/iris-public-server/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://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. - */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if(mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if(mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if(!outputFile.getParentFile().exists()) { - if(!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/iris-public-server/.mvn/wrapper/maven-wrapper.properties b/iris-public-server/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 642d572c..00000000 --- a/iris-public-server/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/iris-public-server/README.md b/iris-public-server/README.md deleted file mode 100644 index 238de101..00000000 --- a/iris-public-server/README.md +++ /dev/null @@ -1,8 +0,0 @@ -Tips: - -You need to set following http header: -Content-Type=application/json;charset=UTF-8 - -You can not submit requests directly to the public server because they need to be signed. - -Instead, start and submit the requests to the iris-client. diff --git a/iris-public-server/mvnw b/iris-public-server/mvnw deleted file mode 100755 index a16b5431..00000000 --- a/iris-public-server/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# 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 -# -# https://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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/iris-public-server/mvnw.cmd b/iris-public-server/mvnw.cmd deleted file mode 100644 index c8d43372..00000000 --- a/iris-public-server/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/iris-public-server/pom.xml b/iris-public-server/pom.xml deleted file mode 100644 index cc7992a7..00000000 --- a/iris-public-server/pom.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.4.2 - - - iris-gateway - iris-public-server - 0.0.1-SNAPSHOT - IRIS Public Server - Central public IRIS instance that receives and collects data and passes it through the IRIS system to the correct health department. - - - GNU Affero General Public License (AGPL) v3 - https://www.gnu.org/licenses/agpl-3.0 - - - - - UTF-8 - 11 - inoeg - ${project.version} - 0.10.3 - 1.4.18 - - - - - localDev - - - src/main/resources/application-local.properties - - - - - dev,local - - - - - com.h2database - h2 - runtime - - - - - - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.h2database - h2 - test - - - org.postgresql - postgresql - runtime - - - org.flywaydb - flyway-core - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-hateoas - - - org.springframework.boot - spring-boot-starter-validation - - - - - org.springframework.boot - spring-boot-starter-security - - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-configuration-processor - true - - - - - org.xmlbeam - xmlprojector - ${xmlprojector-version} - - - - - org.apache.commons - commons-lang3 - - - org.projectlombok - lombok - true - - - io.vavr - vavr - ${vavr-version} - - - org.apache.httpcomponents - httpclient - - - - - org.springdoc - springdoc-openapi-ui - 1.5.7 - - - - - ${project.artifactId}-${version.tag} - - - - org.springframework.boot - spring-boot-maven-plugin - - - ${spring.profiles.active} - - - - org.projectlombok - lombok - - - - ${docker.image.prefix}/${project.artifactId}:${version.tag} - - - docker - - - - - - ${env.DOCKER_HUB_USER} - ${env.DOCKER_HUB_PW} - - - - - - - - pl.project13.maven - git-commit-id-plugin - - true - - - - - diff --git a/iris-public-server/src/main/java/iris/public_server/IrisPublicServerApplication.java b/iris-public-server/src/main/java/iris/public_server/IrisPublicServerApplication.java deleted file mode 100644 index 032f55b1..00000000 --- a/iris-public-server/src/main/java/iris/public_server/IrisPublicServerApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server; - -import org.springframework.boot.ResourceBanner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.support.PropertiesLoaderUtils; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.hateoas.config.EnableHypermediaSupport; -import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType; -import org.springframework.scheduling.annotation.EnableScheduling; - -@SpringBootApplication -@ConfigurationPropertiesScan -@EnableJpaAuditing(dateTimeProviderRef = "irisDateTimeProvider") -@EnableScheduling -@EnableHypermediaSupport(type = HypermediaType.HAL) -public class IrisPublicServerApplication { - - public static void main(String[] args) throws Exception { - - var properties = PropertiesLoaderUtils.loadAllProperties("git.properties"); - var banner = new ResourceBanner(new ClassPathResource("iris-banner.txt")) { - @Override - protected String getApplicationVersion(Class sourceClass) { - return properties.getProperty("git.build.version", "-") + " (" - + properties.getProperty("git.commit.id.abbrev", "-") - + ")"; - } - }; - - var application = new SpringApplication(IrisPublicServerApplication.class); - application.setBanner(banner); - application.run(args); - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/config/AppProviderProperties.java b/iris-public-server/src/main/java/iris/public_server/config/AppProviderProperties.java deleted file mode 100644 index a6a5e7fe..00000000 --- a/iris-public-server/src/main/java/iris/public_server/config/AppProviderProperties.java +++ /dev/null @@ -1,40 +0,0 @@ -package iris.public_server.config; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.Getter; - -import java.util.List; -import java.util.stream.Collectors; - -import org.apache.commons.lang3.StringUtils; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; - -@ConstructorBinding -@AllArgsConstructor -@ConfigurationProperties(prefix = "providers") -public class AppProviderProperties { - - private final @Getter String hostForSubmission; - private final @Getter Integer portForSubmission; - private final List providers; - - public Provider findByProviderId(String providerId) { - var configurationList = providers.stream() - .filter(it -> StringUtils.equals(it.getId(), providerId)) - .collect(Collectors.toList()); - var listSize = configurationList.size(); - if (listSize != 1) { - throw new RuntimeException( - "Unexpected number of providers for id=" + providerId + " found=" + listSize); - } - return configurationList.get(0); - } - - @Data - public static class Provider { - String id; - String dataRequestEndpoint; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/config/DataSubmissionProperties.java b/iris-public-server/src/main/java/iris/public_server/config/DataSubmissionProperties.java deleted file mode 100644 index a1b065c9..00000000 --- a/iris-public-server/src/main/java/iris/public_server/config/DataSubmissionProperties.java +++ /dev/null @@ -1,17 +0,0 @@ -package iris.public_server.config; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; -import org.springframework.context.annotation.Configuration; - -@ConstructorBinding -@AllArgsConstructor -@Getter -@ConfigurationProperties("iris.data-submission") -public class DataSubmissionProperties { - - private int graceTimeSeconds; - -} diff --git a/iris-public-server/src/main/java/iris/public_server/config/FlywayConfig.java b/iris-public-server/src/main/java/iris/public_server/config/FlywayConfig.java deleted file mode 100644 index 79dab7e1..00000000 --- a/iris-public-server/src/main/java/iris/public_server/config/FlywayConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package iris.public_server.config; - -import lombok.extern.slf4j.Slf4j; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.env.Environment; - -@Configuration -@Slf4j -public class FlywayConfig { - - @Autowired - Environment env; - - @Bean - FlywayMigrationStrategy getFlywayMigrationStrategy() { - - return flyway -> { - - var profiles_clean = List.of("psql_compose_db"); - if (Arrays.stream(env.getActiveProfiles()).anyMatch(profiles_clean::contains)) { - flyway.clean(); - } - - if (log.isDebugEnabled()) { - - var results = flyway.validateWithResult(); - - results.invalidMigrations.forEach(it -> { - - var errorDetails = it.errorDetails; - - log.debug("ValidateOutput: " + it.description + errorDetails != null - ? " | ErrorCode: " + errorDetails.errorCode + " | ErrorMessage: " + errorDetails.errorMessage - : ""); - }); - } - - flyway.migrate(); - }; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/config/I18nConfig.java b/iris-public-server/src/main/java/iris/public_server/config/I18nConfig.java deleted file mode 100644 index e3ef2985..00000000 --- a/iris-public-server/src/main/java/iris/public_server/config/I18nConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.config; - -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.MessageSourceAccessor; - -/** - * @author Jens Kutzsche - */ -@Configuration -public class I18nConfig { - - @Bean - MessageSourceAccessor messageSourceAccessor(MessageSource source) { - return new MessageSourceAccessor(source); - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/config/RestTemplateConfig.java b/iris-public-server/src/main/java/iris/public_server/config/RestTemplateConfig.java deleted file mode 100644 index 29d8bfee..00000000 --- a/iris-public-server/src/main/java/iris/public_server/config/RestTemplateConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package iris.public_server.config; - -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.ssl.SSLContextBuilder; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.web.client.RestTemplate; - -@Configuration -public class RestTemplateConfig { - - @Bean - public RestTemplate restTemplate(RestTemplateBuilder builder) - throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException { - var sslContext = new SSLContextBuilder().loadTrustMaterial((chain, authType) -> true) // trust all server - // certificates - .build(); - var socketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE); - var httpClient = HttpClientBuilder.create().setSSLSocketFactory(socketFactory).build(); - var template = builder.build(); - template.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)); - return template; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/core/Aggregate.java b/iris-public-server/src/main/java/iris/public_server/core/Aggregate.java deleted file mode 100644 index 780753a0..00000000 --- a/iris-public-server/src/main/java/iris/public_server/core/Aggregate.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.core; - -import lombok.EqualsAndHashCode; -import lombok.Getter; - -import javax.persistence.EmbeddedId; -import javax.persistence.EntityListeners; -import javax.persistence.MappedSuperclass; -import javax.persistence.PostLoad; -import javax.persistence.PrePersist; -import javax.persistence.Transient; - -import org.springframework.data.domain.AbstractAggregateRoot; -import org.springframework.data.domain.Persistable; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - -/** - * Base class of aggregates in the sense of DDD - * - * @author Jens Kutzsche - */ -@MappedSuperclass -@Getter -@EqualsAndHashCode(of = "id", callSuper = false) -@EntityListeners(AuditingEntityListener.class) -public abstract class Aggregate, ID extends Id> extends AbstractAggregateRoot - implements Persistable { - - protected @EmbeddedId ID id; - private Metadata metadata = new Metadata(); - private @Transient boolean isNew = true; - - @PrePersist - @PostLoad - void markNotNew() { - this.isNew = false; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/core/Feature.java b/iris-public-server/src/main/java/iris/public_server/core/Feature.java deleted file mode 100644 index 1f4aa5ba..00000000 --- a/iris-public-server/src/main/java/iris/public_server/core/Feature.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.core; - -public enum Feature { - Contacts_Events, Guests -} diff --git a/iris-public-server/src/main/java/iris/public_server/core/Id.java b/iris-public-server/src/main/java/iris/public_server/core/Id.java deleted file mode 100644 index a3c931c2..00000000 --- a/iris-public-server/src/main/java/iris/public_server/core/Id.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.core; - -/** - * Marker interface for entity identifiers - * - * @author Jens Kutzsche - */ -public interface Id {} diff --git a/iris-public-server/src/main/java/iris/public_server/core/IrisDateTimeProvider.java b/iris-public-server/src/main/java/iris/public_server/core/IrisDateTimeProvider.java deleted file mode 100644 index b73e6a60..00000000 --- a/iris-public-server/src/main/java/iris/public_server/core/IrisDateTimeProvider.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.core; - -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; - -import java.time.Instant; -import java.time.Period; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAmount; -import java.util.Optional; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.context.properties.ConstructorBinding; -import org.springframework.context.annotation.Profile; -import org.springframework.data.auditing.DateTimeProvider; -import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; - -/** - * DateTimeProvider to configure the Metadata of Entities for test scenarios - * - * @author Jens Kutzsche - */ -@Component -public class IrisDateTimeProvider implements DateTimeProvider { - - private DateTimeProperties properties; - private @Getter @Setter TemporalAmount delta; - - public IrisDateTimeProvider(@Nullable DateTimeProperties properties) { - - this.properties = properties; - - delta = properties != null ? properties.getDelta() : Period.ZERO; - } - - public void reset() { - this.delta = properties.getDelta(); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.auditing.DateTimeProvider#getNow() - */ - @Override - public Optional getNow() { - return Optional.of(Instant.now().plus(delta)); - } - - @ConstructorBinding - @ConfigurationProperties("date-time") - @RequiredArgsConstructor - @Profile("!prod") - public static class DateTimeProperties { - - private final Period delta; - - public Period getDelta() { - return delta != null ? delta : Period.ZERO; - } - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/core/Metadata.java b/iris-public-server/src/main/java/iris/public_server/core/Metadata.java deleted file mode 100644 index 0ad84ab0..00000000 --- a/iris-public-server/src/main/java/iris/public_server/core/Metadata.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.core; - -import lombok.Getter; - -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZonedDateTime; - -import javax.persistence.Embeddable; - -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.annotation.LastModifiedDate; - -/** - * Encapsulates entity metadata - * - * @author Jens Kutzsche - */ -@Getter -@Embeddable -public class Metadata { - - @CreatedDate - Instant created; - @LastModifiedDate - Instant lastModified; -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/DataRequest.java b/iris-public-server/src/main/java/iris/public_server/data_request/DataRequest.java deleted file mode 100644 index 2013ff92..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/DataRequest.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request; - -import iris.public_server.core.Aggregate; -import iris.public_server.core.Feature; -import iris.public_server.core.Id; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; -import lombok.Setter; - -import java.io.Serializable; -import java.time.Instant; -import java.util.Set; -import java.util.UUID; - -import javax.persistence.*; - -/** - * A data request from the health department to a citizen or event/location operator. - * - * @author Jens Kutzsche - */ -@Entity -@Table(name = "data_request") -@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) -@Getter -@Setter(AccessLevel.PACKAGE) -public class DataRequest extends Aggregate { - - private DepartmentIdentifier departmentId; - - private Instant requestStart; - private Instant requestEnd; - - private @Lob String requestDetails; - - @Enumerated(EnumType.STRING) @ElementCollection(fetch = FetchType.EAGER) @CollectionTable( - name = "data_request_feature", - joinColumns = @JoinColumn(name = "request_id")) @Column(name = "feature", nullable = false) - private Set features; - - @Enumerated(EnumType.STRING) @Column(nullable = false) - private Status status = Status.DATA_REQUESTED; - - public DataRequest(DataRequestIdentifier id, DepartmentIdentifier departmentId, Instant requestStart, - Instant requestEnd, String requestDetails, Set features, Status status) { - - super(); - - this.id = id; - this.departmentId = departmentId; - this.requestStart = requestStart; - this.requestEnd = requestEnd; - this.requestDetails = requestDetails; - this.features = features; - this.status = status; - } - - public boolean isClosed() { - return getStatus() == Status.CLOSED; - } - - @Embeddable - @EqualsAndHashCode - @RequiredArgsConstructor(staticName = "of") - @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) - public static class DataRequestIdentifier implements Id, Serializable { - - private static final long serialVersionUID = -8254677010830428881L; - - final UUID requestId; - - /** - * for JSON deserialization - */ - public static DataRequestIdentifier of(String uuid) { - return of(UUID.fromString(uuid)); - } - - @Override - public String toString() { - return requestId.toString(); - } - } - - public enum Status { - DATA_REQUESTED, DATA_RECEIVED, CLOSED - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/DataRequestRepository.java b/iris-public-server/src/main/java/iris/public_server/data_request/DataRequestRepository.java deleted file mode 100644 index 87d5ec9b..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/DataRequestRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request; - -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Jens Kutzsche - */ -public interface DataRequestRepository extends CrudRepository { - -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApi.java b/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApi.java deleted file mode 100644 index 965d92d7..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApi.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program (3.0.24). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package iris.public_server.data_request.web; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -public interface DataRequestApi { - - @Operation(summary = "Returns the data request for a code.", description = "", tags = {}) - @ApiResponses(value = { @ApiResponse(responseCode = "200", - description = "A data request with all parameters relevant for the data submission and the links to the next possible steps for data submission.", - content = @Content(schema = @Schema(implementation = DataRequestDto.class))), - - @ApiResponse(responseCode = "401", description = "The client is unauthorized to access this API."), - - @ApiResponse(responseCode = "404", description = "The specified resource was not found.") }) - @RequestMapping(value = "/data-requests/{code}", produces = { "application/hal+json" }, method = RequestMethod.GET) - ResponseEntity getDataRequestByCode( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code); -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApiController.java b/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApiController.java deleted file mode 100644 index 52f39618..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestApiController.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request.web; - -import static java.util.function.Predicate.*; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; -import io.vavr.control.Option; -import iris.public_server.data_request.DataRequest; -import iris.public_server.data_request.DataRequestRepository; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import org.springframework.context.support.MessageSourceAccessor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * Controller of the public end-points for apps to exchange data requests. - * - * @author Jens Kutzsche - */ -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -@RestController -@RequiredArgsConstructor -@Slf4j -public class DataRequestApiController implements DataRequestApi { - - private final @NonNull DataRequestRepository requests; - private final @NonNull DataRequestRepresentations representation; - private final @NonNull MessageSourceAccessor messages; - - @Override - public ResponseEntity getDataRequestByCode( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code) { - - return Option.ofOptional(requests.findById(code)) - .toEither(() -> ResponseEntity.status(HttpStatus.NOT_FOUND) - .body(messages.getMessage("dataRequest.notFound"))) - .filterOrElse(not(DataRequest::isClosed), - it -> ResponseEntity.badRequest() - .body(messages.getMessage("dataRequest.isClosed"))) - .map(this::log) - .map(representation::toRepresentation) - .fold(it -> it, ResponseEntity::ok); - } - - private DataRequest log(DataRequest request) { - - log.debug("Request - GET from public: {}", request.getId().toString()); - - return request; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestDto.java b/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestDto.java deleted file mode 100644 index 4cd7cec8..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestDto.java +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request.web; - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.time.Instant; -import java.util.Objects; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import org.springframework.validation.annotation.Validated; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A data request with all parameters relevant for the data submission. - */ -@Schema(description = "A data request with all parameters relevant for the data submission.") -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") - -public class DataRequestDto { - - @JsonProperty("healthDepartment") - private String healthDepartment = null; - - @JsonProperty("keyOfHealthDepartment") - private String keyOfHealthDepartment = null; - - @JsonProperty("keyReference") - private String keyReference = null; - - @JsonProperty("start") - private Instant start = null; - - @JsonProperty("end") - private Instant end = null; - - @JsonProperty("requestDetails") - private String requestDetails = null; - - public DataRequestDto healthDepartment(String healthDepartment) { - this.healthDepartment = healthDepartment; - return this; - } - - /** - * Name of the requesting health department. - * - * @return healthDepartment - **/ - @Schema(required = true, description = "Name of the requesting health department.") - @NotNull - - public String getHealthDepartment() { - return healthDepartment; - } - - public void setHealthDepartment(String healthDepartment) { - this.healthDepartment = healthDepartment; - } - - public DataRequestDto keyOfHealthDepartment(String keyOfHealthDepartment) { - this.keyOfHealthDepartment = keyOfHealthDepartment; - return this; - } - - /** - * The key of the requesting health department that must be used for encryption. - * - * @return keyOfHealthDepartment - **/ - @Schema(required = true, - description = "The key of the requesting health department that must be used for encryption.") - @NotNull - - public String getKeyOfHealthDepartment() { - return keyOfHealthDepartment; - } - - public void setKeyOfHealthDepartment(String keyOfHealthDepartment) { - this.keyOfHealthDepartment = keyOfHealthDepartment; - } - - public DataRequestDto keyReference(String keyReference) { - this.keyReference = keyReference; - return this; - } - - /** - * The key of the requesting health department that must be used for encryption. - * - * @return keyReference - **/ - @Schema(required = true, - description = "The key of the requesting health department that must be used for encryption.") - @NotNull - - public String getKeyReference() { - return keyReference; - } - - public void setKeyReference(String keyReference) { - this.keyReference = keyReference; - } - - public DataRequestDto start(Instant start) { - this.start = start; - return this; - } - - /** - * The start time for which data should be submitted with this request. - * - * @return start - **/ - @Schema(required = true, description = "The start time for which data should be submitted with this request.") - @NotNull - - @Valid - public Instant getStart() { - return start; - } - - public void setStart(Instant start) { - this.start = start; - } - - public DataRequestDto end(Instant end) { - this.end = end; - return this; - } - - /** - * The end time for which data should be submitted with this request. - * - * @return end - **/ - @Schema(description = "The end time for which data should be submitted with this request.") - - @Valid - public Instant getEnd() { - return end; - } - - public void setEnd(Instant end) { - this.end = end; - } - - public DataRequestDto requestDetails(String requestDetails) { - this.requestDetails = requestDetails; - return this; - } - - /** - * Details of the data request, specifying it in more detail and narrowing down the data to be provided (e.g. table - * and environment, seat, rank, ...). - * - * @return end - **/ - @Schema( - description = "Details of the data request, specifying it in more detail and narrowing down the data to be provided (e.g. table and environment, seat, rank, ...).") - - @Valid - public String getRequestDetails() { - return requestDetails; - } - - public void setRequestDetails(String requestDetails) { - this.requestDetails = requestDetails; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DataRequestDto dataRequest = (DataRequestDto) o; - return Objects.equals(this.healthDepartment, dataRequest.healthDepartment) - && Objects.equals(this.keyOfHealthDepartment, dataRequest.keyOfHealthDepartment) - && Objects.equals(this.start, dataRequest.start) && Objects.equals(this.end, dataRequest.end); - } - - @Override - public int hashCode() { - return Objects.hash(healthDepartment, keyOfHealthDepartment, start, end); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DataRequest {\n"); - - sb.append(" healthDepartment: ").append(toIndentedString(healthDepartment)).append("\n"); - sb.append(" keyOfHealthDepartment: ").append(toIndentedString(keyOfHealthDepartment)).append("\n"); - sb.append(" start: ").append(toIndentedString(start)).append("\n"); - sb.append(" end: ").append(toIndentedString(end)).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/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestHdController.java b/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestHdController.java deleted file mode 100644 index a8809b5a..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestHdController.java +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request.web; - -import static org.apache.commons.lang3.StringUtils.*; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; - -import iris.public_server.config.AppProviderProperties; -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequest; -import iris.public_server.data_request.DataRequestRepository; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.data_request.DataRequest.Status; -import iris.public_server.data_submission.web.controller.DataSubmissionApi; -import iris.public_server.department.DepartmentRepository; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NonNull; -import lombok.extern.slf4j.Slf4j; - -import java.time.Instant; -import java.util.Set; -import java.util.UUID; - -import javax.validation.Valid; - -import org.springframework.http.HttpStatus; -import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.client.RestTemplate; - -/** - * Controller of the internal end-points for health department site to exchange data requests. - * - * @author Jens Kutzsche - */ -@RestController -@Slf4j -@AllArgsConstructor -public class DataRequestHdController { - - private final @NonNull RestTemplate rest; - private final @NonNull DataRequestRepository requests; - private final @NonNull DepartmentRepository departments; - private final @NonNull AppProviderProperties appProviders; - - @PutMapping("/hd/data-requests/{id}") - @ResponseStatus(HttpStatus.OK) - void putDataRequest( - @PathVariable("id") DataRequestIdentifier id, - @Valid @RequestBody DataRequestInternalInputDto payload, - Errors errors) { - - var dataRequest = saveOrUpdate(id, payload); - - if (isNotEmpty(payload.providerId) && isNotEmpty(payload.locationId)) { - - var appProviderDataRequest = getAppProviderPayloadForDataRequest(dataRequest, payload.locationId); - - // do request to app server - var appConfig = appProviders.findByProviderId(payload.providerId); - var url = appConfig.getDataRequestEndpoint(); - var res = rest.postForEntity(url, appProviderDataRequest, String.class); - if (res.getStatusCode() != HttpStatus.ACCEPTED) { - // TODO use string templating - var msg = "Unexpected AppServer Status Code " + res.getStatusCode().toString(); - log.error(msg); - // TODO introduce global error handling - throw new RuntimeException(msg); - } - } - - log.debug("Request - PUT from hd client + saved: {}", dataRequest.getId().toString()); - } - - private AppProviderDataRequestDTO getAppProviderPayloadForDataRequest( - DataRequest dataRequest, String locationId) { - var appServerRequestPayload = new AppProviderDataRequestDTO(); - appServerRequestPayload.setHealthDepartment(dataRequest.getDepartmentId().toString()); - appServerRequestPayload.setRequestDetails(dataRequest.getRequestDetails()); - appServerRequestPayload.setLocationId(locationId); - appServerRequestPayload.setStart(dataRequest.getRequestStart()); - appServerRequestPayload.setEnd(dataRequest.getRequestEnd()); - - var uriBuilder = linkTo(methodOn(DataSubmissionApi.class).postGuestsSubmission(dataRequest.getId(), null)) - .toUriComponentsBuilder(); - - var host = appProviders.getHostForSubmission(); - if (host != null) { - uriBuilder = uriBuilder.host(host); - } - var port = appProviders.getPortForSubmission(); - if (port != null) { - uriBuilder = uriBuilder.port(port); - } - - appServerRequestPayload.setSubmissionUri(uriBuilder.toUriString()); - - var department = departments.findById(dataRequest.getDepartmentId()); - if (department.isEmpty()) { - var msg = "No department found for id " + dataRequest.getDepartmentId().toString(); - log.error(msg); - // TODO introduce global error handling - throw new RuntimeException(msg); - } - - appServerRequestPayload.setKeyOfHealthDepartment(department.get().getPublicKey()); - appServerRequestPayload.setKeyReference(department.get().getKeyReference()); - return appServerRequestPayload; - } - - private DataRequest saveOrUpdate(DataRequestIdentifier id, DataRequestInternalInputDto payload) { - var existingDataRequest = requests.findById(id); - existingDataRequest.ifPresent(dataRequest -> requests.deleteById(dataRequest.getId())); - - var dataRequest = new DataRequest( - id, - DepartmentIdentifier.of(payload.departmentId), - payload.requestStart, - payload.requestEnd, - payload.getRequestDetails(), - payload.features, - payload.status); - return requests.save(dataRequest); - } - - @Data - static class AppProviderDataRequestDTO { - String healthDepartment; - String keyOfHealthDepartment; - String keyReference; - Instant start; - Instant end; - String requestDetails; - String submissionUri; - String locationId; - } - - @Data - static class DataRequestInternalInputDto { - - private UUID departmentId; - - private String locationId; - private String providerId; - - private Instant requestStart; - private Instant requestEnd; - - private String requestDetails; - - private Set features; - private Status status; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestRepresentations.java b/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestRepresentations.java deleted file mode 100644 index b5fc0e66..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_request/web/DataRequestRepresentations.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request.web; - -import static iris.public_server.web.IrisLinkRelations.*; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; - -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequest; -import iris.public_server.data_submission.web.controller.DataSubmissionApi; -import iris.public_server.department.DepartmentRepository; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Links; -import org.springframework.stereotype.Component; - -/** - * Responsible for the REST representations - * - * @author Jens Kutzsche - */ -@Component -@RequiredArgsConstructor -public class DataRequestRepresentations { - - private final @NonNull DepartmentRepository departments; - - public EntityModel toRepresentation(DataRequest dataRequest) { - - var request = new DataRequestDto() - .start(dataRequest.getRequestStart()) - .end(dataRequest.getRequestEnd()) - .requestDetails(dataRequest.getRequestDetails()); - - var departmentOpt = departments.findById(dataRequest.getDepartmentId()); - if (departmentOpt.isPresent()) { - - var department = departmentOpt.get(); - - request = request.healthDepartment(department.getName()); - request = request.keyOfHealthDepartment(department.getPublicKey()); - request = request.keyReference(department.getKeyReference()); - } - - var model = EntityModel.of(request); - - var links = Links - .of(linkTo(methodOn(DataRequestApiController.class).getDataRequestByCode(dataRequest.getId())).withSelfRel()) - .andIf(dataRequest.getFeatures().contains(Feature.Contacts_Events), - linkTo(methodOn(DataSubmissionApi.class).postContactsEventsSubmission(dataRequest.getId(), null)) - .withRel(CONTACTS_EVENTS_SUBMISSION).withTitle("Contacts and Events")) - .andIf(dataRequest.getFeatures().contains(Feature.Guests), - linkTo(methodOn(DataSubmissionApi.class).postGuestsSubmission(dataRequest.getId(), null)) - .withRel(GUESTS_SUBMISSION).withTitle("Guests")); - - return model.add(links); - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/model/DataSubmission.java b/iris-public-server/src/main/java/iris/public_server/data_submission/model/DataSubmission.java deleted file mode 100644 index 914c149e..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/model/DataSubmission.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.model; - -import iris.public_server.core.Aggregate; -import iris.public_server.core.Feature; -import iris.public_server.core.Id; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.*; - -import javax.persistence.*; -import java.io.Serializable; -import java.time.Instant; -import java.util.UUID; - -/** - * A data submission from an app of a citizen or event/location operator to the health department. - * - * @author Jens Kutzsche - */ -@Entity -@Table(name = "data_submission") -@NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) -@Getter -@Setter(AccessLevel.PACKAGE) -public class DataSubmission extends Aggregate { - - private DataRequestIdentifier requestId; - private DepartmentIdentifier departmentId; - - private String secret; - private String keyReference; - private @Lob String encryptedData; - - @Setter - private Instant requestedAt; - - @Enumerated(EnumType.STRING) @Column(nullable = false) - private Feature feature; - - public DataSubmission(DataRequestIdentifier requestId, DepartmentIdentifier departmentId, String secret, - String keyReference, String encryptedData, Feature feature) { - - super(); - - this.id = DataSubmissionIdentifier.random(); - this.requestId = requestId; - this.departmentId = departmentId; - this.secret = secret; - this.keyReference = keyReference; - this.encryptedData = encryptedData; - this.feature = feature; - } - - @Embeddable - @EqualsAndHashCode - @RequiredArgsConstructor(staticName = "of") - @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) - public static class DataSubmissionIdentifier implements Id, Serializable { - - private static final long serialVersionUID = -8254677010830428881L; - - final UUID submissionId; - - /** - * for JSON deserialization - */ - public static DataSubmissionIdentifier of(String uuid) { - return of(UUID.fromString(uuid)); - } - - static DataSubmissionIdentifier random() { - return of(UUID.randomUUID()); - } - - @Override - public String toString() { - return submissionId.toString(); - } - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/repository/DataSubmissionRepository.java b/iris-public-server/src/main/java/iris/public_server/data_submission/repository/DataSubmissionRepository.java deleted file mode 100644 index e084babc..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/repository/DataSubmissionRepository.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.repository; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.util.Streamable; - -import javax.transaction.Transactional; - -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.department.Department.DepartmentIdentifier; - -import java.time.Instant; - -/** - * @author Jens Kutzsche - */ -public interface DataSubmissionRepository extends CrudRepository { - - @Transactional - Streamable findAllByDepartmentId(DepartmentIdentifier id); - - @Transactional - Streamable findAllByDepartmentIdAndRequestedAtIsBefore( - DepartmentIdentifier departmentIdentifier, - Instant searchDate); - - @Transactional - Streamable findAllByRequestedAtBefore(Instant time); -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionMaintenanceJob.java b/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionMaintenanceJob.java deleted file mode 100644 index cc59b48d..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionMaintenanceJob.java +++ /dev/null @@ -1,25 +0,0 @@ -package iris.public_server.data_submission.service; - -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import javax.validation.constraints.NotNull; - -@Component -@Slf4j -@AllArgsConstructor -public class DataSubmissionMaintenanceJob { - - private final @NotNull DataSubmissionService dataSubmissionService; - - @Scheduled(fixedDelayString = "${iris.data-submission.maintenance-job-interval}") - void run() { - - log.info("Maintenance Job running..."); - dataSubmissionService.deleteSubmissionsAfterGraceTime(); - - } - -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionService.java b/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionService.java deleted file mode 100644 index 265d032b..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionService.java +++ /dev/null @@ -1,17 +0,0 @@ -package iris.public_server.data_submission.service; - -import org.springframework.data.util.Streamable; - -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.department.Department; - -import java.time.Instant; - -public interface DataSubmissionService { - - void deleteDataSubmissionById(DataSubmission.DataSubmissionIdentifier id); - - Streamable getSubmissionsForDepartmentFrom(Department.DepartmentIdentifier departmentId); - - void deleteSubmissionsAfterGraceTime(); -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionServiceImpl.java b/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionServiceImpl.java deleted file mode 100644 index a3f46c7a..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/service/DataSubmissionServiceImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -package iris.public_server.data_submission.service; - -import iris.public_server.config.DataSubmissionProperties; -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.data_submission.repository.DataSubmissionRepository; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.time.Instant; - -import javax.validation.constraints.NotNull; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.data.util.Streamable; -import org.springframework.stereotype.Service; - -@Service -@Slf4j -@AllArgsConstructor -@ConfigurationProperties(prefix = "iris.public-api", ignoreUnknownFields = false) -public class DataSubmissionServiceImpl implements DataSubmissionService { - - private final @NotNull DataSubmissionRepository submissions; - private final @NotNull DataSubmissionProperties dataSubmissionProperties; - - @Override - public void deleteDataSubmissionById(DataSubmission.DataSubmissionIdentifier submissionId) { - - log.debug("Deleting submission " + submissionId); - - DataSubmission submissionToDelete = submissions.findById(submissionId).orElse(null); - if (submissionToDelete == null) - return; - - submissions.delete(submissionToDelete); - log.info("Deleted submission " + submissionToDelete.getId()); - } - - @Override - public Streamable getSubmissionsForDepartmentFrom(DepartmentIdentifier departmentId) { - - Streamable dataSubmissions = submissions - .findAllByDepartmentId(departmentId); - - setRequestedAt(dataSubmissions); - - return dataSubmissions; - - } - - @Override - public void deleteSubmissionsAfterGraceTime() { - - Streamable orphanedSubmissions = submissions.findAllByRequestedAtBefore( - Instant.now().minusSeconds(dataSubmissionProperties.getGraceTimeSeconds())); - - orphanedSubmissions.forEach(dataSubmission -> - log.info("Delete submission "+dataSubmission.getId()+" after "+dataSubmissionProperties.getGraceTimeSeconds()+"s grace time")); - - submissions.deleteAll(orphanedSubmissions.toList()); - - } - - private void setRequestedAt(Streamable dataSubmissions) { - - dataSubmissions.forEach(submission -> { - if (submission.getRequestedAt() == null) - submission.setRequestedAt(Instant.now()); - }); - - submissions.saveAll(dataSubmissions.toList()); - - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApi.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApi.java deleted file mode 100644 index 6142ee87..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApi.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program (3.0.24). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package iris.public_server.data_submission.web.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.data_submission.web.dto.ContactsEventsSubmissionDto; -import iris.public_server.data_submission.web.dto.GuestsSubmissionDto; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.validation.Valid; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -public interface DataSubmissionApi { - - @Operation( - summary = "Receives a data submission of contacts and events for the health department and transmits them in the further process.", - description = "", tags = {}) - @ApiResponses(value = { @ApiResponse(responseCode = "202", - description = "Submission was accepted and saved for later processing by the client in the health department."), - - @ApiResponse(responseCode = "401", description = "The client is unauthorized to access this API."), - - @ApiResponse(responseCode = "404", description = "The specified resource was not found."), - - @ApiResponse(responseCode = "422", - description = "The transferred entity is not expected for the data request.") }) - @RequestMapping(value = "/data-submissions/{code}/contacts_events", consumes = { "application/json" }, - method = RequestMethod.POST) - @ResponseStatus(HttpStatus.ACCEPTED) - ResponseEntity postContactsEventsSubmission( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code, - @Parameter(in = ParameterIn.DEFAULT, description = "", required = true, - schema = @Schema()) @Valid @RequestBody ContactsEventsSubmissionDto body); - - @Operation( - summary = "Receives a data submission of guests for the health department and transmits them in the further process.", - description = "", tags = {}) - @ApiResponses(value = { @ApiResponse(responseCode = "202", - description = "Submission was accepted and saved for later processing by the client in the health department."), - - @ApiResponse(responseCode = "401", description = "The client is unauthorized to access this API."), - - @ApiResponse(responseCode = "404", description = "The specified resource was not found."), - - @ApiResponse(responseCode = "422", - description = "The transferred entity is not expected for the data request.") }) - @RequestMapping(value = "/data-submissions/{code}/guests", consumes = { "application/json" }, - method = RequestMethod.POST) - @ResponseStatus(HttpStatus.ACCEPTED) - ResponseEntity postGuestsSubmission( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code, - @Parameter(in = ParameterIn.DEFAULT, description = "", required = true, - schema = @Schema()) @Valid @RequestBody GuestsSubmissionDto body); - -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApiController.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApiController.java deleted file mode 100644 index ebe7b292..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionApiController.java +++ /dev/null @@ -1,131 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.web.controller; - -import static java.util.function.Predicate.*; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; -import io.vavr.control.Option; -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequest; -import iris.public_server.data_request.DataRequestRepository; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.data_request.web.DataRequestRepresentations; -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.data_submission.repository.DataSubmissionRepository; -import iris.public_server.data_submission.web.dto.ContactsEventsSubmissionDto; -import iris.public_server.data_submission.web.dto.DataSubmissionDto; -import iris.public_server.data_submission.web.dto.GuestsSubmissionDto; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; - -import org.springframework.context.support.MessageSourceAccessor; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * Controller of the public end-points for apps to exchange data submissions. - * - * @author Jens Kutzsche - */ -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -@RestController -@Slf4j -@RequiredArgsConstructor -public class DataSubmissionApiController implements DataSubmissionApi { - - private final @NonNull DataRequestRepository requests; - private final @NonNull DataSubmissionRepository submissions; - private final @NonNull DataRequestRepresentations representation; - private final @NonNull MessageSourceAccessor messages; - - @Override - public ResponseEntity postContactsEventsSubmission( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code, - @Parameter(in = ParameterIn.DEFAULT, description = "", required = true, - schema = @Schema()) @Valid @RequestBody ContactsEventsSubmissionDto body) { - - return handleRequest(code, body, body.getEncryptedData(), Feature.Contacts_Events); - } - - @Override - public ResponseEntity postGuestsSubmission( - @Parameter(in = ParameterIn.PATH, description = "The code of a data request sent by the health department.", - required = true, schema = @Schema()) @PathVariable("code") DataRequestIdentifier code, - @Parameter(in = ParameterIn.DEFAULT, description = "", required = true, - schema = @Schema()) @Valid @RequestBody GuestsSubmissionDto body) { - - return handleRequest(code, body, body.getEncryptedData(), Feature.Guests); - } - - private ResponseEntity handleRequest(DataRequestIdentifier code, DataSubmissionDto dto, String encryptedData, - Feature feature) { - - return Option.ofOptional(requests.findById(code)) - .toEither(() -> ResponseEntity.status(HttpStatus.NOT_FOUND) - .body(messages.getMessage("dataRequest.notFound"))) - .filterOrElse(not(DataRequest::isClosed), - it -> ResponseEntity.badRequest() - .body(messages.getMessage("dataRequest.isClosed"))) - .filterOrElse(it -> requestMatchesFeature(it, feature), - it -> ResponseEntity.badRequest() - .body(messages.getMessage("dataSubmission.wrong.feature"))) - .map(it -> createAndSaveDataSubmission(it, dto, encryptedData, feature)) - .peekLeft(it -> logWrongRequest(code, feature)) - .peek(this::log) - .fold(it -> it, it -> ResponseEntity.accepted().build()); - } - - private DataSubmission createAndSaveDataSubmission(DataRequest dataRequest, @NotNull DataSubmissionDto dto, - String encryptedData, Feature feature) { - - var submission = createSubmission(dataRequest, dto, encryptedData, feature); - return submissions.save(submission); - } - - private boolean requestMatchesFeature(DataRequest dataRequest, Feature feature) { - return dataRequest.getFeatures().contains(feature); - } - - private DataSubmission createSubmission(DataRequest request, DataSubmissionDto dto, String encryptedData, - Feature feature) { - - return new DataSubmission(request.getId(), request.getDepartmentId(), dto.getSecret(), - dto.getKeyReference(), encryptedData, feature); - } - - private DataSubmission log(DataSubmission submission) { - - log.debug("Submission - POST from public + saved: {} (Type: {}; Department: {})", - submission.getRequestId().toString(), submission.getFeature().name(), submission.getDepartmentId()); - - return submission; - } - - private void logWrongRequest(DataRequestIdentifier code, Feature feature) { - log.warn("Submission - POST from public not valid: {} (Type: {}", code, feature.name()); - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionHdController.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionHdController.java deleted file mode 100644 index 9003d751..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/controller/DataSubmissionHdController.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.web.controller; - -import iris.public_server.core.Feature; -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.data_submission.model.DataSubmission.DataSubmissionIdentifier; -import iris.public_server.data_submission.repository.DataSubmissionRepository; -import iris.public_server.data_submission.service.DataSubmissionService; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.Data; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.http.HttpEntity; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import java.time.Instant; -import java.time.ZoneId; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Controller of the internal end-points for health department site to exchange data submissions. - * - * @author Jens Kutzsche - */ -@RestController -@Slf4j -@RequiredArgsConstructor -public class DataSubmissionHdController { - - private final @NonNull DataSubmissionRepository submissions; - - private final @NonNull DataSubmissionService dataSubmissionService; - - @GetMapping("/hd/data-submissions") - HttpEntity> getDataSubmissions( - @RequestParam("departmentId") DepartmentIdentifier departmentId) { - - var dataSubmissions = dataSubmissionService.getSubmissionsForDepartmentFrom(departmentId); - - var dtos = dataSubmissions.map(DataSubmissionInternalOutputDto::of).toList(); - - log.debug("Submission - GET from hd client: {}", - dtos.stream().map(DataSubmissionInternalOutputDto::getRequestId).collect(Collectors.joining(", "))); - - return ResponseEntity.ok().body(dtos); - } - - @DeleteMapping("/hd/data-submissions/{dataSubmissionId}") - void deleteDataSubmissions(@PathVariable("dataSubmissionId") DataSubmissionIdentifier dataSubmissionId) { - - dataSubmissionService.deleteDataSubmissionById(dataSubmissionId); - } - - @Data - static class DataSubmissionInternalOutputDto { - - private final String id; - private final String requestId; - private final String departmentId; - private final String secret; - private final String keyReference; - private final String encryptedData; - private final Feature feature; - - static DataSubmissionInternalOutputDto of(DataSubmission submission) { - return new DataSubmissionInternalOutputDto( - submission.getId().toString(), - submission.getRequestId().toString(), - submission.getDepartmentId().toString(), - submission.getSecret(), - submission.getKeyReference(), - submission.getEncryptedData(), - submission.getFeature()); - } - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/ContactsEventsSubmissionDto.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/ContactsEventsSubmissionDto.java deleted file mode 100644 index 5ee38b3d..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/ContactsEventsSubmissionDto.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.web.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import java.util.Objects; - -/** - * ContactsSubmission - */ -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") - -public class ContactsEventsSubmissionDto extends DataSubmissionDto { - - @JsonProperty("encryptedData") - private String encryptedData = null; - - public ContactsEventsSubmissionDto encryptedData(String encryptedData) { - this.encryptedData = encryptedData; - return this; - } - - /** - * Get encryptedData - * - * @return encryptedData - **/ - @Schema(required = true, description = "") - @NotNull - - @Valid - @Pattern(regexp = "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") - public String getEncryptedData() { - return encryptedData; - } - - public void setEncryptedData(String encryptedData) { - this.encryptedData = encryptedData; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ContactsEventsSubmissionDto contactsSubmission = (ContactsEventsSubmissionDto) o; - return Objects.equals(this.encryptedData, contactsSubmission.encryptedData) && super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(encryptedData, super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ContactsSubmission {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" encryptedData: ").append(toIndentedString(encryptedData)).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/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/DataSubmissionDto.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/DataSubmissionDto.java deleted file mode 100644 index b3428fa1..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/DataSubmissionDto.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.web.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.validation.annotation.Validated; - -import javax.validation.constraints.NotNull; -import java.util.Objects; - -/** - * Basic data type of a data submission which contains the unencrypted metadata needed for processing. - */ -@Schema( - description = "Basic data type of a data submission which contains the unencrypted metadata needed for processing.") -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") - -public class DataSubmissionDto { - - @JsonProperty("secret") - private String secret = null; - - @JsonProperty("keyReference") - private String keyReference = null; - - public DataSubmissionDto secret(String secret) { - this.secret = secret; - return this; - } - - /** - * The encrypted secret key for encryption. - * - * @return secret - **/ - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public DataSubmissionDto keyReference(String keyReference) { - this.keyReference = keyReference; - return this; - } - - /** - * Reference to the used key. - * - * @return keyReference - **/ - @Schema(required = true, description = "Reference to the used key.") - @NotNull - - public String getKeyReference() { - return keyReference; - } - - public void setKeyReference(String keyReference) { - this.keyReference = keyReference; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DataSubmissionDto dataSubmission = (DataSubmissionDto) o; - return Objects.equals(this.secret, dataSubmission.secret) - && Objects.equals(this.keyReference, dataSubmission.keyReference); - } - - @Override - public int hashCode() { - return Objects.hash(secret, keyReference); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DataSubmission {\n"); - - sb.append(" secret: ").append(toIndentedString(secret)).append("\n"); - sb.append(" keyReference: ").append(toIndentedString(keyReference)).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/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/GuestsSubmissionDto.java b/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/GuestsSubmissionDto.java deleted file mode 100644 index 11552be7..00000000 --- a/iris-public-server/src/main/java/iris/public_server/data_submission/web/dto/GuestsSubmissionDto.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission.web.dto; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import java.util.Objects; - -/** - * GuestsSubmission - */ -@Validated -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") - -public class GuestsSubmissionDto extends DataSubmissionDto { - - @JsonProperty("encryptedData") - private String encryptedData = null; - - public GuestsSubmissionDto encryptedData(String encryptedData) { - this.encryptedData = encryptedData; - return this; - } - - /** - * Get encryptedData - * - * @return encryptedData - **/ - @Schema(required = true, description = "") - @NotNull - - @Valid - @Pattern(regexp = "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$") - public String getEncryptedData() { - return encryptedData; - } - - public void setEncryptedData(String encryptedData) { - this.encryptedData = encryptedData; - } - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - GuestsSubmissionDto guestsSubmission = (GuestsSubmissionDto) o; - return Objects.equals(this.encryptedData, guestsSubmission.encryptedData) && super.equals(o); - } - - @Override - public int hashCode() { - return Objects.hash(encryptedData, super.hashCode()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class GuestsSubmission {\n"); - sb.append(" ").append(toIndentedString(super.toString())).append("\n"); - sb.append(" encryptedData: ").append(toIndentedString(encryptedData)).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/iris-public-server/src/main/java/iris/public_server/department/Department.java b/iris-public-server/src/main/java/iris/public_server/department/Department.java deleted file mode 100644 index 5c5efdce..00000000 --- a/iris-public-server/src/main/java/iris/public_server/department/Department.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.department; - -import iris.public_server.core.Aggregate; -import iris.public_server.core.Id; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; -import lombok.Setter; - -import java.io.Serializable; -import java.util.UUID; - -import javax.persistence.Embeddable; -import javax.persistence.Entity; -import javax.persistence.Lob; -import javax.persistence.Table; - -/** - * @author Jens Kutzsche - */ -@Entity -@Table(name = "department") -@NoArgsConstructor(force = true) -@Getter -@Setter(AccessLevel.PACKAGE) -public class Department extends Aggregate { - - private final String name; - private String keyReference; - private final @Lob String publicKey; - - public Department(DepartmentIdentifier id, String name, String keyReference, String publicKey) { - - super(); - - this.id = id; - this.name = name; - this.keyReference = keyReference; - this.publicKey = publicKey; - } - - @Embeddable - @EqualsAndHashCode - @RequiredArgsConstructor(staticName = "of") - @NoArgsConstructor(force = true, access = AccessLevel.PRIVATE) - public static class DepartmentIdentifier implements Id, Serializable { - - private static final long serialVersionUID = -5946799883757153213L; - final UUID departmentId; - - public static DepartmentIdentifier of(String uuid) { - return of(UUID.fromString(uuid)); - } - - @Override - public String toString() { - return departmentId.toString(); - } - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/department/DepartmentRepository.java b/iris-public-server/src/main/java/iris/public_server/department/DepartmentRepository.java deleted file mode 100644 index bb04d1e0..00000000 --- a/iris-public-server/src/main/java/iris/public_server/department/DepartmentRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.department; - -import iris.public_server.department.Department.DepartmentIdentifier; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Jens Kutzsche - */ -public interface DepartmentRepository extends CrudRepository { - -} diff --git a/iris-public-server/src/main/java/iris/public_server/department/web/DepartmentHdController.java b/iris-public-server/src/main/java/iris/public_server/department/web/DepartmentHdController.java deleted file mode 100644 index 92990e3a..00000000 --- a/iris-public-server/src/main/java/iris/public_server/department/web/DepartmentHdController.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.department.web; - -import iris.public_server.department.Department; -import iris.public_server.department.DepartmentRepository; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.Data; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import javax.validation.Valid; - -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.http.HttpStatus; -import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * Controller of the internal end-points for department informations. - * - * @author Jens Kutzsche - */ -@RestController -@Slf4j -@RequiredArgsConstructor -public class DepartmentHdController { - - private final @NonNull DepartmentRepository departments; - - @PutMapping("/hd/departments/{id}") - @ResponseStatus(HttpStatus.OK) - DepartmentDto putDataRequest(@PathVariable("id") DepartmentIdentifier id, @Valid @RequestBody DepartmentDto payload, - Errors errors) { - - var department = new Department(id, payload.getName(), payload.getKeyReference(), payload.key); - - try { - departments.deleteById(department.getId()); - } catch (EmptyResultDataAccessException e) {} - departments.save(department); - - log.debug("Department - PUT from hd + saved: {} (Name: {}; Key-Referenz: {})", department.getId().toString(), - department.getName(), department.getKeyReference()); - - return payload; - } - - @Data - static class DepartmentDto { - - private String name; - private String keyReference; - private String key; - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/web/DefaultApi.java b/iris-public-server/src/main/java/iris/public_server/web/DefaultApi.java deleted file mode 100644 index 3ebffaef..00000000 --- a/iris-public-server/src/main/java/iris/public_server/web/DefaultApi.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * NOTE: This class is auto generated by the swagger code generator program (3.0.24). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package iris.public_server.web; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.hateoas.RepresentationModel; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -public interface DefaultApi { - - @Operation(summary = "Entry point returns next steps by links.", - description = "Entry point for the clients of the API. From here, they are guided through the API by means of links.", - tags = {}) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Links for the next posible steps."), - - @ApiResponse(responseCode = "401", description = "The client is unauthorized to access this API.") }) - @RequestMapping(value = "/", method = RequestMethod.GET) - RepresentationModel rootGet(); - -} diff --git a/iris-public-server/src/main/java/iris/public_server/web/DefaultApiController.java b/iris-public-server/src/main/java/iris/public_server/web/DefaultApiController.java deleted file mode 100644 index ac2ef76e..00000000 --- a/iris-public-server/src/main/java/iris/public_server/web/DefaultApiController.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.web; - -import static iris.public_server.web.IrisLinkRelations.*; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*; -import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.*; - -import iris.public_server.data_request.web.DataRequestApi; - -import org.springframework.hateoas.IanaLinkRelations; -import org.springframework.hateoas.Links; -import org.springframework.hateoas.RepresentationModel; -import org.springframework.hateoas.mediatype.hal.HalModelBuilder; -import org.springframework.hateoas.server.mvc.MvcLink; -import org.springframework.web.bind.annotation.RestController; - -/** - * Controller for the entry point to the IRIS API - * - * @author Jens Kutzsche - */ -@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", - date = "2021-02-18T08:11:24.698Z[GMT]") -@RestController -public class DefaultApiController implements DefaultApi { - - @Override - public RepresentationModel rootGet() { - - Links links = Links.of(MvcLink.of(on(DefaultApi.class).rootGet(), IanaLinkRelations.SELF)) - .and(linkTo(methodOn(DataRequestApi.class).getDataRequestByCode(null)).withRel(REQUEST_BY_CODE)); - - return HalModelBuilder.emptyHalModel().links(links).build(); - } -} diff --git a/iris-public-server/src/main/java/iris/public_server/web/IrisLinkRelations.java b/iris-public-server/src/main/java/iris/public_server/web/IrisLinkRelations.java deleted file mode 100644 index 73c0e069..00000000 --- a/iris-public-server/src/main/java/iris/public_server/web/IrisLinkRelations.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.web; - -import org.springframework.hateoas.LinkRelation; - -/** - * @author Jens Kutzsche - */ -public interface IrisLinkRelations { - - LinkRelation REQUEST_BY_CODE = LinkRelation.of("GetDataRequestByCode"); - - LinkRelation CONTACTS_EVENTS_SUBMISSION = LinkRelation.of("PostContactsEventsSubmission"); - LinkRelation GUESTS_SUBMISSION = LinkRelation.of("PostGuestsSubmission"); -} diff --git a/iris-public-server/src/main/java/iris/public_server/web/IrisWebSecurityConfigurerAdapter.java b/iris-public-server/src/main/java/iris/public_server/web/IrisWebSecurityConfigurerAdapter.java deleted file mode 100644 index 311b5798..00000000 --- a/iris-public-server/src/main/java/iris/public_server/web/IrisWebSecurityConfigurerAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.web; - -import lombok.RequiredArgsConstructor; - -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.BadCredentialsException; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.web.authentication.preauth.x509.SubjectDnX509PrincipalExtractor; -import org.springframework.security.web.authentication.preauth.x509.X509AuthenticationFilter; - -/** - * @author Jens Kutzsche - */ -@Configuration -@EnableWebSecurity -@RequiredArgsConstructor -public class IrisWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { - - @Override - protected void configure(HttpSecurity httpSecurity) throws Exception { - - var filter = new X509AuthenticationFilter(); - var extractor = new SubjectDnX509PrincipalExtractor(); - extractor.setSubjectDnRegex("(?:OU|CN)=(.*?)(?:,|$)"); - filter.setPrincipalExtractor(extractor); - - filter.setAuthenticationManager(authentication -> { - if (authentication.getPrincipal() != null) { - authentication.setAuthenticated(true); - return authentication; - } else { - throw new BadCredentialsException("Access Denied."); - } - }); - - httpSecurity.antMatcher("/hd/**").csrf().disable().sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().addFilter(filter).authorizeRequests().anyRequest() - .authenticated(); - } -} diff --git a/iris-public-server/src/main/resources/.gitignore b/iris-public-server/src/main/resources/.gitignore deleted file mode 100644 index 0776e6f1..00000000 --- a/iris-public-server/src/main/resources/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/application-local.properties diff --git a/iris-public-server/src/main/resources/application-dev_env.properties b/iris-public-server/src/main/resources/application-dev_env.properties deleted file mode 100644 index b2521f50..00000000 --- a/iris-public-server/src/main/resources/application-dev_env.properties +++ /dev/null @@ -1,18 +0,0 @@ -spring.jackson.serialization.indent-output=true - -# certificate authentication -server.ssl.key-store=classpath:security/server/keystore.p12 -server.ssl.key-store-password=iris -server.ssl.key-store-type=JKS - -server.ssl.trust-store=classpath:security/server/truststore.p12 -server.ssl.trust-store-password=iris -server.ssl.trust-store-type=JKS - -server.ssl.client-auth=want -server.port=8443 -#server.port=8090 - -springdoc.api-docs.enabled=true - -logging.level.iris=DEBUG diff --git a/iris-public-server/src/main/resources/application-docker.properties b/iris-public-server/src/main/resources/application-docker.properties deleted file mode 100644 index ac0e74a7..00000000 --- a/iris-public-server/src/main/resources/application-docker.properties +++ /dev/null @@ -1,28 +0,0 @@ -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST:postgres}:5432/iris_public -spring.datasource.username=${POSTGRES_USER:postgres} -spring.datasource.password=${POSTGRES_PASSWORD:postgres} -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect - -# certificate authentication -server.ssl.key-store=classpath:security/server/keystore.p12 -server.ssl.key-store-password=iris -server.ssl.key-store-type=JKS - -server.ssl.trust-store=classpath:security/server/truststore.p12 -server.ssl.trust-store-password=iris -server.ssl.trust-store-type=JKS - -server.ssl.client-auth=want -server.port=8443 - -springdoc.api-docs.enabled=true - -# Loglevel -logging.level.iris=DEBUG - -providers.providers.[0].id=f002f370-bd54-4325-ad91-1aff3bf730a5 -providers.providers.[0].data-request-endpoint=https://demo-checkin-app:8091/api/iris/data-request - -providers.providers.[1].id=bcf054fd-c904-484a-acdb-798e151c5142 -providers.providers.[1].data-request-endpoint=https://staging.iris.smartmeeting.online/api/services/iris/v1/data-request diff --git a/iris-public-server/src/main/resources/application-h2_db.properties b/iris-public-server/src/main/resources/application-h2_db.properties deleted file mode 100644 index 90e5d99f..00000000 --- a/iris-public-server/src/main/resources/application-h2_db.properties +++ /dev/null @@ -1,4 +0,0 @@ -spring.datasource.driver-class-name=org.h2.Driver -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect -spring.datasource.generate-unique-name=true -spring.h2.console.enabled=true diff --git a/iris-public-server/src/main/resources/application-prod_db.properties b/iris-public-server/src/main/resources/application-prod_db.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/iris-public-server/src/main/resources/application-psql_compose_db.properties b/iris-public-server/src/main/resources/application-psql_compose_db.properties deleted file mode 100644 index bc65e388..00000000 --- a/iris-public-server/src/main/resources/application-psql_compose_db.properties +++ /dev/null @@ -1,5 +0,0 @@ -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://localhost:5433/iris_public -spring.datasource.username=postgres -spring.datasource.password=postgres -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect diff --git a/iris-public-server/src/main/resources/application.properties b/iris-public-server/src/main/resources/application.properties deleted file mode 100644 index 076ecdd2..00000000 --- a/iris-public-server/src/main/resources/application.properties +++ /dev/null @@ -1,39 +0,0 @@ -spring.profiles.group.dev=h2_db,dev_env,local -spring.profiles.group.dev_psql=psql_compose_db,dev_env -spring.profiles.group.prod=prod_db - -spring.application.name=IRIS Public Server - -# Whether to fall back to the system Locale -# if no files for a specific Locale have been found. -spring.messages.fallback-to-system-locale=false - -# Hibernate ddl auto (create, create-drop, validate, update) -spring.jpa.hibernate.ddl-auto=validate -spring.jpa.generate-ddl=false - -#springfox.documentation.open-api.v3.path=/api-docs - -# JSON Marshalling -spring.jackson.generator.escape-non-ascii=true -spring.jackson.mapper.accept-case-insensitive-enums=true -spring.jackson.default-property-inclusion: NON_ABSENT -#spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false #false is default - -springdoc.api-docs.enabled=false - -logging.level.iris=INFO - -#providers.host-for-submission= -#providers.port-for-submission= - -providers.providers.[0].id=f002f370-bd54-4325-ad91-1aff3bf730a5 -providers.providers.[0].data-request-endpoint=https://localhost:8091/api/iris/data-request - -providers.providers.[1].id=bcf054fd-c904-484a-acdb-798e151c5142 -providers.providers.[1].data-request-endpoint=https://staging.iris.smartmeeting.online/api/services/iris/v1/data-request - -iris.data-submission.maintenance-job-interval = 15000 - -iris.data-submission.grace-time-seconds = 5 - diff --git a/iris-public-server/src/main/resources/db/migration/V1001__Initial_schema.sql b/iris-public-server/src/main/resources/db/migration/V1001__Initial_schema.sql deleted file mode 100644 index e75f346a..00000000 --- a/iris-public-server/src/main/resources/db/migration/V1001__Initial_schema.sql +++ /dev/null @@ -1,45 +0,0 @@ -CREATE TABLE data_request ( - request_id uuid NOT NULL, - department_id uuid NOT NULL, - request_start timestamp NULL, - request_end timestamp NULL, - request_details text NULL, - status varchar(50) NOT NULL, - created timestamp NOT NULL, - last_modified timestamp NOT NULL, - CONSTRAINT request_pkey PRIMARY KEY (request_id) -); - -CREATE TABLE data_request_feature ( - request_id uuid, - feature varchar(50), - PRIMARY KEY (request_id, feature), - FOREIGN KEY (request_id) REFERENCES data_request(request_id) - ON DELETE CASCADE - ON UPDATE CASCADE -); - - -CREATE TABLE data_submission ( - submission_id uuid NOT NULL, - request_id uuid NOT NULL, - department_id uuid NOT NULL, - secret varchar(1000) NULL, - key_reference varchar(50) NOT NULL, - feature varchar(50) NOT NULL, - encrypted_data text NULL, - created timestamp NOT NULL, - last_modified timestamp NOT NULL, - requested_at timestamp NULL, - CONSTRAINT submission_pkey PRIMARY KEY (submission_id) -); - -CREATE TABLE department ( - department_id uuid NOT NULL, - name varchar(50) NULL, - public_key text NOT NULL, - key_reference varchar(50) NOT NULL, - created timestamp NOT NULL, - last_modified timestamp NOT NULL, - CONSTRAINT department_pkey PRIMARY KEY (department_id) -) diff --git a/iris-public-server/src/main/resources/iris-banner.txt b/iris-public-server/src/main/resources/iris-banner.txt deleted file mode 100644 index ed8be752..00000000 --- a/iris-public-server/src/main/resources/iris-banner.txt +++ /dev/null @@ -1,7 +0,0 @@ - _____ _____ _____ _____ - |_ _| __ \|_ _|/ ____| ${spring.application.name} - | | | |__) | | | | (___ - | | | _ / | | \___ \ - _| |_| | \ \ _| |_ ____) | - |_____|_| \_\_____|_____/ ${application.version} - \ No newline at end of file diff --git a/iris-public-server/src/main/resources/messages.properties b/iris-public-server/src/main/resources/messages.properties deleted file mode 100644 index 13289243..00000000 --- a/iris-public-server/src/main/resources/messages.properties +++ /dev/null @@ -1,3 +0,0 @@ -dataRequest.notFound=There is no data request for the code used, please contact your health department. -dataRequest.isClosed=Data request has already been closed, please contact your health department. -dataSubmission.wrong.feature=Your app is not providing the requested data. diff --git a/iris-public-server/src/main/resources/messages_de.properties b/iris-public-server/src/main/resources/messages_de.properties deleted file mode 100644 index 40046d85..00000000 --- a/iris-public-server/src/main/resources/messages_de.properties +++ /dev/null @@ -1,3 +0,0 @@ -dataRequest.notFound=Es gibt keine Datenanfrage für den verwendeten Code, bitte wenden Sie sich an Ihr Gesundheitsamt. -dataRequest.isClosed=Die Datenanforderung ist bereits abgeschlossen, bitte wenden Sie sich an Ihr Gesundheitsamt. -dataSubmission.wrong.feature=Ihre App liefert die angeforderten Daten nicht. diff --git a/iris-public-server/src/main/resources/security/server/keystore.p12 b/iris-public-server/src/main/resources/security/server/keystore.p12 deleted file mode 100644 index 21aba307..00000000 Binary files a/iris-public-server/src/main/resources/security/server/keystore.p12 and /dev/null differ diff --git a/iris-public-server/src/main/resources/security/server/truststore.p12 b/iris-public-server/src/main/resources/security/server/truststore.p12 deleted file mode 100644 index 263c1979..00000000 Binary files a/iris-public-server/src/main/resources/security/server/truststore.p12 and /dev/null differ diff --git a/iris-public-server/src/test/java/iris/public_server/DataInitializer.java b/iris-public-server/src/test/java/iris/public_server/DataInitializer.java deleted file mode 100644 index 227d5628..00000000 --- a/iris-public-server/src/test/java/iris/public_server/DataInitializer.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server; - -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -/** - * For data initialization on application startup. - * - * @author Jens Kutzsche - */ -@Component -public interface DataInitializer { - - @Transactional - void initialize(); -} diff --git a/iris-public-server/src/test/java/iris/public_server/DataInitializerInvoker.java b/iris-public-server/src/test/java/iris/public_server/DataInitializerInvoker.java deleted file mode 100644 index bef9ea4f..00000000 --- a/iris-public-server/src/test/java/iris/public_server/DataInitializerInvoker.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server; - -import lombok.NonNull; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.util.List; - -import org.springframework.aop.support.AopUtils; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.context.annotation.Profile; -import org.springframework.core.annotation.Order; -import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -@Slf4j -@Profile({ "psql_compose_db", "h2_db" }) -@Order(100) -class DataInitializerInvoker implements ApplicationRunner { - - private final @NonNull List initializers; - - /* - * (non-Javadoc) - * @see org.springframework.boot.ApplicationRunner#run(org.springframework.boot.ApplicationArguments) - */ - @Override - public void run(@Nullable ApplicationArguments args) throws Exception { - initializers.stream().peek(it -> log.info("Data initialization for " + AopUtils.getTargetClass(it))) - .forEach(DataInitializer::initialize); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/DepartmentDataInitializer.java b/iris-public-server/src/test/java/iris/public_server/DepartmentDataInitializer.java deleted file mode 100644 index 92a0eef2..00000000 --- a/iris-public-server/src/test/java/iris/public_server/DepartmentDataInitializer.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server; - -import iris.public_server.department.Department; -import iris.public_server.department.DepartmentRepository; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.RequiredArgsConstructor; - -import java.util.UUID; - -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -public class DepartmentDataInitializer implements DataInitializer { - - public static final DepartmentIdentifier DEPARTMENT_ID_1 = DepartmentIdentifier - .of(UUID.fromString("a04d2e43-3d1a-464e-9926-e190ccf2dd03")); - public static final DepartmentIdentifier DEPARTMENT_ID_2 = DepartmentIdentifier - .of(UUID.fromString("6afbbe9b-938c-46d7-93e4-7c9e1f737273")); - - private final DepartmentRepository departments; - - @Override - public void initialize() { - - departments.save(new Department(DEPARTMENT_ID_1, "Gesundheitsamt Meißen", "keyRef-XYZ", "key of HD")); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/I18nIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/I18nIntegrationTests.java deleted file mode 100644 index 2e2584d5..00000000 --- a/iris-public-server/src/test/java/iris/public_server/I18nIntegrationTests.java +++ /dev/null @@ -1,51 +0,0 @@ -package iris.public_server; - -import static iris.public_server.data_request.DataRequestDataInitializer.*; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import lombok.RequiredArgsConstructor; - -import java.util.Locale; - -import org.junit.jupiter.api.Test; -import org.springframework.test.web.servlet.MockMvc; - -import com.jayway.jsonpath.JsonPath; - -@IrisWebIntegrationTest -@RequiredArgsConstructor -class I18nIntegrationTests { - - private final MockMvc mvc; - - @Test - void errorsInGerman() throws Exception { - - var response = performeGet(REQ_ID_4, Locale.GERMAN); - - var document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).contains("Gesundheitsamt"); - } - - @Test - void errorsInEnglish() throws Exception { - - var response = performeGet(REQ_ID_4, Locale.ENGLISH); - - var document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).contains("health department"); - } - - private String performeGet(DataRequestIdentifier id, Locale locale) throws Exception { - return mvc.perform( - get("/data-requests/{code}", id.toString()) - .locale(locale)) - .andExpect(status().isBadRequest()) - .andReturn().getResponse().getContentAsString(); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/IrisWebIntegrationTest.java b/iris-public-server/src/test/java/iris/public_server/IrisWebIntegrationTest.java deleted file mode 100644 index 4a1f3914..00000000 --- a/iris-public-server/src/test/java/iris/public_server/IrisWebIntegrationTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package iris.public_server; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestConstructor; -import org.springframework.test.context.TestConstructor.AutowireMode; - -@SpringBootTest(classes = { SecurityConfiguration.class }, webEnvironment = WebEnvironment.RANDOM_PORT) -@AutoConfigureMockMvc -@TestConstructor(autowireMode = AutowireMode.ALL) -@TestInstance(Lifecycle.PER_CLASS) -@ActiveProfiles({ "dev", "inttest" }) -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IrisWebIntegrationTest { - -} diff --git a/iris-public-server/src/test/java/iris/public_server/SecurityConfiguration.java b/iris-public-server/src/test/java/iris/public_server/SecurityConfiguration.java deleted file mode 100644 index 4270a941..00000000 --- a/iris-public-server/src/test/java/iris/public_server/SecurityConfiguration.java +++ /dev/null @@ -1,17 +0,0 @@ -package iris.public_server; - -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.core.annotation.Order; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; - -@TestConfiguration -@Order(1) -public class SecurityConfiguration extends WebSecurityConfigurerAdapter { - - @Override - public void init(WebSecurity builder) throws Exception { - builder.ignoring().requestMatchers(new AntPathRequestMatcher("/**")); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/X509AuthenticationIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/X509AuthenticationIntegrationTests.java deleted file mode 100644 index c2b4f89d..00000000 --- a/iris-public-server/src/test/java/iris/public_server/X509AuthenticationIntegrationTests.java +++ /dev/null @@ -1,76 +0,0 @@ -package iris.public_server; - -import static org.assertj.core.api.Assertions.*; - -import lombok.RequiredArgsConstructor; - -import java.time.Instant; -import java.util.UUID; - -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.ssl.SSLContextBuilder; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.core.io.ResourceLoader; -import org.springframework.http.HttpStatus; -import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -import org.springframework.web.client.HttpClientErrorException.Forbidden; -import org.springframework.web.client.RestTemplate; - -@IrisWebIntegrationTest -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -@RequiredArgsConstructor -class X509AuthenticationIntegrationTests { - - private @LocalServerPort String port; - private final ResourceLoader resources; - private final RestTemplateBuilder builder; - - @Test - void allowsAccessToHdResourceIfCertificatePresent() throws Exception { - - var response = createRestTemplate(true).getForEntity( - "https://localhost:{port}/hd/data-submissions?departmentId={depId}&from={from}", - String.class, port, UUID.randomUUID().toString(), Instant.now()); - - assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - } - - @Test - void rejectsAccessToHdResourceIfNoneCertificatePresent() throws Exception { - - assertThatExceptionOfType(Forbidden.class) - .isThrownBy( - () -> createRestTemplate(false).getForEntity( - "https://localhost:{port}/hd/data-submissions?departmentId={depId}&from={from}", - String.class, port, UUID.randomUUID().toString(), Instant.now())); - } - - RestTemplate createRestTemplate(boolean withKeystore) throws Exception { - - var password = "iris"; - - var keyStore = resources.getResource("classpath:security/client/keystore.p12"); - var trustStore = resources.getResource("classpath:security/client/truststore.p12"); - - var sslContext = new SSLContextBuilder() - .loadTrustMaterial(trustStore.getURL(), password.toCharArray(), (chain, authType) -> false); - - if (withKeystore) { - sslContext = sslContext.loadKeyMaterial(keyStore.getURL(), password.toCharArray(), password.toCharArray()); - } - - var socketFactory = new SSLConnectionSocketFactory(sslContext.build(), NoopHostnameVerifier.INSTANCE); - var httpClient = HttpClientBuilder.create().setSSLSocketFactory(socketFactory).build(); - - var restTemplate = builder.build(); - restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)); - - return restTemplate; - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/data_request/DataRequestDataInitializer.java b/iris-public-server/src/test/java/iris/public_server/data_request/DataRequestDataInitializer.java deleted file mode 100644 index a897de4e..00000000 --- a/iris-public-server/src/test/java/iris/public_server/data_request/DataRequestDataInitializer.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_request; - -import static java.time.temporal.ChronoUnit.*; - -import iris.public_server.DataInitializer; -import iris.public_server.DepartmentDataInitializer; -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequest; -import iris.public_server.data_request.DataRequestRepository; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.data_request.DataRequest.Status; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.UUID; - -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -@Slf4j -public class DataRequestDataInitializer implements DataInitializer { - - public static final DataRequestIdentifier REQ_ID_1 = DataRequestIdentifier - .of(UUID.fromString("790b9a69-17f8-4ba7-a8ae-2f7bf34e0b80")); - public static final DataRequestIdentifier REQ_ID_2 = DataRequestIdentifier - .of(UUID.fromString("2707fd28-9b4f-4140-b80e-d56d9aad831f")); - public static final DataRequestIdentifier REQ_ID_3 = DataRequestIdentifier - .of(UUID.fromString("3907e730-af89-4944-8e75-fbe6ba60c904")); - public static final DataRequestIdentifier REQ_ID_4 = DataRequestIdentifier - .of(UUID.fromString("c3f042a6-1da0-468e-b607-ffabfaa2dc2e")); - - private final DataRequestRepository requests; - - /* - * (non-Javadoc) - * @see quarano.core.DataInitializer#initialize() - */ - @Override - public void initialize() { - - log.debug("Test data: creating data requests …"); - - var list = new ArrayList(); - - list.add(new DataRequest(REQ_ID_1, DepartmentDataInitializer.DEPARTMENT_ID_1, Instant.now().minus(2, DAYS), null, - "requestDetails", EnumSet.of(Feature.Contacts_Events), Status.DATA_REQUESTED)); - - list.add(new DataRequest(REQ_ID_2, DepartmentDataInitializer.DEPARTMENT_ID_1, Instant.now().minus(4, DAYS), - Instant.now().minus(2, DAYS), null, EnumSet.of(Feature.Guests), Status.DATA_REQUESTED)); - - list.add(new DataRequest(REQ_ID_3, DepartmentDataInitializer.DEPARTMENT_ID_2, Instant.now().minus(4, DAYS), - Instant.now().minus(2, DAYS), null, EnumSet.of(Feature.Contacts_Events), Status.DATA_REQUESTED)); - - list.add(new DataRequest(REQ_ID_4, DepartmentDataInitializer.DEPARTMENT_ID_2, Instant.now().minus(4, DAYS), - Instant.now().minus(2, DAYS), null, EnumSet.of(Feature.Contacts_Events), Status.CLOSED)); - - requests.saveAll(list); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/data_request/web/DataRequestApiControllerIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/data_request/web/DataRequestApiControllerIntegrationTests.java deleted file mode 100644 index 443a46c6..00000000 --- a/iris-public-server/src/test/java/iris/public_server/data_request/web/DataRequestApiControllerIntegrationTests.java +++ /dev/null @@ -1,79 +0,0 @@ -package iris.public_server.data_request.web; - -import static iris.public_server.data_request.DataRequestDataInitializer.*; -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import iris.public_server.IrisWebIntegrationTest; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.web.IrisLinkRelations; -import lombok.RequiredArgsConstructor; - -import java.util.UUID; - -import org.junit.jupiter.api.Test; -import org.springframework.hateoas.client.LinkDiscoverer; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultMatcher; - -import com.jayway.jsonpath.JsonPath; - -@IrisWebIntegrationTest -@RequiredArgsConstructor -class DataRequestApiControllerIntegrationTests { - - private final MockMvc mvc; - private final LinkDiscoverer discoverer; - - @Test - void getDataRequestByCode_contactsEvents() throws Exception { - - var response = performeGet(REQ_ID_1, status().isOk()); - - var document = JsonPath.parse(response); - - assertThat(discoverer.findLinkWithRel(IrisLinkRelations.CONTACTS_EVENTS_SUBMISSION, document.jsonString())) - .isPresent(); - assertThat(discoverer.findLinkWithRel(IrisLinkRelations.GUESTS_SUBMISSION, document.jsonString())).isNotPresent(); - assertThat(document.read("$.healthDepartment", String.class)).isEqualTo("Gesundheitsamt Meißen"); - assertThat(document.read("$.keyOfHealthDepartment", String.class)).isEqualTo("key of HD"); - assertThat(document.read("$.keyReference", String.class)).isEqualTo("keyRef-XYZ"); - assertThat(document.read("$.start", String.class)).isNotNull(); - assertThat(document.read("$.requestDetails", String.class)).isEqualTo("requestDetails"); - } - - @Test - void getDataRequestByCode_guests() throws Exception { - - var response = performeGet(REQ_ID_2, status().isOk()); - - var document = JsonPath.parse(response); - - assertThat(discoverer.findLinkWithRel(IrisLinkRelations.GUESTS_SUBMISSION, document.jsonString())).isPresent(); - assertThat(discoverer.findLinkWithRel(IrisLinkRelations.CONTACTS_EVENTS_SUBMISSION, document.jsonString())) - .isNotPresent(); - } - - @Test - void getDataRequestByCode_missingCode() throws Exception { - performeGet(DataRequestIdentifier.of(UUID.randomUUID()), status().isNotFound()); - } - - @Test - void getDataRequestByCode_closedReq() throws Exception { - - var response = performeGet(REQ_ID_4, status().isBadRequest()); - - var document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).isNotNull(); - } - - private String performeGet(DataRequestIdentifier id, ResultMatcher resultMatcher) throws Exception { - return mvc.perform( - get("/data-requests/{code}", id.toString())) - .andExpect(resultMatcher) - .andReturn().getResponse().getContentAsString(); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/data_submission/DataSubmissionDataInitializer.java b/iris-public-server/src/test/java/iris/public_server/data_submission/DataSubmissionDataInitializer.java deleted file mode 100644 index a59e2a79..00000000 --- a/iris-public-server/src/test/java/iris/public_server/data_submission/DataSubmissionDataInitializer.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - *******************************************************************************/ -package iris.public_server.data_submission; - -import iris.public_server.DataInitializer; -import iris.public_server.DepartmentDataInitializer; -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequestDataInitializer; -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.data_submission.repository.DataSubmissionRepository; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.util.ArrayList; - -import org.springframework.stereotype.Component; - -@Component -@RequiredArgsConstructor -@Slf4j -class DataSubmissionDataInitializer implements DataInitializer { - - private final DataSubmissionRepository submissions; - - /* - * (non-Javadoc) - * @see quarano.core.DataInitializer#initialize() - */ - @Override - public void initialize() { - - log.debug("Test data: creating data submissions …"); - - submissions.deleteAll(); - - var list = new ArrayList(); - list.add( - new DataSubmission(DataRequestDataInitializer.REQ_ID_1, DepartmentDataInitializer.DEPARTMENT_ID_1, "secret", - "keyReference", "DATA", Feature.Contacts_Events)); - - list.add( - new DataSubmission(DataRequestDataInitializer.REQ_ID_1, DepartmentDataInitializer.DEPARTMENT_ID_1, "secret", - "keyReference", "DATA", Feature.Contacts_Events)); - - list.add( - new DataSubmission(DataRequestDataInitializer.REQ_ID_2, DepartmentDataInitializer.DEPARTMENT_ID_1, "secret", - "keyReference", "DATA", Feature.Guests)); - - list.add( - new DataSubmission(DataRequestDataInitializer.REQ_ID_3, DepartmentDataInitializer.DEPARTMENT_ID_2, "secret", - "keyReference", "DATA", Feature.Contacts_Events)); - - submissions.saveAll(list); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionApiControllerIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionApiControllerIntegrationTests.java deleted file mode 100644 index 612db20f..00000000 --- a/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionApiControllerIntegrationTests.java +++ /dev/null @@ -1,169 +0,0 @@ -package iris.public_server.data_submission.web; - -import static iris.public_server.data_request.DataRequestDataInitializer.*; -import static java.nio.charset.StandardCharsets.*; -import static org.assertj.core.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; -import static org.springframework.http.MediaType.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import iris.public_server.IrisWebIntegrationTest; -import iris.public_server.core.Feature; -import iris.public_server.data_request.DataRequest.DataRequestIdentifier; -import iris.public_server.data_submission.model.DataSubmission; -import iris.public_server.data_submission.repository.DataSubmissionRepository; -import iris.public_server.data_submission.web.dto.ContactsEventsSubmissionDto; -import iris.public_server.data_submission.web.dto.DataSubmissionDto; -import iris.public_server.data_submission.web.dto.GuestsSubmissionDto; -import lombok.RequiredArgsConstructor; - -import java.util.UUID; - -import org.apache.commons.codec.binary.Base64; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mockito; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.http.MediaType; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultActions; -import org.springframework.test.web.servlet.ResultMatcher; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.jayway.jsonpath.JsonPath; - -@IrisWebIntegrationTest -@RequiredArgsConstructor -class DataSubmissionApiControllerIntegrationTests { - - private static final String DATA = Base64.encodeBase64String("EncryptedData".getBytes()); - - private final MockMvc mvc; - private final ObjectMapper mapper; - - @MockBean - private DataSubmissionRepository dataSubmissions; - - @Captor - ArgumentCaptor captor; - - @Test - void postContactsEventsSubmission() throws Exception { - - when(dataSubmissions.save(any())).thenAnswer(invocation -> invocation.getArguments()[0]); - - performPostSubmission(createContactSubmission(), "/data-submissions/{code}/contacts_events", REQ_ID_3, - status().isAccepted()); - - Mockito.verify(dataSubmissions).save(captor.capture()); - var value = captor.getValue(); - assertThat(value.getEncryptedData()).isEqualTo(DATA); - assertThat(value.getFeature()).isEqualTo(Feature.Contacts_Events); - assertThat(value.getRequestId()).isEqualTo(REQ_ID_3); - } - - @Test - void postGuestsSubmission() throws Exception { - - when(dataSubmissions.save(any())).thenAnswer(invocation -> invocation.getArguments()[0]); - - performPostSubmission(createGuestSubmission(), "/data-submissions/{code}/guests", REQ_ID_2, status().isAccepted()); - - Mockito.verify(dataSubmissions).save(captor.capture()); - var value = captor.getValue(); - assertThat(value.getEncryptedData()).isEqualTo(DATA); - assertThat(value.getFeature()).isEqualTo(Feature.Guests); - assertThat(value.getRequestId()).isEqualTo(REQ_ID_2); - } - - @Test - void postSubmission_missingRequestId() throws Exception { - - performPostSubmission(createContactSubmission(), "/data-submissions/{code}/contacts_events", - DataRequestIdentifier.of(UUID.randomUUID()), status().isNotFound()); - - performPostSubmission(createGuestSubmission(), "/data-submissions/{code}/guests", - DataRequestIdentifier.of(UUID.randomUUID()), status().isNotFound()); - } - - @Test - void postSubmission_wrongFeature() throws Exception { - - var result = performPostSubmission(createContactSubmission(), "/data-submissions/{code}/contacts_events", - REQ_ID_2, status().isBadRequest()); - - var response = result.andReturn().getResponse().getContentAsString(); - var document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).isNotNull(); - - result = performPostSubmission(createGuestSubmission(), "/data-submissions/{code}/guests", - REQ_ID_3, status().isBadRequest()); - - response = result.andReturn().getResponse().getContentAsString(); - document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).isNotNull(); - } - - @Test - void postSubmission_dataNotBase64() throws Exception { - - var dto2 = new ContactsEventsSubmissionDto(); - dto2.setEncryptedData("EncryptedData"); - fillDto(dto2); - performPostSubmission(dto2, "/data-submissions/{code}/contacts_events", - REQ_ID_3, status().isBadRequest()); - - var dto = new GuestsSubmissionDto(); - dto.setEncryptedData("EncryptedData"); - fillDto(dto); - performPostSubmission(dto, "/data-submissions/{code}/guests", - REQ_ID_2, status().isBadRequest()); - } - - @Test - void postSubmission_closedReq() throws Exception { - - var result = performPostSubmission(createContactSubmission(), "/data-submissions/{code}/contacts_events", - REQ_ID_4, status().isBadRequest()); - - var response = result.andReturn().getResponse().getContentAsString(); - var document = JsonPath.parse(response); - - assertThat(document.read("$", String.class)).isNotNull(); - } - - private ContactsEventsSubmissionDto createContactSubmission() { - var dto = new ContactsEventsSubmissionDto(); - dto.setEncryptedData(DATA); - fillDto(dto); - return dto; - } - - private GuestsSubmissionDto createGuestSubmission() { - var dto = new GuestsSubmissionDto(); - dto.setEncryptedData(DATA); - fillDto(dto); - return dto; - } - - private void fillDto(DataSubmissionDto dto) { - dto.setKeyReference("KeyReference"); - dto.setSecret("Secret"); - } - - private ResultActions performPostSubmission(DataSubmissionDto dto, String uri, DataRequestIdentifier id, - ResultMatcher resultMatcher) - throws Exception, JsonProcessingException { - return mvc.perform( - post(uri, id.toString()) - .contentType(new MediaType(APPLICATION_JSON, UTF_8)) - .content(mapper.writeValueAsString(dto))) - .andExpect(resultMatcher); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionHdControllerIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionHdControllerIntegrationTests.java deleted file mode 100644 index c681bc81..00000000 --- a/iris-public-server/src/test/java/iris/public_server/data_submission/web/DataSubmissionHdControllerIntegrationTests.java +++ /dev/null @@ -1,101 +0,0 @@ -package iris.public_server.data_submission.web; - -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import iris.public_server.DataInitializer; -import iris.public_server.DepartmentDataInitializer; -import iris.public_server.IrisWebIntegrationTest; -import iris.public_server.department.Department.DepartmentIdentifier; -import lombok.RequiredArgsConstructor; - -import java.io.UnsupportedEncodingException; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.time.temporal.ChronoUnit; -import java.util.UUID; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.test.web.servlet.MockMvc; - -import com.jayway.jsonpath.JsonPath; - -@IrisWebIntegrationTest -@RequiredArgsConstructor -class DataSubmissionHdControllerIntegrationTests { - - private final MockMvc mvc; - - /** - * Prevents the tests from running too quickly after the data is created and thus ignoring the data. - */ - @BeforeAll - void waitASec() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) {} - } - - @Test - void getAndDeleteSubmissions() throws Exception { - - var departmentId = DepartmentDataInitializer.DEPARTMENT_ID_1; - var from = Instant.now().minus(1, ChronoUnit.DAYS); - - var response = getSubmissions(departmentId, from); - var document = JsonPath.parse(response); - assertThat(document.read("$..requestId", String[].class)).hasSize(3); - - response = getSubmissions(DepartmentDataInitializer.DEPARTMENT_ID_2, from); - document = JsonPath.parse(response); - assertThat(document.read("$..requestId", String[].class)).hasSize(1); - - mvc.perform( - delete("/hd/data-submissions/"+document.read("$[0].id"))) - .andExpect(status().isOk()); - - response = getSubmissions(DepartmentDataInitializer.DEPARTMENT_ID_2, from); - document = JsonPath.parse(response); - assertThat(document.read("$..requestId", String[].class)).isEmpty(); - - // Wait for Maintenance Job - try { - Thread.sleep(15000); - } catch (InterruptedException e) {} - - response = getSubmissions(departmentId, from); - document = JsonPath.parse(response); - assertThat(document.read("$..requestId", String[].class)).isEmpty(); - - } - - @Test - void getSubmissions_noneForUnknownDepartment() throws Exception { - - var from = Instant.now().minus(1, ChronoUnit.DAYS); - - var response = getSubmissions(DepartmentIdentifier.of(UUID.randomUUID()), from); - - var document = JsonPath.parse(response); - - assertThat(document.read("$..requestId", String[].class)).isEmpty(); - } - - private String getSubmissions(DepartmentIdentifier departmentId, Instant from) - throws UnsupportedEncodingException, Exception { - - return mvc.perform( - get("/hd/data-submissions?departmentId={depId}&from={from}", - departmentId, from.toString())) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - } -} diff --git a/iris-public-server/src/test/java/iris/public_server/web/DefaultApiControllerIntegrationTests.java b/iris-public-server/src/test/java/iris/public_server/web/DefaultApiControllerIntegrationTests.java deleted file mode 100644 index 36d60452..00000000 --- a/iris-public-server/src/test/java/iris/public_server/web/DefaultApiControllerIntegrationTests.java +++ /dev/null @@ -1,35 +0,0 @@ -package iris.public_server.web; - -import static org.assertj.core.api.Assertions.*; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -import iris.public_server.IrisWebIntegrationTest; -import iris.public_server.web.IrisLinkRelations; -import lombok.RequiredArgsConstructor; - -import org.junit.jupiter.api.Test; -import org.springframework.hateoas.client.LinkDiscoverer; -import org.springframework.test.web.servlet.MockMvc; - -import com.jayway.jsonpath.JsonPath; - -@IrisWebIntegrationTest -@RequiredArgsConstructor -class DefaultApiControllerIntegrationTests { - - private final MockMvc mvc; - private final LinkDiscoverer discoverer; - - @Test - void getLinksFromRootUrl() throws Exception { - - var response = mvc.perform(get("/")) - .andExpect(status().isOk()) - .andReturn().getResponse().getContentAsString(); - - var document = JsonPath.parse(response); - - assertThat(discoverer.findLinkWithRel(IrisLinkRelations.REQUEST_BY_CODE, document.jsonString())).isPresent(); - } -} diff --git a/iris-public-server/src/test/resources/security/client/keystore.p12 b/iris-public-server/src/test/resources/security/client/keystore.p12 deleted file mode 100644 index cf856c65..00000000 Binary files a/iris-public-server/src/test/resources/security/client/keystore.p12 and /dev/null differ diff --git a/iris-public-server/src/test/resources/security/client/truststore.p12 b/iris-public-server/src/test/resources/security/client/truststore.p12 deleted file mode 100644 index 5e5f991e..00000000 Binary files a/iris-public-server/src/test/resources/security/client/truststore.p12 and /dev/null differ