token-import: introduce parcelable SecurityTokenInfo
This commit is contained in:
@@ -956,6 +956,25 @@ public class SecurityTokenHelper {
|
||||
return mOpenPgpCapabilities;
|
||||
}
|
||||
|
||||
public SecurityTokenInfo getTokenInfo() throws IOException {
|
||||
byte[] fingerprints = getFingerprints();
|
||||
|
||||
byte[] fpSign = new byte[20];
|
||||
byte[] fpDecrypt = new byte[20];
|
||||
byte[] fpAuth = new byte[20];
|
||||
ByteBuffer buf = ByteBuffer.wrap(fingerprints);
|
||||
buf.get(fpSign);
|
||||
buf.get(fpDecrypt);
|
||||
buf.get(fpAuth);
|
||||
|
||||
byte[] aid = getAid();
|
||||
String userId = getUserId();
|
||||
String url = getUrl();
|
||||
byte[] pwInfo = getPwStatusBytes();
|
||||
|
||||
return SecurityTokenInfo.create(fpSign, fpDecrypt, fpAuth, aid, userId, url, pwInfo[4], pwInfo[6]);
|
||||
}
|
||||
|
||||
private static class LazyHolder {
|
||||
private static final SecurityTokenHelper SECURITY_TOKEN_HELPER = new SecurityTokenHelper();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.sufficientlysecure.keychain.securitytoken;
|
||||
|
||||
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
|
||||
@AutoValue
|
||||
public abstract class SecurityTokenInfo implements Parcelable {
|
||||
@Nullable
|
||||
public abstract byte[] getFingerprintSign();
|
||||
@Nullable
|
||||
public abstract byte[] getFingerprintDecrypt();
|
||||
@Nullable
|
||||
public abstract byte[] getFingerprintAuth();
|
||||
@Nullable
|
||||
public abstract byte[] getAid();
|
||||
@Nullable
|
||||
public abstract String getUserId();
|
||||
@Nullable
|
||||
public abstract String getUrl();
|
||||
public abstract int getVerifyRetries();
|
||||
public abstract int getVerifyAdminRetries();
|
||||
|
||||
public byte[][] getAllFingerprints() {
|
||||
byte[][] fingerprints = new byte[3][];
|
||||
fingerprints[0] = getFingerprintSign();
|
||||
fingerprints[1] = getFingerprintDecrypt();
|
||||
fingerprints[2] = getFingerprintAuth();
|
||||
return fingerprints;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getFingerprintSign() == null && getFingerprintDecrypt() == null && getFingerprintAuth() == null;
|
||||
}
|
||||
|
||||
public static SecurityTokenInfo create(byte[] fpSign, byte[] fpDecrypt, byte[] fpAuth,
|
||||
byte[] aid, String userId, String url, int verifyRetries, int verifyAdminRetries) {
|
||||
return new AutoValue_SecurityTokenInfo(fpSign, fpDecrypt, fpAuth, aid,
|
||||
userId, url, verifyRetries, verifyAdminRetries);
|
||||
}
|
||||
|
||||
public static SecurityTokenInfo createBlank(byte[] aid) {
|
||||
return new AutoValue_SecurityTokenInfo(null, null, null, aid, null, null, 0, 0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user