From ffd51ee55a330455f40c277dd0e8bcc6222ac521 Mon Sep 17 00:00:00 2001 From: xioayue Date: Wed, 29 Jun 2022 23:42:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AF=81=E4=B9=A6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=AF=86=E9=92=A5=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/chjyj/szwh/constant/ChConstant.java | 2 +- .../java/cn/chjyj/szwh/JwtRsaTokenTests.java | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/test/java/cn/chjyj/szwh/JwtRsaTokenTests.java diff --git a/src/main/java/cn/chjyj/szwh/constant/ChConstant.java b/src/main/java/cn/chjyj/szwh/constant/ChConstant.java index dd21219..37acbe0 100644 --- a/src/main/java/cn/chjyj/szwh/constant/ChConstant.java +++ b/src/main/java/cn/chjyj/szwh/constant/ChConstant.java @@ -14,7 +14,7 @@ public class ChConstant { public static final String DB_CONF = "/conf/db.properties"; // 其他配置 - public static final String SZWH_CONF="/conf/cert"; + public static final String SZWH_CONF="/conf/szwh.properties"; //用户认证token密钥 public static final String USER_PEM="user_real"; diff --git a/src/test/java/cn/chjyj/szwh/JwtRsaTokenTests.java b/src/test/java/cn/chjyj/szwh/JwtRsaTokenTests.java new file mode 100644 index 0000000..171b1a0 --- /dev/null +++ b/src/test/java/cn/chjyj/szwh/JwtRsaTokenTests.java @@ -0,0 +1,38 @@ +package cn.chjyj.szwh; + +import cn.chjyj.szwh.constant.ChConstant; +import cn.chjyj.szwh.utils.SzFileUtils; +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import java.io.File; +import java.io.FileReader; +import java.util.Properties; + +/** + * jwt token 测试 + */ +@SpringBootTest +public class JwtRsaTokenTests { + + /** + * 委托系统token测试 + */ + @Test + public void entrTokenTest(){ + // 资源文件 + String dbconf = ChConstant.WORK_DIR + ChConstant.SZWH_CONF; + Properties prop = new Properties(); + try { + prop.load(new FileReader(dbconf)); + // 委托系统 密钥 + String entr_prikey=prop.getProperty("entrust.pem.prikey.path");//私钥路径 + // 私钥 + String prinote = SzFileUtils.getKeyFromFile(ChConstant.WORK_DIR + "/" + entr_prikey); + System.out.println("文件内容"+prinote); + }catch (Exception ex){ + ex.printStackTrace(); + } + + } +}