mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-10-04 19:42:01 +08:00
add:根据name(传入String)获取Identity;设置默认Identity(不带密码的)
This commit is contained in:
1 parent
d117f5359b
commit
d93a7af653
3 files changed
+77
-1
No files matched your search
@@ -88,7 +88,6 @@ public class IdentityManager {
|
||||
|
||||
/**
|
||||
* 从sqlite中加载全部网络身份信息并封装成identifies与versionMap
|
||||
* @return {ConcurrentMap}
|
||||
* @throws Exception
|
||||
*/
|
||||
private void loadAllIdentifies() throws Exception{
|
||||
@@ -260,6 +259,7 @@ public class IdentityManager {
|
||||
Persist.setDefaultIdentityByNameInStorage(identity.getName());
|
||||
// 数据库设置成功后再设置内存中数据
|
||||
this.defaultIdentity = identity;
|
||||
this.version += 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,49 @@ public class KeyChain {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置默认的的网络身份,不带密码
|
||||
* @param identity 身份对象
|
||||
* @return boolean
|
||||
* @author zhengqi wu
|
||||
* @date 2021/6/12
|
||||
**/
|
||||
public void setDefaultIdentity(Identity identity) throws KeyChainException {
|
||||
boolean res = false;
|
||||
try {
|
||||
res = this.identityManager.setDefaultIdentity(identity, true); // 操作修改到数据库中
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new KeyChainException("Set Default Identity Failed! " + e.getMessage());
|
||||
}
|
||||
|
||||
if (!res)
|
||||
{
|
||||
throw new KeyChainException("Maybe the identity is null.");
|
||||
}
|
||||
this.currentIdentity = identity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以身份名称字符串名称获取身份对象,查询不到返回为空
|
||||
* @param identityName 身份名称字符串
|
||||
* @return Identity 身份对象
|
||||
* @author zhengqi wu
|
||||
* @date 2021/6/12
|
||||
**/
|
||||
public Identity getIdentityByName(String identityName) throws KeyChainException {
|
||||
Identity res = null;
|
||||
try {
|
||||
res = this.identityManager.getIdentityByName(identityName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new KeyChainException("Get" + identityName + " failed! " + e.getMessage());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为一个网络身份申请证书
|
||||
* @param identity
|
||||
|
||||
Reference in new issue
Block a user