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

The serverName is no longer null in ConnectionManager (a restart is no longer needed).

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/branches/openfire_3_5_0@10005 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1588d977
......@@ -96,7 +96,7 @@ public class ClearspaceUserProvider implements UserProvider {
} catch (UserAlreadyExistsException uaee) {
throw uaee;
} catch (Exception e) {
throw new UnsupportedOperationException("Error creatin the user", e);
throw new UnsupportedOperationException("Error creating the user", e);
}
}
......
......@@ -13,6 +13,7 @@ import org.jivesoftware.openfire.commands.SessionData;
import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserAlreadyExistsException;
import org.jivesoftware.openfire.XMPPServer;
import org.jivesoftware.util.StringUtils;
import org.dom4j.Element;
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
......@@ -83,6 +84,13 @@ public class AddUser extends AdHocCommand {
String name = (givenName == null ? "" : givenName) + (surName == null ? "" : surName);
name = (name.equals("") ? null : name);
// If provider requires email, validate
if (UserManager.getUserProvider().isEmailRequired() && !StringUtils.isValidEmailAddress(email)) {
note.addAttribute("type", "error");
note.setText("No email was specified.");
return;
}
try {
UserManager.getInstance().createUser(account.getNode(), password, name, email);
}
......
......@@ -408,6 +408,7 @@ public class IQRegisterHandler extends IQHandler implements ServerFeaturesProvid
reply = IQ.createResultIQ(packet);
reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.not_acceptable);
Log.warn(e);
}
catch (UnsupportedOperationException e) {
// The User provider is read-only so this operation is not allowed
......
......@@ -521,6 +521,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
public void initialize(XMPPServer server) {
super.initialize(server);
this.server = server;
serverName = server.getServerInfo().getXMPPDomain();
router = server.getPacketRouter();
routingTable = server.getRoutingTable();
deliverer = server.getPacketDeliverer();
......@@ -813,7 +814,6 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
public void start() {
super.start();
serverName = server.getServerInfo().getXMPPDomain();
createListeners();
startListeners();
SocketSendingTracker.getInstance().start();
......
......@@ -131,7 +131,8 @@ public class User implements Cacheable, Externalizable, Result {
}
this.name = name;
if (UserManager.getUserProvider().isEmailRequired() && !StringUtils.isValidEmailAddress(email)) {
throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address");
throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address. User: "
+ username + " Email: " + email);
}
this.email = email;
this.creationDate = creationDate;
......
......@@ -144,10 +144,12 @@ public class UserManager implements IQResultListener {
throw new IllegalArgumentException("Invalid username: " + username, se);
}
if (provider.isNameRequired() && (name == null || name.equals(""))) {
throw new IllegalArgumentException("Invalid or empty name specified with provider that requires name");
throw new IllegalArgumentException("Invalid or empty name specified with provider that requires name. User: "
+ username + " Name: " + name);
}
if (provider.isEmailRequired() && !StringUtils.isValidEmailAddress(email)) {
throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address");
throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address. User: "
+ username + " Email: " + email);
}
User user = provider.createUser(username, password, name, email);
userCache.put(username, user);
......
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