fitnesse.authentication.MultiUserAuthenticator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.authentication;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class MultiUserAuthenticator extends Authenticator {
private Map users;
private PasswordCipher cipher;
public MultiUserAuthenticator(String passwdFile) throws IOException, ReflectiveOperationException {
PasswordFile passwords = new PasswordFile(passwdFile);
users = passwords.getPasswordMap();
cipher = passwords.getCipher();
}
@Override
public boolean isAuthenticated(String username, String password) {
if (username == null || password == null)
return false;
String foundPassword = users.get(username);
if (foundPassword == null)
return false;
String encryptedPassword = cipher.encrypt(password);
return encryptedPassword.equals(foundPassword);
}
public int userCount() {
return users.size();
}
public String getPasswd(String user) {
return users.get(user);
}
}