Merge pull request #43 from informatik-ag-ngl/f/user_name_validation

Validate user name during registration
This commit is contained in:
Kai S. K. Engelbart 2020-06-27 09:24:24 +00:00 committed by GitHub
commit 97b7b8070f

View File

@ -20,6 +20,7 @@ import envoy.server.data.PersistenceManager;
import envoy.server.data.User; import envoy.server.data.User;
import envoy.server.net.ConnectionManager; import envoy.server.net.ConnectionManager;
import envoy.server.net.ObjectWriteProxy; import envoy.server.net.ObjectWriteProxy;
import envoy.util.Bounds;
import envoy.util.EnvoyLog; import envoy.util.EnvoyLog;
/** /**
@ -76,6 +77,12 @@ public final class LoginCredentialProcessor implements ObjectProcessor<LoginCred
return; return;
} }
} else { } 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 { try {
// Checking that no user already has this identifier // Checking that no user already has this identifier
PersistenceManager.getInstance().getUserByName(credentials.getIdentifier()); PersistenceManager.getInstance().getUserByName(credentials.getIdentifier());