commit 0107759d67bc9c3ca6633187899c0f31fda481a2 Author: pioneer Date: Mon Dec 12 15:40:52 2022 +0800 open diff --git a/README.md b/README.md new file mode 100644 index 0000000..9b636eb --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# open-JSD-10341 + +JSD-10341 客户移动端浏览器禁用了COOKIE,需要通过URL参数传递token实现登录效果\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..ffd0e3a --- /dev/null +++ b/plugin.xml @@ -0,0 +1,20 @@ + + com.eco.plugin.xx.njnrfilter + + yes + 1.0.7 + 10.0 + 2018-07-31 + fr.open + + + com.eco.plugin.xx.njnrfilter + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/eco/plugin/xx/njnrfilter/filter/SSOFilter.java b/src/main/java/com/eco/plugin/xx/njnrfilter/filter/SSOFilter.java new file mode 100644 index 0000000..84553d6 --- /dev/null +++ b/src/main/java/com/eco/plugin/xx/njnrfilter/filter/SSOFilter.java @@ -0,0 +1,111 @@ +package com.eco.plugin.xx.njnrfilter.filter; + +import com.eco.plugin.xx.njnrfilter.utils.FRUtils; +import com.eco.plugin.xx.njnrfilter.utils.Utils; +import com.fr.decision.fun.impl.AbstractGlobalRequestFilterProvider; +import com.fr.plugin.context.PluginContexts; +import com.fr.plugin.transform.FunctionRecorder; +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.xx.njnrfilter") +@FunctionRecorder +public class SSOFilter extends AbstractGlobalRequestFilterProvider { + @Override + public String filterName() { + return "njnrFilter"; + } + + @Override + public String[] urlPatterns() { + return new String[]{"/*"}; + } + + @Override + public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain ){ + + if(PluginContexts.currentContext().isAvailable()){ + FRUtils.FRLogInfo("url:"+FRUtils.getAllUrl(req)); + if(isRelease(req)){ + release(req,res,chain); + return ; + } + + //如果refer中有token + String refer = req.getHeader("Referer"); + FRUtils.FRLogInfo("refer:"+refer); + if(refer.contains("fine_auth_token")){ + String url = Utils.getRedirectUrl(req,""); + FRUtils.FRLogInfo("reqUrl:"+url); + //获取token + String token = ""; + String param = refer.split("\\?")[1]; + String[] params = param.split("&"); + for(int i=0;i parameterMap){ + if(parameterMap == null){ + parameterMap = new HashMap(); + } + + try { + String macPage = TemplateUtils.renderTemplate(path, parameterMap); + WebUtils.printAsString(res, macPage); + }catch (Exception e){ + FRUtils.FRLogError("跳转页面异常"); + } + + } + + /** + * 判断是否是管理员 + * @param username + * @return + */ + public static boolean isAdmin(String username) throws Exception{ + return UserService.getInstance().isAdmin(UserService.getInstance().getUserByUserName(username).getId()); + } + + /** + * 去掉浏览器中的参数 + * @param url + * @param param + * @return + */ + public static String removeParam(String url,String param){ + if(!url.contains("?"+param) && !url.contains("&"+param)){ + return url; + } + + return url.substring(0,url.indexOf(url.contains("?"+param) ? "?"+param : "&"+param)); + } + + /** + * 获取跳转链接 + * @param req + * @param param + * @return + */ + public static String getRedirectUrl(HttpServletRequest req,String param){ + String url = FRUtils.getAllUrl(req); + + if(isNotNullStr(param)){ + url = removeParam(url,param); + } + + url = encodeCH(url); + + return url; + } + + /** + * 去除空格换行 + * @param str + * @return + */ + public static String trim(String str){ + return str.trim().replaceAll("\n","").replaceAll("\r",""); + } + + /** + * list 转化为指定字符分割的字符串 + * @param list + * @param list + * @return + */ + public static String listToStr(List list, String split){ + String result = ""; + + if(list == null || list.size() <= 0){ + return result; + } + + for(String str : list){ + result+=","+str; + } + + result = result.substring(1); + + return result; + } + + /** + * array 转化为指定字符分割的字符串 + * @param list + * @param list + * @return + */ + public static String arrayToStr(String[] list, String split){ + String result = ""; + + if(list == null ||list.length <= 0){ + return result; + } + + for(int i=0;i