try {
UsernamePasswordHashUtil uph = new UsernamePasswordHashUtil();
if (userName == null || realm == null) {
throw new SaslException("Insufficient information to generate hash.");
}
dhc.setHash(uph.generateHashedURP(userName, realm, password.toCharArray()));
} catch (NoSuchAlgorithmException e) {
throw new SaslException("Unable to generate hash", e);
}
}
}