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.
63 lines
1.9 KiB
63 lines
1.9 KiB
2 years ago
|
package com.eco.plugin.gfkdsso.logout;
|
||
|
|
||
|
import com.eco.plugin.gfkdsso.config.PluginSimpleConfig;
|
||
|
import com.eco.plugin.gfkdsso.utils.HttpUtils;
|
||
|
import com.eco.plugin.gfkdsso.utils.Utils;
|
||
|
import com.fr.decision.fun.impl.AbstractLogInOutEventProvider;
|
||
|
import com.fr.decision.webservice.login.LogInOutResultInfo;
|
||
|
import com.fr.decision.webservice.v10.login.LoginService;
|
||
|
import com.fr.json.JSONObject;
|
||
|
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpSession;
|
||
|
|
||
|
public class Logout extends AbstractLogInOutEventProvider {
|
||
|
|
||
|
@Override
|
||
|
public String logoutAction(LogInOutResultInfo result) {
|
||
|
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
|
||
|
HttpSession session = result.getRequest().getSession(true);
|
||
|
logout(result.getRequest(),psc);
|
||
|
LoginService.getInstance().crossDomainLogout(result.getRequest(),result.getResponse(),"");
|
||
|
session.invalidate();
|
||
|
return psc.getLogoutUrl();
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 登出
|
||
|
* @param req
|
||
|
* @param psc
|
||
|
*/
|
||
|
public void logout(HttpServletRequest req, PluginSimpleConfig psc) {
|
||
|
String token = String.valueOf(req.getSession(true).getAttribute("admin_token"));
|
||
|
|
||
|
if(Utils.isNullStr(token)){
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
String result = requestinfo(token,psc,psc.getLogoutserviceid());
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 发起请求
|
||
|
* @param token
|
||
|
* @param pluginSimpleConfig
|
||
|
* @param
|
||
|
* @return
|
||
|
*/
|
||
|
private String requestinfo(String token, PluginSimpleConfig pluginSimpleConfig, String serviceid) {
|
||
|
String url = pluginSimpleConfig.getSsoUrl();
|
||
|
JSONObject formParam = new JSONObject();
|
||
|
formParam.put("cookie",token);
|
||
|
|
||
|
JSONObject param = new JSONObject();
|
||
|
param.put("serviceId",serviceid);
|
||
|
param.put("method","GET");
|
||
|
param.put("dataType","form");
|
||
|
param.put("formParams",formParam);
|
||
|
|
||
|
return HttpUtils.HttpPostJson(url,param.toString(),null);
|
||
|
}
|
||
|
}
|
||
|
|