使用mapDB持久化identity(50%)

This commit is contained in:
ghy committed 2021-03-09 22:00:57 +08:00
1 parent 9827414ac5
commit f693a7a120
5 files changed
+194 -4

No files matched your search

@@ -20,6 +20,7 @@ import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.io.IOException;
import java.io.Serializable;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@@ -43,10 +44,12 @@ public class Identity {
private PublicKeyInterface Pubkey;
private String Passwd;
private Certificate Cert;
private boolean IsDefault;
public Identity(String name, KeyParam keyParam,
PrivateKeyInterface prikey, byte[] prikeyRawByte,
PublicKeyInterface pubkey, String passwd, Certificate cert) {
PublicKeyInterface pubkey, String passwd, Certificate cert,
boolean isDefault) {
Name = name;
KeyParam = keyParam;
Prikey = prikey;
@@ -54,6 +57,7 @@ public class Identity {
Pubkey = pubkey;
Passwd = passwd;
Cert = cert;
IsDefault = isDefault;
}
@@ -240,16 +244,27 @@ public class Identity {
Cert = cert;
}
public boolean isDefault() {
return IsDefault;
}
public void setDefault(boolean aDefault) {
IsDefault = aDefault;
}
@Override
public String toString() {
return "Identity{" +
"Name='" + Name + '\'' +
", KeyParam=" + KeyParam +
", Prikey=" + Prikey +
", KeyParam.signAlgo=" + KeyParam.SignatureAlgorithm +
", KeyParam.pubAlgo=" + KeyParam.PublicKeyAlgorithm +
", Prikey=" + ByteUtils.toHexString(Prikey.getBytes()) +
", pubKey=" + ByteUtils.toHexString(Pubkey.getBytes()) +
", PrikeyRawByte=" + (PrikeyRawByte == null ? "null":ByteUtils.toHexString(PrikeyRawByte)) +
", Pubkey=" + Pubkey +
", Passwd='" + Passwd + '\'' +
", Cert=" + Cert +
", isDefault=" + IsDefault +
'}';
}
}