public Authentication authenticate(Authentication authentication) throws AuthenticationException { Authentication result = null; if (authentication instanceof CheckHOTPToken) { CheckHOTPToken authRequest = (CheckHOTPToken) authentication; if (authRequest.getCredentials() == null) { throw new BadOTPValueException("Null HOTP value"); } boolean ok = ssoService.authenticateUsingHOTP(authRequest.getName(), authRequest.getCredentials().toString()); if (!ok) { throw new BadOTPValueException("Invalid HOTP value"); } result = createAuthentication(authRequest.getSsoUser()); } return result; }