Index: org/jivesoftware/smack/XMPPConnection.java
===================================================================
--- org/jivesoftware/smack/XMPPConnection.java (revision 10869)
+++ org/jivesoftware/smack/XMPPConnection.java (working copy)
@@ -1082,7 +1082,7 @@
catch (Exception ex) {
try {
debuggerClass =
- Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
+ Class.forName("org.jivesoftware.smack.debugger.ConsoleDebugger");
}
catch (Exception ex2) {
ex2.printStackTrace();
Index: org/jivesoftware/smack/sasl/SASLMechanism.java
===================================================================
--- org/jivesoftware/smack/sasl/SASLMechanism.java (revision 10869)
+++ org/jivesoftware/smack/sasl/SASLMechanism.java (working copy)
@@ -20,24 +20,18 @@
package org.jivesoftware.smack.sasl;
-import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.SASLAuthentication;
-import org.jivesoftware.smack.util.Base64;
-
import java.io.IOException;
-import java.util.Map;
import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.sasl.RealmCallback;
-import javax.security.sasl.RealmChoiceCallback;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
+import org.jivesoftware.smack.SASLAuthentication;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.util.Base64;
+
/**
* Base class for SASL mechanisms. Subclasses must implement these methods:
* <ul>
@@ -56,7 +50,7 @@
public abstract class SASLMechanism implements CallbackHandler {
private SASLAuthentication saslAuthentication;
- protected SaslClient sc;
+ //protected SaslClient sc;
protected String authenticationId;
protected String password;
protected String hostname;
@@ -88,7 +82,7 @@
String[] mechanisms = { getName() };
Map<String,String> props = new HashMap<String,String>();
- sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
+ //sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
authenticate();
}
@@ -105,7 +99,7 @@
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException {
String[] mechanisms = { getName() };
Map<String,String> props = new HashMap<String,String>();
- sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
+ //sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
authenticate();
}
@@ -113,17 +107,17 @@
StringBuilder stanza = new StringBuilder();
stanza.append("<auth mechanism=\"").append(getName());
stanza.append("\" xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
- try {
- if(sc.hasInitialResponse()) {
- byte[] response = sc.evaluateChallenge(new byte[0]);
- String authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
- if(authenticationText != null && !authenticationText.equals("")) {
- stanza.append(authenticationText);
- }
- }
- } catch (SaslException e) {
- throw new XMPPException("SASL authentication failed", e);
- }
+// try {
+// if(sc.hasInitialResponse()) {
+// byte[] response = sc.evaluateChallenge(new byte[0]);
+// String authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
+// if(authenticationText != null && !authenticationText.equals("")) {
+// stanza.append(authenticationText);
+// }
+// }
+// } catch (SaslException e) {
+// throw new XMPPException("SASL authentication failed", e);
+// }
stanza.append("</auth>");
// Send the authentication to the server
@@ -142,12 +136,12 @@
// Build the challenge response stanza encoding the response text
StringBuilder stanza = new StringBuilder();
- byte response[];
- if(challenge != null) {
- response = sc.evaluateChallenge(Base64.decode(challenge));
- } else {
- response = sc.evaluateChallenge(null);
- }
+ byte response[] = null;
+// if(challenge != null) {
+// response = sc.evaluateChallenge(Base64.decode(challenge));
+// } else {
+// response = sc.evaluateChallenge(null);
+// }
String authenticationText = Base64.encodeBytes(response,Base64.DONT_BREAK_LINES);
if(authenticationText.equals("")) {
@@ -179,21 +173,21 @@
*/
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
- if (callbacks[i] instanceof NameCallback) {
- NameCallback ncb = (NameCallback)callbacks[i];
- ncb.setName(authenticationId);
- } else if(callbacks[i] instanceof PasswordCallback) {
- PasswordCallback pcb = (PasswordCallback)callbacks[i];
- pcb.setPassword(password.toCharArray());
- } else if(callbacks[i] instanceof RealmCallback) {
- RealmCallback rcb = (RealmCallback)callbacks[i];
- rcb.setText(hostname);
- } else if(callbacks[i] instanceof RealmChoiceCallback){
- //unused
- //RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
- } else {
+// if (callbacks[i] instanceof NameCallback) {
+// NameCallback ncb = (NameCallback)callbacks[i];
+// ncb.setName(authenticationId);
+// } else if(callbacks[i] instanceof PasswordCallback) {
+// PasswordCallback pcb = (PasswordCallback)callbacks[i];
+// pcb.setPassword(password.toCharArray());
+// } else if(callbacks[i] instanceof RealmCallback) {
+// RealmCallback rcb = (RealmCallback)callbacks[i];
+// rcb.setText(hostname);
+// } else if(callbacks[i] instanceof RealmChoiceCallback){
+// //unused
+// //RealmChoiceCallback rccb = (RealmChoiceCallback)callbacks[i];
+// } else {
throw new UnsupportedCallbackException(callbacks[i]);
- }
+ //}
}
}
}
Index: org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java
===================================================================
--- org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java (revision 10869)
+++ org/jivesoftware/smack/sasl/SASLGSSAPIMechanism.java (working copy)
@@ -25,8 +25,6 @@
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
import javax.security.auth.callback.CallbackHandler;
/**
@@ -62,8 +60,8 @@
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException {
String[] mechanisms = { getName() };
Map props = new HashMap();
- props.put(Sasl.SERVER_AUTH,"TRUE");
- sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
+ //props.put(Sasl.SERVER_AUTH,"TRUE");
+ //sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
authenticate();
}
@@ -81,8 +79,8 @@
public void authenticate(String username, String host, String password) throws IOException, XMPPException {
String[] mechanisms = { getName() };
Map props = new HashMap();
- props.put(Sasl.SERVER_AUTH,"TRUE");
- sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
+ //props.put(Sasl.SERVER_AUTH,"TRUE");
+ //sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
authenticate();
}
Index: org/jivesoftware/smack/ConnectionConfiguration.java
===================================================================
--- org/jivesoftware/smack/ConnectionConfiguration.java (revision 10869)
+++ org/jivesoftware/smack/ConnectionConfiguration.java (working copy)
@@ -57,13 +57,13 @@
private boolean compressionEnabled = false;
- private boolean saslAuthenticationEnabled = true;
+ private boolean saslAuthenticationEnabled = false;
/**
* Used to get information from the user
*/
private CallbackHandler callbackHandler;
- private boolean debuggerEnabled = XMPPConnection.DEBUG_ENABLED;
+ private boolean debuggerEnabled = true;//XMPPConnection.DEBUG_ENABLED;
// Flag that indicates if a reconnection should be attempted when abruptly disconnected
private boolean reconnectionAllowed = true;
@@ -517,7 +517,7 @@
* logging into the server.
*/
public void setSASLAuthenticationEnabled(boolean saslAuthenticationEnabled) {
- this.saslAuthenticationEnabled = saslAuthenticationEnabled;
+ //this.saslAuthenticationEnabled = saslAuthenticationEnabled;
}
/**
Index: org/jivesoftware/smack/util/DNSUtil.java
===================================================================
--- org/jivesoftware/smack/util/DNSUtil.java (revision 10869)
+++ org/jivesoftware/smack/util/DNSUtil.java (working copy)
@@ -19,9 +19,6 @@
package org.jivesoftware.smack.util;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.InitialDirContext;
import java.util.Hashtable;
import java.util.Map;
@@ -38,13 +35,13 @@
*/
private static Map cache = new Cache(100, 1000*60*10);
- private static DirContext context;
+ //private static DirContext context;
static {
try {
Hashtable env = new Hashtable();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
- context = new InitialDirContext(env);
+// context = new InitialDirContext(env);
}
catch (Exception e) {
// Ignore.
@@ -69,39 +66,8 @@
* server can be reached at for the specified domain.
*/
public static HostAddress resolveXMPPDomain(String domain) {
- if (context == null) {
return new HostAddress(domain, 5222);
- }
- String key = "c" + domain;
- // Return item from cache if it exists.
- if (cache.containsKey(key)) {
- HostAddress address = (HostAddress)cache.get(key);
- if (address != null) {
- return address;
- }
- }
- String host = domain;
- int port = 5222;
- try {
- Attributes dnsLookup =
- context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"});
- String srvRecord = (String)dnsLookup.get("SRV").get();
- String [] srvRecordEntries = srvRecord.split(" ");
- port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
- host = srvRecordEntries[srvRecordEntries.length-1];
- }
- catch (Exception e) {
- // Ignore.
- }
- // Host entries in DNS should end with a ".".
- if (host.endsWith(".")) {
- host = host.substring(0, host.length()-1);
- }
- HostAddress address = new HostAddress(host, port);
- // Add item to cache.
- cache.put(key, address);
- return address;
- }
+ }
/**
* Returns the host name and port that the specified XMPP server can be
@@ -121,50 +87,8 @@
* server can be reached at for the specified domain.
*/
public static HostAddress resolveXMPPServerDomain(String domain) {
- if (context == null) {
return new HostAddress(domain, 5269);
- }
- String key = "s" + domain;
- // Return item from cache if it exists.
- if (cache.containsKey(key)) {
- HostAddress address = (HostAddress)cache.get(key);
- if (address != null) {
- return address;
- }
- }
- String host = domain;
- int port = 5269;
- try {
- Attributes dnsLookup =
- context.getAttributes("_xmpp-server._tcp." + domain, new String[]{"SRV"});
- String srvRecord = (String)dnsLookup.get("SRV").get();
- String [] srvRecordEntries = srvRecord.split(" ");
- port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
- host = srvRecordEntries[srvRecordEntries.length-1];
- }
- catch (Exception e) {
- // Attempt lookup with older "jabber" name.
- try {
- Attributes dnsLookup =
- context.getAttributes("_jabber._tcp." + domain, new String[]{"SRV"});
- String srvRecord = (String)dnsLookup.get("SRV").get();
- String [] srvRecordEntries = srvRecord.split(" ");
- port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
- host = srvRecordEntries[srvRecordEntries.length-1];
- }
- catch (Exception e2) {
- // Ignore.
- }
- }
- // Host entries in DNS should end with a ".".
- if (host.endsWith(".")) {
- host = host.substring(0, host.length()-1);
- }
- HostAddress address = new HostAddress(host, port);
- // Add item to cache.
- cache.put(key, address);
- return address;
- }
+ }
/**
* Encapsulates a hostname and port.
Index: org/jivesoftware/smack/util/PacketParserUtils.java
===================================================================
--- org/jivesoftware/smack/util/PacketParserUtils.java (revision 10869)
+++ org/jivesoftware/smack/util/PacketParserUtils.java (working copy)
@@ -25,7 +25,7 @@
import org.jivesoftware.smack.provider.ProviderManager;
import org.xmlpull.v1.XmlPullParser;
-import java.beans.PropertyDescriptor;
+//import java.beans.PropertyDescriptor;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;
@@ -428,26 +428,26 @@
{
boolean done = false;
Object object = objectClass.newInstance();
- while (!done) {
- int eventType = parser.next();
- if (eventType == XmlPullParser.START_TAG) {
- String name = parser.getName();
- String stringValue = parser.nextText();
- PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
- // Load the class type of the property.
- Class propertyType = descriptor.getPropertyType();
- // Get the value of the property by converting it from a
- // String to the correct object type.
- Object value = decode(propertyType, stringValue);
- // Set the value of the bean.
- descriptor.getWriteMethod().invoke(object, value);
- }
- else if (eventType == XmlPullParser.END_TAG) {
- if (parser.getName().equals(elementName)) {
- done = true;
- }
- }
- }
+// while (!done) {
+// int eventType = parser.next();
+// if (eventType == XmlPullParser.START_TAG) {
+// String name = parser.getName();
+// String stringValue = parser.nextText();
+// PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
+// // Load the class type of the property.
+// Class propertyType = descriptor.getPropertyType();
+// // Get the value of the property by converting it from a
+// // String to the correct object type.
+// Object value = decode(propertyType, stringValue);
+// // Set the value of the bean.
+// descriptor.getWriteMethod().invoke(object, value);
+// }
+// else if (eventType == XmlPullParser.END_TAG) {
+// if (parser.getName().equals(elementName)) {
+// done = true;
+// }
+// }
+// }
return object;
}