public final class OtpQRScanResult extends java.lang.Object implements IQRScanResult
OtpQRScanResult
handles one-time password data scanned from a QR code.Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<OtpQRScanResult> |
CREATOR |
Constructor and Description |
---|
OtpQRScanResult()
Returns an instance of a new
OtpQRScanResult object. |
OtpQRScanResult(java.util.Map<java.lang.String,java.lang.String> data)
Returns an instance of a new
OtpQRScanResult object. |
OtpQRScanResult(java.lang.String type,
java.lang.String issuer,
java.lang.String secret,
java.lang.String username,
HmacAlgorithm algorithm,
int digits,
int counter_or_period)
Returns an instance of a new
OtpQRScanResult object. |
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Returns a bitmask indicating the set of special object types marshaled by this Parcelable
object instance.
|
HmacAlgorithm |
getAlgorithm()
Returns the algorithm used to calculate the one-time password.
|
int |
getCounter()
Returns the counter that is required for use with
hotp . |
int |
getDigits()
Returns the length of the one-time password to be displayed.
|
java.lang.String |
getIssuer()
Returns the name of the issuer providing the service.
|
int |
getPeriod()
Returns the period a
totp code will be valid for, in seconds. |
java.lang.String |
getSecret()
Returns the secret value encoded in Base32.
|
java.lang.String |
getType()
Returns the type of the QR scanned.
|
java.lang.String |
getUsername()
Returns the username associated with the service.
|
OtpQRScanResult |
parse(java.lang.String value)
Parses the incoming data from the QR code.
|
void |
writeToParcel(android.os.Parcel dest,
int flags)
Writes the object into a parcel.
|
public static final android.os.Parcelable.Creator<OtpQRScanResult> CREATOR
public OtpQRScanResult()
OtpQRScanResult
object.public OtpQRScanResult(java.lang.String type, java.lang.String issuer, java.lang.String secret, java.lang.String username, HmacAlgorithm algorithm, int digits, int counter_or_period)
OtpQRScanResult
object.type
- the type of the QR scanned. Has to be either hotp
or totp
.
Otherwise, no value will be set.issuer
- the name of the issuer providing the servicesecret
- the secret value encoded in Base32username
- the user associated with the servicealgorithm
- the algorithm used to calculate the one-time password. the default is `HmacAlgorithm.SHA1`.digits
- the length of the one-time password to be displayed. The default is 6.counter_or_period
- the counter is required for use with HotpChallenge
.
It will set the initial counter value. The period is required to use with
TotpChallenge
. It represents the time, the code will be valid for.
The default value is 30.java.lang.IllegalArgumentException
- if any parameter is nulljava.security.InvalidParameterException
- if 'type' is neither 'hotp' nor 'totp'public OtpQRScanResult(java.util.Map<java.lang.String,java.lang.String> data)
OtpQRScanResult
object.data
- the hashmap of one-time passsord attributesjava.lang.IllegalArgumentException
- if parameter is nullpublic OtpQRScanResult parse(java.lang.String value)
parse
in interface IQRScanResult
value
- the incoming value from the QR code scanIQRScanResult
if parameter can be parsed, otherwise null.public java.lang.String getType()
hotp
or totp
.public java.lang.String getIssuer()
public java.lang.String getSecret()
public java.lang.String getUsername()
public HmacAlgorithm getAlgorithm()
HmacAlgorithm.SHA1
.public int getDigits()
public int getCounter()
hotp
. It will set the initial counter value.hotp
public int getPeriod()
totp
code will be valid for, in seconds. The default value is 30.totp
code will be valid for, in secondspublic int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
dest
- the parcel where the object is written intoflags
- flags about how the object should be written