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.
69 lines
2.1 KiB
69 lines
2.1 KiB
3 years ago
|
package com.eco.plugin.xxx.bwjtsso.filter;
|
||
|
|
||
|
import com.eco.plugin.xxx.bwjtsso.config.PluginSimpleConfig;
|
||
|
import com.eco.plugin.xxx.bwjtsso.utils.AesUtils;
|
||
|
import com.eco.plugin.xxx.bwjtsso.utils.FRUtils;
|
||
|
import com.eco.plugin.xxx.bwjtsso.utils.ResponseUtils;
|
||
|
import com.eco.plugin.xxx.bwjtsso.utils.Utils;
|
||
|
import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider;
|
||
|
import com.fr.json.JSONObject;
|
||
|
import com.fr.plugin.context.PluginContexts;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.stable.fun.Authorize;
|
||
|
import javax.servlet.FilterChain;
|
||
|
import javax.servlet.http.HttpServletRequest;
|
||
|
import javax.servlet.http.HttpServletResponse;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
@EnableMetrics
|
||
|
@Authorize(callSignKey = "com.eco.plugin.xxx.bwjtsso")
|
||
|
public class SSOFilter extends AbstractGlobalRequestFilterProvider {
|
||
|
@Override
|
||
|
public String filterName() {
|
||
|
return "bwjtssoFilter";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String[] urlPatterns() {
|
||
|
return new String[]{"/*"};
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain ){
|
||
|
|
||
|
if(PluginContexts.currentContext().isAvailable()){
|
||
|
PluginSimpleConfig psc = PluginSimpleConfig.getInstance();
|
||
|
String param = psc.getParam();
|
||
|
String userid = req.getParameter(param);
|
||
|
|
||
|
if(Utils.isNullStr(userid)){
|
||
|
release(req,res,chain);
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
String key = psc.getKey();
|
||
|
String username = AesUtils.decrypt(userid,key);
|
||
|
|
||
|
if(Utils.isNullStr(username)){
|
||
|
ResponseUtils.failedResponse(res,"解析token失败!");
|
||
|
return ;
|
||
|
}
|
||
|
|
||
|
FRUtils.login(req,res,username,Utils.removeParam(FRUtils.getAllUrl(req),param));
|
||
|
}
|
||
|
|
||
|
release(req,res,chain);
|
||
|
}
|
||
|
|
||
|
|
||
|
//放行拦截器
|
||
|
private void release(HttpServletRequest req, HttpServletResponse res, FilterChain chain) {
|
||
|
try{
|
||
|
chain.doFilter(req,res);
|
||
|
}catch (Exception e){
|
||
|
FRUtils.FRLogInfo("拦截失败");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|