Browse Source

测试证书获取密钥内容

master
xyiege 4 years ago
parent
commit
ffd51ee55a
  1. 2
      src/main/java/cn/chjyj/szwh/constant/ChConstant.java
  2. 38
      src/test/java/cn/chjyj/szwh/JwtRsaTokenTests.java

2
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";

38
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();
}
}
}
Loading…
Cancel
Save