public class CredentialData
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_DIGITS |
static int |
DEFAULT_PERIOD |
| Constructor and Description |
|---|
CredentialData(java.lang.String name,
OathType oathType,
HashAlgorithm hashAlgorithm,
byte[] secret,
int digits,
int period,
int counter,
java.lang.String issuer)
Creates instance of
Credential |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object o) |
int |
getCounter()
Initial counter (for HOTP) , default is 0
|
int |
getDigits()
Number of digits that going to be used for code (value: 6,7 or 8)
|
HashAlgorithm |
getHashAlgorithm()
Hash algorithm
HashAlgorithm |
byte[] |
getId()
Gets name of credential that used as unique identifier
|
java.lang.String |
getIssuer()
Name of credential issuer (e.g.
|
java.lang.String |
getName()
Get the name of the credential, typically a username.
|
OathType |
getOathType()
Oath type
OathType |
int |
getPeriod()
Period in seconds for how long code is valid from its calculation/generation time
|
byte[] |
getSecret()
Secret that is going to be hashed with hashAlgorithm
|
int |
hashCode() |
boolean |
isTouchRequired() |
static CredentialData |
parseUri(android.net.Uri uri)
Parse credential properties from an otpauth:// URI, as specified by
https://github.com/google/google-authenticator/wiki/Key-Uri-Format
Format example: otpauth://totp/Example:alice@google.com?secret=JBSWY3DPEHPK3PXP&issuer=Example
|
void |
setIssuer(java.lang.String issuer)
Set the issuer for the Credential, typically the name of the service.
|
void |
setName(java.lang.String name)
Set the name of the Credential, typically a username.
|
void |
setTouchRequired(boolean touchRequired)
Sets flag that credential requires touch.
|
public static final int DEFAULT_PERIOD
public static final int DEFAULT_DIGITS
public CredentialData(java.lang.String name,
OathType oathType,
HashAlgorithm hashAlgorithm,
byte[] secret,
int digits,
int period,
int counter,
java.lang.String issuer)
Credentialname - the name/labeloathType - TOTP or HOTPhashAlgorithm - SHA1, SHA265 or SHA 512secret - the key datadigits - the number of digits in OATH codeperiod - the period in seconds how long TOTP is validcounter - Imf for HOTPissuer - issuer namepublic static CredentialData parseUri(android.net.Uri uri) throws ParseUriException
uri - Uri that received from QR reader or manually from server that requires TOTP/HOTPParseUriException - in case if Uri format is incorrectpublic void setIssuer(java.lang.String issuer)
issuer - the name of the issuer.public void setName(java.lang.String name)
name - the name of the Credential.public void setTouchRequired(boolean touchRequired)
touchRequired - true if requires touch, default is falsepublic java.lang.String getName()
public byte[] getId()
public HashAlgorithm getHashAlgorithm()
HashAlgorithmpublic byte[] getSecret()
public java.lang.String getIssuer()
public int getDigits()
public int getPeriod()
public int getCounter()
public boolean isTouchRequired()
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object