commit b48f6cd5e2f89aeb25ac38c6475b657fdf949f6a Author: Zed Date: Thu Feb 13 16:34:23 2020 +0800 提供demo diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..8033320 --- /dev/null +++ b/build.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..7040718 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,18 @@ + + + com.fr.plugin.decision.transmission.decrypt + + yes + 1.0 + 10.0 + 2020-02-01 + zed + + + ]]> + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..b04918e --- /dev/null +++ b/pom.xml @@ -0,0 +1,41 @@ + + + 4.0.0 + + + com.fr.decision + decision-feature + 10.0 + compile + + + com.fr.decision + decision-feature + 10.0 + compile + + + + com.fr.plugin + starter + 10.0 + + jar + decision.transmission.decrypt + + + ${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.decision.transmission.decrypt-1.0/classes + + + org.apache.maven.plugins + maven-compiler-plugin + + 6 + 6 + + + + + \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..f2b9c98 --- /dev/null +++ b/readme.md @@ -0,0 +1,8 @@ +# 平台私密信息传输自定义加解密 +前台向后台传递密码等私密信息时,需要经过可逆的加密算法进行加密处理,提高安全性 + +# 效果截图 +默认为AES加密 +![result](screenshots/result1.png) +安装插件之后变为Base64加密 +![result](screenshots/result2.png) diff --git a/screenshots/result1.png b/screenshots/result1.png new file mode 100644 index 0000000..41340fa Binary files /dev/null and b/screenshots/result1.png differ diff --git a/screenshots/result2.png b/screenshots/result2.png new file mode 100644 index 0000000..26c5e92 Binary files /dev/null and b/screenshots/result2.png differ diff --git a/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Component.java b/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Component.java new file mode 100644 index 0000000..aaf3c57 --- /dev/null +++ b/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Component.java @@ -0,0 +1,23 @@ +package com.fr.plugin.decision.transmission.decrypt; + +import com.fr.web.struct.Component; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ScriptPath; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/2/11 + */ +public class Base64Component extends Component { + + public static final Base64Component KEY = new Base64Component(); + + private Base64Component() { + } + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/plugin/decision/transmission/decrypt/plugin.js"); + } +} \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Decrypt.java b/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Decrypt.java new file mode 100644 index 0000000..57d8e15 --- /dev/null +++ b/src/main/java/com/fr/plugin/decision/transmission/decrypt/Base64Decrypt.java @@ -0,0 +1,43 @@ +package com.fr.plugin.decision.transmission.decrypt; + +import com.fr.base.Base64; +import com.fr.base.ServerConfig; +import com.fr.decision.fun.impl.AbstractTransmissionDecryptProvider; +import com.fr.decision.web.CommonComponent; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.stable.StringUtils; +import com.fr.web.struct.Atom; + +/** + * @author Zed + * @version 10.0 + * Created by Zed on 2020/2/11 + */ +@FunctionRecorder +public class Base64Decrypt extends AbstractTransmissionDecryptProvider { + + @Override + public String decrypt(String encryptionInfo) { + try { + if (StringUtils.isNotEmpty(encryptionInfo)) { + return new String(Base64.decode(encryptionInfo), ServerConfig.getInstance().getServerCharset()); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + + return StringUtils.EMPTY; + } + + @Override + public Atom attach() { + return CommonComponent.KEY; + } + + @Override + public Atom client() { + return Base64Component.KEY; + } + +} diff --git a/src/main/resources/.gitkeep b/src/main/resources/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fr/plugin/decision/transmission/decrypt/plugin.js b/src/main/resources/com/fr/plugin/decision/transmission/decrypt/plugin.js new file mode 100644 index 0000000..849dcc8 --- /dev/null +++ b/src/main/resources/com/fr/plugin/decision/transmission/decrypt/plugin.js @@ -0,0 +1,7 @@ +!(function () { + BI.config("dec.provider.cipher", function (provider) { + provider.encrypt(function (pwd) { + return BI.encode(pwd); + }); + }); +})(); \ No newline at end of file