use of eu.bcvsolutions.idm.core.security.api.domain.TwoFactorAuthenticationType in project CzechIdMng by bcvsolutions.
the class DefaultTwoFactorAuthenticationManager method requireTwoFactorAuthentication.
@Override
@Transactional
public boolean requireTwoFactorAuthentication(UUID identityId, UUID tokenId) {
// check two factor authentication is enabled
TwoFactorAuthenticationType twoFactorAuthenticationType = getTwoFactorAuthenticationType(identityId);
if (twoFactorAuthenticationType == null) {
return false;
}
//
IdmTokenDto token = tokenManager.getToken(tokenId);
if (token.isSecretVerified()) {
// token was already verified
return false;
}
//
if (TwoFactorAuthenticationType.NOTIFICATION == twoFactorAuthenticationType) {
IdmPasswordDto password = passwordService.findOneByIdentity(identityId);
if (password == null) {
throw new EntityNotFoundException(IdmIdentityDto.class, identityId);
}
sendVerificationCode(identityService.get(identityId), generateCode(new GuardedString(password.getVerificationSecret())));
}
//
return true;
}
Aggregations