Commit 6e22cea8 authored by Armando Jagucki's avatar Armando Jagucki Committed by ajagucki

Ported changes between 8945 and 8964 from trunk.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/pep@8965 b35dd754-fafc-0310-a699-88a17e54d16e
parent c8215986
...@@ -203,13 +203,27 @@ public class IQRouter extends BasicModule { ...@@ -203,13 +203,27 @@ public class IQRouter extends BasicModule {
/** /**
* A JID is considered local if: * A JID is considered local if:
* 1) is null or * 1) is null or
* 2) has no domain or domain is empty or * 2) has no domain or domain is empty
* 3) has no resource or resource is empty * or
* if it's not a full JID and it was sent to the server itself.
*
* @param recipientJID address to check.
* @return true if the specified address belongs to the local server.
*/ */
private boolean isLocalServer(JID recipientJID) { private boolean isLocalServer(JID recipientJID) {
return recipientJID == null || recipientJID.getDomain() == null // Check if no address was specified in the IQ packet
|| "".equals(recipientJID.getDomain()) || recipientJID.getResource() == null boolean implicitServer =
|| "".equals(recipientJID.getResource()); recipientJID == null || recipientJID.getDomain() == null || "".equals(recipientJID.getDomain());
if (!implicitServer) {
// We found an address. Now check if it's a bare or full JID
if (recipientJID.getNode() == null || recipientJID.getResource() == null) {
// Address is a bare JID so check if it was sent to the server itself
return serverName.equals(recipientJID.getDomain());
}
// Address is a full JID. IQ packets sent to full JIDs are not handle by the server
return false;
}
return true;
} }
private void handle(IQ packet) { private void handle(IQ packet) {
...@@ -297,7 +311,7 @@ public class IQRouter extends BasicModule { ...@@ -297,7 +311,7 @@ public class IQRouter extends BasicModule {
} }
} }
else { else {
// JID is of the form <node@domain/resource> // JID is of the form <node@domain/resource> or belongs to a remote server
routingTable.routePacket(recipientJID, packet, false); routingTable.routePacket(recipientJID, packet, false);
} }
} }
......
...@@ -416,6 +416,9 @@ public class XMPPServer { ...@@ -416,6 +416,9 @@ public class XMPPServer {
finishSetup.start(); finishSetup.start();
// We can now safely indicate that setup has finished // We can now safely indicate that setup has finished
setupMode = false; setupMode = false;
// Update server info
xmppServerInfo = new XMPPServerInfoImpl(name, version, startDate, getConnectionManager());
} }
} }
......
...@@ -51,7 +51,7 @@ public class HttpSession extends LocalClientSession { ...@@ -51,7 +51,7 @@ public class HttpSession extends LocalClientSession {
private int maxPollingInterval; private int maxPollingInterval;
private long lastPoll = -1; private long lastPoll = -1;
private Set<SessionListener> listeners = new CopyOnWriteArraySet<SessionListener>(); private Set<SessionListener> listeners = new CopyOnWriteArraySet<SessionListener>();
private boolean isClosed; private volatile boolean isClosed;
private int inactivityTimeout; private int inactivityTimeout;
private long lastActivity; private long lastActivity;
private long lastRequestID; private long lastRequestID;
...@@ -124,7 +124,7 @@ public class HttpSession extends LocalClientSession { ...@@ -124,7 +124,7 @@ public class HttpSession extends LocalClientSession {
* Closes the session. After a session has been closed it will no longer accept new connections * Closes the session. After a session has been closed it will no longer accept new connections
* on the session ID. * on the session ID.
*/ */
public synchronized void close() { public void close() {
if (isClosed) { if (isClosed) {
return; return;
} }
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
package org.jivesoftware.openfire.ldap; package org.jivesoftware.openfire.ldap;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.user.*;
import org.jivesoftware.util.JiveConstants; import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.user.*;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import javax.naming.NamingEnumeration; import javax.naming.NamingEnumeration;
...@@ -70,14 +71,12 @@ public class LdapUserProvider implements UserProvider { ...@@ -70,14 +71,12 @@ public class LdapUserProvider implements UserProvider {
} }
public User loadUser(String username) throws UserNotFoundException { public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) { if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1)); if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@")); username = username.substring(0,username.lastIndexOf("@"));
} }
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
}
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
DirContext ctx = null; DirContext ctx = null;
......
...@@ -12,8 +12,13 @@ ...@@ -12,8 +12,13 @@
package org.jivesoftware.openfire.user; package org.jivesoftware.openfire.user;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.*; import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.auth.AuthFactory; import org.jivesoftware.openfire.auth.AuthFactory;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.xmpp.packet.JID;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
...@@ -57,14 +62,12 @@ public class DefaultUserProvider implements UserProvider { ...@@ -57,14 +62,12 @@ public class DefaultUserProvider implements UserProvider {
"UPDATE jiveUser SET modificationDate=? WHERE username=?"; "UPDATE jiveUser SET modificationDate=? WHERE username=?";
public User loadUser(String username) throws UserNotFoundException { public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) { if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1)); if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@")); username = username.substring(0,username.lastIndexOf("@"));
} }
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
}
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
......
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
package org.jivesoftware.openfire.user; package org.jivesoftware.openfire.user;
import org.jivesoftware.database.DbConnectionManager; import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
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.xmpp.packet.JID;
import java.sql.*; import java.sql.*;
import java.util.*; import java.util.*;
...@@ -97,13 +99,11 @@ public class JDBCUserProvider implements UserProvider { ...@@ -97,13 +99,11 @@ public class JDBCUserProvider implements UserProvider {
} }
public User loadUser(String username) throws UserNotFoundException { public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) { if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1)); if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@")); username = username.substring(0,username.lastIndexOf("@"));
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
} }
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
......
...@@ -74,7 +74,8 @@ be configured under Server/Server Manager/System Properties: ...@@ -74,7 +74,8 @@ be configured under Server/Server Manager/System Properties:
by letting anyone send broadcast messages to groups.</li> by letting anyone send broadcast messages to groups.</li>
<li><tt>plugin.broadcast.allowedUsers</tt> -- the comma-delimitted list of users allowed <li><tt>plugin.broadcast.allowedUsers</tt> -- the comma-delimitted list of users allowed
to broadcast messages to all connected users at once. When this property isn't set, to broadcast messages to all connected users at once. When this property isn't set,
anyone is allowed to broadcast messages to all users.</li> anyone is allowed to broadcast messages to all users. Users should be specified by their
bare JID (e.g. john@myserver.com)</li>
</ul> </ul>
<h2>Using the Plugin</h2> <h2>Using the Plugin</h2>
......
...@@ -4,14 +4,14 @@ ...@@ -4,14 +4,14 @@
- $Date: 2005-05-26 23:00:40 -0700 (Thu, 26 May 2005) $ - $Date: 2005-05-26 23:00:40 -0700 (Thu, 26 May 2005) $
--%> --%>
<%@ page import="org.jivesoftware.util.JiveGlobals, <%@ page import="org.jivesoftware.openfire.XMPPServer,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils,
org.jivesoftware.openfire.XMPPServer,
org.jivesoftware.openfire.auth.AuthFactory, org.jivesoftware.openfire.auth.AuthFactory,
org.jivesoftware.openfire.ldap.LdapManager, org.jivesoftware.openfire.ldap.LdapManager,
org.jivesoftware.openfire.user.User" %> org.jivesoftware.openfire.user.User,
<%@ page import="org.jivesoftware.openfire.user.UserManager"%> org.jivesoftware.openfire.user.UserManager,
org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.ParamUtils" %>
<%@ page import="org.jivesoftware.util.StringUtils"%>
<%@ page import="org.xmpp.packet.JID"%> <%@ page import="org.xmpp.packet.JID"%>
<%@ page import="javax.servlet.http.HttpSession" %> <%@ page import="javax.servlet.http.HttpSession" %>
<%@ page import="java.net.URLEncoder" %> <%@ page import="java.net.URLEncoder" %>
...@@ -100,7 +100,8 @@ ...@@ -100,7 +100,8 @@
return; return;
} }
catch (Exception e) { catch (Exception e) {
System.err.println("Could not find UserManager"); //System.err.println("Could not find UserManager");
e.printStackTrace();
errors.put("general", "There was an unexpected error encountered when " errors.put("general", "There was an unexpected error encountered when "
+ "setting the new admin information. Please check your error " + "setting the new admin information. Please check your error "
+ "logs and try to remedy the problem."); + "logs and try to remedy the problem.");
......
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