From babc992e119033685d653e3a535feb8f99ddca2a Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Fri, 23 May 2008 00:42:16 +0000 Subject: [PATCH] Fixed SASL authentication that required a realm like DIGEST-MD5. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10429 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/sasl/SASLMechanism.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/org/jivesoftware/smack/sasl/SASLMechanism.java b/source/org/jivesoftware/smack/sasl/SASLMechanism.java index d16fd5ba1..6704a4682 100644 --- a/source/org/jivesoftware/smack/sasl/SASLMechanism.java +++ b/source/org/jivesoftware/smack/sasl/SASLMechanism.java @@ -59,6 +59,7 @@ public abstract class SASLMechanism implements CallbackHandler { protected SaslClient sc; protected String authenticationId; protected String password; + protected String hostname; public SASLMechanism(SASLAuthentication saslAuthentication) { @@ -83,6 +84,7 @@ public abstract class SASLMechanism implements CallbackHandler { //Set the authenticationID as the username, since they must be the same in this case. this.authenticationId = username; this.password = password; + this.hostname = host; String[] mechanisms = { getName() }; Map props = new HashMap(); @@ -115,7 +117,7 @@ public abstract class SASLMechanism implements CallbackHandler { if(sc.hasInitialResponse()) { byte[] response = sc.evaluateChallenge(new byte[0]); String authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES); - if(authenticationText != null && !authenticationText.equals("")) { + if(authenticationText != null && !authenticationText.equals("")) { stanza.append(authenticationText); } } @@ -184,8 +186,8 @@ public abstract class SASLMechanism implements CallbackHandler { PasswordCallback pcb = (PasswordCallback)callbacks[i]; pcb.setPassword(password.toCharArray()); } else if(callbacks[i] instanceof RealmCallback) { - //unused - //RealmCallback rcb = (RealmCallback)callbacks[i]; + RealmCallback rcb = (RealmCallback)callbacks[i]; + rcb.setText(hostname); } else if(callbacks[i] instanceof RealmChoiceCallback){ //unused //RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];