final String encyptedPassword = getPasswordEncoder().encode(credential.getPassword());
final int count;
try {
count = getJdbcTemplate().queryForObject(this.sql, Integer.class, username, encyptedPassword);
} catch (final DataAccessException e) {
throw new PreventedException("SQL exception while executing query for " + username, e);
}
if (count == 0) {
throw new FailedLoginException(username + " not found with SQL query.");
}
return createHandlerResult(credential, new SimplePrincipal(username), null);