From 43c967638b12ad85bd3920a152f782d301783be4 Mon Sep 17 00:00:00 2001 From: Marc Beyer Date: Mon, 7 Feb 2022 11:26:49 +0100 Subject: [PATCH] Added equals methods --- .../com/vpr/server/controller/AuthController.java | 3 --- .../com/vpr/server/controller/EventController.java | 2 +- .../com/vpr/server/controller/MainController.java | 11 ++++------- .../com/vpr/server/controller/UserController.java | 1 - .../dao/implementation/UserDAOImplementation.java | 1 - .../src/main/java/com/vpr/server/data/UserEvent.java | 1 - .../src/main/java/com/vpr/server/json/JSONMapper.java | 1 - .../src/main/java/com/vpr/server/json/Validator.java | 4 ---- .../com/vpr/server/repository/EventRepository.java | 7 ------- .../src/main/java/com/vpr/server/security/Token.java | 3 ++- 10 files changed, 7 insertions(+), 27 deletions(-) diff --git a/server/src/main/java/com/vpr/server/controller/AuthController.java b/server/src/main/java/com/vpr/server/controller/AuthController.java index 31bbe08..1c6d1e2 100644 --- a/server/src/main/java/com/vpr/server/controller/AuthController.java +++ b/server/src/main/java/com/vpr/server/controller/AuthController.java @@ -2,9 +2,6 @@ package com.vpr.server.controller; import com.vpr.server.data.User; import com.vpr.server.repository.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; public class AuthController { diff --git a/server/src/main/java/com/vpr/server/controller/EventController.java b/server/src/main/java/com/vpr/server/controller/EventController.java index ba1e9e2..af699bd 100644 --- a/server/src/main/java/com/vpr/server/controller/EventController.java +++ b/server/src/main/java/com/vpr/server/controller/EventController.java @@ -1,9 +1,9 @@ package com.vpr.server.controller; +import com.vpr.server.dao.interfaces.EventDAO; import com.vpr.server.data.Event; import com.vpr.server.data.User; import com.vpr.server.data.UserEvent; -import com.vpr.server.dao.interfaces.EventDAO; import com.vpr.server.json.JSONMapper; import com.vpr.server.json.Validator; import com.vpr.server.repository.EventRepository; diff --git a/server/src/main/java/com/vpr/server/controller/MainController.java b/server/src/main/java/com/vpr/server/controller/MainController.java index 7435fbb..3f4cbcd 100644 --- a/server/src/main/java/com/vpr/server/controller/MainController.java +++ b/server/src/main/java/com/vpr/server/controller/MainController.java @@ -1,8 +1,5 @@ package com.vpr.server.controller; -import com.vpr.server.data.Event; -import com.vpr.server.data.User; -import com.vpr.server.data.UserEvent; import com.vpr.server.repository.EventRepository; import com.vpr.server.repository.UserEventRepository; import com.vpr.server.repository.UserRepository; @@ -10,12 +7,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.server.ResponseStatusException; -import java.sql.Time; -import java.text.SimpleDateFormat; - @Controller // This means that this class is a Controller @RequestMapping(path = "/vpr") // This means URL's start with /demo (after Application path) public class MainController { diff --git a/server/src/main/java/com/vpr/server/controller/UserController.java b/server/src/main/java/com/vpr/server/controller/UserController.java index 5cb3090..2f43906 100644 --- a/server/src/main/java/com/vpr/server/controller/UserController.java +++ b/server/src/main/java/com/vpr/server/controller/UserController.java @@ -1,7 +1,6 @@ package com.vpr.server.controller; import com.vpr.server.dao.interfaces.UserDAO; -import com.vpr.server.data.Event; import com.vpr.server.data.User; import com.vpr.server.json.JSONMapper; import com.vpr.server.repository.UserRepository; diff --git a/server/src/main/java/com/vpr/server/dao/implementation/UserDAOImplementation.java b/server/src/main/java/com/vpr/server/dao/implementation/UserDAOImplementation.java index c3c44da..d3e56ac 100644 --- a/server/src/main/java/com/vpr/server/dao/implementation/UserDAOImplementation.java +++ b/server/src/main/java/com/vpr/server/dao/implementation/UserDAOImplementation.java @@ -1,7 +1,6 @@ package com.vpr.server.dao.implementation; import com.vpr.server.dao.interfaces.UserDAO; -import com.vpr.server.data.Event; import com.vpr.server.data.User; import org.springframework.stereotype.Repository; diff --git a/server/src/main/java/com/vpr/server/data/UserEvent.java b/server/src/main/java/com/vpr/server/data/UserEvent.java index 55c4112..c29fe3e 100644 --- a/server/src/main/java/com/vpr/server/data/UserEvent.java +++ b/server/src/main/java/com/vpr/server/data/UserEvent.java @@ -2,7 +2,6 @@ package com.vpr.server.data; import javax.persistence.*; import java.sql.Date; -import java.util.Calendar; // @Entity creates a table out of this class with Hibernate // @Table defines the table-name diff --git a/server/src/main/java/com/vpr/server/json/JSONMapper.java b/server/src/main/java/com/vpr/server/json/JSONMapper.java index 066c47c..914af66 100644 --- a/server/src/main/java/com/vpr/server/json/JSONMapper.java +++ b/server/src/main/java/com/vpr/server/json/JSONMapper.java @@ -5,7 +5,6 @@ import com.vpr.server.data.User; import com.vpr.server.data.UserEvent; import java.sql.Time; - import java.util.ArrayList; import java.util.List; diff --git a/server/src/main/java/com/vpr/server/json/Validator.java b/server/src/main/java/com/vpr/server/json/Validator.java index 54b3d98..15a4ced 100644 --- a/server/src/main/java/com/vpr/server/json/Validator.java +++ b/server/src/main/java/com/vpr/server/json/Validator.java @@ -1,9 +1,5 @@ package com.vpr.server.json; -import com.vpr.server.data.UserEvent; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; - import java.sql.Date; import java.sql.Time; import java.text.SimpleDateFormat; diff --git a/server/src/main/java/com/vpr/server/repository/EventRepository.java b/server/src/main/java/com/vpr/server/repository/EventRepository.java index e76e91d..bb5d1c6 100644 --- a/server/src/main/java/com/vpr/server/repository/EventRepository.java +++ b/server/src/main/java/com/vpr/server/repository/EventRepository.java @@ -1,18 +1,11 @@ package com.vpr.server.repository; import com.vpr.server.data.Event; -import com.vpr.server.data.UserEvent; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; -import javax.persistence.ColumnResult; -import javax.persistence.ConstructorResult; -import javax.persistence.NamedNativeQuery; -import javax.persistence.SqlResultSetMapping; import javax.transaction.Transactional; -import java.util.List; -import java.util.Optional; // This will be AUTO IMPLEMENTED by Spring into a Bean called eventRepository // CRUD refers Create, Read, Update, Delete diff --git a/server/src/main/java/com/vpr/server/security/Token.java b/server/src/main/java/com/vpr/server/security/Token.java index 4f9a4c0..7b94987 100644 --- a/server/src/main/java/com/vpr/server/security/Token.java +++ b/server/src/main/java/com/vpr/server/security/Token.java @@ -4,11 +4,12 @@ import io.jsonwebtoken.JwtException; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; import io.jsonwebtoken.security.Keys; + import java.security.Key; public class Token { - private static Key KEY = Keys.secretKeyFor(SignatureAlgorithm.HS256); + private static final Key KEY = Keys.secretKeyFor(SignatureAlgorithm.HS256); public static String Generate(String subject){ return Jwts.builder().setSubject(subject).signWith(KEY).compact();