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

Fixed NPE during setup.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8949 b35dd754-fafc-0310-a699-88a17e54d16e
parent ca999b6c
...@@ -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,13 +71,11 @@ public class LdapUserProvider implements UserProvider { ...@@ -70,13 +71,11 @@ 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))) {
username = username.substring(0,username.lastIndexOf("@")); throw new UserNotFoundException("Cannot load user of remote server: " + username);
} }
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) { username = username.substring(0,username.lastIndexOf("@"));
throw new UserNotFoundException("Unknown domain: "+userDomain);
} }
// Un-escape username. // Un-escape username.
username = JID.unescapeNode(username); username = JID.unescapeNode(username);
......
...@@ -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,13 +62,11 @@ public class DefaultUserProvider implements UserProvider { ...@@ -57,13 +62,11 @@ 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))) {
username = username.substring(0,username.lastIndexOf("@")); throw new UserNotFoundException("Cannot load user of remote server: " + username);
} }
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) { username = username.substring(0,username.lastIndexOf("@"));
throw new UserNotFoundException("Unknown domain: "+userDomain);
} }
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = 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))) {
username = username.substring(0,username.lastIndexOf("@")); throw new UserNotFoundException("Cannot load user of remote server: " + username);
} }
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) { username = username.substring(0,username.lastIndexOf("@"));
throw new UserNotFoundException("Unknown domain: "+userDomain);
} }
Connection con = null; Connection con = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
......
...@@ -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