|
|
|
@ -55,7 +55,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain filterChain) { |
|
|
|
|
try { |
|
|
|
|
if (!PluginContexts.currentContext().isAvailable()) { |
|
|
|
|
LogKit.info("龙光IDM集成登录,许可证过期"); |
|
|
|
|
LogKit.info("集成登录,许可证过期"); |
|
|
|
|
filterChain.doFilter(req, res); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -63,7 +63,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
String reqUrl = req.getRequestURL().toString(); |
|
|
|
|
String fullUrl = Utils.getFullRequestUrl(req); |
|
|
|
|
String method = req.getMethod(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,记录访问地址:" + method + " " + fullUrl); |
|
|
|
|
LogKit.info("集成登录,记录访问地址:" + method + " " + fullUrl); |
|
|
|
|
|
|
|
|
|
if (!"GET".equalsIgnoreCase(method)) { |
|
|
|
|
filterChain.doFilter(req, res); |
|
|
|
@ -94,7 +94,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (isAllowIdmOAuthLogin(req)) { |
|
|
|
|
String requestUrl = getRequestUrl(req); |
|
|
|
|
requestUrl = replaceUrl(requestUrl); |
|
|
|
|
LogKit.info("龙光IDM集成登录,真实访问地址," + requestUrl); |
|
|
|
|
LogKit.info("集成登录,真实访问地址," + requestUrl); |
|
|
|
|
//CustomDataConfig.addUrl(state, requestUrl);
|
|
|
|
|
String locationUrl = Utils.getOAuthCodeUrl(requestUrl); |
|
|
|
|
Utils.sendRedirect(res, locationUrl); |
|
|
|
@ -107,17 +107,17 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LogKit.info("龙光IDM集成登录, OAuth 用户名:" + loginUsername); |
|
|
|
|
LogKit.info("集成登录, OAuth 用户名:" + loginUsername); |
|
|
|
|
User user = UserService.getInstance().getUserByUserName(loginUsername); |
|
|
|
|
boolean tipsOption = false; |
|
|
|
|
String tipsContent = ""; |
|
|
|
|
if (user == null) { |
|
|
|
|
tipsOption = true; |
|
|
|
|
LogKit.info("龙光IDM集成登录,用户名:" + loginUsername + "在报表平台不存在"); |
|
|
|
|
LogKit.info("集成登录,用户名:" + loginUsername + "在报表平台不存在"); |
|
|
|
|
tipsContent = "在报表服务器上不存在"; |
|
|
|
|
} else if (!user.isEnable()) { |
|
|
|
|
tipsOption = true; |
|
|
|
|
LogKit.info("龙光IDM集成登录,用户名:" + loginUsername + "在报表平台上被禁用"); |
|
|
|
|
LogKit.info("集成登录,用户名:" + loginUsername + "在报表平台上被禁用"); |
|
|
|
|
tipsContent = "在报表平台上被禁用"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -146,9 +146,9 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//loginUsername = user.getUserName();
|
|
|
|
|
//LogKit.info("龙光IDM集成登录,报表平台用户名:" + loginUsername);
|
|
|
|
|
//LogKit.info("集成登录,报表平台用户名:" + loginUsername);
|
|
|
|
|
|
|
|
|
|
LogKit.info("龙光IDM集成登录,报表平台用户名:" + loginUsername + "生成 login token"); |
|
|
|
|
LogKit.info("集成登录,报表平台用户名:" + loginUsername + "生成 login token"); |
|
|
|
|
String loginToken = LoginService.getInstance().login(req, res, loginUsername); |
|
|
|
|
req.setAttribute("fine_auth_token", loginToken); |
|
|
|
|
|
|
|
|
@ -160,13 +160,13 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (fullUrl.indexOf("code=") >= 0) { |
|
|
|
|
String requestUrl = getRequestUrl(req); |
|
|
|
|
requestUrl = replaceUrl(requestUrl); |
|
|
|
|
LogKit.info("龙光IDM集成登录,真实跳转地址:" + requestUrl); |
|
|
|
|
LogKit.info("集成登录,真实跳转地址:" + requestUrl); |
|
|
|
|
Utils.sendRedirect(res, requestUrl); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
filterChain.doFilter(req, res); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LogKit.error("龙光IDM集成登录出错," + e.getMessage(), e); |
|
|
|
|
LogKit.error("集成登录出错," + e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -295,19 +295,16 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (StringKit.isEmpty(oAuthCode)) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
LogKit.info("龙光IDM集成登录,code:" + oAuthCode); |
|
|
|
|
LogKit.info("集成登录,code:" + oAuthCode); |
|
|
|
|
RequestConfig requestConfig = RequestConfig.custom() |
|
|
|
|
.setConnectionRequestTimeout(10000) |
|
|
|
|
.setSocketTimeout(10000) // 服务端相应超时
|
|
|
|
|
.setConnectTimeout(10000) // 建立socket链接超时时间
|
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
//获取Access Token
|
|
|
|
|
//环境地址/getTokens
|
|
|
|
|
//http://ssotestnew.logan.com.cn:28080/siam/oauth2.0/accessTokenByJson
|
|
|
|
|
//"client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=GRANTTYPE&code=CODE&redirect_uri=REDIRECTURL";
|
|
|
|
|
|
|
|
|
|
String accessTokenUrl = CustomDataConfig.getInstance().getAccessTokenUrl(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取access_toke url:" + accessTokenUrl); |
|
|
|
|
LogKit.info("集成登录,获取access_toke url:" + accessTokenUrl); |
|
|
|
|
|
|
|
|
|
HttpPost httpPost = new HttpPost(accessTokenUrl); |
|
|
|
|
httpPost.addHeader("User-Agent", DEFAULT_USER_AGENT); |
|
|
|
@ -332,7 +329,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (statusCode != HttpStatus.SC_OK) { |
|
|
|
|
response.close(); |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取Access Token请求出错,http status:" + statusCode); |
|
|
|
|
LogKit.info("集成登录,获取Access Token请求出错,http status:" + statusCode); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -340,30 +337,30 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (httpEntity == null) { |
|
|
|
|
response.close(); |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取Access Token请求出错,http响应内容为空"); |
|
|
|
|
LogKit.info("集成登录,获取Access Token请求出错,http响应内容为空"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
String responseContent = EntityUtils.toString(httpEntity, "UTF-8"); |
|
|
|
|
response.close(); |
|
|
|
|
if (StringKit.isEmpty(responseContent)) { |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取Access Token请求出错,http响应内容为空1"); |
|
|
|
|
LogKit.info("集成登录,获取Access Token请求出错,http响应内容为空1"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取Access Token请求,http响应内容\n" + responseContent); |
|
|
|
|
LogKit.info("集成登录,获取Access Token请求,http响应内容\n" + responseContent); |
|
|
|
|
|
|
|
|
|
String accessToken = getAccessToken(responseContent); |
|
|
|
|
if (StringKit.isEmpty(accessToken)) { |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取Access Token请求出错,access_token为空"); |
|
|
|
|
LogKit.info("集成登录,获取Access Token请求出错,access_token为空"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
LogKit.info("龙光IDM集成登录,Access Token:" + accessToken); |
|
|
|
|
LogKit.info("集成登录,Access Token:" + accessToken); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//http://192.168.0.115:8080/sso/oauth2.0/profile?access_token=TGT-2-QQbe3iHQJeXYx13daRnKRxMYh4HucodEmFlxwiSCpua2hMSxXB-c01
|
|
|
|
|
|
|
|
|
|
String userUrl = CustomDataConfig.getInstance().getUserUrl(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息Url:" + userUrl); |
|
|
|
|
LogKit.info("集成登录,获取用户信息Url:" + userUrl); |
|
|
|
|
httpPost = new HttpPost(userUrl); |
|
|
|
|
httpPost.setConfig(requestConfig); |
|
|
|
|
httpPost.addHeader("User-Agent", DEFAULT_USER_AGENT); |
|
|
|
@ -378,7 +375,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (statusCode != HttpStatus.SC_OK) { |
|
|
|
|
response.close(); |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求出错,http status:" + statusCode); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求出错,http status:" + statusCode); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -386,28 +383,28 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
if (httpEntity == null) { |
|
|
|
|
response.close(); |
|
|
|
|
httpClient.close(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求出错,http响应内容为空"); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求出错,http响应内容为空"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
responseContent = EntityUtils.toString(httpEntity, "UTF-8"); |
|
|
|
|
response.close(); |
|
|
|
|
httpClient.close(); |
|
|
|
|
if (StringKit.isEmpty(responseContent)) { |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求出错,http响应内容为空1"); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求出错,http响应内容为空1"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求,http响应内容\n" + responseContent); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求,http响应内容\n" + responseContent); |
|
|
|
|
|
|
|
|
|
String uid = getUsername(responseContent); |
|
|
|
|
if (StringKit.isEmpty(uid)) { |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求出错,用户名为空"); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求出错,用户名为空"); |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
LogKit.info("龙光IDM集成登录,用户名:" + uid); |
|
|
|
|
LogKit.info("集成登录,用户名:" + uid); |
|
|
|
|
uid = uid.toLowerCase(); |
|
|
|
|
return uid; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
LogKit.error("龙光IDM集成登录获取用户名出错," + e.getMessage(), e); |
|
|
|
|
LogKit.error("集成登录获取用户名出错," + e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
@ -469,7 +466,7 @@ public class SessionGlobalRequestFilterProvider extends AbstractGlobalRequestFil
|
|
|
|
|
// continue;
|
|
|
|
|
//}
|
|
|
|
|
paraValues = entry.getValue(); |
|
|
|
|
LogKit.info("龙光IDM集成登录,获取用户信息请求出错,login_name为空"); |
|
|
|
|
LogKit.info("集成登录,获取用户信息请求出错,login_name为空"); |
|
|
|
|
queryStr = addParaToQuery(queryStr, paraName, paraValues); |
|
|
|
|
} |
|
|
|
|
if (StringKit.isEmpty(queryStr)) { |
|
|
|
|