├── .classpath ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── .project ├── .settings ├── org.eclipse.core.resources.prefs ├── org.eclipse.jdt.core.prefs ├── org.eclipse.m2e.core.prefs └── org.eclipse.wst.common.project.facet.core.xml ├── LICENSE ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml ├── src ├── main │ ├── java │ │ └── com │ │ │ └── klayrocha │ │ │ └── helpdesk │ │ │ ├── HelpDeskApplication.java │ │ │ └── api │ │ │ ├── controller │ │ │ ├── TicketController.java │ │ │ └── UserController.java │ │ │ ├── dto │ │ │ └── Summary.java │ │ │ ├── filter │ │ │ └── SimpleCORSFilter.java │ │ │ ├── repository │ │ │ ├── ChangeStatusRepository.java │ │ │ ├── TicketRepository.java │ │ │ └── UserRepository.java │ │ │ ├── response │ │ │ └── Response.java │ │ │ ├── security │ │ │ ├── config │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── controller │ │ │ │ └── AuthenticationRestController.java │ │ │ ├── entity │ │ │ │ ├── ChangeStatus.java │ │ │ │ ├── Ticket.java │ │ │ │ └── User.java │ │ │ ├── enums │ │ │ │ ├── PriorityEnum.java │ │ │ │ ├── ProfileEnum.java │ │ │ │ └── StatusEnum.java │ │ │ ├── jwt │ │ │ │ ├── JwtAuthenticationEntryPoint.java │ │ │ │ ├── JwtAuthenticationRequest.java │ │ │ │ ├── JwtAuthenticationTokenFilter.java │ │ │ │ ├── JwtTokenUtil.java │ │ │ │ ├── JwtUser.java │ │ │ │ └── JwtUserFactory.java │ │ │ ├── model │ │ │ │ └── CurrentUser.java │ │ │ └── service │ │ │ │ └── JwtUserDetailsServiceImpl.java │ │ │ └── service │ │ │ ├── TicketService.java │ │ │ ├── UserService.java │ │ │ └── impl │ │ │ ├── TicketServiceImpl.java │ │ │ └── UserServiceImpl.java │ └── resources │ │ └── application.properties └── test │ └── java │ └── com │ └── klayrocha │ └── helpdesk │ └── HelpDeskApplicationTests.java └── target ├── classes ├── META-INF │ ├── MANIFEST.MF │ └── maven │ │ └── com.klayrocha │ │ └── HelpDesk │ │ ├── pom.properties │ │ └── pom.xml ├── application.properties └── com │ └── klayrocha │ └── helpdesk │ ├── HelpDeskApplication.class │ └── api │ ├── controller │ ├── TicketController.class │ └── UserController.class │ ├── dto │ └── Summary.class │ ├── filter │ └── SimpleCORSFilter.class │ ├── repository │ ├── ChangeStatusRepository.class │ ├── TicketRepository.class │ └── UserRepository.class │ ├── response │ └── Response.class │ ├── security │ ├── config │ │ └── WebSecurityConfig.class │ ├── controller │ │ └── AuthenticationRestController.class │ ├── entity │ │ ├── ChangeStatus.class │ │ ├── Ticket.class │ │ └── User.class │ ├── enums │ │ ├── PriorityEnum.class │ │ ├── ProfileEnum.class │ │ └── StatusEnum.class │ ├── jwt │ │ ├── JwtAuthenticationEntryPoint.class │ │ ├── JwtAuthenticationRequest.class │ │ ├── JwtAuthenticationTokenFilter.class │ │ ├── JwtTokenUtil.class │ │ ├── JwtUser.class │ │ └── JwtUserFactory.class │ ├── model │ │ └── CurrentUser.class │ └── service │ │ └── JwtUserDetailsServiceImpl.class │ └── service │ ├── TicketService.class │ ├── UserService.class │ └── impl │ ├── TicketServiceImpl.class │ └── UserServiceImpl.class └── test-classes └── com └── klayrocha └── helpdesk └── HelpDeskApplicationTests.class /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip 2 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelpDesk 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.m2e.core.maven2Builder 20 | 21 | 22 | 23 | 24 | org.springframework.ide.eclipse.core.springbuilder 25 | 26 | 27 | 28 | 29 | org.springframework.ide.eclipse.boot.validation.springbootbuilder 30 | 31 | 32 | 33 | 34 | 35 | org.springframework.ide.eclipse.core.springnature 36 | org.eclipse.jdt.core.javanature 37 | org.eclipse.m2e.core.maven2Nature 38 | org.eclipse.wst.common.project.facet.core.nature 39 | 40 | 41 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding//src/test/java=UTF-8 5 | encoding/=UTF-8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 3 | org.eclipse.jdt.core.compiler.compliance=1.8 4 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 5 | org.eclipse.jdt.core.compiler.source=1.8 6 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 klayrocha 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # angular-spring-api 2 | Curso Angular com Sprign API 3 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Migwn, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | echo $MAVEN_PROJECTBASEDIR 205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 206 | 207 | # For Cygwin, switch paths to Windows format before running java 208 | if $cygwin; then 209 | [ -n "$M2_HOME" ] && 210 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 211 | [ -n "$JAVA_HOME" ] && 212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 213 | [ -n "$CLASSPATH" ] && 214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 215 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 217 | fi 218 | 219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 220 | 221 | exec "$JAVACMD" \ 222 | $MAVEN_OPTS \ 223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 226 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.klayrocha 7 | HelpDesk 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | HelpDesk 12 | Project HelpDesk 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 0.7.0 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-data-rest 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-mongodb 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-security 46 | 47 | 48 | io.jsonwebtoken 49 | jjwt 50 | ${jjwt.version} 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-validation 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-devtools 59 | runtime 60 | 61 | 62 | org.springframework.security 63 | spring-security-test 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/HelpDeskApplication.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.security.crypto.password.PasswordEncoder; 8 | 9 | import com.klayrocha.helpdesk.api.repository.UserRepository; 10 | import com.klayrocha.helpdesk.api.security.entity.User; 11 | import com.klayrocha.helpdesk.api.security.enums.ProfileEnum; 12 | 13 | 14 | @SpringBootApplication 15 | public class HelpDeskApplication { 16 | 17 | public static void main(String[] args) { 18 | SpringApplication.run(HelpDeskApplication.class, args); 19 | } 20 | 21 | @Bean 22 | CommandLineRunner init(UserRepository userRepository, PasswordEncoder passwordEncoder) { 23 | return args -> { 24 | initUsers(userRepository, passwordEncoder); 25 | }; 26 | 27 | } 28 | 29 | private void initUsers(UserRepository userRepository, PasswordEncoder passwordEncoder) { 30 | User admin = new User(); 31 | admin.setEmail("admin@helpdesk.com"); 32 | admin.setPassword(passwordEncoder.encode("123456")); 33 | admin.setProfile(ProfileEnum.ROLE_ADMIN); 34 | 35 | User find = userRepository.findByEmail("admin@helpdesk.com"); 36 | if (find == null) { 37 | userRepository.save(admin); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/controller/TicketController.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.Random; 8 | 9 | import javax.servlet.http.HttpServletRequest; 10 | 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.domain.Page; 13 | import org.springframework.http.ResponseEntity; 14 | import org.springframework.security.access.prepost.PreAuthorize; 15 | import org.springframework.validation.BindingResult; 16 | import org.springframework.validation.ObjectError; 17 | import org.springframework.web.bind.annotation.CrossOrigin; 18 | import org.springframework.web.bind.annotation.DeleteMapping; 19 | import org.springframework.web.bind.annotation.GetMapping; 20 | import org.springframework.web.bind.annotation.PathVariable; 21 | import org.springframework.web.bind.annotation.PostMapping; 22 | import org.springframework.web.bind.annotation.PutMapping; 23 | import org.springframework.web.bind.annotation.RequestBody; 24 | import org.springframework.web.bind.annotation.RequestMapping; 25 | import org.springframework.web.bind.annotation.RestController; 26 | 27 | import com.klayrocha.helpdesk.api.dto.Summary; 28 | import com.klayrocha.helpdesk.api.response.Response; 29 | import com.klayrocha.helpdesk.api.security.entity.ChangeStatus; 30 | import com.klayrocha.helpdesk.api.security.entity.Ticket; 31 | import com.klayrocha.helpdesk.api.security.entity.User; 32 | import com.klayrocha.helpdesk.api.security.enums.ProfileEnum; 33 | import com.klayrocha.helpdesk.api.security.enums.StatusEnum; 34 | import com.klayrocha.helpdesk.api.security.jwt.JwtTokenUtil; 35 | import com.klayrocha.helpdesk.api.service.TicketService; 36 | import com.klayrocha.helpdesk.api.service.UserService; 37 | 38 | 39 | @RestController 40 | @RequestMapping("/api/ticket") 41 | @CrossOrigin(origins = "*") 42 | public class TicketController { 43 | 44 | @Autowired 45 | private TicketService ticketService; 46 | 47 | @Autowired 48 | protected JwtTokenUtil jwtTokenUtil; 49 | 50 | @Autowired 51 | private UserService userService; 52 | 53 | @PostMapping() 54 | @PreAuthorize("hasAnyRole('CUSTOMER')") 55 | public ResponseEntity> create(HttpServletRequest request, @RequestBody Ticket ticket, 56 | BindingResult result) { 57 | Response response = new Response(); 58 | try { 59 | validateCreateTicket(ticket, result); 60 | if (result.hasErrors()) { 61 | result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage())); 62 | return ResponseEntity.badRequest().body(response); 63 | } 64 | ticket.setStatus(StatusEnum.getStatus("New")); 65 | ticket.setUser(userFromRequest(request)); 66 | ticket.setDate(new Date()); 67 | ticket.setNumber(generateNumber()); 68 | Ticket ticketPersisted = (Ticket) ticketService.createOrUpdate(ticket); 69 | response.setData(ticketPersisted); 70 | } catch (Exception e) { 71 | response.getErrors().add(e.getMessage()); 72 | return ResponseEntity.badRequest().body(response); 73 | } 74 | return ResponseEntity.ok(response); 75 | } 76 | 77 | private void validateCreateTicket(Ticket ticket, BindingResult result) { 78 | if (ticket.getTitle() == null) { 79 | result.addError(new ObjectError("Ticket", "Title no information")); 80 | return; 81 | } 82 | } 83 | 84 | public User userFromRequest(HttpServletRequest request) { 85 | String token = request.getHeader("Authorization"); 86 | String email = jwtTokenUtil.getUsernameFromToken(token); 87 | return userService.findByEmail(email); 88 | } 89 | 90 | private Integer generateNumber() { 91 | Random random = new Random(); 92 | return random.nextInt(9999); 93 | } 94 | 95 | @PutMapping() 96 | @PreAuthorize("hasAnyRole('CUSTOMER')") 97 | public ResponseEntity> update(HttpServletRequest request, @RequestBody Ticket ticket, 98 | BindingResult result) { 99 | Response response = new Response(); 100 | try { 101 | validateUpdateTicket(ticket, result); 102 | if (result.hasErrors()) { 103 | result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage())); 104 | return ResponseEntity.badRequest().body(response); 105 | } 106 | Ticket ticketCurrent = ticketService.findById(ticket.getId()); 107 | ticket.setStatus(ticketCurrent.getStatus()); 108 | ticket.setUser(ticketCurrent.getUser()); 109 | ticket.setDate(ticketCurrent.getDate()); 110 | ticket.setNumber(ticketCurrent.getNumber()); 111 | if(ticketCurrent.getAssignedUser() != null) { 112 | ticket.setAssignedUser(ticketCurrent.getAssignedUser()); 113 | } 114 | Ticket ticketPersisted = (Ticket) ticketService.createOrUpdate(ticket); 115 | response.setData(ticketPersisted); 116 | } catch (Exception e) { 117 | response.getErrors().add(e.getMessage()); 118 | return ResponseEntity.badRequest().body(response); 119 | } 120 | return ResponseEntity.ok(response); 121 | } 122 | 123 | private void validateUpdateTicket(Ticket ticket, BindingResult result) { 124 | if (ticket.getId() == null) { 125 | result.addError(new ObjectError("Ticket", "Id no information")); 126 | return; 127 | } 128 | if (ticket.getTitle() == null) { 129 | result.addError(new ObjectError("Ticket", "Title no information")); 130 | return; 131 | } 132 | } 133 | 134 | 135 | @GetMapping(value = "{id}") 136 | @PreAuthorize("hasAnyRole('CUSTOMER','TECHNICIAN')") 137 | public ResponseEntity> findById(@PathVariable("id") String id) { 138 | Response response = new Response(); 139 | Ticket ticket = ticketService.findById(id); 140 | if (ticket == null) { 141 | response.getErrors().add("Register not found id:" + id); 142 | return ResponseEntity.badRequest().body(response); 143 | } 144 | List changes = new ArrayList(); 145 | Iterable changesCurrent = ticketService.listChangeStatus(ticket.getId()); 146 | for (Iterator iterator = changesCurrent.iterator(); iterator.hasNext();) { 147 | ChangeStatus changeStatus = iterator.next(); 148 | changeStatus.setTicket(null); 149 | changes.add(changeStatus); 150 | } 151 | ticket.setChanges(changes); 152 | response.setData(ticket); 153 | return ResponseEntity.ok(response); 154 | } 155 | 156 | @DeleteMapping(value = "/{id}") 157 | @PreAuthorize("hasAnyRole('CUSTOMER')") 158 | public ResponseEntity> delete(@PathVariable("id") String id) { 159 | Response response = new Response(); 160 | Ticket ticket = ticketService.findById(id); 161 | if (ticket == null) { 162 | response.getErrors().add("Register not found id:" + id); 163 | return ResponseEntity.badRequest().body(response); 164 | } 165 | ticketService.delete(id); 166 | return ResponseEntity.ok(new Response()); 167 | } 168 | 169 | 170 | @GetMapping(value = "{page}/{count}") 171 | @PreAuthorize("hasAnyRole('CUSTOMER','TECHNICIAN')") 172 | public ResponseEntity>> findAll(HttpServletRequest request, @PathVariable int page, @PathVariable int count) { 173 | 174 | Response> response = new Response>(); 175 | Page tickets = null; 176 | User userRequest = userFromRequest(request); 177 | if(userRequest.getProfile().equals(ProfileEnum.ROLE_TECHNICIAN)) { 178 | tickets = ticketService.listTicket(page, count); 179 | } else if(userRequest.getProfile().equals(ProfileEnum.ROLE_CUSTOMER)) { 180 | tickets = ticketService.findByCurrentUser(page, count, userRequest.getId()); 181 | } 182 | response.setData(tickets); 183 | return ResponseEntity.ok(response); 184 | } 185 | 186 | @GetMapping(value = "{page}/{count}/{number}/{title}/{status}/{priority}/{assigned}") 187 | @PreAuthorize("hasAnyRole('CUSTOMER','TECHNICIAN')") 188 | public ResponseEntity>> findByParams(HttpServletRequest request, 189 | @PathVariable int page, 190 | @PathVariable int count, 191 | @PathVariable Integer number, 192 | @PathVariable String title, 193 | @PathVariable String status, 194 | @PathVariable String priority, 195 | @PathVariable boolean assigned) { 196 | 197 | title = title.equals("uninformed") ? "" : title; 198 | status = status.equals("uninformed") ? "" : status; 199 | priority = priority.equals("uninformed") ? "" : priority; 200 | 201 | Response> response = new Response>(); 202 | Page tickets = null; 203 | if(number > 0) { 204 | tickets = ticketService.findByNumber(page, count, number); 205 | } else { 206 | User userRequest = userFromRequest(request); 207 | if(userRequest.getProfile().equals(ProfileEnum.ROLE_TECHNICIAN)) { 208 | if(assigned) { 209 | tickets = ticketService.findByParametersAndAssignedUser(page, count, title, status, priority, userRequest.getId()); 210 | } else { 211 | tickets = ticketService.findByParameters(page, count, title, status, priority); 212 | } 213 | } else if(userRequest.getProfile().equals(ProfileEnum.ROLE_CUSTOMER)) { 214 | tickets = ticketService.findByParametersAndCurrentUser(page, count, title, status, priority, userRequest.getId()); 215 | } 216 | } 217 | response.setData(tickets); 218 | return ResponseEntity.ok(response); 219 | } 220 | 221 | @PutMapping(value = "/{id}/{status}") 222 | @PreAuthorize("hasAnyRole('CUSTOMER','TECHNICIAN')") 223 | public ResponseEntity> changeStatus( 224 | @PathVariable("id") String id, 225 | @PathVariable("status") String status, 226 | HttpServletRequest request, 227 | @RequestBody Ticket ticket, 228 | BindingResult result) { 229 | 230 | Response response = new Response(); 231 | try { 232 | validateChangeStatus(id, status, result); 233 | if (result.hasErrors()) { 234 | result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage())); 235 | return ResponseEntity.badRequest().body(response); 236 | } 237 | Ticket ticketCurrent = ticketService.findById(id); 238 | ticketCurrent.setStatus(StatusEnum.getStatus(status)); 239 | if(status.equals("Assigned")) { 240 | ticketCurrent.setAssignedUser(userFromRequest(request)); 241 | } 242 | Ticket ticketPersisted = (Ticket) ticketService.createOrUpdate(ticketCurrent); 243 | ChangeStatus changeStatus = new ChangeStatus(); 244 | changeStatus.setUserChange(userFromRequest(request)); 245 | changeStatus.setDateChangeStatus(new Date()); 246 | changeStatus.setStatus(StatusEnum.getStatus(status)); 247 | changeStatus.setTicket(ticketPersisted); 248 | ticketService.createChangeStatus(changeStatus); 249 | response.setData(ticketPersisted); 250 | } catch (Exception e) { 251 | response.getErrors().add(e.getMessage()); 252 | return ResponseEntity.badRequest().body(response); 253 | } 254 | return ResponseEntity.ok(response); 255 | } 256 | 257 | private void validateChangeStatus(String id,String status, BindingResult result) { 258 | if (id == null || id.equals("")) { 259 | result.addError(new ObjectError("Ticket", "Id no information")); 260 | return; 261 | } 262 | if (status == null || status.equals("")) { 263 | result.addError(new ObjectError("Ticket", "Status no information")); 264 | return; 265 | } 266 | } 267 | 268 | @GetMapping(value = "/summary") 269 | public ResponseEntity> findChart() { 270 | Response response = new Response(); 271 | Summary chart = new Summary(); 272 | int amountNew = 0; 273 | int amountResolved = 0; 274 | int amountApproved = 0; 275 | int amountDisapproved = 0; 276 | int amountAssigned = 0; 277 | int amountClosed = 0; 278 | Iterable tickets = ticketService.findAll(); 279 | if (tickets != null) { 280 | for (Iterator iterator = tickets.iterator(); iterator.hasNext();) { 281 | Ticket ticket = iterator.next(); 282 | if(ticket.getStatus().equals(StatusEnum.New)){ 283 | amountNew ++; 284 | } 285 | if(ticket.getStatus().equals(StatusEnum.Resolved)){ 286 | amountResolved ++; 287 | } 288 | if(ticket.getStatus().equals(StatusEnum.Approved)){ 289 | amountApproved ++; 290 | } 291 | if(ticket.getStatus().equals(StatusEnum.Disapproved)){ 292 | amountDisapproved ++; 293 | } 294 | if(ticket.getStatus().equals(StatusEnum.Assigned)){ 295 | amountAssigned ++; 296 | } 297 | if(ticket.getStatus().equals(StatusEnum.Closed)){ 298 | amountClosed ++; 299 | } 300 | } 301 | } 302 | chart.setAmountNew(amountNew); 303 | chart.setAmountResolved(amountResolved); 304 | chart.setAmountApproved(amountApproved); 305 | chart.setAmountDisapproved(amountDisapproved); 306 | chart.setAmountAssigned(amountAssigned); 307 | chart.setAmountClosed(amountClosed); 308 | response.setData(chart); 309 | return ResponseEntity.ok(response); 310 | } 311 | 312 | } 313 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.dao.DuplicateKeyException; 7 | import org.springframework.data.domain.Page; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.security.access.prepost.PreAuthorize; 10 | import org.springframework.security.crypto.password.PasswordEncoder; 11 | import org.springframework.validation.BindingResult; 12 | import org.springframework.validation.ObjectError; 13 | import org.springframework.web.bind.annotation.CrossOrigin; 14 | import org.springframework.web.bind.annotation.DeleteMapping; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.PostMapping; 18 | import org.springframework.web.bind.annotation.PutMapping; 19 | import org.springframework.web.bind.annotation.RequestBody; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RestController; 22 | 23 | import com.klayrocha.helpdesk.api.response.Response; 24 | import com.klayrocha.helpdesk.api.security.entity.User; 25 | import com.klayrocha.helpdesk.api.service.UserService; 26 | 27 | @RestController 28 | @RequestMapping("/api/user") 29 | @CrossOrigin(origins = "*") 30 | public class UserController { 31 | 32 | @Autowired 33 | private UserService userService; 34 | 35 | @Autowired 36 | private PasswordEncoder passwordEncoder; 37 | 38 | @PostMapping() 39 | @PreAuthorize("hasAnyRole('ADMIN')") 40 | public ResponseEntity> create(HttpServletRequest request, @RequestBody User user, 41 | BindingResult result) { 42 | Response response = new Response(); 43 | try { 44 | validateCreateUser(user, result); 45 | if (result.hasErrors()) { 46 | result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage())); 47 | return ResponseEntity.badRequest().body(response); 48 | } 49 | user.setPassword(passwordEncoder.encode(user.getPassword())); 50 | User userPersisted = (User) userService.createOrUpdate(user); 51 | response.setData(userPersisted); 52 | } catch (DuplicateKeyException dE) { 53 | response.getErrors().add("E-mail already registered !"); 54 | return ResponseEntity.badRequest().body(response); 55 | } catch (Exception e) { 56 | response.getErrors().add(e.getMessage()); 57 | return ResponseEntity.badRequest().body(response); 58 | } 59 | return ResponseEntity.ok(response); 60 | } 61 | 62 | private void validateCreateUser(User user, BindingResult result) { 63 | if (user.getEmail() == null) { 64 | result.addError(new ObjectError("User", "Email no information")); 65 | return; 66 | } 67 | } 68 | 69 | @PutMapping() 70 | @PreAuthorize("hasAnyRole('ADMIN')") 71 | public ResponseEntity> update(HttpServletRequest request, @RequestBody User user, 72 | BindingResult result) { 73 | Response response = new Response(); 74 | try { 75 | validateUpdate(user, result); 76 | if (result.hasErrors()) { 77 | result.getAllErrors().forEach(error -> response.getErrors().add(error.getDefaultMessage())); 78 | return ResponseEntity.badRequest().body(response); 79 | } 80 | user.setPassword(passwordEncoder.encode(user.getPassword())); 81 | User userPersisted = (User) userService.createOrUpdate(user); 82 | response.setData(userPersisted); 83 | } catch (Exception e) { 84 | response.getErrors().add(e.getMessage()); 85 | return ResponseEntity.badRequest().body(response); 86 | } 87 | return ResponseEntity.ok(response); 88 | } 89 | 90 | private void validateUpdate(User user, BindingResult result) { 91 | if (user.getId() == null) { 92 | result.addError(new ObjectError("User", "Id no information")); 93 | return; 94 | } 95 | if (user.getEmail() == null) { 96 | result.addError(new ObjectError("User", "Email no information")); 97 | return; 98 | } 99 | } 100 | 101 | @GetMapping(value = "{id}") 102 | @PreAuthorize("hasAnyRole('ADMIN')") 103 | public ResponseEntity> findById(@PathVariable("id") String id) { 104 | Response response = new Response(); 105 | User user = userService.findById(id); 106 | if (user == null) { 107 | response.getErrors().add("Register not found id:" + id); 108 | return ResponseEntity.badRequest().body(response); 109 | } 110 | response.setData(user); 111 | return ResponseEntity.ok(response); 112 | } 113 | 114 | @DeleteMapping(value = "/{id}") 115 | @PreAuthorize("hasAnyRole('ADMIN')") 116 | public ResponseEntity> delete(@PathVariable("id") String id) { 117 | Response response = new Response(); 118 | User user = userService.findById(id); 119 | if (user == null) { 120 | response.getErrors().add("Register not found id:" + id); 121 | return ResponseEntity.badRequest().body(response); 122 | } 123 | userService.delete(id); 124 | return ResponseEntity.ok(new Response()); 125 | } 126 | 127 | 128 | @GetMapping(value = "{page}/{count}") 129 | @PreAuthorize("hasAnyRole('ADMIN')") 130 | public ResponseEntity>> findAll(@PathVariable int page, @PathVariable int count) { 131 | Response> response = new Response>(); 132 | Page users = userService.findAll(page, count); 133 | response.setData(users); 134 | return ResponseEntity.ok(response); 135 | } 136 | 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/dto/Summary.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Summary implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | private Integer amountNew; 9 | private Integer amountResolved; 10 | private Integer amountApproved; 11 | private Integer amountDisapproved; 12 | private Integer amountAssigned; 13 | private Integer amountClosed; 14 | 15 | public Integer getAmountNew() { 16 | return amountNew; 17 | } 18 | 19 | public void setAmountNew(Integer amountNew) { 20 | this.amountNew = amountNew; 21 | } 22 | 23 | public Integer getAmountResolved() { 24 | return amountResolved; 25 | } 26 | 27 | public void setAmountResolved(Integer amountResolved) { 28 | this.amountResolved = amountResolved; 29 | } 30 | 31 | public Integer getAmountDisapproved() { 32 | return amountDisapproved; 33 | } 34 | 35 | public void setAmountDisapproved(Integer amountDisapproved) { 36 | this.amountDisapproved = amountDisapproved; 37 | } 38 | 39 | public Integer getAmountApproved() { 40 | return amountApproved; 41 | } 42 | 43 | public void setAmountApproved(Integer amountApproved) { 44 | this.amountApproved = amountApproved; 45 | } 46 | 47 | public Integer getAmountAssigned() { 48 | return amountAssigned; 49 | } 50 | 51 | public void setAmountAssigned(Integer amountAssigned) { 52 | this.amountAssigned = amountAssigned; 53 | } 54 | 55 | public Integer getAmountClosed() { 56 | return amountClosed; 57 | } 58 | 59 | public void setAmountClosed(Integer amountClosed) { 60 | this.amountClosed = amountClosed; 61 | } 62 | 63 | public static long getSerialversionuid() { 64 | return serialVersionUID; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/filter/SimpleCORSFilter.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.filter; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.Filter; 6 | import javax.servlet.FilterChain; 7 | import javax.servlet.FilterConfig; 8 | import javax.servlet.ServletException; 9 | import javax.servlet.ServletRequest; 10 | import javax.servlet.ServletResponse; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import org.apache.catalina.servlet4preview.http.HttpServletRequest; 14 | import org.apache.commons.logging.Log; 15 | import org.apache.commons.logging.LogFactory; 16 | import org.springframework.core.Ordered; 17 | import org.springframework.core.annotation.Order; 18 | import org.springframework.stereotype.Component; 19 | 20 | @Component 21 | @Order(Ordered.HIGHEST_PRECEDENCE) 22 | public class SimpleCORSFilter implements Filter { 23 | 24 | private final Log logger = LogFactory.getLog(this.getClass()); 25 | 26 | @Override 27 | public void init(FilterConfig fc) throws ServletException { 28 | logger.info("HelpDesk-API | SimpleCORSFilter loaded"); 29 | } 30 | 31 | @Override 32 | public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { 33 | HttpServletResponse response = (HttpServletResponse) resp; 34 | HttpServletRequest request = (HttpServletRequest) req; 35 | response.setHeader("Access-Control-Allow-Origin", "*"); 36 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT"); 37 | response.setHeader("Access-Control-Max-Age", "3600"); 38 | response.setHeader("Access-Control-Allow-Headers", "x-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN"); 39 | 40 | if ("OPTIONS".equalsIgnoreCase(request.getMethod())) { 41 | response.setStatus(HttpServletResponse.SC_OK); 42 | } else { 43 | chain.doFilter(req, resp); 44 | } 45 | 46 | } 47 | 48 | @Override 49 | public void destroy() { 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/repository/ChangeStatusRepository.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.repository; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | 5 | import com.klayrocha.helpdesk.api.security.entity.ChangeStatus; 6 | 7 | public interface ChangeStatusRepository extends MongoRepository { 8 | 9 | Iterable findByTicketIdOrderByDateChangeStatusDesc(String ticketId); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/repository/TicketRepository.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.repository; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | 7 | import com.klayrocha.helpdesk.api.security.entity.Ticket; 8 | 9 | public interface TicketRepository extends MongoRepository { 10 | 11 | 12 | Page findByUserIdOrderByDateDesc(Pageable pages,String userId); 13 | 14 | Page findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingOrderByDateDesc( 15 | String title,String status,String priority,Pageable pages); 16 | 17 | Page findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingAndUserIdOrderByDateDesc( 18 | String title,String status,String priority,String userId,Pageable pages); 19 | 20 | Page findByNumber(Integer number,Pageable pages); 21 | 22 | Page findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingAndAssignedUserIdOrderByDateDesc( 23 | String title,String status,String priority,String assignedUserId,Pageable pages); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.repository; 2 | 3 | import org.springframework.data.mongodb.repository.MongoRepository; 4 | 5 | import com.klayrocha.helpdesk.api.security.entity.User; 6 | 7 | public interface UserRepository extends MongoRepository { 8 | 9 | User findByEmail(String email); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/response/Response.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.response; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Response { 7 | 8 | private T data; 9 | private List errors; 10 | 11 | public T getData() { 12 | return data; 13 | } 14 | 15 | public void setData(T data) { 16 | this.data = data; 17 | } 18 | 19 | public List getErrors() { 20 | if(this.errors == null) { 21 | this.errors = new ArrayList(); 22 | } 23 | return errors; 24 | } 25 | 26 | public void setErrors(List errors) { 27 | this.errors = errors; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/config/WebSecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.config; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.http.HttpMethod; 7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 11 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 12 | import org.springframework.security.config.http.SessionCreationPolicy; 13 | import org.springframework.security.core.userdetails.UserDetailsService; 14 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 15 | import org.springframework.security.crypto.password.PasswordEncoder; 16 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 17 | 18 | import com.klayrocha.helpdesk.api.security.jwt.JwtAuthenticationEntryPoint; 19 | import com.klayrocha.helpdesk.api.security.jwt.JwtAuthenticationTokenFilter; 20 | 21 | @Configuration 22 | @EnableWebSecurity 23 | @EnableGlobalMethodSecurity(prePostEnabled = true) 24 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter { 25 | 26 | @Autowired 27 | private JwtAuthenticationEntryPoint unauthorizedHandler; 28 | 29 | @Autowired 30 | private UserDetailsService userDetailsService; 31 | 32 | @Autowired 33 | public void configureAuthentication(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 34 | authenticationManagerBuilder.userDetailsService(this.userDetailsService).passwordEncoder(passwordEncoder()); 35 | } 36 | 37 | @Bean 38 | public PasswordEncoder passwordEncoder() { 39 | return new BCryptPasswordEncoder(); 40 | } 41 | 42 | @Bean 43 | public JwtAuthenticationTokenFilter authenticationTokenFilterBean() throws Exception { 44 | return new JwtAuthenticationTokenFilter(); 45 | } 46 | 47 | @Override 48 | protected void configure(HttpSecurity httpSecurity) throws Exception { 49 | httpSecurity.csrf().disable() 50 | .exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and() 51 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() 52 | .authorizeRequests() 53 | .antMatchers( 54 | HttpMethod.GET, 55 | "/", 56 | "/*.html", 57 | "/favicon.ico", 58 | "/**/*.html", 59 | "/**/*.css", 60 | "/**/*.js" 61 | ).permitAll() 62 | .antMatchers("/api/auth/**").permitAll() 63 | .anyRequest().authenticated(); 64 | httpSecurity.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class); 65 | httpSecurity.headers().cacheControl(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/controller/AuthenticationRestController.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.controller; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.security.authentication.AuthenticationManager; 8 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 9 | import org.springframework.security.core.Authentication; 10 | import org.springframework.security.core.AuthenticationException; 11 | import org.springframework.security.core.context.SecurityContextHolder; 12 | import org.springframework.security.core.userdetails.UserDetails; 13 | import org.springframework.security.core.userdetails.UserDetailsService; 14 | import org.springframework.web.bind.annotation.CrossOrigin; 15 | import org.springframework.web.bind.annotation.PostMapping; 16 | import org.springframework.web.bind.annotation.RequestBody; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.klayrocha.helpdesk.api.security.entity.User; 20 | import com.klayrocha.helpdesk.api.security.jwt.JwtAuthenticationRequest; 21 | import com.klayrocha.helpdesk.api.security.jwt.JwtTokenUtil; 22 | import com.klayrocha.helpdesk.api.security.model.CurrentUser; 23 | import com.klayrocha.helpdesk.api.service.UserService; 24 | 25 | @RestController 26 | @CrossOrigin(origins = "*") 27 | public class AuthenticationRestController { 28 | 29 | @Autowired 30 | private AuthenticationManager authenticationManager; 31 | 32 | @Autowired 33 | private JwtTokenUtil jwtTokenUtil; 34 | 35 | @Autowired 36 | private UserDetailsService userDetailsService; 37 | 38 | @Autowired 39 | private UserService userService; 40 | 41 | @PostMapping(value="/api/auth") 42 | public ResponseEntity createAuthenticationToken(@RequestBody JwtAuthenticationRequest authenticationRequest) throws AuthenticationException { 43 | 44 | final Authentication authentication = authenticationManager.authenticate( 45 | new UsernamePasswordAuthenticationToken( 46 | authenticationRequest.getEmail(), 47 | authenticationRequest.getPassword() 48 | ) 49 | ); 50 | SecurityContextHolder.getContext().setAuthentication(authentication); 51 | final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.getEmail()); 52 | final String token = jwtTokenUtil.generateToken(userDetails); 53 | final User user = userService.findByEmail(authenticationRequest.getEmail()); 54 | user.setPassword(null); 55 | return ResponseEntity.ok(new CurrentUser(token, user)); 56 | } 57 | 58 | @PostMapping(value="/api/refresh") 59 | public ResponseEntity refreshAndGetAuthenticationToken(HttpServletRequest request) { 60 | String token = request.getHeader("Authorization"); 61 | String username = jwtTokenUtil.getUsernameFromToken(token); 62 | final User user = userService.findByEmail(username); 63 | 64 | if (jwtTokenUtil.canTokenBeRefreshed(token)) { 65 | String refreshedToken = jwtTokenUtil.refreshToken(token); 66 | return ResponseEntity.ok(new CurrentUser(refreshedToken, user)); 67 | } else { 68 | return ResponseEntity.badRequest().body(null); 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/entity/ChangeStatus.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.entity; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.data.annotation.Id; 6 | import org.springframework.data.mongodb.core.mapping.DBRef; 7 | import org.springframework.data.mongodb.core.mapping.Document; 8 | 9 | import com.klayrocha.helpdesk.api.security.enums.StatusEnum; 10 | 11 | @Document 12 | public class ChangeStatus { 13 | 14 | @Id 15 | private String id; 16 | 17 | @DBRef 18 | private Ticket ticket; 19 | 20 | @DBRef 21 | private User userChange; 22 | 23 | private Date dateChangeStatus; 24 | 25 | private StatusEnum status; 26 | 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | public void setId(String id) { 32 | this.id = id; 33 | } 34 | 35 | public Ticket getTicket() { 36 | return ticket; 37 | } 38 | 39 | public void setTicket(Ticket ticket) { 40 | this.ticket = ticket; 41 | } 42 | 43 | 44 | public User getUserChange() { 45 | return userChange; 46 | } 47 | 48 | public void setUserChange(User userChange) { 49 | this.userChange = userChange; 50 | } 51 | 52 | public Date getDateChangeStatus() { 53 | return dateChangeStatus; 54 | } 55 | 56 | public void setDateChangeStatus(Date dateChangeStatus) { 57 | this.dateChangeStatus = dateChangeStatus; 58 | } 59 | 60 | public StatusEnum getStatus() { 61 | return status; 62 | } 63 | 64 | public void setStatus(StatusEnum status) { 65 | this.status = status; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/entity/Ticket.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.entity; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | 6 | import org.springframework.data.annotation.Id; 7 | import org.springframework.data.annotation.Transient; 8 | import org.springframework.data.mongodb.core.mapping.DBRef; 9 | import org.springframework.data.mongodb.core.mapping.Document; 10 | 11 | import com.klayrocha.helpdesk.api.security.enums.PriorityEnum; 12 | import com.klayrocha.helpdesk.api.security.enums.StatusEnum; 13 | 14 | @Document 15 | public class Ticket { 16 | 17 | @Id 18 | private String id; 19 | 20 | @DBRef(lazy = true) 21 | private User user; 22 | 23 | private Date date; 24 | 25 | private String title; 26 | 27 | private Integer number; 28 | 29 | private StatusEnum status; 30 | 31 | private PriorityEnum priority; 32 | 33 | @DBRef(lazy = true) 34 | private User assignedUser; 35 | 36 | private String description; 37 | 38 | private String image; 39 | 40 | @Transient 41 | private List changes; 42 | 43 | public String getId() { 44 | return id; 45 | } 46 | 47 | public void setId(String id) { 48 | this.id = id; 49 | } 50 | 51 | public User getUser() { 52 | return user; 53 | } 54 | 55 | public void setUser(User user) { 56 | this.user = user; 57 | } 58 | 59 | public Date getDate() { 60 | return date; 61 | } 62 | 63 | public void setDate(Date date) { 64 | this.date = date; 65 | } 66 | 67 | public String getTitle() { 68 | return title; 69 | } 70 | 71 | public void setTitle(String title) { 72 | this.title = title; 73 | } 74 | 75 | public Integer getNumber() { 76 | return number; 77 | } 78 | 79 | public void setNumber(Integer number) { 80 | this.number = number; 81 | } 82 | 83 | public StatusEnum getStatus() { 84 | return status; 85 | } 86 | 87 | public void setStatus(StatusEnum status) { 88 | this.status = status; 89 | } 90 | 91 | public PriorityEnum getPriority() { 92 | return priority; 93 | } 94 | 95 | public void setPriority(PriorityEnum priority) { 96 | this.priority = priority; 97 | } 98 | 99 | public User getAssignedUser() { 100 | return assignedUser; 101 | } 102 | 103 | public void setAssignedUser(User assignedUser) { 104 | this.assignedUser = assignedUser; 105 | } 106 | 107 | public String getDescription() { 108 | return description; 109 | } 110 | 111 | public void setDescription(String description) { 112 | this.description = description; 113 | } 114 | 115 | public String getImage() { 116 | return image; 117 | } 118 | 119 | public void setImage(String image) { 120 | this.image = image; 121 | } 122 | 123 | public List getChanges() { 124 | return changes; 125 | } 126 | 127 | public void setChanges(List changes) { 128 | this.changes = changes; 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.entity; 2 | 3 | import javax.validation.constraints.Size; 4 | 5 | import org.hibernate.validator.constraints.Email; 6 | import org.hibernate.validator.constraints.NotBlank; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.index.Indexed; 9 | import org.springframework.data.mongodb.core.mapping.Document; 10 | 11 | import com.klayrocha.helpdesk.api.security.enums.ProfileEnum; 12 | 13 | @Document 14 | public class User { 15 | 16 | @Id 17 | private String id; 18 | 19 | @Indexed(unique = true) 20 | @NotBlank(message = "Email required") 21 | @Email(message = "Email invalid") 22 | private String email; 23 | 24 | @NotBlank(message = "Password required") 25 | @Size(min = 6) 26 | private String password; 27 | 28 | private ProfileEnum profile; 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public void setId(String id) { 35 | this.id = id; 36 | } 37 | 38 | public String getEmail() { 39 | return email; 40 | } 41 | 42 | public void setEmail(String email) { 43 | this.email = email; 44 | } 45 | 46 | public String getPassword() { 47 | return password; 48 | } 49 | 50 | public void setPassword(String password) { 51 | this.password = password; 52 | } 53 | 54 | public ProfileEnum getProfile() { 55 | return profile; 56 | } 57 | 58 | public void setProfile(ProfileEnum profile) { 59 | this.profile = profile; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/enums/PriorityEnum.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.enums; 2 | 3 | public enum PriorityEnum { 4 | High, 5 | Normal, 6 | Low 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/enums/ProfileEnum.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.enums; 2 | 3 | public enum ProfileEnum { 4 | ROLE_ADMIN, 5 | ROLE_CUSTOMER, 6 | ROLE_TECHNICIAN 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/enums/StatusEnum.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.enums; 2 | 3 | public enum StatusEnum { 4 | New, 5 | Resolved, 6 | Approved, 7 | Disapproved, 8 | Assigned, 9 | Closed; 10 | 11 | public static StatusEnum getStatus(String status) { 12 | switch(status) { 13 | case "New" : return New; 14 | case "Resolved" : return Resolved; 15 | case "Approved" : return Approved; 16 | case "Disapproved" : return Disapproved; 17 | case "Assigned" : return Assigned; 18 | case "Closed" : return Closed; 19 | default : return New; 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.io.IOException; 4 | import java.io.Serializable; 5 | 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletResponse; 8 | 9 | import org.springframework.security.core.AuthenticationException; 10 | import org.springframework.security.web.AuthenticationEntryPoint; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Override 19 | public void commence(HttpServletRequest request, 20 | HttpServletResponse response, AuthenticationException authException) throws IOException { 21 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationRequest.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.io.Serializable; 4 | 5 | public class JwtAuthenticationRequest implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | private String email; 9 | private String password; 10 | 11 | public JwtAuthenticationRequest() { 12 | super(); 13 | } 14 | 15 | public JwtAuthenticationRequest(String email, String password) { 16 | this.setEmail(email); 17 | this.setPassword(password); 18 | } 19 | 20 | public String getEmail() { 21 | return email; 22 | } 23 | 24 | public void setEmail(String email) { 25 | this.email = email; 26 | } 27 | 28 | public String getPassword() { 29 | return this.password; 30 | } 31 | 32 | public void setPassword(String password) { 33 | this.password = password; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationTokenFilter.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.io.IOException; 4 | 5 | import javax.servlet.FilterChain; 6 | import javax.servlet.ServletException; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.security.core.userdetails.UserDetails; 14 | import org.springframework.security.core.userdetails.UserDetailsService; 15 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 16 | import org.springframework.web.filter.OncePerRequestFilter; 17 | 18 | public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { 19 | 20 | @Autowired 21 | private UserDetailsService userDetailsService; 22 | 23 | @Autowired 24 | private JwtTokenUtil jwtTokenUtil; 25 | 26 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) 27 | throws ServletException, IOException { 28 | String authToken = request.getHeader("Authorization"); 29 | String username = jwtTokenUtil.getUsernameFromToken(authToken); 30 | 31 | if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) { 32 | UserDetails userDetails = this.userDetailsService.loadUserByUsername(username); 33 | if (jwtTokenUtil.validateToken(authToken, userDetails)) { 34 | UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken( 35 | userDetails, null, userDetails.getAuthorities()); 36 | authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); 37 | logger.info("authenticated user " + username + ", setting security context"); 38 | SecurityContextHolder.getContext().setAuthentication(authentication); 39 | } 40 | } 41 | chain.doFilter(request, response); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtTokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.io.Serializable; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import org.springframework.beans.factory.annotation.Value; 9 | import org.springframework.security.core.userdetails.UserDetails; 10 | import org.springframework.stereotype.Component; 11 | 12 | import io.jsonwebtoken.Claims; 13 | import io.jsonwebtoken.Jwts; 14 | import io.jsonwebtoken.SignatureAlgorithm; 15 | 16 | @Component 17 | public class JwtTokenUtil implements Serializable { 18 | 19 | private static final long serialVersionUID = -3301605591108950415L; 20 | static final String CLAIM_KEY_USERNAME = "sub"; 21 | static final String CLAIM_KEY_CREATED = "created"; 22 | static final String CLAIM_KEY_EXPIRED = "exp"; 23 | 24 | @Value("${jwt.secret}") 25 | private String secret; 26 | 27 | @Value("${jwt.expiration}") 28 | private Long expiration; 29 | 30 | public String getUsernameFromToken(String token) { 31 | String username; 32 | try { 33 | final Claims claims = getClaimsFromToken(token); 34 | username = claims.getSubject(); 35 | } catch (Exception e) { 36 | username = null; 37 | } 38 | return username; 39 | } 40 | 41 | public Date getExpirationDateFromToken(String token) { 42 | Date expiration; 43 | try { 44 | final Claims claims = getClaimsFromToken(token); 45 | expiration = claims.getExpiration(); 46 | } catch (Exception e) { 47 | expiration = null; 48 | } 49 | return expiration; 50 | } 51 | 52 | private Claims getClaimsFromToken(String token) { 53 | Claims claims; 54 | try { 55 | claims = Jwts.parser() 56 | .setSigningKey(secret) 57 | .parseClaimsJws(token) 58 | .getBody(); 59 | } catch (Exception e) { 60 | claims = null; 61 | } 62 | return claims; 63 | } 64 | 65 | private Boolean isTokenExpired(String token) { 66 | final Date expiration = getExpirationDateFromToken(token); 67 | return expiration.before(new Date()); 68 | } 69 | 70 | public String generateToken(UserDetails userDetails) { 71 | Map claims = new HashMap<>(); 72 | 73 | claims.put(CLAIM_KEY_USERNAME, userDetails.getUsername()); 74 | 75 | final Date createdDate = new Date(); 76 | claims.put(CLAIM_KEY_CREATED, createdDate); 77 | 78 | return doGenerateToken(claims); 79 | } 80 | 81 | private String doGenerateToken(Map claims) { 82 | final Date createdDate = (Date) claims.get(CLAIM_KEY_CREATED); 83 | final Date expirationDate = new Date(createdDate.getTime() + expiration * 1000); 84 | return Jwts.builder() 85 | .setClaims(claims) 86 | .setExpiration(expirationDate) 87 | .signWith(SignatureAlgorithm.HS512, secret) 88 | .compact(); 89 | } 90 | 91 | public Boolean canTokenBeRefreshed(String token) { 92 | return (!isTokenExpired(token)); 93 | } 94 | 95 | public String refreshToken(String token) { 96 | String refreshedToken; 97 | try { 98 | final Claims claims = getClaimsFromToken(token); 99 | claims.put(CLAIM_KEY_CREATED, new Date()); 100 | refreshedToken = doGenerateToken(claims); 101 | } catch (Exception e) { 102 | refreshedToken = null; 103 | } 104 | return refreshedToken; 105 | } 106 | 107 | public Boolean validateToken(String token, UserDetails userDetails) { 108 | JwtUser user = (JwtUser) userDetails; 109 | final String username = getUsernameFromToken(token); 110 | return ( 111 | username.equals(user.getUsername()) 112 | && !isTokenExpired(token)); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtUser.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.util.Collection; 4 | 5 | import org.springframework.security.core.GrantedAuthority; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | 8 | import com.fasterxml.jackson.annotation.JsonIgnore; 9 | 10 | public class JwtUser implements UserDetails { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | private final String id; 15 | private final String username; 16 | private final String password; 17 | private final Collection authorities; 18 | 19 | public JwtUser(String id, String username, String password, Collection authorities) { 20 | this.id = id; 21 | this.username = username; 22 | this.password = password; 23 | this.authorities = authorities; 24 | } 25 | 26 | @JsonIgnore 27 | public String getId() { 28 | return id; 29 | } 30 | 31 | @Override 32 | public String getUsername() { 33 | return username; 34 | } 35 | 36 | @JsonIgnore 37 | @Override 38 | public boolean isAccountNonExpired() { 39 | return true; 40 | } 41 | 42 | @JsonIgnore 43 | @Override 44 | public boolean isAccountNonLocked() { 45 | return true; 46 | } 47 | 48 | @JsonIgnore 49 | @Override 50 | public boolean isCredentialsNonExpired() { 51 | return true; 52 | } 53 | 54 | @JsonIgnore 55 | @Override 56 | public String getPassword() { 57 | return password; 58 | } 59 | 60 | @Override 61 | public Collection getAuthorities() { 62 | return authorities; 63 | } 64 | 65 | @Override 66 | public boolean isEnabled() { 67 | return true; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/jwt/JwtUserFactory.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.jwt; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.security.core.GrantedAuthority; 7 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 8 | 9 | import com.klayrocha.helpdesk.api.security.entity.User; 10 | import com.klayrocha.helpdesk.api.security.enums.ProfileEnum; 11 | 12 | public class JwtUserFactory { 13 | private JwtUserFactory() { 14 | } 15 | 16 | public static JwtUser create(User user) { 17 | return new JwtUser( 18 | user.getId(), 19 | user.getEmail(), 20 | user.getPassword(), 21 | mapToGrantedAuthorities(user.getProfile()) 22 | ); 23 | } 24 | 25 | private static List mapToGrantedAuthorities(ProfileEnum profileEnum) { 26 | List authorities = new ArrayList(); 27 | authorities.add(new SimpleGrantedAuthority(profileEnum.toString())); 28 | return authorities ; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/model/CurrentUser.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.model; 2 | 3 | import com.klayrocha.helpdesk.api.security.entity.User; 4 | 5 | public class CurrentUser { 6 | 7 | private String token; 8 | private User user; 9 | 10 | public CurrentUser(String token, User user) { 11 | this.token = token; 12 | this.user = user; 13 | } 14 | 15 | public String getToken() { 16 | return token; 17 | } 18 | 19 | public void setToken(String token) { 20 | this.token = token; 21 | } 22 | 23 | public User getUser() { 24 | return user; 25 | } 26 | 27 | public void setUser(User user) { 28 | this.user = user; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/security/service/JwtUserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.security.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.core.userdetails.UserDetails; 5 | import org.springframework.security.core.userdetails.UserDetailsService; 6 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.klayrocha.helpdesk.api.security.entity.User; 10 | import com.klayrocha.helpdesk.api.security.jwt.JwtUserFactory; 11 | import com.klayrocha.helpdesk.api.service.UserService; 12 | 13 | @Service 14 | public class JwtUserDetailsServiceImpl implements UserDetailsService { 15 | 16 | @Autowired 17 | private UserService userService; 18 | 19 | @Override 20 | public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { 21 | 22 | User user = userService.findByEmail(email); 23 | if (user == null) { 24 | throw new UsernameNotFoundException(String.format("No user found with username '%s'.", email)); 25 | } else { 26 | return JwtUserFactory.create(user); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/service/TicketService.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.service; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.stereotype.Component; 5 | 6 | import com.klayrocha.helpdesk.api.security.entity.ChangeStatus; 7 | import com.klayrocha.helpdesk.api.security.entity.Ticket; 8 | 9 | @Component 10 | public interface TicketService { 11 | 12 | Ticket createOrUpdate(Ticket ticket); 13 | 14 | Ticket findById(String id); 15 | 16 | void delete(String id); 17 | 18 | Page listTicket(int page, int count); 19 | 20 | ChangeStatus createChangeStatus(ChangeStatus changeStatus); 21 | 22 | Iterable listChangeStatus(String ticketId); 23 | 24 | Page findByCurrentUser(int page, int count, String userId); 25 | 26 | Page findByParameters(int page, int count,String title,String status,String priority); 27 | 28 | Page findByParametersAndCurrentUser(int page, int count,String title,String status,String priority,String userId); 29 | 30 | Page findByNumber(int page, int count,Integer number); 31 | 32 | Iterable findAll(); 33 | 34 | public Page findByParametersAndAssignedUser(int page, int count,String title,String status,String priority,String assignedUserId); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.service; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.stereotype.Component; 5 | 6 | import com.klayrocha.helpdesk.api.security.entity.User; 7 | 8 | @Component 9 | public interface UserService { 10 | 11 | User findByEmail(String email); 12 | 13 | User createOrUpdate(User user); 14 | 15 | User findById(String id); 16 | 17 | void delete(String id); 18 | 19 | Page findAll(int page, int count); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/service/impl/TicketServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.klayrocha.helpdesk.api.repository.ChangeStatusRepository; 10 | import com.klayrocha.helpdesk.api.repository.TicketRepository; 11 | import com.klayrocha.helpdesk.api.security.entity.ChangeStatus; 12 | import com.klayrocha.helpdesk.api.security.entity.Ticket; 13 | import com.klayrocha.helpdesk.api.service.TicketService; 14 | 15 | @Component 16 | public class TicketServiceImpl implements TicketService { 17 | 18 | @Autowired 19 | private TicketRepository ticketRepository; 20 | 21 | @Autowired 22 | private ChangeStatusRepository changeStatusRepository; 23 | 24 | public Ticket createOrUpdate(Ticket ticket) { 25 | return this.ticketRepository.save(ticket); 26 | } 27 | 28 | public Ticket findById(String id) { 29 | return this.ticketRepository.findOne(id); 30 | } 31 | 32 | public void delete(String id) { 33 | this.ticketRepository.delete(id); 34 | } 35 | 36 | public Page listTicket(int page, int count) { 37 | Pageable pages = new PageRequest(page, count); 38 | return this.ticketRepository.findAll(pages); 39 | } 40 | 41 | public Iterable findAll() { 42 | return this.ticketRepository.findAll(); 43 | } 44 | 45 | public Page findByCurrentUser(int page, int count, String userId) { 46 | Pageable pages = new PageRequest(page, count); 47 | return this.ticketRepository.findByUserIdOrderByDateDesc(pages,userId); 48 | } 49 | 50 | public ChangeStatus createChangeStatus(ChangeStatus changeStatus) { 51 | return this.changeStatusRepository.save(changeStatus); 52 | } 53 | 54 | public Iterable listChangeStatus(String ticketId) { 55 | return this.changeStatusRepository.findByTicketIdOrderByDateChangeStatusDesc(ticketId); 56 | } 57 | 58 | public Page findByParameters(int page, int count,String title,String status,String priority) { 59 | Pageable pages = new PageRequest(page, count); 60 | return this.ticketRepository. 61 | findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingOrderByDateDesc( 62 | title,status,priority,pages); 63 | } 64 | 65 | public Page findByParametersAndCurrentUser(int page, int count,String title,String status, 66 | String priority,String userId) { 67 | Pageable pages = new PageRequest(page, count); 68 | return this.ticketRepository. 69 | findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingAndUserIdOrderByDateDesc( 70 | title,status,priority,userId,pages); 71 | } 72 | 73 | public Page findByNumber(int page, int count,Integer number){ 74 | Pageable pages = new PageRequest(page, count); 75 | return this.ticketRepository.findByNumber(number, pages); 76 | } 77 | 78 | public Page findByParametersAndAssignedUser(int page, int count,String title,String status, 79 | String priority,String assignedUserId) { 80 | Pageable pages = new PageRequest(page, count); 81 | return this.ticketRepository. 82 | findByTitleIgnoreCaseContainingAndStatusIgnoreCaseContainingAndPriorityIgnoreCaseContainingAndAssignedUserIdOrderByDateDesc( 83 | title,status,priority,assignedUserId,pages); 84 | } 85 | } -------------------------------------------------------------------------------- /src/main/java/com/klayrocha/helpdesk/api/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk.api.service.impl; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.PageRequest; 6 | import org.springframework.data.domain.Pageable; 7 | import org.springframework.stereotype.Component; 8 | 9 | import com.klayrocha.helpdesk.api.repository.UserRepository; 10 | import com.klayrocha.helpdesk.api.security.entity.User; 11 | import com.klayrocha.helpdesk.api.service.UserService; 12 | 13 | @Component 14 | public class UserServiceImpl implements UserService { 15 | 16 | @Autowired 17 | private UserRepository userRepository; 18 | 19 | public User findByEmail(String email) { 20 | return this.userRepository.findByEmail(email); 21 | } 22 | 23 | public User createOrUpdate(User user) { 24 | return this.userRepository.save(user); 25 | } 26 | 27 | public User findById(String id) { 28 | return this.userRepository.findOne(id); 29 | } 30 | 31 | public void delete(String id) { 32 | this.userRepository.delete(id); 33 | } 34 | 35 | public Page findAll(int page, int count) { 36 | Pageable pages = new PageRequest(page, count); 37 | return this.userRepository.findAll(pages); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.data.mongodb.host=localhost 2 | spring.data.mongodb.port=27017 3 | spring.data.mongodb.database=helpdesk 4 | 5 | jwt.secret=helpDesk_klay 6 | # expiration 7 days 7 | jwt.expiration=604800 8 | 9 | logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG -------------------------------------------------------------------------------- /src/test/java/com/klayrocha/helpdesk/HelpDeskApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.klayrocha.helpdesk; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class HelpDeskApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /target/classes/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Implementation-Title: HelpDesk 3 | Implementation-Version: 0.0.1-SNAPSHOT 4 | Built-By: klayrocha 5 | Implementation-Vendor-Id: com.klayrocha 6 | Build-Jdk: 1.8.0_171 7 | Implementation-URL: http://projects.spring.io/spring-boot/HelpDesk/ 8 | Created-By: Maven Integration for Eclipse 9 | Implementation-Vendor: Pivotal Software, Inc. 10 | 11 | -------------------------------------------------------------------------------- /target/classes/META-INF/maven/com.klayrocha/HelpDesk/pom.properties: -------------------------------------------------------------------------------- 1 | #Generated by Maven Integration for Eclipse 2 | #Mon May 21 21:22:43 BRT 2018 3 | version=0.0.1-SNAPSHOT 4 | groupId=com.klayrocha 5 | m2e.projectName=HelpDesk 6 | m2e.projectLocation=/Users/klayrocha/CursoUdemy/angular-spring-api 7 | artifactId=HelpDesk 8 | -------------------------------------------------------------------------------- /target/classes/META-INF/maven/com.klayrocha/HelpDesk/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.klayrocha 7 | HelpDesk 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | HelpDesk 12 | Project HelpDesk 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.10.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 0.7.0 25 | 1.8 26 | 27 | 28 | 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-data-rest 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-mongodb 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-security 46 | 47 | 48 | io.jsonwebtoken 49 | jjwt 50 | ${jjwt.version} 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-validation 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-devtools 59 | runtime 60 | 61 | 62 | org.springframework.security 63 | spring-security-test 64 | test 65 | 66 | 67 | 68 | 69 | 70 | 71 | org.springframework.boot 72 | spring-boot-maven-plugin 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /target/classes/application.properties: -------------------------------------------------------------------------------- 1 | spring.data.mongodb.host=localhost 2 | spring.data.mongodb.port=27017 3 | spring.data.mongodb.database=helpdesk 4 | 5 | jwt.secret=helpDesk_klay 6 | # expiration 7 days 7 | jwt.expiration=604800 8 | 9 | logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/HelpDeskApplication.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/HelpDeskApplication.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/controller/TicketController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/controller/TicketController.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/controller/UserController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/controller/UserController.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/dto/Summary.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/dto/Summary.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/filter/SimpleCORSFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/filter/SimpleCORSFilter.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/repository/ChangeStatusRepository.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/repository/ChangeStatusRepository.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/repository/TicketRepository.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/repository/TicketRepository.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/repository/UserRepository.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/repository/UserRepository.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/response/Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/response/Response.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/config/WebSecurityConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/config/WebSecurityConfig.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/controller/AuthenticationRestController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/controller/AuthenticationRestController.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/entity/ChangeStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/entity/ChangeStatus.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/entity/Ticket.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/entity/Ticket.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/entity/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/entity/User.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/enums/PriorityEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/enums/PriorityEnum.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/enums/ProfileEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/enums/ProfileEnum.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/enums/StatusEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/enums/StatusEnum.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationEntryPoint.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationEntryPoint.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationRequest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationRequest.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationTokenFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtAuthenticationTokenFilter.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtTokenUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtTokenUtil.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtUser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtUser.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtUserFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/jwt/JwtUserFactory.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/model/CurrentUser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/model/CurrentUser.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/security/service/JwtUserDetailsServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/security/service/JwtUserDetailsServiceImpl.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/service/TicketService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/service/TicketService.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/service/UserService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/service/UserService.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/service/impl/TicketServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/service/impl/TicketServiceImpl.class -------------------------------------------------------------------------------- /target/classes/com/klayrocha/helpdesk/api/service/impl/UserServiceImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/classes/com/klayrocha/helpdesk/api/service/impl/UserServiceImpl.class -------------------------------------------------------------------------------- /target/test-classes/com/klayrocha/helpdesk/HelpDeskApplicationTests.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klayrocha/angular-spring-api/142517a1993e61acbe4debaff77040d17235447a/target/test-classes/com/klayrocha/helpdesk/HelpDeskApplicationTests.class --------------------------------------------------------------------------------