Search in sources :

Example 1 with CodeGenerationException

use of dev.samstevens.totp.exceptions.CodeGenerationException in project CzechIdMng by bcvsolutions.

the class DefaultTwoFactorAuthenticationManager method generateCode.

@Override
public GuardedString generateCode(GuardedString verificationSecret) {
    Assert.notNull(verificationSecret, "Verification secret is required.");
    // 
    long currentBucket = Math.floorDiv(timeProvider.getTime(), props.getTime().getPeriod());
    try {
        return new GuardedString(codeGenerator.generate(verificationSecret.asString(), currentBucket));
    } catch (CodeGenerationException ex) {
        throw new ResultCodeException(CoreResultCode.TWO_FACTOR_GENERATE_CODE_FAILED, ex);
    }
}
Also used : CodeGenerationException(dev.samstevens.totp.exceptions.CodeGenerationException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString)

Aggregations

CodeGenerationException (dev.samstevens.totp.exceptions.CodeGenerationException)1 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1