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; ...@@ -13,6 +13,8 @@ package org.jivesoftware.messenger.auth;
import org.jivesoftware.util.*; import org.jivesoftware.util.*;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.messenger.user.UserManager;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
...@@ -81,6 +83,21 @@ public class AuthFactory { ...@@ -81,6 +83,21 @@ public class AuthFactory {
return authProvider.isDigestSupported(); 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 * 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 * AuthToken. If the username and password do not match the record of
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
package org.jivesoftware.messenger.net; package org.jivesoftware.messenger.net;
import org.jivesoftware.messenger.user.UserManager; import org.jivesoftware.messenger.auth.AuthFactory;
import org.jivesoftware.messenger.user.UserNotFoundException; import org.jivesoftware.messenger.user.UserNotFoundException;
import javax.security.auth.callback.*; import javax.security.auth.callback.*;
...@@ -60,8 +60,8 @@ public class XMPPCallbackHandler implements CallbackHandler { ...@@ -60,8 +60,8 @@ public class XMPPCallbackHandler implements CallbackHandler {
try { try {
// Get the password from the UserProvider. Some UserProviders may not support // Get the password from the UserProvider. Some UserProviders may not support
// this operation // this operation
((PasswordCallback) callbacks[i]).setPassword(UserManager.getUserProvider() ((PasswordCallback) callbacks[i])
.getPassword(name).toCharArray()); .setPassword(AuthFactory.getPassword(name).toCharArray());
//Log.info("PasswordCallback: " //Log.info("PasswordCallback: "
//+ new String(((PasswordCallback) callbacks[i]).getPassword())); //+ new String(((PasswordCallback) callbacks[i]).getPassword()));
......
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