|
|
@@ -2,15 +2,18 @@ package com.uas.sso.sync.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.sso.SSOConfig;
|
|
|
+import com.uas.sso.SSOConfiguration;
|
|
|
import com.uas.sso.common.util.HttpUtil;
|
|
|
import com.uas.sso.sync.entity.*;
|
|
|
-import com.uas.sso.sync.service.SsoService;
|
|
|
+import com.uas.sso.sync.service.SyncSsoService;
|
|
|
import com.usoft.mq.utils.RabbitSendService;
|
|
|
import com.usoft.security.utils.OpenApiSignUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.servlet.http.Cookie;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
|
@@ -23,7 +26,7 @@ import java.util.UUID;
|
|
|
* @date 2019-01-18 15:26
|
|
|
*/
|
|
|
@Service
|
|
|
-public class SsoServiceImpl implements SsoService {
|
|
|
+public class SyncSsoServiceImpl implements SyncSsoService {
|
|
|
|
|
|
@Value("${sync.stc.secret.key}")
|
|
|
private String stcSecretKey;
|
|
|
@@ -71,7 +74,7 @@ public class SsoServiceImpl implements SsoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void sendUserLoginStateToSso(Long spaceUU, Long userUU, HttpServletResponse response) {
|
|
|
+ public void sendUserLoginStateToSso(Long spaceUU, Long userUU, HttpServletResponse response, Integer maxAge) {
|
|
|
if (spaceUU == null || userUU == null) {
|
|
|
throw new RuntimeException("用户信息不能为空");
|
|
|
}
|
|
|
@@ -80,12 +83,18 @@ public class SsoServiceImpl implements SsoService {
|
|
|
accountCenterLoginState.setEnuu(userUU.intValue());
|
|
|
String token = UUID.randomUUID().toString();
|
|
|
accountCenterLoginState.setToken(token);
|
|
|
+
|
|
|
+ // 设置cookies
|
|
|
+ Cookie tokenCookie = new Cookie("token", token);
|
|
|
+ tokenCookie.setPath("/");
|
|
|
+ tokenCookie.setDomain(SSOConfig.getInstance().getCookieDomain());
|
|
|
+ tokenCookie.setMaxAge(maxAge);
|
|
|
+ response.addCookie(tokenCookie);
|
|
|
try {
|
|
|
rabbitSendService.sendMessage("CTS", userUU + "", AppIdConstant.ACCOUNT_SERVICE, MqBizTypeConstant.CTS_LOGIN, userUU + "", JSON.toJSONString(accountCenterLoginState));
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|