Compare commits

...

No commits in common. "371ba904e224e2c335b309efdb62def3548f73c1" and "90a69d1663c0183c7f5cb9ba692aced066ea43db" have entirely different histories.

29 changed files with 29 additions and 1436 deletions

26
.gitignore vendored Normal file
View File

@ -0,0 +1,26 @@
# ---> Java
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

View File

@ -1,19 +0,0 @@
# 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.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# auth-server
microserive for authentication and authoroization

View File

@ -1,8 +0,0 @@
services:
rabbitmq:
image: 'rabbitmq:latest'
environment:
- 'RABBITMQ_DEFAULT_PASS=secret'
- 'RABBITMQ_DEFAULT_USER=myuser'
ports:
- '5672'

259
mvnw vendored
View File

@ -1,259 +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.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.2
#
# Optional ENV vars
# -----------------
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
# MVNW_REPOURL - repo url base for downloading maven distribution
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
# ----------------------------------------------------------------------------
set -euf
[ "${MVNW_VERBOSE-}" != debug ] || set -x
# OS specific support.
native_path() { printf %s\\n "$1"; }
case "$(uname)" in
CYGWIN* | MINGW*)
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
native_path() { cygpath --path --windows "$1"; }
;;
esac
# set JAVACMD and JAVACCMD
set_java_home() {
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
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"
JAVACCMD="$JAVA_HOME/jre/sh/javac"
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
return 1
fi
fi
else
JAVACMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v java
)" || :
JAVACCMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
return 1
fi
fi
}
# hash string like Java String::hashCode
hash_string() {
str="${1:-}" h=0
while [ -n "$str" ]; do
char="${str%"${str#?}"}"
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
str="${str#?}"
done
printf %x\\n $h
}
verbose() { :; }
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
die() {
printf %s\\n "$1" >&2
exit 1
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
esac
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
case "${distributionUrl##*/}" in
maven-mvnd-*bin.*)
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
*)
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
distributionPlatform=linux-amd64
;;
esac
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
;;
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
esac
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
distributionUrlName="${distributionUrl##*/}"
distributionUrlNameMain="${distributionUrlName%.*}"
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
exec_maven() {
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
}
if [ -d "$MAVEN_HOME" ]; then
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
exec_maven "$@"
fi
case "${distributionUrl-}" in
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
esac
# prepare tmp dir
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
trap clean HUP INT TERM EXIT
else
die "cannot create temp dir"
fi
mkdir -p -- "${MAVEN_HOME%/*}"
# Download and Install Apache Maven
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
verbose "Downloading from: $distributionUrl"
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
distributionUrl="${distributionUrl%.zip}.tar.gz"
distributionUrlName="${distributionUrl##*/}"
fi
# verbose opt
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
# normalize http auth
case "${MVNW_PASSWORD:+has-password}" in
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
esac
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
verbose "Found wget ... using wget"
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
cat >"$javaSource" <<-END
public class Downloader extends java.net.Authenticator
{
protected java.net.PasswordAuthentication getPasswordAuthentication()
{
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
}
public static void main( String[] args ) throws Exception
{
setDefault( new Downloader() );
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
}
}
END
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
verbose " - Compiling Downloader.java ..."
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
verbose " - Running Downloader.java ..."
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
fi
# If specified, validate the SHA-256 sum of the Maven distribution zip file
if [ -n "${distributionSha256Sum-}" ]; then
distributionSha256Result=false
if [ "$MVN_CMD" = mvnd.sh ]; then
echo "Checksum validation is not supported for maven-mvnd." >&2
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
elif command -v sha256sum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
elif command -v shasum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
fi
if [ $distributionSha256Result = false ]; then
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
exit 1
fi
fi
# unzip and move
if command -v unzip >/dev/null; then
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
else
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
fi
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
clean || :
exec_maven "$@"

149
mvnw.cmd vendored
View File

@ -1,149 +0,0 @@
<# : batch portion
@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 Apache Maven Wrapper startup batch script, version 3.3.2
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
}
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"

296
pom.xml
View File

@ -1,296 +0,0 @@
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.stktrk</groupId>
<artifactId>app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>app</name>
<description>stktrk backend</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.flywaydb/flyway-database-postgresql -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
<version>10.4.1</version>
<!-- <scope>runtime</scope> -->
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>rabbitmq</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
<version>2.3.17.Final</version>
</dependency>
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-gremlin</artifactId>
<version>24.6.1</version>
</dependency>
<dependency>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-server</artifactId>
<version>24.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tinkerpop/gremlin-server
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-server</artifactId>
<version>3.7.2</version>
</dependency>
<!- https://mvnrepository.com/artifact/org.opencypher/util-9.0
<dependency>
<groupId>org.opencypher</groupId>
<artifactId>util-9.0</artifactId>
<version>9.0.1</version>
</dependency>
leaving these here for now, documentation apparently lied about needing them...
-->
<!-- https://mvnrepository.com/artifact/org.apache.tinkerpop/gremlin-groovy -->
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>3.7.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.opencypher/util-9.0 -->
<dependency>
<groupId>org.opencypher.gremlin</groupId>
<artifactId>translation</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.hashids</groupId>
<artifactId>hashids</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>10.17.2</version>
<configuration>
<configFiles>${project.basedir}/src/main/resources/application.properties</configFiles>
<locations>
<location>classpath:com/stktrk/app/db/migrations</location>
</locations>
<sqlMigrationSeparator>__</sqlMigrationSeparator>
<url>jdbc:postgresql://192.168.178.50:7654/flyway_db</url>
<user>flyway_user</user>
<password>7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi</password>
<schemas>
<schema>flyway_db</schema>
</schemas>
</configuration>
<dependencies>
<!- https://mvnrepository.com/artifact/org.postgresql/postgresql
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.4</version>
</dependency>
</dependencies>
</plugin>
-->
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</project>

View File

@ -1,16 +0,0 @@
# stktrk.com repository
Might have to
- Build -> Build Project
- maven reload all projects
- generate sources
- mvn clean install
- To run
- mvn spring-boot:run
- in IntelliJ: Run Icon in `src/main/java/com/stktrk/app/AppApplication.java`
http://localhost:9090/swagger-ui/index.html
http://localhost:9090/actuator

View File

@ -1,18 +0,0 @@
package com.stktrk.app;
import jakarta.annotation.Nullable;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
// https://stackoverflow.com/questions/51221777/failed-to-configure-a-datasource-url-attribute-is-not-specified-and-no-embedd
@SpringBootApplication(exclude = {FlywayAutoConfiguration.class})
public class AppApplication extends SpringBootServletInitializer {
public static void main(@Nullable String[] args) {
SpringApplication.run(AppApplication.class, args);
}
}

View File

@ -1,51 +0,0 @@
package com.stktrk.app;
import jakarta.annotation.Nonnull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
/**
* Code was copied from <a href="https://www.baeldung.com/spring-boot-security-autoconfiguration">here</a>
*/
@Configuration
@EnableWebSecurity
public class BasicConfiguration {
@Bean
@Nonnull
public InMemoryUserDetailsManager userDetailsService(@Nonnull PasswordEncoder passwordEncoder) {
UserDetails user = User.withUsername("Rasmus")
.password(passwordEncoder.encode("password"))
.roles("USER")
.build();
UserDetails admin = User.withUsername("Christian")
.password(passwordEncoder.encode("password"))
.roles("USER", "ADMIN")
.build();
return new InMemoryUserDetailsManager(user, admin);
}
@Bean
@Nonnull
public SecurityFilterChain filterChain(@Nonnull HttpSecurity http) throws Exception {
return http.authorizeHttpRequests(request -> request.anyRequest()
.authenticated())
.httpBasic(Customizer.withDefaults())
.build();
}
@Bean
@Nonnull
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactories.createDelegatingPasswordEncoder();
}
}

View File

@ -1,76 +0,0 @@
package com.stktrk.app.application.profile;
import com.stktrk.app.domain.profile.ProfileService;
import com.stktrk.app.domain.profile.types.Profile;
import jakarta.annotation.Nonnull;
import jakarta.validation.Valid;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;
import javax.annotation.security.RolesAllowed;
import java.security.InvalidKeyException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("profile")
@AllArgsConstructor(access = AccessLevel.PROTECTED)
public class ProfileController {
@Autowired
@Nonnull
private final ProfileService profileService;
// TODO figure out how to handle the exception.
@Nonnull
@GetMapping("/")
public List<?> findAll(@Nonnull Authentication authentication) {
return profileService.findAll();
}
@PostMapping ("/")
public void addProfile (@Nonnull @Valid @RequestBody Profile profile){
profileService.addProfile(profile);
}
@GetMapping("/_delete")
@Nonnull
public ResponseEntity<String> delete() {
profileService.deleteAll ();
return ResponseEntity.status(HttpStatus.OK)
.body("Deleted all Profiles");
}
@GetMapping ("/_fake")
@Nonnull
public ResponseEntity<String> _fake() {
profileService.createFakeProfile();
return ResponseEntity.status(HttpStatus.OK)
.body("Created Profile");
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
@Nonnull
public Map<String, String> handleValidationExceptions(
@Nonnull MethodArgumentNotValidException ex) {
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach((error) -> {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
errors.put(fieldName, errorMessage);
});
return errors;
}
}

View File

@ -1,17 +0,0 @@
package com.stktrk.app.domain.profile;
import com.stktrk.app.domain.profile.types.Profile;
import jakarta.annotation.Nonnull;
import java.util.List;
public interface ProfileRepository {
@Nonnull
List<?> findAll();
void addProfile(@Nonnull Profile profile);
void createFakeProfile();
void deleteAll();
}

View File

@ -1,31 +0,0 @@
package com.stktrk.app.domain.profile;
import com.stktrk.app.domain.profile.types.Profile;
import jakarta.annotation.Nonnull;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@AllArgsConstructor
public class ProfileService {
@Nonnull private final ProfileRepository profileRepository;
@Nonnull
public List<?> findAll() {
return profileRepository.findAll ();
}
public void addProfile (@Nonnull Profile profile) {
profileRepository.addProfile (profile);
}
public void createFakeProfile() {
profileRepository.createFakeProfile();
}
public void deleteAll() {
profileRepository.deleteAll();
}
}

View File

@ -1,20 +0,0 @@
package com.stktrk.app.domain.profile.types;
import jakarta.annotation.Nullable;
import jakarta.validation.constraints.NotEmpty;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class Profile {
@Nullable
private String id;
@NotEmpty(message = "Name is mandatory")
private String name;
@NotEmpty(message = "Last name is mandatory")
private String lastName;
}

View File

@ -1,26 +0,0 @@
package com.stktrk.app.integration.configuration.types;
import jakarta.annotation.Nonnull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Getter
@Setter
@ConfigurationProperties(prefix = "graph")
public class GraphDbConfig {
@Nonnull
String host;
int httpPort;
int postgresPort;
@Nonnull
String graphName;
@Nonnull
String user;
@Nonnull
String password;
}

View File

@ -1,35 +0,0 @@
package com.stktrk.app.integration.flyway;
import com.arcadedb.gremlin.ArcadeGraph;
import com.arcadedb.gremlin.ArcadeGraphFactory;
import com.stktrk.app.integration.configuration.types.GraphDbConfig;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
@Component
public class ConnectionPool {
@Nullable
static ArcadeGraphFactory pool;
@Autowired
@Nullable
GraphDbConfig graphDbConfig;
@PostConstruct
void init() {
pool = ArcadeGraphFactory.withRemote(graphDbConfig.getHost(),
graphDbConfig.getHttpPort(),
graphDbConfig.getGraphName(),
graphDbConfig.getUser(),
graphDbConfig.getPassword());
}
@Nonnull
public static ArcadeGraph getGraph() {
return pool.get();
}
}

View File

@ -1,53 +0,0 @@
package com.stktrk.app.integration.flyway;
import jakarta.annotation.Nullable;
import jakarta.annotation.PostConstruct;
import org.flywaydb.core.Flyway;
import org.flywaydb.core.api.migration.JavaMigration;
import org.flywaydb.core.api.output.MigrateResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.sql.SQLException;
@Configuration
public class FlywayConfig {
// TODO move to properties
// Custom migration history table name
@Nullable
private static final String SCHEMA_HISTORY_TABLE = "flyway_schema_history";
@Autowired
@Nullable
private DataSource dataSource;
@Autowired
@Nullable
private ApplicationContext applicationContext;
@PostConstruct
public void migrate() throws SQLException {
// Retrieving all migration implementation classes through the Spring container
// All implementation classes no longer need to be defined in the `db.migration` package,
// they can be placed in any location that supports Bean scanning
JavaMigration[] migrationBeans = applicationContext
.getBeansOfType(JavaMigration.class)
.values()
.toArray(new JavaMigration[0]);
Flyway flyway = Flyway.configure()
.dataSource(dataSource) // No need to configure flyway JDBC URL by using the original DataSource
.defaultSchema(dataSource.getConnection().getSchema())
.locations("integration/flyway/migration") // Default migration script path
.table(SCHEMA_HISTORY_TABLE) // Default migration history table is `flyway_schema_history`
.baselineOnMigrate(true) // Default false, must be set to true for initial migration on existing databases
.baselineVersion("0") // Default "1"
.executeInTransaction(true) // Performing migration as a transaction
.installedBy(applicationContext.getId()) // Using microservice name as migration executor
.javaMigrations(migrationBeans) // Registering migration classes
.load();
MigrateResult migrate = flyway.migrate(); // Executing migration by calling subclass implementations sequentially
}
}

View File

@ -1,33 +0,0 @@
package com.stktrk.app.integration.flyway;
import com.stktrk.app.integration.configuration.types.GraphDbConfig;
import jakarta.annotation.Nonnull;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public interface MigrationWrapper {
default void executeQuery(@Nonnull GraphDbConfig graphDbConfig, @Nonnull String query) throws ClassNotFoundException, SQLException {
Class.forName("org.postgresql.Driver");
Properties props = new Properties();
props.setProperty("user", graphDbConfig.getUser());
props.setProperty("password", graphDbConfig.getPassword());
props.setProperty("ssl", "false");
props.setProperty("sslmode", "disable");
System.out.println ( graphDbConfig.getHost());
try (Connection connection = DriverManager.getConnection("jdbc:postgresql://" + graphDbConfig.getHost() + ":" + graphDbConfig.getPostgresPort() + "/" + graphDbConfig.getGraphName(), props)) {
Statement st = connection.createStatement();
st.execute(query);
}
}
}

View File

@ -1,25 +0,0 @@
package com.stktrk.app.integration.flyway.migrations;
import com.stktrk.app.integration.configuration.types.GraphDbConfig;
import com.stktrk.app.integration.flyway.MigrationWrapper;
import jakarta.annotation.Nonnull;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@EqualsAndHashCode(callSuper = true)
@Component
@Value
public class V1__CreateTest extends BaseJavaMigration implements MigrationWrapper {
@Autowired
@Nonnull
GraphDbConfig graphDbConfig;
public void migrate(@Nonnull Context context) throws Exception {
this.executeQuery(graphDbConfig,"CREATE VERTEX TYPE test");
}
}

View File

@ -1,25 +0,0 @@
package com.stktrk.app.integration.flyway.migrations;
import com.stktrk.app.integration.configuration.types.GraphDbConfig;
import com.stktrk.app.integration.flyway.MigrationWrapper;
import jakarta.annotation.Nonnull;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@EqualsAndHashCode(callSuper = true)
@Component
@Value
public class V2__CreateUser extends BaseJavaMigration implements MigrationWrapper {
@Autowired
@Nonnull
GraphDbConfig graphDbConfig;
public void migrate(@Nonnull Context context) throws Exception {
this.executeQuery(graphDbConfig,"CREATE VERTEX TYPE user");
}
}

View File

@ -1,24 +0,0 @@
package com.stktrk.app.integration.flyway.migrations;
import com.stktrk.app.integration.configuration.types.GraphDbConfig;
import com.stktrk.app.integration.flyway.MigrationWrapper;
import jakarta.annotation.Nonnull;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@EqualsAndHashCode(callSuper = true)
@Component
@Value
public class V3__CreateProfile extends BaseJavaMigration implements MigrationWrapper {
@Nonnull
@Autowired
GraphDbConfig graphDbConfig;
public void migrate(@Nonnull Context context) throws Exception {
this.executeQuery(graphDbConfig,"CREATE VERTEX TYPE Profile IF NOT EXISTS; CREATE PROPERTY Profile.name STRING (MANDATORY true); CREATE PROPERTY Profile.lastName STRING (MANDATORY true, notnull true);");
}
}

View File

@ -1,70 +0,0 @@
package com.stktrk.app.integration.profile;
import com.arcadedb.gremlin.ArcadeGraph;
import com.github.javafaker.Faker;
import com.stktrk.app.integration.flyway.ConnectionPool;
import com.stktrk.app.domain.profile.ProfileRepository;
import com.stktrk.app.domain.profile.types.Profile;
import com.stktrk.app.utils.EncryptId;
import jakarta.annotation.Nonnull;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Random;
@Repository
public class ProfileRepositoryImpl implements ProfileRepository {
@Nonnull
@Override
public List<?> findAll() {
ArcadeGraph g = ConnectionPool.getGraph();
List<? extends Vertex> profiles = g.traversal().V().hasLabel("Profile").toList();
g.close();
return profiles.stream()
.map(this::buildProfile)
.toList();
}
@Override
public void addProfile(@Nonnull Profile profile) {
ArcadeGraph g = ConnectionPool.getGraph();
Vertex profiles = g.traversal()
.addV("Profile")
.property("name", profile.getName())
.property("lastName", profile.getLastName())
.next();
g.close();
}
@Override
public void createFakeProfile() {
Faker faker = new Faker();
ArcadeGraph g = ConnectionPool.getGraph();
List<Vertex> vertices = g.traversal().V().hasLabel("Profile").toList();
Vertex target = vertices.isEmpty() ? null : vertices.get(new Random().nextInt(vertices.size()));
Vertex res = g.traversal().addV("Profile").property("name", faker.name().firstName()).property("lastName", faker.name().lastName())
.next();
if (target != null) {
g.traversal().V(res.id()).addE("friend").to(target).iterate();
}
g.close();
}
@Override
public void deleteAll () {
ArcadeGraph g = ConnectionPool.getGraph();
g.traversal().V().hasLabel("Profile").drop().iterate();
}
@Nonnull
private Profile buildProfile (@Nonnull Vertex v) {
return Profile.builder()
.name((String) v.property("name").value())
.lastName((String) v.property("lastName").value())
.id(EncryptId.encrypt ((String)v.id()))
.build();
}
}

View File

@ -1,44 +0,0 @@
package com.stktrk.app.utils;
import com.arcadedb.database.RID;
import jakarta.annotation.Nonnull;
import jakarta.validation.constraints.NotEmpty;
import org.hashids.Hashids;
import java.security.InvalidKeyException;
public class EncryptId {
// TODO move salt into properties
@Nonnull
private static final String SALT = "yG8kWVG0kei4wqwXGgt99AXxJWD7K2fnK4xv3BDR0M0AHchvFFCjFJK4VH1nLvm1";
@Nonnull
public static String encrypt(@Nonnull RID rid) {
return new Hashids(SALT).encode(rid.getBucketId(), rid.getPosition());
}
// TODO illegal argument exception thrown from RID - if we only allow this to come from the DB, we should be good.
@Nonnull
public static String encrypt(@NotEmpty String rid) {
RID obj = new RID(rid);
return new Hashids(SALT).encode(obj.getBucketId(), obj.getPosition());
}
@Nonnull
public static RID decrypt(@NotEmpty String hash) throws InvalidKeyException {
long[] res = new Hashids(SALT).decode(hash);
if (res == null || res.length != 2 ) {
throw new InvalidKeyException("invalid id");
}
return new RID((int) res[0], res[1]);
}
@Nonnull
private Boolean isValidRid (String rid) {
return rid.matches("#\\d+\\.\\d+");
}
}

View File

@ -1,25 +0,0 @@
spring.application.name=app
server.port=9090
springdoc.swagger-ui.path=/swagger-ui.html
#spring.flyway.user=flyway_user
#spring.flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
#spring.flyway.schemas=flyway_db
#spring.flyway.url=jdbc:postgresql://192.168.178.50:7654/flyway_db
#spring.flyway.locations=classpath:com/stktrk/app/db/migrations
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url= jdbc:postgresql://192.168.178.50:7654/flyway_db
spring.datasource.username=flyway_user
spring.datasource.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
spring.datasource.defaultSchema=flyway_db
spring.datasource.hikari.schema=flyway_db
graph.user=root
graph.password=playwithdata
graph.connection=jdbc:postgresql://192.168.178.50:5432/graph
graph.http-port:2480
graph.postgres-port:5432
graph.host=192.168.178.50
graph.graph-name=graph

View File

@ -1,47 +0,0 @@
spring.application.name=app
server.port=9090
springdoc.swagger-ui.path=/swagger-ui.html
#spring.flyway.user=flyway_user
#spring.flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
#spring.flyway.schemas=flyway_db
#spring.flyway.url=jdbc:postgresql://192.168.178.50:7654/flyway_db
#spring.flyway.locations=classpath:com/stktrk/app/db/migrations
#spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.url= jdbc:postgresql://192.168.178.50:7654/flyway_db
#spring.datasource.username=flyway_user2
#spring.datasource.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
#spring.datasource.defaultSchema=flyway_db
#spring.datasource.hikari.schema=flyway_db
#graph.user=root
##graph.password=playwithdata
#graph.connection=jdbc:postgresql://192.168.178.50:5432/graph
#graph.http-port:2480
#graph.postgres-port:5432
#graph.host=192.168.178.50
#graph.graph-name=graph
#spring.flyway.user=flyway_user
#spring.flyway.password=7e7v55UcYGrY0e3UPYI0qtyMA4YJ1ZkTEaoyZ252GluFkiEMHVT9U5ULS7Rg2rGi
#spring.flyway.schemas=flyway_db
#spring.flyway.url=jdbc:postgresql://192.168.178.50:7654/flyway_db
#spring.flyway.locations=classpath:com/stktrk/app/db/migrations
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url= jdbc:postgresql://localhost:7654/flyway_db
spring.datasource.username=flyway_user
spring.datasource.password=stdUNmu7KTUQV6KGMKjzHIiwQ2gbipArvg02
spring.datasource.defaultSchema=flyway_db
spring.datasource.hikari.schema=flyway_db
graph.user=root
graph.password=playwithdata
graph.connection=jdbc:postgresql://localhost:5432/graph
graph.http-port:2480
graph.postgres-port:5432
graph.host=localhost
graph.graph-name=graph

View File

@ -1,15 +0,0 @@
package com.stktrk.app;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
@Import(TestcontainersConfiguration.class)
@SpringBootTest
class AppApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -1,12 +0,0 @@
package com.stktrk.app;
import jakarta.annotation.Nonnull;
import org.springframework.boot.SpringApplication;
public class TestAppApplication {
public static void main(@Nonnull String[] args) {
SpringApplication.from(AppApplication::main).with(TestcontainersConfiguration.class).run(args);
}
}

View File

@ -1,20 +0,0 @@
package com.stktrk.app;
import jakarta.annotation.Nonnull;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.testcontainers.containers.RabbitMQContainer;
import org.testcontainers.utility.DockerImageName;
@TestConfiguration(proxyBeanMethods = false)
class TestcontainersConfiguration {
@Bean
@ServiceConnection
@Nonnull
RabbitMQContainer rabbitContainer() {
return new RabbitMQContainer(DockerImageName.parse("rabbitmq:latest"));
}
}

View File

@ -1,22 +0,0 @@
package com.stktrk.app.utils;
import com.arcadedb.database.RID;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.security.InvalidKeyException;
class EncryptIdTest {
@Test
void encrypt() {
Assertions.assertEquals("nOua", EncryptId.encrypt(new RID(1,2L)));
}
@Test
void decrypt() throws InvalidKeyException {
Assertions.assertEquals(new RID(1,2L), EncryptId.decrypt("nOua"));
}
}