}
private Object checkPassword(ServerSession session, String username, String password) throws Exception {
PasswordAuthenticator auth = session.getServerFactoryManager().getPasswordAuthenticator();
if (auth != null) {
Object identity = auth.authenticate(username, password, session);
if (identity != null) {
return identity;
} else {
throw new Exception("Authentication failed: bad username or password supplied");
}