|
|
|
@ -8,23 +8,23 @@ import me.impy.aegis.encoding.Base32;
|
|
|
|
|
|
|
|
|
|
public class KeyInfo implements Serializable {
|
|
|
|
|
private String type;
|
|
|
|
|
private String label;
|
|
|
|
|
private byte[] secret;
|
|
|
|
|
private String accountName;
|
|
|
|
|
private String issuer;
|
|
|
|
|
private long counter;
|
|
|
|
|
private String algorithm = "HmacSHA1";
|
|
|
|
|
private int digits = 6;
|
|
|
|
|
private long counter;
|
|
|
|
|
private int period = 30;
|
|
|
|
|
|
|
|
|
|
public String getType() {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
public String getLabel() {
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
public byte[] getSecret() {
|
|
|
|
|
return secret;
|
|
|
|
|
}
|
|
|
|
|
public String getAccountName() {
|
|
|
|
|
return accountName;
|
|
|
|
|
}
|
|
|
|
|
public String getIssuer() {
|
|
|
|
|
return issuer;
|
|
|
|
|
}
|
|
|
|
@ -65,11 +65,28 @@ public class KeyInfo implements Serializable {
|
|
|
|
|
info.secret = Base32.decode(secret);
|
|
|
|
|
|
|
|
|
|
// provider info used to disambiguate accounts
|
|
|
|
|
// these parameters are not required but I don't want them to be null either
|
|
|
|
|
String path = url.getPath();
|
|
|
|
|
String label = path != null ? path.substring(1) : "";
|
|
|
|
|
|
|
|
|
|
if (label.contains(":")) {
|
|
|
|
|
// a label can only contain one colon
|
|
|
|
|
// it's ok to fail if that's not the case
|
|
|
|
|
String[] strings = label.split(":");
|
|
|
|
|
|
|
|
|
|
if (strings.length == 2) {
|
|
|
|
|
info.issuer = strings[0];
|
|
|
|
|
info.accountName = strings[1];
|
|
|
|
|
} else {
|
|
|
|
|
// at this point, just dump the whole thing into the accountName
|
|
|
|
|
info.accountName = label;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// label only contains the account name
|
|
|
|
|
// grab the issuer's info from the 'issuer' parameter if it's present
|
|
|
|
|
String issuer = url.getQueryParameter("issuer");
|
|
|
|
|
String label = url.getPath();
|
|
|
|
|
info.issuer = issuer != null ? issuer : "";
|
|
|
|
|
info.label = label != null ? label.substring(1) : "";
|
|
|
|
|
info.accountName = label;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// just use the defaults if these parameters aren't set
|
|
|
|
|
String algorithm = url.getQueryParameter("algorithm");
|
|
|
|
|