| | |
| | | throws AuthenticationException, IOException, ServletException { |
| | | String tokenPayload = request.getHeader(WebSecurityConfig.AUTHENTICATION_HEADER_NAME); |
| | | RawAccessJwtToken token = new RawAccessJwtToken(tokenExtractor.extract(tokenPayload)); |
| | | try { |
| | | throw new Exception("11111111111111111"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return getAuthenticationManager().authenticate(new JwtAuthenticationToken(token)); |
| | | } |
| | | |
| | |
| | | } else if (e instanceof AuthMethodNotSupportedException) { |
| | | mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
| | | } |
| | | mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
| | | // mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
| | | // mapper.writeValue(response.getWriter(), ErrorResponse.of("Authentication failed", ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
| | | mapper.writeValue(response.getWriter(), ErrorResponse.of(e.getMessage(), ErrorCode.AUTHENTICATION, HttpStatus.UNAUTHORIZED)); |
| | | } |
| | | } |
| | |
| | | response.setStatus(HttpStatus.OK.value()); |
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE); |
| | | mapper.writeValue(response.getWriter(), tokenMap); |
| | | |
| | | clearAuthenticationAttributes(request); |
| | | } |
| | | |