add:根据name(传入String)获取Identity;设置默认Identity(不带密码的)

This commit is contained in:
ChessNineeee
2021-06-12 10:26:34 +08:00
parent d117f5359b
commit d93a7af653
3 changed files with 77 additions and 1 deletions
+43
View File
@@ -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