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 @@
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,14 +71,12 @@ 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));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@"));
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
}
// Un-escape username.
username = JID.unescapeNode(username);
DirContext ctx = null;
......
......@@ -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,14 +62,12 @@ 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));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@"));
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
}
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = 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));
if (!XMPPServer.getInstance().isLocal(new JID(username))) {
throw new UserNotFoundException("Cannot load user of remote server: " + username);
}
username = username.substring(0,username.lastIndexOf("@"));
}
if(!userDomain.equals(JiveGlobals.getProperty("xmpp.domain"))) {
throw new UserNotFoundException("Unknown domain: "+userDomain);
}
Connection con = null;
PreparedStatement pstmt = null;
......
......@@ -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