|
|
|
@ -6,7 +6,11 @@ import com.fr.decision.config.AppearanceConfig;
|
|
|
|
|
import com.fr.decision.config.FSConfig; |
|
|
|
|
import com.fr.decision.webservice.Response; |
|
|
|
|
import com.fr.decision.webservice.v10.login.LoginService; |
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
import com.fr.third.socketio.SocketIOClient; |
|
|
|
|
import com.fr.web.utils.WebUtils; |
|
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
@ -87,13 +91,32 @@ public class LoginKit {
|
|
|
|
|
* @return 新的token |
|
|
|
|
* @throws Exception 异常 |
|
|
|
|
*/ |
|
|
|
|
public static Object refreshToken(String oldJwt, long tokenTimeout, SocketIOClient socketIOClient, Object responseData, String errorCode, String errorMsg) throws Exception{ |
|
|
|
|
Response response = new Response(); |
|
|
|
|
response = LoginService.getInstance().refreshToken(oldJwt, tokenTimeout, socketIOClient); |
|
|
|
|
responseData = response.getData(); |
|
|
|
|
errorCode = response.getErrorCode(); |
|
|
|
|
errorMsg = response.getErrorMsg(); |
|
|
|
|
return response; |
|
|
|
|
public static void refreshToken(String oldJwt, long tokenTimeout, SocketIOClient socketIOClient) throws Exception { |
|
|
|
|
LoginService.getInstance().refreshToken(oldJwt, tokenTimeout, socketIOClient); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 刷新用户名对应的token,并输出response |
|
|
|
|
* |
|
|
|
|
* @param oldJwt 老的token |
|
|
|
|
* @param socketIOClient socket客户端 |
|
|
|
|
* @param tokenTimeout 设置的超时时长,仅对非保持登录有用,0<= tokenTimeOut <= LoginConfig.LoginTimeOut |
|
|
|
|
* @param res HttpServletResponse |
|
|
|
|
* |
|
|
|
|
* @return 新的token |
|
|
|
|
* @throws Exception 异常 |
|
|
|
|
*/ |
|
|
|
|
public static void refreshTokenAndWriteResponse(String oldJwt, long tokenTimeout, SocketIOClient socketIOClient, HttpServletResponse res) throws Exception { |
|
|
|
|
Response response = LoginService.getInstance().refreshToken(oldJwt, tokenTimeout, socketIOClient); |
|
|
|
|
if (StringUtils.isNotEmpty(response.getErrorCode())) { |
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
object.put("errorCode", response.getErrorCode()); |
|
|
|
|
object.put("errorMsg", response.getErrorMsg()); |
|
|
|
|
WebUtils.printAsJSON(res, object); |
|
|
|
|
} else if (response.getData() != null) { |
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
WebUtils.printAsString(res, mapper.writeValueAsString(response)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|