From 71d6a1218326c668e54232953bf0c30bbd4ee05e Mon Sep 17 00:00:00 2001 From: free will <2647778488@qq.com> Date: Thu, 5 Aug 2021 15:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=AF=81=E4=B9=A6=E6=97=B6?= =?UTF-8?q?=E4=BC=9A=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=AF=BC=E5=85=A5=E8=AF=81=E4=B9=A6?= =?UTF-8?q?=E6=97=B6=E6=9C=89=E5=AF=86=E9=92=A5=EF=BC=8C=E9=82=A3=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E6=97=B6=E5=80=99=E5=8A=A0=E8=BD=BD=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=B9=9F=E8=A6=81=E5=AF=86=E7=A0=81=E7=9A=84=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/examples/VPNLoginExample.java | 10 +++++----- src/main/java/security/IdentityManager.java | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/examples/VPNLoginExample.java b/src/main/java/examples/VPNLoginExample.java index 636dd28..221bf29 100644 --- a/src/main/java/examples/VPNLoginExample.java +++ b/src/main/java/examples/VPNLoginExample.java @@ -31,7 +31,7 @@ public class VPNLoginExample { // 身份信息保存位置 public static String identityPath="D:\\TEST\\Identitys\\"; // 用户名 - public static String username="freesajgl111"; + public static String username="frwiwawuwh1"; // VMS发送来的证书的密码 public static byte[] certPasswd="123456".getBytes(StandardCharsets.UTF_8); // 基于用户名的用户身份标识 @@ -39,7 +39,7 @@ public class VPNLoginExample { // 注册用户的IP public static String vms_ip="121.15.171.91"; // 注册邮箱 - public static String email="25556272asjys111@163.com"; + public static String email="25wgjyggys111@163.com"; /** * 生成本地密钥,持久化存储到本地硬盘 @@ -234,9 +234,9 @@ public class VPNLoginExample { // 测试注册登录 public static void main(String[] args){ -// new VPNLoginExample().testRegister(); + new VPNLoginExample().testRegister(); // new VPNLoginExample().testLogin(); - VpnServerInfoListExample infoList = new VPNLoginExample().testGetVPNInfo(); - System.out.println(infoList); +// VpnServerInfoListExample infoList = new VPNLoginExample().testGetVPNInfo(); +// System.out.println(infoList); } } diff --git a/src/main/java/security/IdentityManager.java b/src/main/java/security/IdentityManager.java index 0953fb2..b432859 100644 --- a/src/main/java/security/IdentityManager.java +++ b/src/main/java/security/IdentityManager.java @@ -311,10 +311,10 @@ public class IdentityManager { * @author hongyu guo * @date 2021/5/21 **/ - public boolean loadCert(String identityName, Certificate cert) throws Exception { + public boolean loadCert(String identityName, Certificate cert,String passwd) throws Exception { if(existIdentity(identityName)) { // 已经存在 - Identity id = Persist.getIdentityByNameFromStorage(identityName, ""); + Identity id = Persist.getIdentityByNameFromStorage(identityName, passwd); if(id == null) throw new IdentifyManagerException("can not find identity by name [" + identityName + "] in sqlite"); Certificate oldCert = id.getCert(); @@ -338,6 +338,9 @@ public class IdentityManager { } return true; } + public boolean loadCert(String identityName, Certificate cert) throws Exception { + return loadCert(identityName,cert,""); + } /** * 使用指定的网络身份给自己签发一个自签证书 @@ -472,7 +475,7 @@ public class IdentityManager { public boolean importCert(byte[] bytesOfCert,byte[] passwd) throws Exception { Certificate cert = CertUtils.fromPem(new String(bytesOfCert), passwd, Common.SM4ECB); LoggerHelper.info("importing cert: "+cert.toString()); - return loadCert(cert.getIssueTo(), cert); + return loadCert(cert.getIssueTo(), cert,new String(passwd)); } public ConcurrentMap getIdentifies() {