private boolean validate_otps ( List < String > otps , NameCallback nameCb ) throws LoginException { boolean validated = false ; for ( String otp : otps ) { log . trace ( "Checking OTP {}" , otp ) ; VerificationResponse ykr ; try { ykr = this . yc . verify ( otp ) ; } catch ( YubicoVerificationException e ) { log . warn ( "Errors during validation: " , e ) ; throw new LoginException ( "Errors during validation: " + e . getMessage ( ) ) ; } catch ( YubicoValidationFailure e ) { log . warn ( "Something went very wrong during authentication: " , e ) ; throw new LoginException ( "Something went very wrong during authentication: " + e . getMessage ( ) ) ; } if ( ykr != null ) { log . trace ( "OTP {} verify result : {}" , otp , ykr . getStatus ( ) . toString ( ) ) ; if ( ykr . getStatus ( ) == ResponseStatus . OK ) { String publicId = YubicoClient . getPublicId ( otp ) ; log . info ( "OTP verified successfully (YubiKey id {})" , publicId ) ; if ( is_right_user ( nameCb . getName ( ) , publicId ) ) { this . principals . add ( new YubikeyPrincipal ( publicId , this . idRealm ) ) ; /* Don't just return here, we want to "consume" all OTPs if * more than one is provided. */ validated = true ; } } else { log . debug ( "OTP validation returned {}" , ykr . getStatus ( ) . toString ( ) ) ; } } } return validated ; }
Try to validate all the OTPs provided .