From 3624fec540a4476f84f6d4db04b1b7cffc42ac19 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 1 Apr 2019 11:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=88=B0demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.xml | 2 - .../signature/SignatureGenerator.java | 46 ------------------- 2 files changed, 48 deletions(-) delete mode 100644 src/main/java/com/fr/security/function/signature/SignatureGenerator.java diff --git a/plugin.xml b/plugin.xml index 1f12bdd..fc4a535 100755 --- a/plugin.xml +++ b/plugin.xml @@ -10,13 +10,11 @@ richie [2019-01-12]初始化插件。
]]>
- diff --git a/src/main/java/com/fr/security/function/signature/SignatureGenerator.java b/src/main/java/com/fr/security/function/signature/SignatureGenerator.java deleted file mode 100644 index fd79e3e..0000000 --- a/src/main/java/com/fr/security/function/signature/SignatureGenerator.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.fr.security.function.signature; - -import com.fr.cert.token.JwtBuilder; -import com.fr.cert.token.Jwts; -import com.fr.cert.token.SignatureAlgorithm; -import com.fr.general.GeneralUtils; -import com.fr.script.AbstractFunction; -import com.fr.security.function.conf.RemoteEvalConfig; -import com.fr.stable.ArrayUtils; -import com.fr.stable.Primitive; - -import java.util.Date; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2019-01-14 - */ -public class SignatureGenerator extends AbstractFunction { - - private static final long VALIDATE_TIME = 10 * 60 * 1000; - @Override - public Object run(Object[] args) { - if (ArrayUtils.isEmpty(args)) { - return Primitive.NULL; - } - return createJwt(GeneralUtils.objectToString(args[0]), RemoteEvalConfig.getInstance().getSignatureText()); - } - - private String createJwt(String subject, String key) { - SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; - Date currentTime = new Date(); - Date expirationTime = new Date(currentTime.getTime() + VALIDATE_TIME); - JwtBuilder builder = Jwts.builder() - .setSubject(subject) - .setIssuedAt(currentTime) - .setExpiration(expirationTime) - .signWith(signatureAlgorithm, key); - return builder.compact(); - } - - public static void main(String... args) { - SignatureGenerator generator = new SignatureGenerator(); - System.out.println(generator.createJwt("/习题9.cpt", "GhzUsb4fmGwmSk57d3uBZ9jVFCRgZ9CVMT3WoomMHi4=")); - } -}