Commit 30c3abfb authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified to get the user password from the AuthFactory.

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2814 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8c99ea20
......@@ -13,6 +13,8 @@ package org.jivesoftware.messenger.auth;
import org.jivesoftware.util.*;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.user.UserManager;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
......@@ -81,6 +83,21 @@ public class AuthFactory {
return authProvider.isDigestSupported();
}
/**
* Returns the user's password. This method will throw an UnsupportedOperationException
* if this operation is not supported by the backend user store.
*
* @param username the username of the user.
* @return the user's password.
* @throws UserNotFoundException if the given user could not be found.
* @throws UnsupportedOperationException if the provider does not
* support the operation (this is an optional operation).
*/
public static String getPassword(String username) throws UserNotFoundException,
UnsupportedOperationException {
return UserManager.getUserProvider().getPassword(username);
}
/**
* Authenticates a user with a username and plain text password and returns and
* AuthToken. If the username and password do not match the record of
......
......@@ -11,7 +11,7 @@
package org.jivesoftware.messenger.net;
import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.auth.AuthFactory;
import org.jivesoftware.messenger.user.UserNotFoundException;
import javax.security.auth.callback.*;
......@@ -60,10 +60,10 @@ public class XMPPCallbackHandler implements CallbackHandler {
try {
// Get the password from the UserProvider. Some UserProviders may not support
// this operation
((PasswordCallback) callbacks[i]).setPassword(UserManager.getUserProvider()
.getPassword(name).toCharArray());
((PasswordCallback) callbacks[i])
.setPassword(AuthFactory.getPassword(name).toCharArray());
//Log.info("PasswordCallback: "
//Log.info("PasswordCallback: "
//+ new String(((PasswordCallback) callbacks[i]).getPassword()));
} catch (UserNotFoundException e) {
throw new IOException(e.toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment