protected void isValidUsername(String username) throws UsersRepositoryException {
int i = username.indexOf("@");
if (supportVirtualHosting()) {
// need a @ in the username
if (i == -1) {
throw new UsersRepositoryException("Given Username needs to contain a @domainpart");
} else {
String domain = username.substring(i + 1);
try {
if (!domainList.containsDomain(domain)) {
throw new UsersRepositoryException("Domain does not exist in DomainList");
} else {
}
} catch (DomainListException e) {
throw new UsersRepositoryException("Unable to query DomainList", e);
}
}
} else {
// @ only allowed when virtualhosting is supported
if (i != -1) {
throw new UsersRepositoryException("Given Username contains a @domainpart but virtualhosting support is disabled");
}
}
}