commit 7ea9b7966c3e3a07f2266d410f1f43bff933127c Author: Afly Date: Mon Oct 11 09:40:58 2021 +0800 DEC-20904 feat: token扩展接口 diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..a851177 --- /dev/null +++ b/build.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/encrypt.xml b/encrypt.xml new file mode 100644 index 0000000..1401cd1 --- /dev/null +++ b/encrypt.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ 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..6b626db 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..2af42b2 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,16 @@ + + + com.fr.plugin.demo.custom.login + + yes + no + 1.0.0 + 10.0~10.0 + 2021-09-09 + Afly + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ec3d9b8 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + + plugin + com.fr.maven + 10.0 + + 4.0.0 + + demo-custom-token + + + com.fanruan.api + finekit + 10.0 + system + ${project.basedir}/lib/finekit-10.0.jar + + + + + ${web-inf-path}/plugins/plugin-com.fr.plugin.demo.custom.token-0.0.1/classes + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/login/CustomTokenProcessor.java b/src/main/java/com/fr/plugin/login/CustomTokenProcessor.java new file mode 100644 index 0000000..5bba3e6 --- /dev/null +++ b/src/main/java/com/fr/plugin/login/CustomTokenProcessor.java @@ -0,0 +1,36 @@ +package com.fr.plugin.login; + +import com.fr.decision.fun.impl.AbstractLoginTokenProcessor; +import com.fr.decision.privilege.TransmissionTool; +import com.fr.plugin.transform.FunctionRecorder; +import com.fr.security.JwtUtils; + +import java.util.Map; + +/** + * @author Afly + * created on 2021-10-09 + */ +@FunctionRecorder +public class CustomTokenProcessor extends AbstractLoginTokenProcessor { + + @Override + public String generateToken(String username, Map extraInfo, long timeout) { + return JwtUtils.createDefaultJWT(TransmissionTool.defaultEncrypt(username), extraInfo, timeout); + } + + @Override + public String getUsername(String token) { + return TransmissionTool.decrypt(JwtUtils.parseJWT(token).getSubject()); + } + + @Override + public Map getExtraInfo(String token) { + return JwtUtils.parseJWT(token); + } + + @Override + public boolean checkTokenExpired(String token) { + return JwtUtils.checkJWTExpired(token); + } +}