perform(user, password);
}
public void perform(String user, String password)
{
CRAMMD5HexInitialiser initialiser = new CRAMMD5HexInitialiser();
//Use properties to create a PrincipalDatabase
Properties users = new Properties();
users.put(user, password);
PropertiesPrincipalDatabase db = new PropertiesPrincipalDatabase(users);
initialiser.initialise(db);
//setup the callbacks
PasswordCallback passwordCallback = new PasswordCallback("password:", false);
NameCallback usernameCallback = new NameCallback("user:", user);
Callback[] callbacks = new Callback[]{usernameCallback, passwordCallback};
//Check the
try
{
assertNull("The password was not null before the handle call.", passwordCallback.getPassword());
initialiser.getCallbackHandler().handle(callbacks);
}
catch (IOException e)
{
fail(e.getMessage());
}