Browse Source

commit modif

placidenduwayo 2 years ago
parent
commit
2edd92a5c7

+ 10
- 3
src/main/java/fr/natan/microservices/springsecurityserverjwt/tt_authorizationFilter/JWTAuthorizationFilter.java View File

@@ -4,6 +4,7 @@ import com.auth0.jwt.JWT;
4 4
 import com.auth0.jwt.JWTVerifier;
5 5
 import com.auth0.jwt.algorithms.Algorithm;
6 6
 import com.auth0.jwt.interfaces.DecodedJWT;
7
+import com.fasterxml.jackson.databind.ObjectMapper;
7 8
 import fr.natan.microservices.springsecurityserverjwt.t_authenticationFilter.b_authenticationFilter.FinalVariables;
8 9
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
9 10
 import org.springframework.security.core.GrantedAuthority;
@@ -16,9 +17,10 @@ import javax.servlet.ServletException;
16 17
 import javax.servlet.http.HttpServletRequest;
17 18
 import javax.servlet.http.HttpServletResponse;
18 19
 import java.io.IOException;
19
-import java.util.ArrayList;
20
-import java.util.Collection;
21
-import java.util.List;
20
+import java.util.*;
21
+
22
+import static org.springframework.http.HttpStatus.FORBIDDEN;
23
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
22 24
 
23 25
 
24 26
 public class JWTAuthorizationFilter extends OncePerRequestFilter {
@@ -50,6 +52,11 @@ public class JWTAuthorizationFilter extends OncePerRequestFilter {
50 52
 
51 53
            }catch (Exception exception){
52 54
                response.setHeader("error-message", exception.getMessage());
55
+               Map<String, String> errors = new HashMap<>();
56
+               errors.put("error-message", exception.getMessage());
57
+               response.setContentType(APPLICATION_JSON_VALUE);
58
+               new ObjectMapper().writeValue(response.getOutputStream(), errors);
59
+               response.sendError(FORBIDDEN.value());
53 60
            }
54 61
         }
55 62
         else{

+ 2
- 0
src/main/java/fr/natan/microservices/springsecurityserverjwt/web/AccountController.java View File

@@ -53,4 +53,6 @@ public class AccountController {
53 53
     private UserAccount getProfil(Principal principal) throws UserAccountNotFoundException {
54 54
         return accountService.getUserByUsername(principal.getName());
55 55
     }
56
+
57
+    //develop here refresh token
56 58
 }

Powered by TurnKey Linux.