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 {
/**
* A JID is considered local if:
* 1) is null or
* 2) has no domain or domain is empty or
* 3) has no resource or resource is empty
* 2) has no domain or domain 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) {
return recipientJID == null || recipientJID.getDomain() == null
|| "".equals(recipientJID.getDomain()) || recipientJID.getResource() == null
|| "".equals(recipientJID.getResource());
// Check if no address was specified in the IQ packet
boolean implicitServer =
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) {
......@@ -297,7 +311,7 @@ public class IQRouter extends BasicModule {
}
}
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);
}
}
......
......@@ -416,6 +416,9 @@ public class XMPPServer {
finishSetup.start();
// We can now safely indicate that setup has finished
setupMode = false;
// Update server info
xmppServerInfo = new XMPPServerInfoImpl(name, version, startDate, getConnectionManager());
}
}
......
......@@ -51,7 +51,7 @@ public class HttpSession extends LocalClientSession {
private int maxPollingInterval;
private long lastPoll = -1;
private Set<SessionListener> listeners = new CopyOnWriteArraySet<SessionListener>();
private boolean isClosed;
private volatile boolean isClosed;
private int inactivityTimeout;
private long lastActivity;
private long lastRequestID;
......@@ -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
* on the session ID.
*/
public synchronized void close() {
public void close() {
if (isClosed) {
return;
}
......
......@@ -11,10 +11,11 @@
package org.jivesoftware.openfire.ldap;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.openfire.user.*;
import org.jivesoftware.util.JiveConstants;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.openfire.user.*;
import org.xmpp.packet.JID;
import javax.naming.NamingEnumeration;
......@@ -70,13 +71,11 @@ public class LdapUserProvider implements UserProvider {
}
public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1));
username = username.substring(0,username.lastIndexOf("@"));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
username = username.substring(0,username.lastIndexOf("@"));
}
// Un-escape username.
username = JID.unescapeNode(username);
......
......@@ -12,8 +12,13 @@
package org.jivesoftware.openfire.user;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.util.*;
import org.jivesoftware.openfire.XMPPServer;
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.util.*;
......@@ -57,13 +62,11 @@ public class DefaultUserProvider implements UserProvider {
"UPDATE jiveUser SET modificationDate=? WHERE username=?";
public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1));
username = username.substring(0,username.lastIndexOf("@"));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
username = username.substring(0,username.lastIndexOf("@"));
}
Connection con = null;
PreparedStatement pstmt = null;
......
......@@ -11,9 +11,11 @@
package org.jivesoftware.openfire.user;
import org.jivesoftware.database.DbConnectionManager;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.xmpp.packet.JID;
import java.sql.*;
import java.util.*;
......@@ -97,13 +99,11 @@ public class JDBCUserProvider implements UserProvider {
}
public User loadUser(String username) throws UserNotFoundException {
String userDomain = JiveGlobals.getProperty("xmpp.domain");
if(username.contains("@")) {
userDomain = username.substring((username.lastIndexOf("@")+1));
username = username.substring(0,username.lastIndexOf("@"));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
username = username.substring(0,username.lastIndexOf("@"));
}
Connection con = null;
PreparedStatement pstmt = null;
......
......@@ -74,7 +74,8 @@ be configured under Server/Server Manager/System Properties:
by letting anyone send broadcast messages to groups.</li>
<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,
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>
<h2>Using the Plugin</h2>
......
......@@ -4,14 +4,14 @@
- $Date: 2005-05-26 23:00:40 -0700 (Thu, 26 May 2005) $
--%>
<%@ page import="org.jivesoftware.util.JiveGlobals,
org.jivesoftware.util.ParamUtils,
org.jivesoftware.util.StringUtils,
org.jivesoftware.openfire.XMPPServer,
<%@ page import="org.jivesoftware.openfire.XMPPServer,
org.jivesoftware.openfire.auth.AuthFactory,
org.jivesoftware.openfire.ldap.LdapManager,
org.jivesoftware.openfire.user.User" %>
<%@ page import="org.jivesoftware.openfire.user.UserManager"%>
org.jivesoftware.openfire.user.User,
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="javax.servlet.http.HttpSession" %>
<%@ page import="java.net.URLEncoder" %>
......@@ -100,7 +100,8 @@
return;
}
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 "
+ "setting the new admin information. Please check your error "
+ "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