mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 07:10:25 +08:00
fix:Keychain无法签名验签的问题(IdentifierComponent.toUri()使用百分号编码导致),使用临时方法代替,具体解决方法待更新。
This commit is contained in:
@@ -216,6 +216,19 @@ public class Identifier implements TlvComponentBase, IEncodingAble {
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回字符串,不使用IdentifierComponent百分号编码
|
||||
* 临时使用,等待后续keychain更新
|
||||
* @return
|
||||
*/
|
||||
public String toUriTemp() throws ComponentException {
|
||||
String res = "";
|
||||
for (int i = 0; i < components.length(); i++) {
|
||||
res += components.getElement(i).toUriTemp();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
try {
|
||||
String res = "";
|
||||
|
||||
@@ -355,6 +355,22 @@ public class IdentifierComponent implements TlvComponentBase, IEncodingAble {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接返回字符串,不使用百分号编码
|
||||
* 临时使用,等待后续keychain更新
|
||||
* @return
|
||||
*/
|
||||
public String toUriTemp() {
|
||||
if (isString()) {
|
||||
return this.stringValue;
|
||||
} else if(isByteArray()){
|
||||
return StringHelper.escape(new String(this.byteArrayValue));
|
||||
}else{
|
||||
// todo: 需要对long类型按照指定编码规则编码成字符串
|
||||
return Long.valueOf(this.intValue).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* marker加上标识中的内容转换成的字符串数据
|
||||
* @return
|
||||
|
||||
@@ -79,6 +79,7 @@ public class IdentityManager {
|
||||
this.identifies = loadAllIdentifies();
|
||||
this.defaultIdentity = Persist.getDefaultIdentityFromStorage("");
|
||||
this.privateKeyEncryptionAlgorithm = Common.SM4ECB;
|
||||
this.versionMap = new ConcurrentHashMap<>(); // TODO versionMap初始化方式待定
|
||||
}catch (Exception ex){
|
||||
System.out.println(String.format("创建IdentifyManager实例失败:%s", ex.getMessage()));
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class KeyChain {
|
||||
// 提取签名区的第一个签名进行验证(认为签名区的第一个签名为包的签名,包含标识区和只读区签名)
|
||||
Signature signature = minPacket.signatureField.getSignature(0);
|
||||
|
||||
String identityName = signature.getSigInfo().getKeyLocator().getIdentifier().toUri();
|
||||
String identityName = signature.getSigInfo().getKeyLocator().getIdentifier().toUriTemp();
|
||||
Identity identity = this.identityManager.getIdentityByName(identityName);
|
||||
|
||||
if (identity == null){
|
||||
|
||||
@@ -107,7 +107,8 @@ public class KeyChainTest {
|
||||
// 测试设置新身份为当前身份
|
||||
KeyChain keyChain = new KeyChain();
|
||||
Identity id = createRandomIdentity();
|
||||
// keyChain.getIdentifyManager().setDefaultIdentity(id, true);
|
||||
IdentityManager idm = keyChain.getIdentifyManager();
|
||||
idm.setDefaultIdentity(id, true);
|
||||
// // 输入密码用于解锁身份
|
||||
// keyChain.setCurrentIdentity(keyChain.getIdentifyManager().getDefaultIdentity(), "0123456789abcdef");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user