forked from github/dataease
perf: 格式化代码
This commit is contained in:
parent
9490dc3d67
commit
3c0c39ff46
@ -5,7 +5,6 @@ import java.net.URLEncoder;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.servlet.http.Cookie;
|
import javax.servlet.http.Cookie;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -52,7 +51,7 @@ public class SSOServer {
|
|||||||
String idToken = null;
|
String idToken = null;
|
||||||
try {
|
try {
|
||||||
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
||||||
if(beansOfType.keySet().size() == 0) {
|
if (beansOfType.keySet().size() == 0) {
|
||||||
DEException.throwException("缺少oidc插件");
|
DEException.throwException("缺少oidc插件");
|
||||||
}
|
}
|
||||||
oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||||
@ -63,14 +62,15 @@ public class SSOServer {
|
|||||||
Map<String, String> config = config(oidcXpackService);
|
Map<String, String> config = config(oidcXpackService);
|
||||||
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
|
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
|
||||||
idToken = ssoToken.getIdToken();
|
idToken = ssoToken.getIdToken();
|
||||||
Cookie cookie_id_token = new Cookie("IdToken", ssoToken.getIdToken());cookie_id_token.setPath("/");
|
Cookie cookie_id_token = new Cookie("IdToken", ssoToken.getIdToken());
|
||||||
|
cookie_id_token.setPath("/");
|
||||||
response.addCookie(cookie_id_token);
|
response.addCookie(cookie_id_token);
|
||||||
|
|
||||||
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
|
SSOUserInfo ssoUserInfo = oidcXpackService.requestUserInfo(config, ssoToken.getAccessToken());
|
||||||
|
|
||||||
|
|
||||||
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
SysUserEntity sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||||
if(null == sysUserEntity){
|
if (null == sysUserEntity) {
|
||||||
sysUserService.validateExistUser(ssoUserInfo.getUsername(), ssoUserInfo.getNickName(), ssoUserInfo.getEmail());
|
sysUserService.validateExistUser(ssoUserInfo.getUsername(), ssoUserInfo.getNickName(), ssoUserInfo.getEmail());
|
||||||
sysUserService.saveOIDCUser(ssoUserInfo);
|
sysUserService.saveOIDCUser(ssoUserInfo);
|
||||||
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
sysUserEntity = authUserService.getUserBySub(ssoUserInfo.getSub());
|
||||||
@ -81,14 +81,16 @@ public class SSOServer {
|
|||||||
ServletUtils.setToken(token);
|
ServletUtils.setToken(token);
|
||||||
|
|
||||||
|
|
||||||
Cookie cookie_token = new Cookie("Authorization", token);cookie_token.setPath("/");
|
Cookie cookie_token = new Cookie("Authorization", token);
|
||||||
|
cookie_token.setPath("/");
|
||||||
|
|
||||||
Cookie cookie_ac_token = new Cookie("AccessToken", ssoToken.getAccessToken());cookie_ac_token.setPath("/");
|
Cookie cookie_ac_token = new Cookie("AccessToken", ssoToken.getAccessToken());
|
||||||
|
cookie_ac_token.setPath("/");
|
||||||
|
|
||||||
response.addCookie(cookie_token);
|
response.addCookie(cookie_token);
|
||||||
|
|
||||||
response.addCookie(cookie_ac_token);
|
response.addCookie(cookie_ac_token);
|
||||||
}catch(Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
if (null != e.getCause()) {
|
if (null != e.getCause()) {
|
||||||
@ -112,14 +114,13 @@ public class SSOServer {
|
|||||||
}
|
}
|
||||||
return modelAndView;
|
return modelAndView;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> config(OidcXpackService oidcXpackService) {
|
private Map<String, String> config(OidcXpackService oidcXpackService) {
|
||||||
List<SysSettingDto> sysSettingDtos = oidcXpackService.oidcSettings();
|
List<SysSettingDto> sysSettingDtos = oidcXpackService.oidcSettings();
|
||||||
Map<String, String> config = sysSettingDtos.stream().collect(HashMap::new,(m, v)->m.put(v.getParamKey(), v.getParamValue()), HashMap::putAll);
|
Map<String, String> config = sysSettingDtos.stream().collect(HashMap::new, (m, v) -> m.put(v.getParamKey(), v.getParamValue()), HashMap::putAll);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user