Fixed MD5 auth

This commit is contained in:
Michael Jumper
2010-12-04 23:40:24 -08:00
parent 0adaae171d
commit 59988b1177
2 changed files with 3 additions and 12 deletions

View File

@@ -94,8 +94,7 @@ public class BasicLogin extends HttpServlet {
if (info != null) { if (info != null) {
// Validate username and password // Validate username and password
if (info.getAuthorizedUsername().equals(username) if (info.validate(username, password)) {
&& info.getAuthorizedPassword().equals(password)) {
// Store authorized configuration // Store authorized configuration
HttpSession session = req.getSession(true); HttpSession session = req.getSession(true);

View File

@@ -40,14 +40,6 @@ public class BasicUserMappingContentHandler extends DefaultHandler {
this.auth_encoding = auth_encoding; this.auth_encoding = auth_encoding;
} }
public String getAuthorizedUsername() {
return auth_username;
}
public String getAuthorizedPassword() {
return auth_password;
}
private static final char HEX_CHARS[] = { private static final char HEX_CHARS[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
@@ -87,7 +79,7 @@ public class BasicUserMappingContentHandler extends DefaultHandler {
try { try {
MessageDigest digest = MessageDigest.getInstance("MD5"); MessageDigest digest = MessageDigest.getInstance("MD5");
String hashedPassword = getHexString(digest.digest(password.getBytes())); String hashedPassword = getHexString(digest.digest(password.getBytes()));
return hashedPassword.equals(auth_password); return hashedPassword.equals(auth_password.toUpperCase());
} }
catch (NoSuchAlgorithmException e) { catch (NoSuchAlgorithmException e) {
throw new UnsupportedOperationException("Unexpected lack of MD5 support.", e); throw new UnsupportedOperationException("Unexpected lack of MD5 support.", e);
@@ -137,7 +129,7 @@ public class BasicUserMappingContentHandler extends DefaultHandler {
// Finalize mapping for this user // Finalize mapping for this user
authMapping.put( authMapping.put(
current.getAuthorizedUsername(), current.auth_username,
current current
); );