Class RecoveryCodeGenerator
java.lang.Object
com.iizix.totp.RecoveryCodeGenerator
Generates the recovery codes of a user with a second factor: the codes that sign the user in when the authenticator app is lost. Each code is used once. The codes are shown to the user once, when they are generated, and only a hash of each is kept (SignIn L-6).
Until SignIn L-6 this class and its method were package-private, so nothing outside com.iizix.totp could call them, and nothing did.
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of characters of a recovery code without its dashes: 16.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic String[]generateCodes(int amount) Generates recovery codes in a certain amount.static StringBrings a recovery code as a user typed it to the form it is hashed in: the dashes and all whitespace are removed and the letters are made upper case, so that4ckn xspn-et8t xgr0and4CKN-XSPN-ET8T-XGR0are the same code.
Field Details
LENGTH
public static final int LENGTHThe number of characters of a recovery code without its dashes: 16.- See Also:
Constructor Details
RecoveryCodeGenerator
public RecoveryCodeGenerator()
Method Details
generateCodes
Generates recovery codes in a certain amount.- Parameters:
amount- The amount of recovery codes.- Returns:
- The array of recovery codes.
normalize
Brings a recovery code as a user typed it to the form it is hashed in: the dashes and all whitespace are removed and the letters are made upper case, so that4ckn xspn-et8t xgr0and4CKN-XSPN-ET8T-XGR0are the same code.- Parameters:
typed- The code as typed,nullfor none.- Returns:
- The
LENGTHcharacters of the code, ornullwhen what was typed is not a recovery code: another length, or a character no code is made of.