mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add:Keychain
This commit is contained in:
1 parent
c43a9a3a1c
commit
d09398cacf
4 files changed
+170
-6
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package security;
|
||||
|
||||
import minsecurity.Common;
|
||||
import minsecurity.identity.Identity;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class KeyChainTest {
|
||||
@Test
|
||||
public void testCreateKeyChain(){
|
||||
try{
|
||||
KeyChain keyChain = new KeyChain();
|
||||
Identity identity = new Identity();
|
||||
identity.setName("wzq");
|
||||
identity.setPasswd("123456123456");
|
||||
|
||||
ConcurrentHashMap<String, Identity> identityHashMap = new ConcurrentHashMap<>();
|
||||
identityHashMap.put("/wzq", identity);
|
||||
|
||||
keyChain.getIdentifyManager().setIdentifies(identityHashMap);
|
||||
keyChain.getIdentifyManager().setDefaultIdentity(identity);
|
||||
|
||||
String passwd = "2DD29CA851E7B56E";
|
||||
Identity identity1 = keyChain.getIdentifyManager().createIdentityByName("/wzq1", passwd, false);
|
||||
identity1.unLock(passwd, Common.SM4ECB);
|
||||
System.out.println(identity1.getPrikey());
|
||||
}catch (Exception ex){
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user