国小君统一认证加注释

dev
youhong.ai 2023-07-15 10:55:05 +08:00
parent c44c3355d5
commit f84b755516
1 changed files with 15 additions and 10 deletions

View File

@ -27,7 +27,6 @@ import java.util.Objects;
public class SsoGuoXiaoJunPocImpl { public class SsoGuoXiaoJunPocImpl {
public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso"; public static final String API_SSO_URL = "/api/aiyh/guoxiaojun/sso";
public static final String LOGIN_URL = "/wui/index.html";
public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout"; public static final String API_CHECK_OUT_URI = "/api/hrm/login/checkLogout";
private final Logger log = Util.getLogger(); private final Logger log = Util.getLogger();
@ -55,20 +54,24 @@ public class SsoGuoXiaoJunPocImpl {
if (requestURI.equals(API_CHECK_OUT_URI)) { if (requestURI.equals(API_CHECK_OUT_URI)) {
// 退出登录 // 退出登录
session.removeAttribute("outUserId"); session.removeAttribute("outUserId");
String logOutUrl = Util.getCusConfigValue("oauth2-proxy-logout-url");
response.setHeader("logOutUrl", logOutUrl);
return; return;
} }
// sso 认证 // sso 认证
if (session.getAttribute("outUserId") == null) { if (session.getAttribute("outUserId") == null) {
authorSso(response, session); authorSso(response);
} }
} catch (IOException e) { } catch (IOException e) {
log.error("重定地址失败!" + Util.getErrString(e)); log.error("重定地址失败!" + Util.getErrString(e));
} }
} }
// /**
* <h2>oa</h2>
*
* @param request
* @param response
* @throws IOException
*/
private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException { private void loginOa(HttpServletRequest request, HttpServletResponse response) throws IOException {
HttpSession session; HttpSession session;
String outUserId = request.getHeader("X-Credential-Identifier"); String outUserId = request.getHeader("X-Credential-Identifier");
@ -84,11 +87,13 @@ public class SsoGuoXiaoJunPocImpl {
response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html")); response.sendRedirect(Util.getCusConfigValueNullOrEmpty("SSO_SUCCESS_REDIRECT_URL", "/wui/index.html"));
} }
private void authorSso(HttpServletResponse response, HttpSession session) throws IOException { /**
Object outUserId = session.getAttribute("outUserId"); * <h2></h2>
if (Objects.nonNull(outUserId)) { *
return; * @param response
} * @throws IOException
*/
private void authorSso(HttpServletResponse response) throws IOException {
// 地址重定向到国小君aut2认证地址 // 地址重定向到国小君aut2认证地址
response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url=" response.sendRedirect(Util.getCusConfigValue("oauth2-proxy-url") + "?url="
+ URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8")); + URLEncoder.encode(Util.getCusConfigValue("OA_URL") + API_SSO_URL, "UTF-8"));