Validate user name during registration

This commit is contained in:
Kai S. K. Engelbart 2020-06-26 22:04:40 +02:00
parent f84ea35321
commit cd48ce6755

View File

@ -20,6 +20,7 @@ import envoy.server.data.PersistenceManager;
import envoy.server.data.User;
import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy;
import envoy.util.Bounds;
import envoy.util.EnvoyLog;
/**
@ -76,6 +77,12 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
return;
}
} else {
// Validate user name
if (!Bounds.isValidContactName(credentials.getIdentifier())) {
logger.info("The requested user name is not valid.");
writeProxy.write(socketID, new HandshakeRejection(INTERNAL_ERROR));
return;
}
try {
// Checking that no user already has this identifier
PersistenceManager.getInstance().getUserByName(credentials.getIdentifier());