You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
3 years ago
|
package com.fr.plugin.bsSSO.filter;
|
||
|
|
||
|
import com.fr.decision.fun.impl.AbstractEmbedRequestFilterProvider;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.bsSSO.bean.simple.account.PluginSimpleConfig;
|
||
|
import com.fr.plugin.bsSSO.utils.FRUtils;
|
||
|
import com.fr.plugin.bsSSO.utils.HttpUtils;
|
||
|
import com.fr.plugin.bsSSO.utils.Utils;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class LoginFilter extends AbstractEmbedRequestFilterProvider {
|
||
|
private static String awsServer = ""; //认证中心url
|
||
|
private static String accessKey = ""; //认证中心秘钥
|
||
|
|
||
|
static
|
||
|
{
|
||
|
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
|
||
|
awsServer = psc.getAwsServer();
|
||
|
accessKey = psc.getAccessKey();
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void filter(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException {
|
||
|
String tokenId = httpServletRequest.getParameter("tokenId");
|
||
|
|
||
|
if(!Utils.isNullStr(tokenId)){
|
||
|
FRUtils.FRLogInfo("SSO:tokenId:"+tokenId);
|
||
|
String tokenUrl = awsServer+"/r/jd?cmd=com.actionsoft.apps.addons.sso_validate&tokenId="+tokenId+"&access_key="+accessKey;
|
||
|
|
||
|
FRUtils.FRLogInfo("SSO:tokenUrl:"+tokenUrl);
|
||
|
|
||
|
String result = HttpUtils.HttpPost(tokenUrl);
|
||
|
|
||
|
if(!Utils.isNullStr(result)){
|
||
|
JSONObject jsonObject = new JSONObject(result);
|
||
|
|
||
|
JSONObject data = jsonObject.getJSONObject("data");
|
||
|
boolean validate = data.getBoolean("validate");
|
||
|
|
||
|
if(validate){
|
||
|
String uid = data.getString("uid");
|
||
|
FRUtils.FRLogInfo("SSO:uid:"+uid);
|
||
|
|
||
|
FRUtils.Login(httpServletRequest,httpServletResponse,uid,"");
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|