Commit b2dc7b9c authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Modified to use AuthorizationManager to authenticate user. JM-281

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4159 b35dd754-fafc-0310-a699-88a17e54d16e
parent f6a0af9a
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
package org.jivesoftware.wildfire.net; package org.jivesoftware.wildfire.net;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.auth.AuthFactory; import org.jivesoftware.wildfire.auth.AuthFactory;
import org.jivesoftware.wildfire.sasl.AuthorizationManager;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import javax.security.auth.callback.*; import javax.security.auth.callback.*;
...@@ -20,8 +22,7 @@ import java.io.IOException; ...@@ -20,8 +22,7 @@ import java.io.IOException;
/** /**
* Callback handler that may be used when doing SASL authentication. A CallbackHandler * Callback handler that may be used when doing SASL authentication. A CallbackHandler
* may be required depending on the SASL mechanism being used. Currently DIGEST-MD5 and * may be required depending on the SASL mechanism being used.<p>
* CRAM-MD5 are the only mechanisms that will require a callback handler.<p>
* *
* Mechanisms that use a digest don't include a password so the server needs to use the * Mechanisms that use a digest don't include a password so the server needs to use the
* stored password of the user to compare it (somehow) with the specified digest. This * stored password of the user to compare it (somehow) with the specified digest. This
...@@ -39,7 +40,7 @@ public class XMPPCallbackHandler implements CallbackHandler { ...@@ -39,7 +40,7 @@ public class XMPPCallbackHandler implements CallbackHandler {
public void handle(final Callback[] callbacks) public void handle(final Callback[] callbacks)
throws IOException, UnsupportedCallbackException { throws IOException, UnsupportedCallbackException {
String realm = null; String realm;
String name = null; String name = null;
for (int i = 0; i < callbacks.length; i++) { for (int i = 0; i < callbacks.length; i++) {
...@@ -74,13 +75,18 @@ public class XMPPCallbackHandler implements CallbackHandler { ...@@ -74,13 +75,18 @@ public class XMPPCallbackHandler implements CallbackHandler {
} }
else if (callbacks[i] instanceof AuthorizeCallback) { else if (callbacks[i] instanceof AuthorizeCallback) {
AuthorizeCallback authCallback = ((AuthorizeCallback) callbacks[i]); AuthorizeCallback authCallback = ((AuthorizeCallback) callbacks[i]);
String authenId = authCallback.getAuthenticationID(); String authenId =
String authorId = authCallback.getAuthorizationID(); authCallback.getAuthenticationID(); // Principal that authenticated
if (authenId.equals(authorId)) { String authorId =
authCallback.getAuthorizationID(); // Username requested (not full JID)
if (AuthorizationManager.authorize(authorId, authenId)) {
authCallback.setAuthorized(true); authCallback.setAuthorized(true);
authCallback.setAuthorizedID(authorId); authCallback.setAuthorizedID(authorId);
Log.debug(authenId + " authorized to " + authorId);
}
else {
Log.debug(authenId + " not authorized to " + authorId);
} }
//Log.info("AuthorizeCallback: authorId: " + authorId);
} }
else { else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
......
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