From ceba82155a0a498ce7d9e66ea77916913d66141d Mon Sep 17 00:00:00 2001
From: nemethattilasd <57946802+nemethattilasd@users.noreply.github.com>
Date: Wed, 1 Apr 2020 15:14:23 +0200
Subject: [PATCH 1/4] Add files via upload
Implemented basic tables and functions from sample.
---
backend/issue-tracker.iml | 122 ++++++++
backend/mvnw | 286 ++++++++++++++++++
backend/mvnw.cmd | 161 ++++++++++
backend/pom.xml | 67 ++++
.../main/java/hu/elte/profrate/ProfRate.java | 13 +
.../controllers/CourseController.java | 80 +++++
.../controllers/DepartmentController.java | 81 +++++
.../controllers/ProfessorController.java | 91 ++++++
.../profrate/controllers/UserController.java | 55 ++++
.../hu/elte/profrate/entities/Course.java | 49 +++
.../hu/elte/profrate/entities/Department.java | 36 +++
.../hu/elte/profrate/entities/Professor.java | 72 +++++
.../java/hu/elte/profrate/entities/User.java | 40 +++
.../repositories/CourseRepository.java | 19 ++
.../repositories/DepartmentRepository.java | 10 +
.../repositories/ProfessorRepository.java | 10 +
.../profrate/repositories/UserRepository.java | 20 ++
.../profrate/security/AuthenticatedUser.java | 26 ++
.../CustomBasicAuthenticationEntryPoint.java | 39 +++
.../security/MyUserDetailsService.java | 50 +++
.../profrate/security/WebSecurityConfig.java | 72 +++++
.../src/main/resources/application.properties | 23 ++
backend/src/main/resources/import.sql | 16 +
backend/target/classes/application.properties | 23 ++
.../classes/hu/elte/profrate/ProfRate.class | Bin 0 -> 712 bytes
.../controllers/CourseController.class | Bin 0 -> 4330 bytes
.../controllers/DepartmentController.class | Bin 0 -> 4850 bytes
.../controllers/ProfessorController.class | Bin 0 -> 4043 bytes
.../profrate/controllers/UserController.class | Bin 0 -> 3071 bytes
.../hu/elte/profrate/entities/Course.class | Bin 0 -> 4193 bytes
.../elte/profrate/entities/Department.class | Bin 0 -> 4787 bytes
.../hu/elte/profrate/entities/Professor.class | Bin 0 -> 5565 bytes
.../profrate/entities/User$AccountType.class | Bin 0 -> 1217 bytes
.../hu/elte/profrate/entities/User.class | Bin 0 -> 3701 bytes
.../repositories/CourseRepository.class | Bin 0 -> 435 bytes
.../repositories/DepartmentRepository.class | Bin 0 -> 447 bytes
.../repositories/ProfessorRepository.class | Bin 0 -> 444 bytes
.../repositories/UserRepository.class | Bin 0 -> 627 bytes
.../profrate/security/AuthenticatedUser.class | Bin 0 -> 1850 bytes
.../CustomBasicAuthenticationEntryPoint.class | Bin 0 -> 1895 bytes
.../security/MyUserDetailsService.class | Bin 0 -> 2584 bytes
.../profrate/security/WebSecurityConfig.class | Bin 0 -> 6019 bytes
backend/target/classes/import.sql | 16 +
43 files changed, 1477 insertions(+)
create mode 100644 backend/issue-tracker.iml
create mode 100644 backend/mvnw
create mode 100644 backend/mvnw.cmd
create mode 100644 backend/pom.xml
create mode 100644 backend/src/main/java/hu/elte/profrate/ProfRate.java
create mode 100644 backend/src/main/java/hu/elte/profrate/controllers/CourseController.java
create mode 100644 backend/src/main/java/hu/elte/profrate/controllers/DepartmentController.java
create mode 100644 backend/src/main/java/hu/elte/profrate/controllers/ProfessorController.java
create mode 100644 backend/src/main/java/hu/elte/profrate/controllers/UserController.java
create mode 100644 backend/src/main/java/hu/elte/profrate/entities/Course.java
create mode 100644 backend/src/main/java/hu/elte/profrate/entities/Department.java
create mode 100644 backend/src/main/java/hu/elte/profrate/entities/Professor.java
create mode 100644 backend/src/main/java/hu/elte/profrate/entities/User.java
create mode 100644 backend/src/main/java/hu/elte/profrate/repositories/CourseRepository.java
create mode 100644 backend/src/main/java/hu/elte/profrate/repositories/DepartmentRepository.java
create mode 100644 backend/src/main/java/hu/elte/profrate/repositories/ProfessorRepository.java
create mode 100644 backend/src/main/java/hu/elte/profrate/repositories/UserRepository.java
create mode 100644 backend/src/main/java/hu/elte/profrate/security/AuthenticatedUser.java
create mode 100644 backend/src/main/java/hu/elte/profrate/security/CustomBasicAuthenticationEntryPoint.java
create mode 100644 backend/src/main/java/hu/elte/profrate/security/MyUserDetailsService.java
create mode 100644 backend/src/main/java/hu/elte/profrate/security/WebSecurityConfig.java
create mode 100644 backend/src/main/resources/application.properties
create mode 100644 backend/src/main/resources/import.sql
create mode 100644 backend/target/classes/application.properties
create mode 100644 backend/target/classes/hu/elte/profrate/ProfRate.class
create mode 100644 backend/target/classes/hu/elte/profrate/controllers/CourseController.class
create mode 100644 backend/target/classes/hu/elte/profrate/controllers/DepartmentController.class
create mode 100644 backend/target/classes/hu/elte/profrate/controllers/ProfessorController.class
create mode 100644 backend/target/classes/hu/elte/profrate/controllers/UserController.class
create mode 100644 backend/target/classes/hu/elte/profrate/entities/Course.class
create mode 100644 backend/target/classes/hu/elte/profrate/entities/Department.class
create mode 100644 backend/target/classes/hu/elte/profrate/entities/Professor.class
create mode 100644 backend/target/classes/hu/elte/profrate/entities/User$AccountType.class
create mode 100644 backend/target/classes/hu/elte/profrate/entities/User.class
create mode 100644 backend/target/classes/hu/elte/profrate/repositories/CourseRepository.class
create mode 100644 backend/target/classes/hu/elte/profrate/repositories/DepartmentRepository.class
create mode 100644 backend/target/classes/hu/elte/profrate/repositories/ProfessorRepository.class
create mode 100644 backend/target/classes/hu/elte/profrate/repositories/UserRepository.class
create mode 100644 backend/target/classes/hu/elte/profrate/security/AuthenticatedUser.class
create mode 100644 backend/target/classes/hu/elte/profrate/security/CustomBasicAuthenticationEntryPoint.class
create mode 100644 backend/target/classes/hu/elte/profrate/security/MyUserDetailsService.class
create mode 100644 backend/target/classes/hu/elte/profrate/security/WebSecurityConfig.class
create mode 100644 backend/target/classes/import.sql
diff --git a/backend/issue-tracker.iml b/backend/issue-tracker.iml
new file mode 100644
index 0000000..b7fecbc
--- /dev/null
+++ b/backend/issue-tracker.iml
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/mvnw b/backend/mvnw
new file mode 100644
index 0000000..cb9a979
--- /dev/null
+++ b/backend/mvnw
@@ -0,0 +1,286 @@
+#!/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.
+# ----------------------------------------------------------------------------
+
+# ----------------------------------------------------------------------------
+# Maven2 Start Up Batch script
+#
+# Required ENV vars:
+# ------------------
+# JAVA_HOME - location of a JDK home dir
+#
+# Optional ENV vars
+# -----------------
+# M2_HOME - location of maven2's installed home dir
+# MAVEN_OPTS - parameters passed to the Java VM when running Maven
+# e.g. to debug Maven itself, use
+# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
+# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
+# ----------------------------------------------------------------------------
+
+if [ -z "$MAVEN_SKIP_RC" ] ; then
+
+ if [ -f /etc/mavenrc ] ; then
+ . /etc/mavenrc
+ fi
+
+ if [ -f "$HOME/.mavenrc" ] ; then
+ . "$HOME/.mavenrc"
+ fi
+
+fi
+
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
+mingw=false
+case "`uname`" in
+ CYGWIN*) cygwin=true ;;
+ MINGW*) mingw=true;;
+ Darwin*) darwin=true
+ # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
+ # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -x "/usr/libexec/java_home" ]; then
+ export JAVA_HOME="`/usr/libexec/java_home`"
+ else
+ export JAVA_HOME="/Library/Java/Home"
+ fi
+ fi
+ ;;
+esac
+
+if [ -z "$JAVA_HOME" ] ; then
+ if [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=`java-config --jre-home`
+ fi
+fi
+
+if [ -z "$M2_HOME" ] ; then
+ ## resolve links - $0 may be a link to maven's home
+ PRG="$0"
+
+ # need this for relative symlinks
+ while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG="`dirname "$PRG"`/$link"
+ fi
+ done
+
+ saveddir=`pwd`
+
+ M2_HOME=`dirname "$PRG"`/..
+
+ # make it fully qualified
+ M2_HOME=`cd "$M2_HOME" && pwd`
+
+ cd "$saveddir"
+ # echo Using m2 at $M2_HOME
+fi
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME=`cygpath --unix "$M2_HOME"`
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+# For Mingw, ensure paths are in UNIX format before anything is touched
+if $mingw ; then
+ [ -n "$M2_HOME" ] &&
+ M2_HOME="`(cd "$M2_HOME"; pwd)`"
+ [ -n "$JAVA_HOME" ] &&
+ JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
+ # TODO classpath?
+fi
+
+if [ -z "$JAVA_HOME" ]; then
+ javaExecutable="`which javac`"
+ if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
+ # readlink(1) is not available as standard on Solaris 10.
+ readLink=`which readlink`
+ if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
+ if $darwin ; then
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
+ else
+ javaExecutable="`readlink -f \"$javaExecutable\"`"
+ fi
+ javaHome="`dirname \"$javaExecutable\"`"
+ javaHome=`expr "$javaHome" : '\(.*\)/bin'`
+ JAVA_HOME="$javaHome"
+ export JAVA_HOME
+ fi
+ fi
+fi
+
+if [ -z "$JAVACMD" ] ; then
+ if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
+ JAVACMD="`which java`"
+ fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly." >&2
+ echo " We cannot execute $JAVACMD" >&2
+ exit 1
+fi
+
+if [ -z "$JAVA_HOME" ] ; then
+ echo "Warning: JAVA_HOME environment variable is not set."
+fi
+
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
+
+# traverses directory structure from process work directory to filesystem root
+# first directory with .mvn subdirectory is considered project base directory
+find_maven_basedir() {
+
+ if [ -z "$1" ]
+ then
+ echo "Path not specified to find_maven_basedir"
+ return 1
+ fi
+
+ basedir="$1"
+ wdir="$1"
+ while [ "$wdir" != '/' ] ; do
+ if [ -d "$wdir"/.mvn ] ; then
+ basedir=$wdir
+ break
+ fi
+ # workaround for JBEAP-8937 (on Solaris 10/Sparc)
+ if [ -d "${wdir}" ]; then
+ wdir=`cd "$wdir/.."; pwd`
+ fi
+ # end of workaround
+ done
+ echo "${basedir}"
+}
+
+# concatenates all lines of a file
+concat_lines() {
+ if [ -f "$1" ]; then
+ echo "$(tr -s '\n' ' ' < "$1")"
+ fi
+}
+
+BASE_DIR=`find_maven_basedir "$(pwd)"`
+if [ -z "$BASE_DIR" ]; then
+ exit 1;
+fi
+
+##########################################################################################
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
+##########################################################################################
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found .mvn/wrapper/maven-wrapper.jar"
+ fi
+else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
+ fi
+ jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+ 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 command -v wget > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found wget ... using wget"
+ fi
+ wget "$jarUrl" -O "$wrapperJarPath"
+ elif command -v curl > /dev/null; then
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Found curl ... using curl"
+ fi
+ curl -o "$wrapperJarPath" "$jarUrl"
+ else
+ if [ "$MVNW_VERBOSE" = true ]; then
+ echo "Falling back to using Java to download"
+ fi
+ javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
+ 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
+
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+exec "$JAVACMD" \
+ $MAVEN_OPTS \
+ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
+ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
+ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
diff --git a/backend/mvnw.cmd b/backend/mvnw.cmd
new file mode 100644
index 0000000..a5284c7
--- /dev/null
+++ b/backend/mvnw.cmd
@@ -0,0 +1,161 @@
+@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 Maven2 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 key stroke 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 my setting MAVEN_BATCH_ECHO to 'on'
+@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
+
+@REM set %HOME% to equivalent of $HOME
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
+
+@REM Execute a user defined script before this one
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
+:skipRcPre
+
+@setlocal
+
+set ERROR_CODE=0
+
+@REM To isolate internal variables from possible post scripts, we use another setlocal
+@setlocal
+
+@REM ==== START VALIDATION ====
+if not "%JAVA_HOME%" == "" goto OkJHome
+
+echo.
+echo Error: JAVA_HOME not found in your environment. >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+:OkJHome
+if exist "%JAVA_HOME%\bin\java.exe" goto init
+
+echo.
+echo Error: JAVA_HOME is set to an invalid directory. >&2
+echo JAVA_HOME = "%JAVA_HOME%" >&2
+echo Please set the JAVA_HOME variable in your environment to match the >&2
+echo location of your Java installation. >&2
+echo.
+goto error
+
+@REM ==== END VALIDATION ====
+
+:init
+
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
+@REM Fallback to current working directory if not found.
+
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
+
+set EXEC_DIR=%CD%
+set WDIR=%EXEC_DIR%
+:findBaseDir
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
+cd ..
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
+set WDIR=%CD%
+goto findBaseDir
+
+:baseDirFound
+set MAVEN_PROJECTBASEDIR=%WDIR%
+cd "%EXEC_DIR%"
+goto endDetectBaseDir
+
+:baseDirNotFound
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
+cd "%EXEC_DIR%"
+
+:endDetectBaseDir
+
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
+
+@setlocal EnableExtensions EnableDelayedExpansion
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
+
+:endReadAdditionalConfig
+
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
+
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
+FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
+ IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
+)
+
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
+if exist %WRAPPER_JAR% (
+ echo Found %WRAPPER_JAR%
+) else (
+ echo Couldn't find %WRAPPER_JAR%, downloading it ...
+ echo Downloading from: %DOWNLOAD_URL%
+ powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
+ echo Finished downloading %WRAPPER_JAR%
+)
+@REM End of extension
+
+%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
+if ERRORLEVEL 1 goto error
+goto end
+
+:error
+set ERROR_CODE=1
+
+:end
+@endlocal & set ERROR_CODE=%ERROR_CODE%
+
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
+:skipRcPost
+
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
+
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
+
+exit /B %ERROR_CODE%
diff --git a/backend/pom.xml b/backend/pom.xml
new file mode 100644
index 0000000..73b930d
--- /dev/null
+++ b/backend/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.8.RELEASE
+
+
+ hu.elte
+ course-tracker
+ 0.0.1-SNAPSHOT
+ ProfRate
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ com.h2database
+ h2
+ runtime
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/backend/src/main/java/hu/elte/profrate/ProfRate.java b/backend/src/main/java/hu/elte/profrate/ProfRate.java
new file mode 100644
index 0000000..fb0f91f
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/ProfRate.java
@@ -0,0 +1,13 @@
+package hu.elte.profrate;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ProfRate {
+
+ public static void main(String[] args) {
+ SpringApplication.run(ProfRate.class, args);
+ }
+
+}
diff --git a/backend/src/main/java/hu/elte/profrate/controllers/CourseController.java b/backend/src/main/java/hu/elte/profrate/controllers/CourseController.java
new file mode 100644
index 0000000..7518392
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/controllers/CourseController.java
@@ -0,0 +1,80 @@
+
+package hu.elte.profrate.controllers;
+
+
+import hu.elte.profrate.entities.Course;
+import hu.elte.profrate.entities.Professor;
+import hu.elte.profrate.repositories.CourseRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Optional;
+
+@CrossOrigin
+@RestController
+@RequestMapping("/courses")
+public class CourseController {
+
+ @Autowired
+ private CourseRepository courseRepository;
+
+ @GetMapping("")
+ public ResponseEntity> getAll() {
+ return ResponseEntity.ok(courseRepository.findAll());
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity get(@PathVariable Integer id) {
+ Optional course = courseRepository.findById(id);
+ if (!course.isPresent()) {
+ return ResponseEntity.notFound().build();
+ }
+
+ return ResponseEntity.ok(course.get());
+ }
+
+ @PostMapping("")
+ public ResponseEntity post(@RequestBody Course course) {
+ Course newCourse = courseRepository.save(course);
+ return ResponseEntity.ok(newCourse);
+ }
+
+ @DeleteMapping("/{id}")
+ public ResponseEntity delete(@PathVariable Integer id) {
+ Optional course = courseRepository.findById(id);
+ if (!course.isPresent()) {
+ ResponseEntity.notFound();
+ }
+ courseRepository.delete(course.get());
+
+ return ResponseEntity.ok().build();
+ }
+
+ @PutMapping("/{id}")
+ public ResponseEntity put(@PathVariable Integer id, @RequestBody Course course) {
+ Optional foundCourse = courseRepository.findById(id);
+ if (!foundCourse.isPresent()) {
+ ResponseEntity.notFound();
+ }
+
+ Course courseToUpdate = foundCourse.get();
+ if (course.getName() != null) {
+ courseToUpdate.setName(course.getName());
+ }
+ // if (course.getRatings() != null) {
+ // courseToUpdate.setRatings(course.getRatings());
+ // }
+ if (course.getAverageRating() != null) {
+ courseToUpdate.setAverageRating(course.getAverageRating());
+ }
+ if (course.getProfessors() != null) {
+ courseToUpdate.setProfessors(course.getProfessors());
+ }
+
+ return ResponseEntity.ok(courseRepository.save(courseToUpdate));
+ }
+
+}
+
+
diff --git a/backend/src/main/java/hu/elte/profrate/controllers/DepartmentController.java b/backend/src/main/java/hu/elte/profrate/controllers/DepartmentController.java
new file mode 100644
index 0000000..8f03f3f
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/controllers/DepartmentController.java
@@ -0,0 +1,81 @@
+package hu.elte.profrate.controllers;
+
+import hu.elte.profrate.entities.Department;
+import hu.elte.profrate.entities.Professor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Optional;
+import hu.elte.profrate.repositories.DepartmentRepository;
+@CrossOrigin
+@RestController
+@RequestMapping("/departments")
+public class DepartmentController {
+
+ @Autowired
+ private DepartmentRepository departmentRepository;
+
+ @GetMapping("")
+ public ResponseEntity> getAll() {
+ return ResponseEntity.ok(departmentRepository.findAll());
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity get(@PathVariable Integer id) {
+ Optional department = departmentRepository.findById(id);
+ if (!department.isPresent()) {
+ ResponseEntity.notFound();
+ }
+
+ return ResponseEntity.ok(department.get());
+ }
+
+ @PostMapping("")
+ public ResponseEntity post(@RequestBody Department department) {
+ Department newDepartment = departmentRepository.save(department);
+ return ResponseEntity.ok(newDepartment);
+ }
+
+ @DeleteMapping("/{id}")
+ public ResponseEntity delete(@PathVariable Integer id) {
+ Optional department = departmentRepository.findById(id);
+ if (!department.isPresent()) {
+ ResponseEntity.notFound();
+ }
+ departmentRepository.delete(department.get());
+
+ return ResponseEntity.ok().build();
+ }
+
+ @PutMapping("/{id}")
+ public ResponseEntity put(@PathVariable Integer id, @RequestBody Department department) {
+ Optional foundDepartment = departmentRepository.findById(id);
+ if (!foundDepartment.isPresent()) {
+ ResponseEntity.notFound();
+ }
+
+ Department departmentToUpdate = foundDepartment.get();
+ if(department.getName() != null) {
+ departmentToUpdate.setName(department.getName());
+ }
+ if(department.getAverageRating() != null) {
+ departmentToUpdate.setAverageRating(department.getAverageRating());
+ }
+ if(department.getDoesContainKrisa() != null) {
+ departmentToUpdate.setDoesContainKrisa(department.getDoesContainKrisa());
+ }
+
+ return ResponseEntity.ok(departmentRepository.save(departmentToUpdate));
+ }
+
+ @GetMapping("/{id}/professors")
+ public ResponseEntity> getProfessors(@PathVariable Integer id) {
+ Optional oDepartment = departmentRepository.findById(id);
+ if (oDepartment.isPresent()) {
+ return ResponseEntity.ok(oDepartment.get().getProfessors());
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+}
\ No newline at end of file
diff --git a/backend/src/main/java/hu/elte/profrate/controllers/ProfessorController.java b/backend/src/main/java/hu/elte/profrate/controllers/ProfessorController.java
new file mode 100644
index 0000000..452ab29
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/controllers/ProfessorController.java
@@ -0,0 +1,91 @@
+package hu.elte.profrate.controllers;
+
+
+import hu.elte.profrate.entities.Course;
+import hu.elte.profrate.entities.Professor;
+
+import java.util.Optional;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import hu.elte.profrate.repositories.ProfessorRepository;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@CrossOrigin
+@RestController
+@RequestMapping("/professors")
+public class ProfessorController {
+
+ @Autowired
+ private ProfessorRepository professorRepository;
+/*
+ @Autowired
+ private AuthenticatedUser authenticatedUser;*/
+
+ @GetMapping("")
+ public ResponseEntity> getAll() {
+ return ResponseEntity.ok(professorRepository.findAll());
+ }
+
+ @GetMapping("/{id}")
+ public ResponseEntity get(@PathVariable Integer id) {
+ Optional room = professorRepository.findById(id);
+ if (room.isPresent()) {
+ return ResponseEntity.ok(room.get());
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+ @PostMapping("")
+ public ResponseEntity post(@RequestBody Professor room) {
+ Professor savedCourse = professorRepository.save(room);
+ return ResponseEntity.ok(savedCourse);
+ }
+
+ @PutMapping("/{id}")
+ public ResponseEntity put(@RequestBody Professor room, @PathVariable Integer id) {
+ Optional oCourse = professorRepository.findById(id);
+ if (oCourse.isPresent()) {
+ room.setId(id);
+ return ResponseEntity.ok(professorRepository.save(room));
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+ @DeleteMapping("/{id}")
+ public ResponseEntity delete(@PathVariable Integer id) {
+ Optional oCourse = professorRepository.findById(id);
+ if (oCourse.isPresent()) {
+ professorRepository.deleteById(id);
+ return ResponseEntity.ok().build();
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
+
+ /*@GetMapping("/{id}/courses")
+ public ResponseEntity> getCourses(@PathVariable Integer id) {
+ Optional oCurse = professorRepository.findById(id);
+ if (oCurse.isPresent()) {
+ return ResponseEntity.ok(oCurse.get().getCourses());
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }*/
+
+}
+
diff --git a/backend/src/main/java/hu/elte/profrate/controllers/UserController.java b/backend/src/main/java/hu/elte/profrate/controllers/UserController.java
new file mode 100644
index 0000000..a4f6c9e
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/controllers/UserController.java
@@ -0,0 +1,55 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.controllers;
+
+import hu.elte.profrate.entities.Course;
+import hu.elte.profrate.entities.User;
+import hu.elte.profrate.repositories.UserRepository;
+import hu.elte.profrate.security.AuthenticatedUser;
+
+import java.util.Objects;
+import java.util.Optional;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@CrossOrigin
+@RestController
+@RequestMapping("/users")
+public class UserController {
+ @Autowired
+ private BCryptPasswordEncoder passwordEncoder;
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Autowired
+ private AuthenticatedUser authenticatedUser;
+
+ @PostMapping("/register")
+ public ResponseEntity register(@RequestBody User user) {
+ Optional oUser = userRepository.findByNeptunCode(user.getNeptunCode());
+ if (oUser.isPresent()) {
+ return ResponseEntity.badRequest().build();
+ }
+ user.setPassword(passwordEncoder.encode(user.getPassword()));
+ user.setType(User.AccountType.REGISTERED);
+ return ResponseEntity.ok(userRepository.save(user));
+ }
+
+ @PostMapping("/login")
+ public ResponseEntity login() {
+ return ResponseEntity.ok(authenticatedUser.getUser());
+ }
+
+ //todo: rate courses(??)
+}
diff --git a/backend/src/main/java/hu/elte/profrate/entities/Course.java b/backend/src/main/java/hu/elte/profrate/entities/Course.java
new file mode 100644
index 0000000..d6bfcb7
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/entities/Course.java
@@ -0,0 +1,49 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.entities;
+
+import java.util.List;
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Entity
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode
+public class Course {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column
+ @NotNull
+ private String name;
+
+ //@Column
+ //@NotNull
+ //private List ratings;
+
+ @Column
+ @NotNull
+ private Float averageRating;
+
+ @ManyToMany(mappedBy = "courses", cascade = CascadeType.ALL)
+ @JsonIgnore
+ private List professors;
+
+}
diff --git a/backend/src/main/java/hu/elte/profrate/entities/Department.java b/backend/src/main/java/hu/elte/profrate/entities/Department.java
new file mode 100644
index 0000000..7f1e987
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/entities/Department.java
@@ -0,0 +1,36 @@
+package hu.elte.profrate.entities;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Entity
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode
+public class Department {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column
+ @NotNull
+ private String name;
+
+ @Column
+ @NotNull
+ private Float averageRating;
+
+ @Column
+ @NotNull
+ private Boolean doesContainKrisa;
+
+ @OneToMany(mappedBy = "department", orphanRemoval = true)
+ private List professors;
+}
diff --git a/backend/src/main/java/hu/elte/profrate/entities/Professor.java b/backend/src/main/java/hu/elte/profrate/entities/Professor.java
new file mode 100644
index 0000000..5fab509
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/entities/Professor.java
@@ -0,0 +1,72 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.entities;
+
+import com.fasterxml.jackson.annotation.JsonBackReference;
+import javax.persistence.*;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+import javax.validation.constraints.NotNull;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Entity
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Professor {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column
+ @NotNull
+ private String name;
+
+ /*@Column
+ @NotNull
+ private List ratings;*/
+
+ @Column
+ @NotNull
+ private Float averageRating;
+
+ @Column
+ @NotNull
+ private Integer recommendationCount;
+
+ @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ private List courses;
+
+ @JsonBackReference
+ @ManyToOne(cascade = CascadeType.ALL)
+ private Department department;
+
+ /*public Course getCourseById(Integer courseId) {
+ for(Course course : courses) {
+ if(course.getId().equals(courseId)) {
+ return course;
+ }
+ }
+ return null;
+ }*/
+
+ /*public Exam getRoomById(Integer examId) {
+ for(Exam exam : exams) {
+ if(exam.getId().equals(examId)) {
+ return exam;
+ }
+ }
+ return null;
+ }*/
+}
diff --git a/backend/src/main/java/hu/elte/profrate/entities/User.java b/backend/src/main/java/hu/elte/profrate/entities/User.java
new file mode 100644
index 0000000..de8a994
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/entities/User.java
@@ -0,0 +1,40 @@
+package hu.elte.profrate.entities;
+
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ *
+ * @author KeresztespókKrisztián
+ */
+@Entity
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class User {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ private String neptunCode;
+
+ private String password;
+
+ @Column(nullable = false)
+ @Enumerated(EnumType.STRING)
+ private AccountType type;
+
+ public enum AccountType {
+ GUEST, REGISTERED
+ }
+}
\ No newline at end of file
diff --git a/backend/src/main/java/hu/elte/profrate/repositories/CourseRepository.java b/backend/src/main/java/hu/elte/profrate/repositories/CourseRepository.java
new file mode 100644
index 0000000..3aa548a
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/repositories/CourseRepository.java
@@ -0,0 +1,19 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.repositories;
+
+import hu.elte.profrate.entities.Course;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Repository
+public interface CourseRepository extends CrudRepository {
+
+}
diff --git a/backend/src/main/java/hu/elte/profrate/repositories/DepartmentRepository.java b/backend/src/main/java/hu/elte/profrate/repositories/DepartmentRepository.java
new file mode 100644
index 0000000..a382eed
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/repositories/DepartmentRepository.java
@@ -0,0 +1,10 @@
+package hu.elte.profrate.repositories;
+
+import hu.elte.profrate.entities.Department;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface DepartmentRepository extends CrudRepository {
+
+}
diff --git a/backend/src/main/java/hu/elte/profrate/repositories/ProfessorRepository.java b/backend/src/main/java/hu/elte/profrate/repositories/ProfessorRepository.java
new file mode 100644
index 0000000..a274fb4
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/repositories/ProfessorRepository.java
@@ -0,0 +1,10 @@
+package hu.elte.profrate.repositories;
+
+import hu.elte.profrate.entities.Professor;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface ProfessorRepository extends CrudRepository {
+
+}
diff --git a/backend/src/main/java/hu/elte/profrate/repositories/UserRepository.java b/backend/src/main/java/hu/elte/profrate/repositories/UserRepository.java
new file mode 100644
index 0000000..55418c6
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/repositories/UserRepository.java
@@ -0,0 +1,20 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.repositories;
+
+import hu.elte.profrate.entities.User;
+import java.util.Optional;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Repository
+public interface UserRepository extends CrudRepository {
+ Optional findByNeptunCode(String neptunCode);
+}
diff --git a/backend/src/main/java/hu/elte/profrate/security/AuthenticatedUser.java b/backend/src/main/java/hu/elte/profrate/security/AuthenticatedUser.java
new file mode 100644
index 0000000..6f8d6cf
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/security/AuthenticatedUser.java
@@ -0,0 +1,26 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.security;
+
+import hu.elte.profrate.entities.User;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.annotation.RequestScope;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@RequestScope
+@Component
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class AuthenticatedUser {
+ private User user;
+}
diff --git a/backend/src/main/java/hu/elte/profrate/security/CustomBasicAuthenticationEntryPoint.java b/backend/src/main/java/hu/elte/profrate/security/CustomBasicAuthenticationEntryPoint.java
new file mode 100644
index 0000000..e3fffb9
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/security/CustomBasicAuthenticationEntryPoint.java
@@ -0,0 +1,39 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.security;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+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.authentication.www.BasicAuthenticationEntryPoint;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+public class CustomBasicAuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
+
+ @Override
+ public void commence(final HttpServletRequest request,
+ final HttpServletResponse response,
+ final AuthenticationException authException) throws IOException, ServletException {
+ //Authentication failed, send error response.
+ response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
+ response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName() + "");
+
+ PrintWriter writer = response.getWriter();
+ writer.println("HTTP Status 401 : " + authException.getMessage());
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ setRealmName("MY REALM");
+ super.afterPropertiesSet();
+ }
+}
diff --git a/backend/src/main/java/hu/elte/profrate/security/MyUserDetailsService.java b/backend/src/main/java/hu/elte/profrate/security/MyUserDetailsService.java
new file mode 100644
index 0000000..91baecd
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/security/MyUserDetailsService.java
@@ -0,0 +1,50 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.security;
+
+import hu.elte.profrate.entities.User;
+import hu.elte.profrate.repositories.UserRepository;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Service
+public class MyUserDetailsService implements UserDetailsService {
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Autowired
+ private AuthenticatedUser authenticatedUser;
+
+ @Override
+ @Transactional(readOnly = true)
+ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+ Optional oUser = userRepository.findByNeptunCode(username);
+ if (!oUser.isPresent()) {
+ throw new UsernameNotFoundException(username);
+ }
+ User user = oUser.get();
+ authenticatedUser.setUser(user);
+ Set grantedAuthorities = new HashSet<>();
+ grantedAuthorities.add(new SimpleGrantedAuthority(user.getType().toString()));
+
+ return new org.springframework.security.core.userdetails.User(user.getNeptunCode(), user.getPassword(), grantedAuthorities);
+ }
+}
diff --git a/backend/src/main/java/hu/elte/profrate/security/WebSecurityConfig.java b/backend/src/main/java/hu/elte/profrate/security/WebSecurityConfig.java
new file mode 100644
index 0000000..d3f5739
--- /dev/null
+++ b/backend/src/main/java/hu/elte/profrate/security/WebSecurityConfig.java
@@ -0,0 +1,72 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package hu.elte.profrate.security;
+
+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.authentication.builders.AuthenticationManagerBuilder;
+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.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+/**
+ *
+ * @author KeresztiKrisztián
+ */
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(securedEnabled = true)
+public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
+ @Autowired
+ private UserDetailsService userDetailsService;
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http
+ .cors()
+ .and()
+ .csrf().disable()
+ .authorizeRequests()
+ .antMatchers("/h2/**", "/users/register", "/issues/**", "/issues").permitAll() // important!
+ .anyRequest().authenticated()
+ .and()
+ .httpBasic()
+ .authenticationEntryPoint(getBasicAuthEntryPoint())
+ .and()
+ .headers() // important!
+ .frameOptions().disable()
+ .and()
+ .sessionManagement()
+ .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
+ }
+ @Autowired
+ protected void configureAuthentication(AuthenticationManagerBuilder auth) throws Exception {
+ auth
+ .userDetailsService(userDetailsService)
+ .passwordEncoder(passwordEncoder());
+ }
+ @Autowired
+ protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
+ auth
+ .userDetailsService(userDetailsService)
+ .passwordEncoder(passwordEncoder());
+ }
+
+ @Bean
+ public BCryptPasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ public CustomBasicAuthenticationEntryPoint getBasicAuthEntryPoint(){
+ return new CustomBasicAuthenticationEntryPoint();
+ }
+}
diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties
new file mode 100644
index 0000000..706a287
--- /dev/null
+++ b/backend/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+# we set explicitly the database engine
+spring.datasource.platform=h2
+
+# make the h2 web console enabled
+spring.h2.console.enabled=true
+
+# the path for the h2 web console
+spring.h2.console.path=/h2
+
+# we can change the name of the database, in this case it will be called `mydb`
+spring.datasource.url=jdbc:h2:mem:issuedb
+
+#show sql statement
+logging.level.org.hibernate.SQL=debug
+
+#show sql values
+logging.level.org.hibernate.type.descriptor.sql=trace
+
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=sa
+spring.datasource.password=password
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
diff --git a/backend/src/main/resources/import.sql b/backend/src/main/resources/import.sql
new file mode 100644
index 0000000..8ddf981
--- /dev/null
+++ b/backend/src/main/resources/import.sql
@@ -0,0 +1,16 @@
+insert into user (neptun_code, password, type) values ('student','$2a$10$3FcOqxi/gs6fzGfQDuyAUuC9Fmv.MfRk9QqEO73xBkI6nlq3PsbFa', 'REGISTERED');
+insert into user (neptun_code, password, type) values ('asdf','$2a$10$frxttDeSRymMF./6yOxIA.GspOPGdQkPVQlXJN56HWHnrSPjdb9lK', 'REGISTERED');
+
+insert into department(name,average_rating,does_contain_krisa) values ('numanal',3,true);
+insert into department(name,average_rating,does_contain_krisa) values ('raptor',10,false);
+
+insert into course(name,average_rating) values('linalg',3);
+insert into course(name,average_rating) values('prog',5);
+insert into course(name,average_rating) values('fonya',8);
+insert into course(name,average_rating) values('dimat',5);
+insert into course(name,average_rating) values('anal2',10);
+
+insert into professor(name, average_rating, recommendation_count,department_id) values('Krisa',1,0,1);
+insert into professor(name, average_rating, recommendation_count,department_id) values('Asdf',8,10,1);
+insert into professor(name, average_rating, recommendation_count,department_id) values('Shrek',10,100,1);
+insert into professor(name, average_rating, recommendation_count,department_id) values('AntiKrisa',10,1000,1);
\ No newline at end of file
diff --git a/backend/target/classes/application.properties b/backend/target/classes/application.properties
new file mode 100644
index 0000000..706a287
--- /dev/null
+++ b/backend/target/classes/application.properties
@@ -0,0 +1,23 @@
+# we set explicitly the database engine
+spring.datasource.platform=h2
+
+# make the h2 web console enabled
+spring.h2.console.enabled=true
+
+# the path for the h2 web console
+spring.h2.console.path=/h2
+
+# we can change the name of the database, in this case it will be called `mydb`
+spring.datasource.url=jdbc:h2:mem:issuedb
+
+#show sql statement
+logging.level.org.hibernate.SQL=debug
+
+#show sql values
+logging.level.org.hibernate.type.descriptor.sql=trace
+
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.driverClassName=org.h2.Driver
+spring.datasource.username=sa
+spring.datasource.password=password
+spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
diff --git a/backend/target/classes/hu/elte/profrate/ProfRate.class b/backend/target/classes/hu/elte/profrate/ProfRate.class
new file mode 100644
index 0000000000000000000000000000000000000000..eb40e7a4f2c0b3990cb76947e6d8a3fbc9c53bea
GIT binary patch
literal 712
zcmZ`%O-~y!5Pc2_n}kpxw6r1Rz%9uEUl5m|NHkJU+ZK^39D4FDX5+AHM_w=O-{J(~
zzz^U@RUL1s$RS;6XU6mKJbp9JzaO6f9OIyg3f2NtTc}~3VS6ra1y6-e__t^-W5=+5
zs<;$)CpF
z@W>d)C#Caju}D=coHCl=Z9y{Xg|97)Q<3MxA4{Hz^I*e%xC%Ko+R0yzkBz=oNnu5l
z%B3sF?ZZQc>eyUKhOJO(`L)O*X}|kihIVLTkxqqG{`}&sx|zxuy5WDH?IAOvsQta(
zs&1zg7d9b~-4$VC{fl%nb9F8}NlscyY)(vJWBFP6wl@Fqd*r#H0bCT?sZ35)uKXLd
zHm+om3P&rcDM=TFGsIEJjeHrwCz{3*M?)MUpq21n1cX9<*El
literal 0
HcmV?d00001
diff --git a/backend/target/classes/hu/elte/profrate/controllers/CourseController.class b/backend/target/classes/hu/elte/profrate/controllers/CourseController.class
new file mode 100644
index 0000000000000000000000000000000000000000..ba64775adc9935383f93c703e05163f138734b77
GIT binary patch
literal 4330
zcmcInSyL2O7(I6w7?uVMD3KVWF$BSdmZ*T@5K;o%{9IzyI;`F91&9n?@v1lR{EM
zE$Rez+&0z>-7@T~K9jyJ7kz=cGp23&=LBkcdKVf{kA@T)H8epJIJ%tIrR7UK=Q>NS
z!O5ay`>tbI()IK)C+~W4thhtbzMmKHR
zjz8|?ZQ49dbYi;Qby*r2W_&bnS{xZg4|-ELq~S1*2n_r)H3GG1rBL8-d{+Vl`ZVY`
z#^|z=G48BLbCi-4UJ=;8jXMOz^h>l;TsxuRBnAYMp0Oqcy8k*AW!EN1OG-?o!>1;J_KLiWTaMue
z>Zdi#V3s0OzeQwcIe?)=Xl72sJgx~e)66Vuk@P&r^>_gaHiBz1X?mfF1r0awI*-#t
z`SJEhf9Z7Zf<^E!dEZ$#
zU6~msp~jpHVQ!r?Z8@D^O-uKhsy}pk(pfaD1;aJfI@(P7%O>sV+sozOm0X&sQ^>1w
z*D!BpZNtyIG$G^j>`YlbE7Zs{+r8LwbB53HPvAsVc-CcFPqVm{BXddmQ${YQIL3>=
zW>|T;34wFvDW9-?nPq{AU74sWVX}g>mj@9kAvEFZh*S?BSJqO#ASx5Fkt-x)sLJ_R
zn2>VwzOlH%P@}x=n3DdolbJQtyM?bH<~aSYLXPQ2t$x?c+!HuZN$#Q_6)Yc!oyJ+i
zUoJ40;3xT_X9=F_c`{+1CZ`9Utd4xQ<$BnH2;BKE9f*nW$@riVq!Rh#%gxC{E&c
zd@2#6p8dS);aQZl3EP(Lm}PjuvZb=+6KE>yC)j+}^SeTo?}YkL;P?htbsTR-BfmDd
zy2X{wk(C~`hkk<{#%?Y1w4Sa@eW5a6-Q7L2oFZW&4+$OY7@-@kI?>r
zhsu@gE>qGRDKUaG>AO>`zOb>t!Teh2Ll
zUfRS#fd^b4{T2O@g!3i_6HN2)CiqdRavdVxL05pI#I28r>*!$j*^T36?(0SO^&;wB+fY|K
z6{vS?L0wTj|mx>DDf+(ekY3hMO{0$_;$PZ5aI1mY|Sc#dG4CoC5*fQy`6!ZoyamYS1UEw3DwfpX6aG)&(?Fnu>(98p&)?@o!7uP7*KIu2!>_5Y
N>KYi~PJCV0@F$q9svZCU
literal 0
HcmV?d00001
diff --git a/backend/target/classes/hu/elte/profrate/controllers/DepartmentController.class b/backend/target/classes/hu/elte/profrate/controllers/DepartmentController.class
new file mode 100644
index 0000000000000000000000000000000000000000..299a19cf3955696bb2c37fdcbe93c701c0d28e6d
GIT binary patch
literal 4850
zcmcgvX;U0k6g_Vkm;g;6Ku}y`B#{X*t!6<3Ap!{z!zLuS#I0c-Lnlr5*xdtS-1mJc
zKWUZ!L8~kbez5%H2Y*w_^1Pm&o*o#rr?f1J>3*-@yZ794&%Lkv_dkCA1;7b>)q)fn
zGDvG^M3X?rRb$=IEyK?1vrAXyvM{RZ
zYQcCj_t|wwr~0jDdk)fIMW}qS>kjkJC)Ez5a4YZZpR%0
zdlb;I&B>fVe@&wS_M&fE`fR~B9ow*o{Vv>{!2u2T;GjU~?j-`vrZ?wGk7){W{EUjX
zPs1S`rcc}PC!C^9pQp)ALfCzeNh3!Ej1^6b*8oMohAfWILtfHPcNNtkEg2jY=-ZV;
z0yF(;38=gu)1c!4fwX6=OM%0GO-W470ih3RIF1ukc1~K-=idFb_AV+OPN}313Jlf}
z{Fsy5EJxmoM{qiWAq~SgBXB$^fiW8bjZ2D0fq~>8NcjNHYIqc*R5&T0p;C9!zThhn
z2TR8_oWpr8^~y`DI0;u~$;kjNXm|{h>=iUSy3QiW%X!16C4sK0v`$!#;Rog~YM8<_
zx6u5KE!}bMOFK$#W;M*=3EHHabB^>>4>3&pqHB7FN?E*C#~jC!h8_4?&~OQtxsSef
z@9T-XD{m_~d{VF@aN-uq8|oUWQw{#D;>UNG~v;TK)HF_UX_
zIMx`;&31S2eC1z-UI&&&{koZZP2ga);3F(m%0HDjrE`YAT2?a?k>;BO&y^?o
zlL@Gv93M_*lC0Zuqw>xpu=!tuse|>C$%!O!mEuUgZ(hDsl%B6nD)K*=*x$L}(5-lE
zC={8vTrD{!Bfg$owy&s{nRt>qD`k4gxm?KcC05|m{{c-M$xPnp=8CagwmR`Zuh)tx
zF?aPg>*xRtdv!<91%mH{^10fw;1u0uIbo{fskZ{P^09DCy{-x**W|eCc;2jQ=1rTL
ztbL5uIv@Dv9{WbAb8Aor6+LTuMN#at+N5nucib{OPja|-=X*eF>{X91>3jG+rcS1m
z`oQA#IgXlmeV*40ul!2m?+YC1yz&r3bh(JIc=mo(5v>JP