Commit 570ea689 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

TO attribute of JIDs is now validated when clients are directly connected.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6936 b35dd754-fafc-0310-a699-88a17e54d16e
parent 35ce29f6
...@@ -59,6 +59,10 @@ public class ClientStanzaHandler extends StanzaHandler { ...@@ -59,6 +59,10 @@ public class ClientStanzaHandler extends StanzaHandler {
return JiveGlobals.getBooleanProperty("xmpp.client.validate.host",false); return JiveGlobals.getBooleanProperty("xmpp.client.validate.host",false);
} }
boolean validateJIDs() {
return true;
}
boolean createSession(String namespace, String serverName, XmlPullParser xpp, Connection connection) boolean createSession(String namespace, String serverName, XmlPullParser xpp, Connection connection)
throws XmlPullParserException { throws XmlPullParserException {
if ("jabber:client".equals(namespace)) { if ("jabber:client".equals(namespace)) {
......
...@@ -117,6 +117,10 @@ public class MultiplexerStanzaHandler extends StanzaHandler { ...@@ -117,6 +117,10 @@ public class MultiplexerStanzaHandler extends StanzaHandler {
return false; return false;
} }
boolean validateJIDs() {
return false;
}
boolean createSession(String namespace, String serverName, XmlPullParser xpp, Connection connection) boolean createSession(String namespace, String serverName, XmlPullParser xpp, Connection connection)
throws XmlPullParserException { throws XmlPullParserException {
if (getNamespace().equals(namespace)) { if (getNamespace().equals(namespace)) {
......
...@@ -164,7 +164,7 @@ public abstract class StanzaHandler { ...@@ -164,7 +164,7 @@ public abstract class StanzaHandler {
if ("message".equals(tag)) { if ("message".equals(tag)) {
Message packet; Message packet;
try { try {
packet = new Message(doc, true); packet = new Message(doc, !validateJIDs());
} }
catch(IllegalArgumentException e) { catch(IllegalArgumentException e) {
Log.debug("Rejecting packet. JID malformed", e); Log.debug("Rejecting packet. JID malformed", e);
...@@ -182,7 +182,7 @@ public abstract class StanzaHandler { ...@@ -182,7 +182,7 @@ public abstract class StanzaHandler {
else if ("presence".equals(tag)) { else if ("presence".equals(tag)) {
Presence packet; Presence packet;
try { try {
packet = new Presence(doc, true); packet = new Presence(doc, !validateJIDs());
} }
catch (IllegalArgumentException e) { catch (IllegalArgumentException e) {
Log.debug("Rejecting packet. JID malformed", e); Log.debug("Rejecting packet. JID malformed", e);
...@@ -263,7 +263,7 @@ public abstract class StanzaHandler { ...@@ -263,7 +263,7 @@ public abstract class StanzaHandler {
return new Roster(doc); return new Roster(doc);
} }
else { else {
return new IQ(doc, true); return new IQ(doc, !validateJIDs());
} }
} }
...@@ -619,6 +619,16 @@ public abstract class StanzaHandler { ...@@ -619,6 +619,16 @@ public abstract class StanzaHandler {
*/ */
abstract boolean validateHost(); abstract boolean validateHost();
/**
* Returns true if the value of the 'to' attribute of {@link IQ}, {@link Presence} and
* {@link Message} must be validated. Connection Managers perform their own
* JID validation so there is no need to validate JIDs again but when clients are
* directly connected to the server then we need to validate JIDs.
*
* @return rue if the value of the 'to' attribute of IQ, Presence and Messagemust be validated.
*/
abstract boolean validateJIDs();
/** /**
* Creates the appropriate {@link Session} subclass based on the specified namespace. * Creates the appropriate {@link Session} subclass based on the specified namespace.
* *
......
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