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

Refactoring wortk. JM-924

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6541 b35dd754-fafc-0310-a699-88a17e54d16e
parent 35ca2208
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 3135 $ * $Revision: 3135 $
* $Date: 2005-12-01 02:03:04 -0300 (Thu, 01 Dec 2005) $ * $Date: 2005-12-01 02:03:04 -0300 (Thu, 01 Dec 2005) $
* *
* Copyright (C) 2005 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -17,11 +17,16 @@ import org.jivesoftware.util.Log; ...@@ -17,11 +17,16 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.container.BasicModule; import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.handler.IQHandler; import org.jivesoftware.wildfire.handler.IQHandler;
import org.jivesoftware.wildfire.interceptor.InterceptorManager;
import org.jivesoftware.wildfire.interceptor.PacketRejectedException;
import org.jivesoftware.wildfire.privacy.PrivacyList; import org.jivesoftware.wildfire.privacy.PrivacyList;
import org.jivesoftware.wildfire.privacy.PrivacyListManager; import org.jivesoftware.wildfire.privacy.PrivacyListManager;
import org.jivesoftware.wildfire.session.ClientSession;
import org.jivesoftware.wildfire.session.Session;
import org.jivesoftware.wildfire.user.UserManager; import org.jivesoftware.wildfire.user.UserManager;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -73,7 +78,10 @@ public class IQRouter extends BasicModule { ...@@ -73,7 +78,10 @@ public class IQRouter extends BasicModule {
if (packet == null) { if (packet == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
Session session = sessionManager.getSession(packet.getFrom()); ClientSession session = sessionManager.getSession(packet.getFrom());
try {
// Invoke the interceptors before we process the read packet
InterceptorManager.getInstance().invokeInterceptors(packet, session, true, false);
JID to = packet.getTo(); JID to = packet.getTo();
if (session != null && to != null && session.getStatus() == Session.STATUS_CONNECTED && if (session != null && to != null && session.getStatus() == Session.STATUS_CONNECTED &&
!serverName.equals(to.toString())) { !serverName.equals(to.toString())) {
...@@ -101,6 +109,30 @@ public class IQRouter extends BasicModule { ...@@ -101,6 +109,30 @@ public class IQRouter extends BasicModule {
reply.setError(PacketError.Condition.not_authorized); reply.setError(PacketError.Condition.not_authorized);
sessionManager.getSession(packet.getFrom()).process(reply); sessionManager.getSession(packet.getFrom()).process(reply);
} }
// Invoke the interceptors after we have processed the read packet
InterceptorManager.getInstance().invokeInterceptors(packet, session, true, true);
}
catch (PacketRejectedException e) {
if (session != null) {
// An interceptor rejected this packet so answer a not_allowed error
IQ reply = new IQ();
reply.setChildElement(packet.getChildElement().createCopy());
reply.setID(packet.getID());
reply.setTo(session.getAddress());
reply.setFrom(packet.getTo());
reply.setError(PacketError.Condition.not_allowed);
session.process(reply);
// Check if a message notifying the rejection should be sent
if (e.getRejectionMessage() != null && e.getRejectionMessage().trim().length() > 0) {
// A message for the rejection will be sent to the sender of the rejected packet
Message notification = new Message();
notification.setTo(session.getAddress());
notification.setFrom(packet.getTo());
notification.setBody(e.getRejectionMessage());
session.process(notification);
}
}
}
} }
/** /**
...@@ -279,7 +311,7 @@ public class IQRouter extends BasicModule { ...@@ -279,7 +311,7 @@ public class IQRouter extends BasicModule {
if (XMPPServer.getInstance().isLocal(recipientJID)) { if (XMPPServer.getInstance().isLocal(recipientJID)) {
ClientSession session = sessionManager.getBestRoute(recipientJID); ClientSession session = sessionManager.getBestRoute(recipientJID);
if (session != null) { if (session != null) {
if (!session.shouldBlockPacket(packet)) { if (session.canProcess(packet)) {
session.process(packet); session.process(packet);
handlerFound = true; handlerFound = true;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 3007 $ * $Revision: 3007 $
* $Date: 2005-10-31 13:29:25 -0300 (Mon, 31 Oct 2005) $ * $Date: 2005-10-31 13:29:25 -0300 (Mon, 31 Oct 2005) $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
package org.jivesoftware.wildfire; package org.jivesoftware.wildfire;
import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.interceptor.InterceptorManager;
import org.jivesoftware.wildfire.interceptor.PacketRejectedException;
import org.jivesoftware.wildfire.session.ClientSession;
import org.jivesoftware.wildfire.session.Session;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
...@@ -63,7 +66,10 @@ public class MessageRouter extends BasicModule { ...@@ -63,7 +66,10 @@ public class MessageRouter extends BasicModule {
if (packet == null) { if (packet == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
Session session = sessionManager.getSession(packet.getFrom()); ClientSession session = sessionManager.getSession(packet.getFrom());
try {
// Invoke the interceptors before we process the read packet
InterceptorManager.getInstance().invokeInterceptors(packet, session, true, false);
if (session == null if (session == null
|| session.getStatus() == Session.STATUS_AUTHENTICATED) || session.getStatus() == Session.STATUS_AUTHENTICATED)
{ {
...@@ -103,11 +109,22 @@ public class MessageRouter extends BasicModule { ...@@ -103,11 +109,22 @@ public class MessageRouter extends BasicModule {
packet.setTo(session.getAddress()); packet.setTo(session.getAddress());
packet.setFrom((JID)null); packet.setFrom((JID)null);
packet.setError(PacketError.Condition.not_authorized); packet.setError(PacketError.Condition.not_authorized);
try {
session.process(packet); session.process(packet);
} }
catch (UnauthorizedException ue) { // Invoke the interceptors after we have processed the read packet
Log.error(ue); InterceptorManager.getInstance().invokeInterceptors(packet, session, true, true);
} catch (PacketRejectedException e) {
// An interceptor rejected this packet
if (session != null && e.getRejectionMessage() != null && e.getRejectionMessage().trim().length() > 0) {
// A message for the rejection will be sent to the sender of the rejected packet
Message reply = new Message();
reply.setID(packet.getID());
reply.setTo(session.getAddress());
reply.setFrom(packet.getTo());
reply.setType(packet.getType());
reply.setThread(packet.getThread());
reply.setBody(e.getRejectionMessage());
session.process(reply);
} }
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: $ * $Revision: $
* $Date: $ * $Date: $
* *
* Copyright (C) 2006 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -44,7 +44,7 @@ public class Route extends Packet { ...@@ -44,7 +44,7 @@ public class Route extends Packet {
* @param element the route Element. * @param element the route Element.
*/ */
public Route(Element element) { public Route(Element element) {
super(element); super(element, true);
} }
public Route(Route route) { public Route(Route route) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 3174 $ * $Revision: 3174 $
* $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $ * $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -13,10 +13,10 @@ package org.jivesoftware.wildfire.net; ...@@ -13,10 +13,10 @@ package org.jivesoftware.wildfire.net;
import org.dom4j.Element; import org.dom4j.Element;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.wildfire.ClientSession;
import org.jivesoftware.wildfire.PacketRouter; import org.jivesoftware.wildfire.PacketRouter;
import org.jivesoftware.wildfire.RoutingTable; import org.jivesoftware.wildfire.RoutingTable;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.session.ClientSession;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmpp.packet.IQ; import org.xmpp.packet.IQ;
import org.xmpp.packet.Message; import org.xmpp.packet.Message;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 3174 $ * $Revision: 3174 $
* $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $ * $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -16,8 +16,8 @@ import org.jivesoftware.util.Log; ...@@ -16,8 +16,8 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.PacketRouter; import org.jivesoftware.wildfire.PacketRouter;
import org.jivesoftware.wildfire.RoutingTable; import org.jivesoftware.wildfire.RoutingTable;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.component.ComponentSession;
import org.jivesoftware.wildfire.component.InternalComponentManager; import org.jivesoftware.wildfire.component.InternalComponentManager;
import org.jivesoftware.wildfire.session.ComponentSession;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmpp.component.ComponentException; import org.xmpp.component.ComponentException;
import org.xmpp.packet.PacketError; import org.xmpp.packet.PacketError;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: $ * $Revision: $
* $Date: $ * $Date: $
* *
* Copyright (C) 2005 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -19,13 +19,13 @@ import org.jivesoftware.util.CertificateManager; ...@@ -19,13 +19,13 @@ import org.jivesoftware.util.CertificateManager;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.jivesoftware.wildfire.ClientSession;
import org.jivesoftware.wildfire.Session;
import org.jivesoftware.wildfire.XMPPServer; import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.auth.AuthFactory; import org.jivesoftware.wildfire.auth.AuthFactory;
import org.jivesoftware.wildfire.auth.AuthToken; import org.jivesoftware.wildfire.auth.AuthToken;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.server.IncomingServerSession; import org.jivesoftware.wildfire.session.ClientSession;
import org.jivesoftware.wildfire.session.IncomingServerSession;
import org.jivesoftware.wildfire.session.Session;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLPeerUnverifiedException;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 3174 $ * $Revision: 3174 $
* $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $ * $Date: 2005-12-08 17:41:00 -0300 (Thu, 08 Dec 2005) $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -18,7 +18,7 @@ import org.jivesoftware.wildfire.PacketRouter; ...@@ -18,7 +18,7 @@ import org.jivesoftware.wildfire.PacketRouter;
import org.jivesoftware.wildfire.RoutingTable; import org.jivesoftware.wildfire.RoutingTable;
import org.jivesoftware.wildfire.auth.UnauthorizedException; import org.jivesoftware.wildfire.auth.UnauthorizedException;
import org.jivesoftware.wildfire.interceptor.PacketRejectedException; import org.jivesoftware.wildfire.interceptor.PacketRejectedException;
import org.jivesoftware.wildfire.server.IncomingServerSession; import org.jivesoftware.wildfire.session.IncomingServerSession;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmpp.packet.*; import org.xmpp.packet.*;
......
...@@ -29,7 +29,7 @@ import java.util.List; ...@@ -29,7 +29,7 @@ import java.util.List;
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
class ServerTrustManager implements X509TrustManager { public class ServerTrustManager implements X509TrustManager {
/** /**
* KeyStore that holds the trusted CA * KeyStore that holds the trusted CA
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: 1583 $ * $Revision: 1583 $
* $Date: 2005-07-03 17:55:39 -0300 (Sun, 03 Jul 2005) $ * $Date: 2005-07-03 17:55:39 -0300 (Sun, 03 Jul 2005) $
* *
* Copyright (C) 2004 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -73,14 +73,8 @@ public class SocketAcceptThread extends Thread { ...@@ -73,14 +73,8 @@ public class SocketAcceptThread extends Thread {
} }
this.serverPort = serverPort; this.serverPort = serverPort;
// Set the blocking reading mode to use // Set the blocking reading mode to use
boolean useBlockingMode = JiveGlobals.getBooleanProperty("xmpp.socket.blocking", true);
if (useBlockingMode) {
acceptingMode = new BlockingAcceptingMode(connManager, serverPort, bindInterface); acceptingMode = new BlockingAcceptingMode(connManager, serverPort, bindInterface);
} }
else {
acceptingMode = new NonBlockingAcceptingMode(connManager, serverPort, bindInterface);
}
}
/** /**
* Retrieve the port this server socket is bound to. * Retrieve the port this server socket is bound to.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* $Revision: $ * $Revision: $
* $Date: $ * $Date: $
* *
* Copyright (C) 2006 Jive Software. All rights reserved. * Copyright (C) 2007 Jive Software. All rights reserved.
* *
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
...@@ -18,7 +18,7 @@ import java.io.IOException; ...@@ -18,7 +18,7 @@ import java.io.IOException;
import java.net.ServerSocket; import java.net.ServerSocket;
/** /**
* Abstract class for {@link BlockingAcceptingMode} and {@link NonBlockingAcceptingMode}. * Abstract class for {@link BlockingAcceptingMode}.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
......
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