How to verify a username and password?

The answer probably lies somewhere in the AuthFactory, I could use AuthFactory.getAuthProvider() and then AuthProvider.authenticate(String username, String password), but what about AuthProvider.authenticate(String username, String token, String digest), what if the currently installed Auth Provider uses that? How do I use it?