Merge branch 'develop' into frontend/timo

This commit is contained in:
Timo Volkmann 2019-05-07 09:25:33 +02:00
commit 44aa93338d
3 changed files with 36 additions and 4 deletions

View File

@ -7,7 +7,7 @@ plugins {
apply plugin: 'io.spring.dependency-management'
apply plugin: 'idea'
apply plugin: 'com.moowork.node'
//apply plugin: 'war'
apply plugin: 'war'
group = 'de.hhn.labsw'
version = '0.0.1-SNAPSHOT'
@ -47,7 +47,7 @@ dependencies {
compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.1.4.RELEASE'
//compile group: 'at.favre.lib', name: 'bcrypt', version: '{latest-version}'
//providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
//JWT
compile 'io.jsonwebtoken:jjwt-api:0.10.5'

View File

@ -9,7 +9,6 @@ import hhn.labsw.bugageocaching.repositories.*;
import hhn.labsw.bugageocaching.util.FinderUtil;
import hhn.labsw.bugageocaching.util.VerificationUtil;
import io.jsonwebtoken.Claims;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
@ -1036,6 +1035,38 @@ public class Controller {
return ResponseEntity.status(200).body(new Gson().toJson(pois));
}
@ApiOperation(value = "Returns the Team of a user")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ApiResponse(code = 401, message = "JWT Token expired"),
@ApiResponse(code = 400, message = "Something went wrong at verification")
})
@RequestMapping(value = "/api/getTeamOfUser", method = RequestMethod.GET, produces = "application/json")
public ResponseEntity getTeamOfUser(@RequestParam String token){
// verify user
ResponseEntity verifyToken = VerificationUtil.verifyToken(token);
if (verifyToken.getStatusCodeValue() != 200) {
return verifyToken;
}
//get User
Claims claims = (Claims) verifyToken.getBody();
ResponseEntity getUser = FinderUtil.findUserFromClaim(claims);
if (getUser.getStatusCodeValue() != 200) {
return getUser;
}
User user = (User) getUser.getBody();
User_Info user_info = user_infoRepository.findUser_InfoByUser(user);
return ResponseEntity.status(200).body(user_info.getTeam());
}
@ApiOperation(value = "Test method (Changes its purpose often)")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Database error"),
@ -1047,6 +1078,7 @@ public class Controller {
public ResponseEntity hello(@RequestParam String name) {
return ResponseEntity.status(200).body(userRepository.getRankingPlaceFromUser(name));
}
}

View File

@ -20,7 +20,7 @@ public class VerificationUtil {
public static void fetchPublicKey() {
RestTemplate restTemplate = new RestTemplate();
try {
PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:9080/buga19usermanagement/token/publickey", PublicKey.class);
PublicKey response = restTemplate.getForObject("http://seserver.se.hs-heilbronn.de:8090/buga19usermanagement/token/publickey", PublicKey.class);
byte[] decodedKey = Base64.getDecoder().decode(response.getMessage());
KeyFactory factory = KeyFactory.getInstance("RSA");
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(decodedKey);