diff --git a/JSD-8105-需求确认书V1.docx b/JSD-8105-需求确认书V1.docx
new file mode 100644
index 0000000..b4b1841
Binary files /dev/null and b/JSD-8105-需求确认书V1.docx differ
diff --git a/README.md b/README.md
index 67b2172..3744f13 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# open-JSD-8105
-JSD-8105 开源任务材料
\ No newline at end of file
+JSD-8105 开源任务材料\
+免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
+仅作为开发者学习参考使用!禁止用于任何商业用途!\
+为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。
\ No newline at end of file
diff --git a/lib/finekit-10.0.jar b/lib/finekit-10.0.jar
new file mode 100644
index 0000000..611c8f5
Binary files /dev/null and b/lib/finekit-10.0.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..3ef4733
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,18 @@
+
+
+ com.fr.plugin.third.party.jsd8105
+
+ yes
+ 0.2
+ 10.0
+ 2019-01-01
+ fr.open
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/Utils.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/Utils.java
new file mode 100644
index 0000000..268ebac
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/Utils.java
@@ -0,0 +1,134 @@
+package com.fr.plugin.third.party.jsdibaf;
+
+import com.fanruan.api.log.LogKit;
+import com.fanruan.api.util.StringKit;
+import com.fr.third.org.apache.http.HttpEntity;
+import com.fr.third.org.apache.http.HttpStatus;
+import com.fr.third.org.apache.http.client.config.RequestConfig;
+import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse;
+import com.fr.third.org.apache.http.client.methods.HttpGet;
+import com.fr.third.org.apache.http.client.methods.HttpPost;
+import com.fr.third.org.apache.http.conn.ssl.NoopHostnameVerifier;
+import com.fr.third.org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import com.fr.third.org.apache.http.entity.StringEntity;
+import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
+import com.fr.third.org.apache.http.impl.client.HttpClients;
+import com.fr.third.org.apache.http.ssl.SSLContextBuilder;
+import com.fr.third.org.apache.http.ssl.TrustStrategy;
+import com.fr.third.org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+public class Utils {
+ public static String DEFAULT_USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36";
+ public static RequestConfig REQUEST_CONFIG = RequestConfig.custom()
+ .setConnectionRequestTimeout(30000)
+ .setSocketTimeout(30000) // 服务端相应超时
+ .setConnectTimeout(30000) // 建立socket链接超时时间
+ .build();
+
+ public static CloseableHttpClient createSSLClientDefault() {
+ try {
+ SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
+
+ @Override
+ public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ return true;
+ }
+ }).build();
+ HostnameVerifier hostnameVerifier = NoopHostnameVerifier.INSTANCE;
+ SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
+ return HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ } catch (Exception e) {
+ LogKit.error(e.getMessage(), e);
+ }
+ return HttpClients.createDefault();
+ }
+
+ public static synchronized CloseableHttpClient createHttpClient(String url) {
+ CloseableHttpClient httpClient = null;
+ if (StringKit.isEmpty(url)) {
+ httpClient = HttpClients.createDefault();
+ return httpClient;
+ }
+
+ if (url.startsWith("https://")) {
+ httpClient = createSSLClientDefault();
+ return httpClient;
+ }
+ httpClient = HttpClients.createDefault();
+ return httpClient;
+ }
+
+ public static synchronized String createHttpGetContent(CloseableHttpClient httpClient, String url) throws IOException {
+ if ((httpClient == null) || (StringKit.isEmpty(url))) {
+ return "";
+ }
+
+ HttpGet httpGet = new HttpGet(url);
+ httpGet.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT);
+ httpGet.setConfig(Utils.REQUEST_CONFIG);
+ CloseableHttpResponse response = httpClient.execute(httpGet);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != HttpStatus.SC_OK) {
+ response.close();
+ LogKit.info("http请求出错,http status:" + statusCode);
+ return "";
+ }
+
+ HttpEntity httpEntity = response.getEntity();
+ if (httpEntity == null) {
+ response.close();
+ LogKit.info("http请求出错,http响应内容为空");
+ return "";
+ }
+ String responseContent = EntityUtils.toString(httpEntity, "UTF-8");
+ response.close();
+ if (StringKit.isEmpty(responseContent)) {
+ LogKit.info("http请求出错,http响应内容为空1");
+ return "";
+ }
+ return responseContent;
+ }
+
+ public static synchronized String createHttpPostContent(CloseableHttpClient httpClient, String url, String bodyContent) throws IOException {
+ if ((httpClient == null) || (StringKit.isEmpty(url)) || (StringKit.isEmpty(bodyContent))) {
+ return "";
+ }
+
+ HttpPost httpPost = new HttpPost(url);
+ httpPost.addHeader("User-Agent", Utils.DEFAULT_USER_AGENT);
+ httpPost.setConfig(Utils.REQUEST_CONFIG);
+ StringEntity bodyEntity = new StringEntity(bodyContent, "UTF-8");
+ httpPost.setEntity(bodyEntity);
+ CloseableHttpResponse response = httpClient.execute(httpPost);
+ int statusCode = response.getStatusLine().getStatusCode();
+ if (statusCode != HttpStatus.SC_OK) {
+ response.close();
+ LogKit.info("http请求出错,http status:" + statusCode);
+ return "";
+ }
+
+ HttpEntity httpEntity = response.getEntity();
+ if (httpEntity == null) {
+ response.close();
+ LogKit.info("http请求出错,http响应内容为空");
+ return "";
+ }
+ String responseContent = EntityUtils.toString(httpEntity, "UTF-8");
+ response.close();
+ if (StringKit.isEmpty(responseContent)) {
+ LogKit.info("http请求出错,http响应内容为空1");
+ return "";
+ }
+ return responseContent;
+ }
+
+
+
+
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/config/CustomDataConfig.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/config/CustomDataConfig.java
new file mode 100644
index 0000000..055a4da
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/config/CustomDataConfig.java
@@ -0,0 +1,48 @@
+package com.fr.plugin.third.party.jsdibaf.config;
+
+
+import com.fr.config.*;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+
+/**
+ * 配置数据保存
+ */
+@Visualization(category = "获取登录token配置")
+public class CustomDataConfig extends DefaultConfiguration {
+ public String getNameSpace() {
+ return this.getClass().getName();
+ }
+
+ private static volatile CustomDataConfig config = null;
+
+ public static CustomDataConfig getInstance() {
+ if (config == null) {
+ config = ConfigContext.getConfigInstance(CustomDataConfig.class);
+ }
+ return config;
+ }
+
+ @Identifier(value = "loginUserName", name = "用户名称参数", description = "", status = Status.SHOW)
+ private Conf loginUserName = Holders.simple("fine_username");
+
+
+
+
+ public String getLoginUserName() {
+ return loginUserName.get();
+ }
+
+ public void setLoginUserName(String loginUserName) {
+ this.loginUserName.set(loginUserName);
+ }
+
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ CustomDataConfig cloned = (CustomDataConfig) super.clone();
+ cloned.loginUserName = (Conf) loginUserName.clone();
+ //cloned.frUrl = (Conf) frUrl.clone();
+ return cloned;
+ }
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/config/DataConfigInitializeMonitor.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/config/DataConfigInitializeMonitor.java
new file mode 100644
index 0000000..f5704cb
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/config/DataConfigInitializeMonitor.java
@@ -0,0 +1,24 @@
+package com.fr.plugin.third.party.jsdibaf.config;
+
+import com.fr.intelli.record.Focus;
+import com.fr.intelli.record.Original;
+import com.fr.plugin.context.PluginContext;
+import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
+import com.fr.record.analyzer.EnableMetrics;
+
+/**
+ * 配置信息初始化
+ */
+@EnableMetrics
+public class DataConfigInitializeMonitor extends AbstractPluginLifecycleMonitor {
+ @Override
+ @Focus(id = "com.fr.plugin.third.party.jsd8105", text = "plugin-jsd-8105", source = Original.PLUGIN)
+ public void afterRun(PluginContext pluginContext) {
+ CustomDataConfig.getInstance();
+ }
+
+ @Override
+ public void beforeStop(PluginContext pluginContext) {
+
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/http/HttpHandlerProvider.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/HttpHandlerProvider.java
new file mode 100644
index 0000000..92f0c0e
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/HttpHandlerProvider.java
@@ -0,0 +1,13 @@
+package com.fr.plugin.third.party.jsdibaf.http;
+
+import com.fr.decision.fun.impl.AbstractHttpHandlerProvider;
+import com.fr.decision.fun.impl.BaseHttpHandler;
+
+public class HttpHandlerProvider extends AbstractHttpHandlerProvider {
+ @Override
+ public BaseHttpHandler[] registerHandlers() {
+ return new BaseHttpHandler[] {
+ new LoginTokenHttpHandler()
+ };
+ }
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/http/LoginTokenHttpHandler.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/LoginTokenHttpHandler.java
new file mode 100644
index 0000000..b6003e9
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/LoginTokenHttpHandler.java
@@ -0,0 +1,67 @@
+package com.fr.plugin.third.party.jsdibaf.http;
+
+import com.fanruan.api.util.StringKit;
+import com.fr.decision.authority.data.User;
+import com.fr.decision.fun.impl.BaseHttpHandler;
+import com.fr.decision.webservice.v10.login.LoginService;
+import com.fr.decision.webservice.v10.user.UserService;
+import com.fr.json.JSONObject;
+import com.fr.plugin.third.party.jsdibaf.config.CustomDataConfig;
+import com.fr.third.springframework.web.bind.annotation.RequestMethod;
+import com.fr.web.utils.WebUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class LoginTokenHttpHandler extends BaseHttpHandler {
+
+ @Override
+ public RequestMethod getMethod() {
+ return RequestMethod.GET;
+ }
+
+ @Override
+ public String getPath() {
+ return "/jsd8105/get/login/token";
+ }
+
+ @Override
+ public boolean isPublic() {
+ return true;
+ }
+
+ @Override
+ public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
+ JSONObject jsonContent = new JSONObject();
+ String loginUserName = WebUtils.getHTTPRequestParameter(req, CustomDataConfig.getInstance().getLoginUserName());
+ if (StringKit.isEmpty(loginUserName)) {
+ jsonContent.put("status", "failure");
+ jsonContent.put("msg", "用户名为空");
+ printAsJSON(res,jsonContent);
+ return;
+ }
+ User user = UserService.getInstance().getUserByUserName(loginUserName);
+ if (StringKit.isEmpty(loginUserName)) {
+ jsonContent.put("status", "failure");
+ jsonContent.put("msg", "用户名" + loginUserName + "在报表系统内不存在");
+ printAsJSON(res,jsonContent);
+ return;
+ }
+ if (!user.isEnable()) {
+ jsonContent.put("status", "failure");
+ jsonContent.put("msg", "用户名" + loginUserName + "在报表系统被禁用");
+ printAsJSON(res,jsonContent);
+ return;
+ }
+ String loginToken = LoginService.getInstance().login(req, res, loginUserName);
+ jsonContent.put("status", "success ");
+ jsonContent.put("token", loginToken);
+ printAsJSON(res,jsonContent);
+ }
+
+ private void printAsJSON(HttpServletResponse res, JSONObject json) throws Exception {
+ res.setContentType("application/json");
+ WebUtils.printAsJSON(res, json);
+ }
+
+}
diff --git a/src/main/java/com/fr/plugin/third/party/jsdibaf/http/URLAliasProvider.java b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/URLAliasProvider.java
new file mode 100644
index 0000000..60fca77
--- /dev/null
+++ b/src/main/java/com/fr/plugin/third/party/jsdibaf/http/URLAliasProvider.java
@@ -0,0 +1,14 @@
+package com.fr.plugin.third.party.jsdibaf.http;
+
+import com.fanruan.api.net.URLAliasKit;
+import com.fr.decision.fun.impl.AbstractURLAliasProvider;
+import com.fr.decision.webservice.url.alias.URLAlias;
+
+public class URLAliasProvider extends AbstractURLAliasProvider {
+ @Override
+ public URLAlias[] registerAlias() {
+ return new URLAlias[]{
+ URLAliasKit.createPluginAlias("/jsd8105/get/login/token", "/jsd8105/get/login/token", true),
+ };
+ }
+}
diff --git a/单点登录插件使用手册.docx b/单点登录插件使用手册.docx
new file mode 100644
index 0000000..1333e0f
Binary files /dev/null and b/单点登录插件使用手册.docx differ