Commit 33d10192 by xieshaohua

[新增]获取boss token的方法

parent 10383308
...@@ -10,5 +10,6 @@ public class Constants { ...@@ -10,5 +10,6 @@ public class Constants {
public static final String SSO_API = "sso.API"; public static final String SSO_API = "sso.API";
public static final String SSO_TOKEN = "mcdSsoToken";
} }
...@@ -90,6 +90,14 @@ public class LoginManagement { ...@@ -90,6 +90,14 @@ public class LoginManagement {
return rs; return rs;
} }
@RequestMapping(value = "/getSsoToken", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody
String getSsoToken(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
Object token = session.getAttribute(Constants.SSO_TOKEN);
return token != null ? token.toString() : "";
}
@RequestMapping(value = "/ssoLogin", method = {RequestMethod.POST, RequestMethod.GET}) @RequestMapping(value = "/ssoLogin", method = {RequestMethod.POST, RequestMethod.GET})
public void ssoLogin(HttpServletRequest request, HttpServletResponse response, public void ssoLogin(HttpServletRequest request, HttpServletResponse response,
@RequestParam(required = false, value = "ssoToken") String ssoToken) { @RequestParam(required = false, value = "ssoToken") String ssoToken) {
...@@ -138,6 +146,7 @@ public class LoginManagement { ...@@ -138,6 +146,7 @@ public class LoginManagement {
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
HttpSession session = request.getSession(true); HttpSession session = request.getSession(true);
session.setAttribute("SPRING_SECURITY_CONTEXT", SecurityContextHolder.getContext()); session.setAttribute("SPRING_SECURITY_CONTEXT", SecurityContextHolder.getContext());
session.setAttribute(Constants.SSO_TOKEN, ssoToken);
log.info("单点登录用户:" + userName); log.info("单点登录用户:" + userName);
MDC.put("user", getLogUserInfo(userName, userDName)); MDC.put("user", getLogUserInfo(userName, userDName));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment