This commit is contained in:
Peter Rossa
2023-05-10 12:23:25 +02:00
commit af29efa0f3
131 changed files with 16889 additions and 0 deletions

33
api/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

BIN
api/.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,18 @@
# 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

4
api/.postman/api Normal file
View File

@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
apis[] = {"apiId":"d6f5c611-f7b1-409a-803b-22b44637be76"}
configVersion = 1.0.0
type = api

View File

@@ -0,0 +1,18 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
configVersion = 1.0.0
type = apiEntityData
[config]
id = d6f5c611-f7b1-409a-803b-22b44637be76
[config.relations]
[config.relations.collections]
rootDirectory = postman/collections
[config.relations.collections.metaData]
[config.relations.apiDefinition]
rootDirectory = postman/schemas
[config.relations.apiDefinition.metaData]

316
api/mvnw vendored Normal file
View File

@@ -0,0 +1,316 @@
#!/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 /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
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="`\\unset -f command; \\command -v 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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$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 \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

188
api/mvnw.cmd vendored Normal file
View File

@@ -0,0 +1,188 @@
@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 "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq 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%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\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%
cmd /C exit /B %ERROR_CODE%

100
api/pom.xml Normal file
View File

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rossa</groupId>
<artifactId>api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>api</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!-- <version>2.1.0.RELEASE</version> -->
<version>2.7.2</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- <dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>
<finalName>api</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,39 @@
package com.rossa.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@SpringBootApplication
// @SpringBootApplication(scanBasePackages = "com.rossa.api.controller")
public class ApiApplication extends SpringBootServletInitializer {
// @Override
// protected SpringApplicationBuilder configure(SpringApplicationBuilder
// builder) {
// return builder.sources(ApiApplication.class);
// }
public static void main(String[] args) {
SpringApplication.run(ApiApplication.class, args);
}
// @Bean
// WebMvcConfigurer corsConfigurer() {
// return new WebMvcConfigurer() {
// @Override
// public void addCorsMappings(CorsRegistry registry) {
// registry.addMapping("/**").allowedOrigins("http://localhost:4200",
// "http://192.168.178.21:8180/").maxAge(3000);
// // registry.addMapping("/**")
// // .allowedHeaders("*")
// // .allowedOrigins("*")
// // .maxAge(3000);
// }
// };
// }
}

View File

@@ -0,0 +1,13 @@
package com.rossa.api;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApiApplication.class);
}
}

View File

@@ -0,0 +1,31 @@
package com.rossa.api.config;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
public class CustomAccessDeniedHandler implements AccessDeniedHandler {
@Override
public void handle(HttpServletRequest req,
HttpServletResponse resp,
AccessDeniedException ex) throws IOException, ServletException {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null) {
System.out.println("User '" + auth.getName()
+ "' attempted to access the protected URL: "
+ req.getRequestURI());
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Access Forbidden");
} else {
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
}
}

View File

@@ -0,0 +1,23 @@
package com.rossa.api.config;
import java.io.IOException;
import java.io.Serializable;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = -772511716561421072L;
@Override
public void commence(HttpServletRequest arg0, HttpServletResponse arg1, AuthenticationException arg2)
throws IOException, ServletException {
arg1.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
}

View File

@@ -0,0 +1,143 @@
package com.rossa.api.config;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rossa.api.models.AuthUserInfo;
import com.rossa.api.security.UserAuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;
import io.jsonwebtoken.ExpiredJwtException;
@Component
public class JwtRequestFilter extends OncePerRequestFilter {
private final String _authorizationKey = "authorization";
private final String _bearerTokenPrefix = "bearer ";
@Autowired
private UserAuthenticationService userAuthService;
@Autowired
private JwtTokenUtils<AuthUserInfo> jwtTokenUtils;
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain chain)
throws ServletException, IOException {
System.out.println("--------------------------------");
System.out.println(request.getRequestURL().toString());
AuthUserInfo tokenUserInfo = null;
String jwtToken = getJwtTokenFromHeader(request);
System.out.println("Token: " + jwtToken);
if (StringUtils.hasText(jwtToken)) {
tokenUserInfo = extractJwtUserInfoFromToken(jwtToken);
if (tokenUserInfo != null) {
SecurityContextHolder.getContext().setAuthentication(null);
if (StringUtils.hasText(tokenUserInfo.getUserId())) {
AuthUserInfo userDetails = this.userAuthService.getUserById(tokenUserInfo.getUserId());
if (userDetails != null) {
if (jwtTokenUtils.validateToken(jwtToken, userDetails)) {
List<GrantedAuthority> allAuths = convertUserRolesToGrantedAuthorities(
userDetails.getUserRoles());
if (allAuths != null && allAuths.size() > 0) {
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
userDetails, null, allAuths);
usernamePasswordAuthenticationToken
.setDetails(
new WebAuthenticationDetailsSource().buildDetails(request));
SecurityContextHolder.getContext()
.setAuthentication(usernamePasswordAuthenticationToken);
} else {
System.out.println("User has no roles associated with.");
SecurityContextHolder.getContext().setAuthentication(null);
}
} else {
System.out.println("User credential cannot be validated.");
SecurityContextHolder.getContext().setAuthentication(null);
}
} else {
System.out.println("No valid user credential available.");
SecurityContextHolder.getContext().setAuthentication(null);
}
} else {
System.out.println("Invalid user info detected. Authentication failed.");
SecurityContextHolder.getContext().setAuthentication(null);
}
} else {
System.out.println("Unable to get JWT Token");
SecurityContextHolder.getContext().setAuthentication(null);
}
} else {
System.out.println("JWT Token does not begin with Bearer String");
SecurityContextHolder.getContext().setAuthentication(null);
}
System.out.println("Try normal filtering");
chain.doFilter(request, response);
System.out.println("--------------------------------");
}
private String getJwtTokenFromHeader(HttpServletRequest request) {
String retVal = "";
if (request != null) {
final String requestTokenHeader = request.getHeader(_authorizationKey);
System.out.println("Found Auth Key: [" + requestTokenHeader + "]");
if (StringUtils.hasText(requestTokenHeader) && requestTokenHeader.startsWith(_bearerTokenPrefix)) {
retVal = requestTokenHeader.substring(_bearerTokenPrefix.length());
}
}
return retVal;
}
private AuthUserInfo extractJwtUserInfoFromToken(String tokenStrVal) {
AuthUserInfo retVal = null;
if (StringUtils.hasText(tokenStrVal)) {
try {
retVal = jwtTokenUtils.getUserInfoFromToken(tokenStrVal);
} catch (IllegalArgumentException ex) {
System.out.println("Unable to get JWT Token via token string decryption.");
retVal = null;
} catch (ExpiredJwtException ex) {
System.out.println("JWT Token has expired");
retVal = null;
}
}
return retVal;
}
private List<GrantedAuthority> convertUserRolesToGrantedAuthorities(List<String> allUserRoles) {
List<GrantedAuthority> retVal = new ArrayList<GrantedAuthority>();
if (allUserRoles != null && allUserRoles.size() > 0) {
for (String role : allUserRoles) {
if (StringUtils.hasText(role)) {
retVal.add(new SimpleGrantedAuthority(role));
}
}
}
return retVal;
}
}

View File

@@ -0,0 +1,190 @@
package com.rossa.api.config;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import com.rossa.api.models.AuthUserInfo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.thymeleaf.util.StringUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
@Component
public class JwtTokenUtils<T extends Object> implements Serializable {
private static final long serialVersionUID = -2550185165626007488L;
public static final long JWT_TOKEN_VALIDITY = 15 * 60; // 15 minutes
@Value("${jwt.secret}")
private String secret;
public AuthUserInfo getUserInfoFromToken(String token) {
AuthUserInfo retVal = null;
String userInfoStr = getUserInfoStringFromToken(token);
if (!StringUtils.isEmpty(userInfoStr)) {
ObjectMapper mapper = new ObjectMapper();
try {
retVal = mapper.readValue(userInfoStr, AuthUserInfo.class);
} catch (Exception ex) {
System.out.println("Exception occurred. " + ex.getMessage());
ex.printStackTrace();
retVal = null;
}
}
return retVal;
}
public String getUserInfoStringFromToken(String token) {
String retVal = null;
if (!StringUtils.isEmpty(token)) {
retVal = getClaimFromToken(token, Claims::getSubject);
}
return retVal;
}
public Date getExpirationDateFromToken(String token) {
Date retVal = null;
if (!StringUtils.isEmpty(token)) {
retVal = getClaimFromToken(token, Claims::getExpiration);
}
return retVal;
}
public <K extends Object> K getClaimFromToken(String token,
Function<Claims, K> claimsResolver) {
if (!StringUtils.isEmpty(token)) {
Claims claims = getAllClaimsFromToken(token);
return claimsResolver.apply(claims);
} else {
return null;
}
}
private Claims getAllClaimsFromToken(String token) {
if (!StringUtils.isEmpty(token)) {
if (!StringUtils.isEmpty(secret)) {
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
} else {
System.out.println("Secret key is null or empty, unable to decode claims from token.");
return null;
}
} else {
return null;
}
}
private Boolean isTokenExpired(String token) {
if (!StringUtils.isEmpty(token)) {
Date expiration = getExpirationDateFromToken(token);
if (expiration == null) {
System.out.println("Invalid expiration data. Invalid token detected.");
return false;
}
return expiration.before(new Date());
}
return false;
}
public String generateToken(T userInfo, Map<String, Object> claims, Date startTime, Date expirationTime) {
String userInfoStr = "";
String retVal = null;
if (claims == null) {
System.out.println("Claims object is null or empty, cannot createsecurity token.");
return retVal;
}
if (userInfo == null) {
System.out.println("userInfo object is null or empty, cannot createsecurity token.");
return retVal;
}
try {
ObjectMapper mapper = new ObjectMapper();
userInfoStr = mapper.writeValueAsString(userInfo);
retVal = doGenerateToken(claims, userInfoStr, startTime, expirationTime);
} catch (Exception ex) {
System.out.println("Exception occurred. " + ex.getMessage());
ex.printStackTrace();
retVal = null;
}
return retVal;
}
public String generateToken(T userDetails, Date startTime, Date expirationTime) {
Map<String, Object> emptyClaims = new HashMap<String, Object>();
return generateToken(userDetails, emptyClaims, startTime, expirationTime);
}
private String doGenerateToken(Map<String, Object> claims, String subject, Date startTime, Date expirationTime) {
String retVal = null;
if (StringUtils.isEmpty(secret)) {
System.out.println("Invalid secret key for token encryption.");
return retVal;
}
if (claims == null) {
System.out.println("Invalid token claims object.");
return retVal;
}
if (StringUtils.isEmpty(subject)) {
System.out.println("Invalid subject value for the security token.");
return retVal;
}
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(startTime)
.setExpiration(expirationTime)
.signWith(SignatureAlgorithm.HS512, secret).compact();
}
public Boolean validateToken(String token, AuthUserInfo userDetails) {
if (!StringUtils.isEmpty(token)) {
AuthUserInfo userInfo = getUserInfoFromToken(token);
if (userInfo != null) {
if (userDetails != null) {
String actualUserId = userInfo.getUserId();
if (!StringUtils.isEmpty(actualUserId) && actualUserId.equalsIgnoreCase(userDetails.getUserId())) {
if (userDetails.isUserActive()) {
return !isTokenExpired(token);
} else {
System.out.println(String.format("User with id [%s] is not active. Invalid token.",
userInfo.getUserId()));
return false;
}
} else {
System.out.println("User in the token has a different user id than expected. Invalid token.");
return false;
}
} else {
System.out.println("Expected user details object is invalid. Unable to verify token validity.");
return false;
}
} else {
System.out.println("Decrypted user details object is invalid. Invalid token.");
return false;
}
} else {
System.out.println("Invalid token string detected. Invalid token.");
return false;
}
}
}

View File

@@ -0,0 +1,60 @@
package com.rossa.api.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
public class WebAppSecurityConfig {
@Autowired
private AccessDeniedHandler accessDeniedHandler;
@Autowired
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
@Autowired
private JwtRequestFilter jwtRequestFilter;
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
System.out.println("Security filter chain initialization...");
http.cors().and()
.csrf().disable()
.authorizeRequests()
.antMatchers("/assets/**", "/public/**", "/authenticate", "/app/**").permitAll()
.anyRequest().authenticated().and()
.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint)
.accessDeniedHandler(accessDeniedHandler).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
return http.build();
}
@Bean
public WebMvcConfigurer corsConfigurer() {
String[] allowDomains = new String[2];
allowDomains[0] = "http://localhost:4200";
allowDomains[1] = "http://192.168.178.21:8180/";
System.out.println("CORS configuration....");
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins(allowDomains);
}
};
}
}

View File

@@ -0,0 +1,39 @@
INSERT INTO meters (name) VALUES ('1LOG');
INSERT INTO meters (name) VALUES ('1HEM');
INSERT INTO meters (name) VALUES ('WASSER');
INSERT INTO meters (name) VALUES ('ABWASSER');
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-12-31 00:00:00', 11546.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-09-30 00:00:00', 10504.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-08-30 00:00:00', 10193.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-07-01 00:00:00', 9679.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2021-12-31 00:00:00', 7787.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2021-09-25 00:00:00', 7322.00, 1);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-12-31 00:00:00', 12398.00, 2);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2022-05-31 00:00:00', 10799.00, 2);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2021-12-31 00:00:00', 8758.00, 2);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2021-09-01 00:00:00', 7355.00, 2);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('ENERGY', '2021-06-01 00:00:00', 7163.00, 2);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2022-01-01 00:00:00', 288.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2022-12-31 00:00:00', 464.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2021-01-01 00:00:00', 153.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2021-12-31 00:00:00', 288.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2020-03-03 00:00:00', 153.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2020-12-31 00:00:00', 288.00, 3);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2022-01-01 00:00:00', 116.00, 4);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2022-12-31 00:00:00', 189.00, 4);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2021-01-01 00:00:00', 81.00, 4);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2021-12-31 00:00:00', 116.00, 4);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2020-03-06 00:00:00', 0.00, 4);
INSERT INTO meter_data (type, date, amount, meter_id) VALUES ('WATER', '2020-12-31 00:00:00', 81.00, 4);
/***************
***************/

View File

@@ -0,0 +1,15 @@
CREATE TABLE meters (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE meter_data (
id INT NOT NULL AUTO_INCREMENT,
type ENUM('ENERGY', 'WATER') NOT NULL,
date DATETIME NOT NULL,
amount FLOAT NOT NULL,
meter_id INT NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (meter_id) REFERENCES meter(id)
);

View File

@@ -0,0 +1,16 @@
package com.rossa.api.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class AppContoller {
@RequestMapping(value = "/public/index", method = RequestMethod.GET)
public ModelAndView index() {
ModelAndView retVal = new ModelAndView();
retVal.setViewName("indexPage");
return retVal;
}
}

View File

@@ -0,0 +1,19 @@
package com.rossa.api.controllers;
import com.rossa.api.models.AuthUserInfo;
import org.springframework.security.core.context.SecurityContextHolder;
public class ControllerBase {
protected AuthUserInfo getCurrentUser() {
AuthUserInfo retVal = null;
Object principal = SecurityContextHolder
.getContext()
.getAuthentication()
.getPrincipal();
if (principal != null && principal instanceof AuthUserInfo) {
retVal = (AuthUserInfo) principal;
}
return retVal;
}
}

View File

@@ -0,0 +1,14 @@
package com.rossa.api.controllers;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String index() {
return "Greetings from Spring Boot!";
}
}

View File

@@ -0,0 +1,74 @@
package com.rossa.api.controllers;
import com.rossa.api.models.AuthUserInfo;
import com.rossa.api.models.LoginRequest;
import com.rossa.api.models.OpResponse;
import com.rossa.api.security.UserAuthenticationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController extends ControllerBase {
private UserAuthenticationService _authService;
public LoginController(UserAuthenticationService authService) {
_authService = authService;
}
@RequestMapping(value = "/authenticate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<AuthUserInfo> login(@RequestBody LoginRequest loginReq) {
System.out.println("User Name: " + loginReq.getUserName());
System.out.println("User Pass: " + loginReq.getUserPass());
if (StringUtils.hasText(loginReq.getUserName()) && StringUtils.hasText(loginReq.getUserPass())) {
AuthUserInfo userFound = _authService.authenticateUser(loginReq.getUserName(), loginReq.getUserPass());
if (userFound != null) {
return ResponseEntity.ok(userFound);
} else {
return ResponseEntity.status(403).body((AuthUserInfo) null);
}
} else {
return ResponseEntity.status(403).body((AuthUserInfo) null);
}
}
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/signOut", method = RequestMethod.POST)
public ResponseEntity<OpResponse> signOut() {
ResponseEntity<OpResponse> retVal = null;
OpResponse resp = new OpResponse();
AuthUserInfo currUser = getCurrentUser();
if (currUser != null) {
String userId = currUser.getUserId();
boolean signoutSuccess = _authService.userSignOut(userId);
if (signoutSuccess) {
resp.setSuccessful(true);
resp.setStatus("Log out successful");
resp.setDetailMessage("You have successfully log out from this site.");
retVal = new ResponseEntity<OpResponse>(resp, HttpStatus.OK);
} else {
resp.setSuccessful(false);
resp.setStatus("Operation Failed");
resp.setDetailMessage("Unable to sin out user. Unknown error.");
retVal = new ResponseEntity<OpResponse>(resp, HttpStatus.INTERNAL_SERVER_ERROR);
}
} else {
resp.setSuccessful(false);
resp.setStatus("Operation Failed");
resp.setDetailMessage("You cannot log out if you are not log in first.");
retVal = new ResponseEntity<OpResponse>(resp, HttpStatus.UNAUTHORIZED);
}
System.out.println("sign out called!");
return retVal;
}
}

View File

@@ -0,0 +1,44 @@
package com.rossa.api.controllers;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.MediaType;
import com.rossa.api.exception.ResourceNotFoundException;
import com.rossa.api.models.Meter;
import com.rossa.api.repository.MeterRepository;
@RestController
@PreAuthorize("isAuthenticated()")
public class MeterController {
@Autowired
private MeterRepository meterRepository;
@RequestMapping(value = "/meters", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<Meter> getAllEmployees() {
return meterRepository.findAll();
}
@RequestMapping(value = "/meters/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Meter> getEmployeeById(@PathVariable(value = "id") long meterId)
throws ResourceNotFoundException {
Meter meter = meterRepository.findById(meterId)
.orElseThrow(() -> new ResourceNotFoundException("Meter not found for this id :: " + meterId));
return ResponseEntity.ok().body(meter);
}
@RequestMapping(value = "/meters", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public Meter createMeter(@Valid @RequestBody Meter meter) {
return meterRepository.save(meter);
}
}

View File

@@ -0,0 +1,107 @@
package com.rossa.api.controllers;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.http.MediaType;
import com.rossa.api.exception.ResourceNotFoundException;
import com.rossa.api.models.MeterData;
import com.rossa.api.repository.MeterDataRepository;
@RestController
@PreAuthorize("isAuthenticated()")
// @CrossOrigin(origins = "http://localhost:4200, http://192.168.178.21/")
public class MeterDataController {
@Autowired
private MeterDataRepository meterDataRepository;
@RequestMapping(value = "/meter-data", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<com.rossa.api.models.MeterData> getAllMeterData() {
return meterDataRepository.findAll();
}
@RequestMapping(value = "/meter-data/meter/{meterId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<MeterData> getAllMeterDataByMeterId(@PathVariable(value = "meterId") long meterId) {
return meterDataRepository.findByMeterId(meterId);
}
@RequestMapping(value = "/meter-data/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MeterData> getMeterDataById(@PathVariable(value = "id") long meterDataId)
throws ResourceNotFoundException {
MeterData meterData = meterDataRepository.findById(meterDataId)
.orElseThrow(() -> new ResourceNotFoundException("Meter not found for this id :: " + meterDataId));
return ResponseEntity.ok().body(meterData);
}
@RequestMapping(value = "/meter-data", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public MeterData createMeterData(@Valid @RequestBody MeterData meterData) {
return meterDataRepository.save(meterData);
}
// @PutMapping("/meter-data/{id}")
// public ResponseEntity < MeterData > updateMeterData(@PathVariable(value =
// "id") Long meterDataId,
// @Valid @RequestBody MeterData meterDataDetails) throws
// ResourceNotFoundException {
// MeterData meterData = meterDataRepository.findById(meterDataId)
// .orElseThrow(() -> new ResourceNotFoundException("Employee not found for this
// id :: " + meterDataId));
// meterData.setAmount(meterDataDetails.getAmount());
// meterData.setDate(meterDataDetails.getDate());
// meterData.setMeter(meterDataDetails.getMeter());
// meterData.setType(meterDataDetails.getType());
// final MeterData updatedMeterData = meterDataRepository.save(meterData);
// return ResponseEntity.ok(updatedMeterData);
// }
@RequestMapping(value = "/meter-data/{id}", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<MeterData> updateMeterData(@PathVariable(value = "id") Long meterDataId,
@Valid @RequestBody MeterData meterDataDetails) throws ResourceNotFoundException {
MeterData meterData = meterDataRepository.findById(meterDataId)
.orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + meterDataId));
if (meterDataDetails.getType() != null) {
meterData.setType(meterDataDetails.getType());
}
if (meterDataDetails.getDate() != null) {
meterData.setDate(meterDataDetails.getDate());
}
if (meterDataDetails.getAmount() != null) {
meterData.setAmount(meterDataDetails.getAmount());
}
if (meterDataDetails.getMeter() != null) {
meterData.setMeter(meterDataDetails.getMeter());
}
final MeterData updatedMeterData = meterDataRepository.save(meterData);
return ResponseEntity.ok(updatedMeterData);
}
@RequestMapping(value = "/meter-data/{id}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, Boolean> deleteMeterData(@PathVariable(value = "id") Long meterDataId)
throws ResourceNotFoundException {
MeterData meterData = meterDataRepository.findById(meterDataId)
.orElseThrow(() -> new ResourceNotFoundException("Employee not found for this id :: " + meterDataId));
meterDataRepository.delete(meterData);
Map<String, Boolean> response = new HashMap<>();
response.put("deleted", Boolean.TRUE);
return response;
}
}

View File

@@ -0,0 +1,62 @@
package com.rossa.api.controllers;
import java.util.ArrayList;
import java.util.List;
import com.rossa.api.models.TitleModel;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SecureApiController {
public SecureApiController() {
}
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/secure/allGameTitles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<TitleModel>> allGameTitles() {
List<TitleModel> resp = new ArrayList<TitleModel>();
TitleModel titleToAdd = new TitleModel();
titleToAdd.setGameTitle("Cyberpunk 2077");
titleToAdd.setPublisher("Warnder Bros");
titleToAdd.setDevStudioName("CD Projekt Red");
titleToAdd.setPublishingYear((short) 2019);
titleToAdd.setRetailPrice(69.95f);
resp.add(titleToAdd);
titleToAdd = new TitleModel();
titleToAdd.setGameTitle("Final Fantasy XV");
titleToAdd.setPublisher("Square Enix");
titleToAdd.setDevStudioName("Square Enix");
titleToAdd.setPublishingYear((short) 2016);
titleToAdd.setRetailPrice(59.95f);
resp.add(titleToAdd);
titleToAdd = new TitleModel();
titleToAdd.setGameTitle("Fallout 4");
titleToAdd.setPublisher("Bethesda Softworks");
titleToAdd.setDevStudioName("Bethesda Game Studios");
titleToAdd.setPublishingYear((short) 2015);
titleToAdd.setRetailPrice(59.95f);
resp.add(titleToAdd);
titleToAdd = new TitleModel();
titleToAdd.setGameTitle("Dragon Quest XI");
titleToAdd.setPublisher("Square Enix");
titleToAdd.setDevStudioName("Square Enix");
titleToAdd.setPublishingYear((short) 2017);
titleToAdd.setRetailPrice(59.95f);
resp.add(titleToAdd);
return ResponseEntity.ok(resp);
}
}

View File

@@ -0,0 +1,14 @@
package com.rossa.api.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends Exception{
private static final long serialVersionUID = 1L;
public ResourceNotFoundException(String message){
super(message);
}
}

View File

@@ -0,0 +1,36 @@
package com.rossa.api.models;
import java.util.Date;
public class AuthToken
extends AuthUserInfo {
private Date sessionStartTime;
private Date sessionEndTime;
private String tokenValue;
public Date getSessionStartTime() {
return sessionStartTime;
}
public void setSessionStartTime(Date sessionStartTime) {
this.sessionStartTime = sessionStartTime;
}
public Date getSessionEndTime() {
return sessionEndTime;
}
public void setSessionEndTime(Date sessionEndTime) {
this.sessionEndTime = sessionEndTime;
}
public String getTokenValue() {
return tokenValue;
}
public void setTokenValue(String tokenValue) {
this.tokenValue = tokenValue;
}
}

View File

@@ -0,0 +1,75 @@
package com.rossa.api.models;
import java.util.List;
public class AuthUserInfo {
private String userId;
private String userName;
private String userPassword;
private String userNickName;
private boolean userActive;
private String userEmail;
private List<String> userRoles;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPassword() {
return userPassword;
}
public void setUserPassword(String userPassword) {
this.userPassword = userPassword;
}
public String getUserNickName() {
return userNickName;
}
public void setUserNickName(String userNickName) {
this.userNickName = userNickName;
}
public boolean isUserActive() {
return userActive;
}
public void setUserActive(boolean userActive) {
this.userActive = userActive;
}
public String getUserEmail() {
return userEmail;
}
public void setUserEmail(String userEmail) {
this.userEmail = userEmail;
}
public List<String> getUserRoles() {
return userRoles;
}
public void setUserRoles(List<String> userRoles) {
this.userRoles = userRoles;
}
}

View File

@@ -0,0 +1,23 @@
package com.rossa.api.models;
public class LoginRequest {
private String userName;
private String userPass;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPass() {
return userPass;
}
public void setUserPass(String userPass) {
this.userPass = userPass;
}
}

View File

@@ -0,0 +1,40 @@
package com.rossa.api.models;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "meters")
public class Meter {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "name", nullable = false)
private String name;
public Meter() {
}
// getters and setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -0,0 +1,87 @@
package com.rossa.api.models;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
@Table(name = "meterData")
public class MeterData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Enumerated(EnumType.STRING)
@Column(name = "type", nullable = false)
private UsageType type;
@Column(name = "date", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date date;
@Column(name = "amount", nullable = false)
private Float amount;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "meterId", nullable = false)
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
private Meter meter;
public MeterData() {
}
// getters and setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public UsageType getType() {
return type;
}
public void setType(UsageType type) {
this.type = type;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
public Float getAmount() {
return amount;
}
public void setAmount(Float amount) {
this.amount = amount;
}
public Meter getMeter() {
return meter;
}
public void setMeter(Meter meter) {
this.meter = meter;
}
}

View File

@@ -0,0 +1,33 @@
package com.rossa.api.models;
public class OpResponse {
private boolean successful;
private String status;
private String detailMessage;
public boolean isSuccessful() {
return successful;
}
public void setSuccessful(boolean successful) {
this.successful = successful;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getDetailMessage() {
return detailMessage;
}
public void setDetailMessage(String detailMessage) {
this.detailMessage = detailMessage;
}
}

View File

@@ -0,0 +1,53 @@
package com.rossa.api.models;
public class TitleModel {
private String gameTitle;
private String publisher;
private String devStudioName;
private short publishingYear;
private float retailPrice;
public String getGameTitle() {
return gameTitle;
}
public void setGameTitle(String titleValue) {
this.gameTitle = titleValue;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public String getDevStudioName() {
return devStudioName;
}
public void setDevStudioName(String devStudioName) {
this.devStudioName = devStudioName;
}
public short getPublishingYear() {
return publishingYear;
}
public void setPublishingYear(short publishingYear) {
this.publishingYear = publishingYear;
}
public float getRetailPrice() {
return retailPrice;
}
public void setRetailPrice(float retailPrice) {
this.retailPrice = retailPrice;
}
}

View File

@@ -0,0 +1,25 @@
package com.rossa.api.models;
public enum UsageType {
ENERGY("ENERGY"),
WATER("WATER");
private final String value;
UsageType(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public static UsageType fromValue(String value) {
for (UsageType type : values()) {
if (type.value.equals(value)) {
return type;
}
}
throw new IllegalArgumentException("Invalid UsageType value: " + value);
}
}

View File

@@ -0,0 +1,11 @@
package com.rossa.api.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import com.rossa.api.models.MeterData;
public interface MeterDataRepository extends JpaRepository<MeterData, Long> {
List<MeterData> findByMeterId(long meterId);
}

View File

@@ -0,0 +1,9 @@
package com.rossa.api.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.rossa.api.models.Meter;
public interface MeterRepository extends JpaRepository<Meter, Long> {
}

View File

@@ -0,0 +1,9 @@
package com.rossa.api.repository;
import com.rossa.api.models.AuthUserInfo;
public interface UserRepository {
AuthUserInfo getUser(String userName, boolean userActive);
AuthUserInfo getUserById(String userId);
}

View File

@@ -0,0 +1,82 @@
package com.rossa.api.repository;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.rossa.api.models.AuthUserInfo;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
@Service
public class UserRepositoryImpl implements UserRepository {
private static List<AuthUserInfo> mockUsersList;
static {
mockUsersList = new ArrayList<AuthUserInfo>();
AuthUserInfo userToAdd = new AuthUserInfo();
userToAdd.setUserActive(true);
userToAdd.setUserId("00000001");
userToAdd.setUserEmail("testuser1@teststore.org");
userToAdd.setUserName("testuser1");
userToAdd.setUserNickName("Test User1");
userToAdd.setUserPassword("123test321");
List<String> adminRoles = new ArrayList<String>();
adminRoles.add("ROLE_SITE_ADMIN");
adminRoles.add("ROLE_SITE_SUPERUSER");
adminRoles.add("ROLE_SITE_USER");
userToAdd.setUserRoles(adminRoles);
mockUsersList.add(userToAdd);
userToAdd = new AuthUserInfo();
userToAdd.setUserActive(true);
userToAdd.setUserId("00000001");
userToAdd.setUserEmail("testuser1@teststore.org");
userToAdd.setUserName("testuser1");
userToAdd.setUserNickName("Test User1");
userToAdd.setUserPassword("123test321");
List<String> userRoles = new ArrayList<String>();
userRoles.add("ROLE_SITE_USER");
userToAdd.setUserRoles(userRoles);
mockUsersList.add(userToAdd);
}
@Override
public AuthUserInfo getUser(String userName, boolean userActive) {
AuthUserInfo retVal = null;
if (mockUsersList != null) {
Optional<AuthUserInfo> foundUser = mockUsersList.stream().filter(x -> {
String uname = x.getUserName();
return StringUtils.hasText(uname) && uname.equals(userName) && x.isUserActive() == userActive;
}).findFirst();
if (foundUser.isPresent()) {
retVal = foundUser.get();
}
}
return retVal;
}
@Override
public AuthUserInfo getUserById(String userId) {
AuthUserInfo retVal = null;
if (mockUsersList != null) {
Optional<AuthUserInfo> foundUser = mockUsersList.stream().filter(x -> {
String uid = x.getUserId();
return StringUtils.hasText(uid) && uid.equals(userId);
}).findFirst();
if (foundUser.isPresent()) {
retVal = foundUser.get();
}
}
return retVal;
}
}

View File

@@ -0,0 +1,12 @@
package com.rossa.api.security;
import com.rossa.api.models.AuthToken;
import com.rossa.api.models.AuthUserInfo;
public interface UserAuthenticationService {
AuthToken authenticateUser(String userName, String password);
AuthUserInfo getUserById(String userId);
boolean userSignOut(String userId);
}

View File

@@ -0,0 +1,86 @@
package com.rossa.api.security;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import com.rossa.api.config.JwtTokenUtils;
import com.rossa.api.models.AuthToken;
import com.rossa.api.models.AuthUserInfo;
import com.rossa.api.repository.UserRepository;
@Service
public class UserAuthenticationServiceImpl
implements UserAuthenticationService {
public static final long JWT_TOKEN_VALIDITY = 15 * 60; // 15 minutes
private UserRepository userRepo;
private JwtTokenUtils<AuthUserInfo> jwtTknUtils;
public UserAuthenticationServiceImpl(UserRepository userRepo,
JwtTokenUtils<AuthUserInfo> jwtTknUtils) {
this.userRepo = userRepo;
this.jwtTknUtils = jwtTknUtils;
}
@Override
public AuthToken authenticateUser(String userName, String password) {
AuthToken retVal = null;
if (!StringUtils.hasText(userName)) {
throw new IllegalArgumentException("User name cannot be null or empty.");
}
if (!StringUtils.hasText(password)) {
throw new IllegalArgumentException("User password cannot be null or empty.");
}
AuthUserInfo foundUser = userRepo.getUser(userName, true);
if (foundUser != null) {
String userPass = foundUser.getUserPassword();
if (StringUtils.hasText(userPass) && userPass.equals(password)) {
long currTimeMillisec = System.currentTimeMillis();
Date dateNow = new Date(currTimeMillisec);
Date dateExpires = new Date(currTimeMillisec + JWT_TOKEN_VALIDITY * 1000);
retVal = new AuthToken();
retVal.setUserId(foundUser.getUserId());
retVal.setUserName(foundUser.getUserName());
retVal.setUserNickName(foundUser.getUserNickName());
retVal.setUserEmail(foundUser.getUserEmail());
retVal.setUserActive(foundUser.isUserActive());
retVal.setUserPassword(null);
retVal.setUserRoles(foundUser.getUserRoles());
String jwtTknVal = this.jwtTknUtils.generateToken(foundUser, dateNow, dateExpires);
retVal.setSessionStartTime(dateNow);
retVal.setSessionEndTime(dateExpires);
retVal.setTokenValue(jwtTknVal);
} else {
System.out.println("Unable to validate user credential. Authentication failed.");
retVal = null;
}
} else {
System.out.println("User not found. Authentication failed.");
retVal = null;
}
return retVal;
}
@Override
public AuthUserInfo getUserById(String userId) {
if (!StringUtils.hasText(userId)) {
throw new IllegalArgumentException("User id cannot be null or empty.");
}
AuthUserInfo retVal = userRepo.getUserById(userId);
return retVal;
}
@Override
public boolean userSignOut(String userId) {
// dud method.
return true;
}
}

View File

@@ -0,0 +1,34 @@
# # Database
# db.driver= com.mysql.jdbc.Driver
# db.url= jdbc:mysql://192.168.178.21:3306/rossa_tech_testing
# db.username=db_pezi
# db.password=Pe23Zi0484!_db
# # Hibernate
# hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
# hibernate.show_sql=true
# hibernate.hbm2ddl.auto=update
# entitymanager.packagesToScan=Model
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration
jwt.secret=aquickfoxjumpsoverthelazydog
# Database
spring.datasource.url= jdbc:mysql://192.168.178.21:3306/rossa_tech_testing?useSSL=false
spring.datasource.username= db_pezi
spring.datasource.password= Pe23Zi0484!_db
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jackson.serialization.fail-on-empty-beans=false
#spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
#spring.jpa.hibernate.ddl-auto= update
# spring.security.user.name=pezi
# spring.security.user.password=Password123!
security.basic.enabled=false

View File

@@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Login</title>
<link rel="stylesheet" th:href="@{/assets/bootstrap/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/assets/bootstrap/css/bootstrap-theme.min.css}"/>
<link rel="stylesheet" th:href="@{/assets/css/index.css}"/>
<link rel="icon" type="image/png" th:href="@{/assets/images/favicon.png}">
</head>
<body>
<div class="container" ng-app="sampleApp">
<ui-view></ui-view>
</div>
<script type="text/javascript" th:src="@{/assets/jquery/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/assets/bootstrap/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/assets/angularjs/1.7.5/angular.min.js}"></script>
<script type="text/javascript" th:src="@{/assets/angularjs/1.7.5/angular-resource.min.js}"></script>
<script type="text/javascript" th:src="@{/assets/angularjs/1.7.5/angular-route.min.js}"></script>
<script type="text/javascript" th:src="@{/assets/angularjs/1.7.5/angular-ui-router.min.js}"></script>
<script type="module" th:src="@{/assets/app/js/app.js}"></script>
</body>
</html>