| | |
| | | package com.moral.security.auth.login; |
| | | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.moral.security.config.JwtSettings; |
| | | import com.moral.security.model.UserContext; |
| | | import com.moral.security.model.token.JwtToken; |
| | | import com.moral.security.model.token.JwtTokenFactory; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | public class LoginAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler { |
| | | private final ObjectMapper mapper; |
| | | private final JwtTokenFactory tokenFactory; |
| | | |
| | | @Autowired |
| | | private JwtSettings jwtSettings; |
| | | @Autowired |
| | | public LoginAwareAuthenticationSuccessHandler(final ObjectMapper mapper, final JwtTokenFactory tokenFactory) { |
| | | this.mapper = mapper; |
| | |
| | | Map<String, String> tokenMap = new HashMap<String, String>(); |
| | | tokenMap.put("token", accessToken.getToken()); |
| | | tokenMap.put("refreshToken", refreshToken.getToken()); |
| | | |
| | | tokenMap.put("expiredTime",jwtSettings.getTokenExpirationTime().toString()); |
| | | response.setStatus(HttpStatus.OK.value()); |
| | | response.setContentType(MediaType.APPLICATION_JSON_VALUE); |
| | | mapper.writeValue(response.getWriter(), tokenMap); |