xufenglei
2018-03-13 d4f150414533b95324b2a1c8a81c11d92efb71ec
src/main/java/com/moral/security/auth/login/LoginAwareAuthenticationSuccessHandler.java
@@ -1,6 +1,7 @@
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;
@@ -17,6 +18,7 @@
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;
@@ -31,7 +33,8 @@
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;
@@ -49,7 +52,7 @@
        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);