public class PasscodeGenerator extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
INTERVAL
Default time interval
|
| Constructor and Description |
|---|
PasscodeGenerator(Mac mac) |
PasscodeGenerator(Mac mac,
int passCodeLength) |
PasscodeGenerator(com.predic8.membrane.core.interceptor.authentication.session.totp.PasscodeGenerator.Signer signer) |
PasscodeGenerator(com.predic8.membrane.core.interceptor.authentication.session.totp.PasscodeGenerator.Signer signer,
int passCodeLength) |
| Modifier and Type | Method and Description |
|---|---|
String |
generateResponseCode(byte[] challenge) |
String |
generateResponseCode(long state) |
String |
generateResponseCode(long state,
byte[] challenge) |
boolean |
verifyResponseCode(long challenge,
String response) |
boolean |
verifyTimeoutCode(long currentInterval,
String timeoutCode)
Verify a timeout code.
|
boolean |
verifyTimeoutCode(String timeoutCode,
long currentInterval,
int pastIntervals,
int futureIntervals)
Verify a timeout code.
|
public static final int INTERVAL
public PasscodeGenerator(Mac mac)
mac - A Mac used to generate passcodespublic PasscodeGenerator(com.predic8.membrane.core.interceptor.authentication.session.totp.PasscodeGenerator.Signer signer)
public PasscodeGenerator(Mac mac, int passCodeLength)
mac - A Mac used to generate passcodespassCodeLength - The length of the decimal passcodepublic PasscodeGenerator(com.predic8.membrane.core.interceptor.authentication.session.totp.PasscodeGenerator.Signer signer,
int passCodeLength)
public String generateResponseCode(long state) throws GeneralSecurityException
state - 8-byte integer value representing internal OTP state.GeneralSecurityException - If a JCE exception occurpublic String generateResponseCode(long state, byte[] challenge) throws GeneralSecurityException
state - 8-byte integer value representing internal OTP state.challenge - Optional challenge as array of bytes.GeneralSecurityException - If a JCE exception occurpublic String generateResponseCode(byte[] challenge) throws GeneralSecurityException
challenge - An arbitrary byte array used as a challengeGeneralSecurityException - If a JCE exception occurpublic boolean verifyResponseCode(long challenge,
String response)
throws GeneralSecurityException
challenge - A challenge to check a response againstresponse - A response to verifyGeneralSecurityExceptionpublic boolean verifyTimeoutCode(long currentInterval,
String timeoutCode)
throws GeneralSecurityException
timeoutCode - The timeout codeGeneralSecurityExceptionpublic boolean verifyTimeoutCode(String timeoutCode, long currentInterval, int pastIntervals, int futureIntervals) throws GeneralSecurityException
timeoutCode - The timeout codepastIntervals - The number of past intervals to checkfutureIntervals - The number of future intervals to checkGeneralSecurityExceptionCopyright © 2019. All Rights Reserved.