A user name can only be composed of digits,
standard ASCII letters and the symbols defined in {@link #USERNAME_CONSTRAINTS}.<p>

@see org.opencms.security.I_CmsValidationHandler#checkUserName(java.lang.String)
164712
public void checkUserName(String userName) throws CmsIllegalArgumentException {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
            throw new CmsIllegalArgumentException(
                Messages.get().container(Messages.ERR_BAD_USERNAME_EMPTY_0, userName));
        }

        CmsStringUtil.checkName(userName, USERNAME_CONSTRAINTS, Messages.ERR_BAD_USERNAME_4, Messages.get());
    }
227241
private boolean existsUser(String name) {

        CmsUser user = null;
        try {
            user = m_cms.readUser(name);
        } catch (CmsException e) {
            // this will happen, if the user does not exist
        }
        return user != null;
    }
1372289
protected boolean isAlreadyAvailable(String userName) {

        List<CmsUser> availableUsers;
        try {
            availableUsers = OpenCms.getOrgUnitManager().getUsers(getCms(), m_ou, false);
        } catch (CmsException e) {
            availableUsers = new ArrayList<CmsUser>();
        }
        Iterator<CmsUser> itAvailableUsers = availableUsers.iterator();
        while (itAvailableUsers.hasNext()) {
            if (userName.equals(itAvailableUsers.next().getSimpleName())) {
                return true;
            }
        }
        return false;
    }
855463
def is_full_mxid(user_string):
    """"""
    if not user_string[0] == "@":
        return False
    parts = user_string[1:].split(":")
    localpart_chars = ascii_lowercase + digits + "._-="
    if not (len(parts) == 2 and all([i in localpart_chars for i in parts[0]])):
        return False
    return True
1069455
private void check( String pathName )
    {
        for ( char c : pathName.toCharArray() ) {
            if ( c < 32 || FORBIDDEN_CHAR == c ) {
                throw new IllegalArgumentException( "Pathname contains invalid char " + c + " : " + pathName );
            }
        }
        // Check each component :
        for ( String comp : pathName.split( "/" ) ) {
            if ( !comp.trim().equals( comp ) ) {
                throw new IllegalArgumentException( "Pathname contains leading or trailing spaces : " + pathName );
            }
        }
    }
331693
private String getSimpleUsername(String username) {
        int lastSlash = username.lastIndexOf('\\');
        if (lastSlash > -1) {
            username = username.substring(lastSlash + 1);
        }

        return username;
    }
540443
public boolean isUserGuest(String userName) {

        if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
            return false;
        }
        return m_userGuest.equals(userName);
    }
1246551
public static boolean isValidJavaIdentifier(String s)
	{
		if (s == null || s.length() == 0)
		{
			return false;
		}

		if (isJavaKeyword(s))
		{
			return false;
		}

		char[] c = s.toCharArray();
		if (!Character.isJavaIdentifierStart(c[0]))
		{
			return false;
		}

		for (int i = 1; i < c.length; i++)
		{
			if (!Character.isJavaIdentifierPart(c[i]))
			{
				return false;
			}
		}

		return true;
	}
922639
void validateAffiliationNames(String name) throws InvalidArgumentException {
        checkFormat(name);
        if (name.startsWith(".")) {
            throw new InvalidArgumentException("Affiliation name cannot start with a dot '.'");
        }
        if (name.endsWith(".")) {
            throw new InvalidArgumentException("Affiliation name cannot end with a dot '.'");
        }
        for (int i = 0; i < name.length(); i++) {
            if ((name.charAt(i) == '.') && (name.charAt(i) == name.charAt(i - 1))) {
                throw new InvalidArgumentException("Affiliation name cannot contain multiple consecutive dots '.'");
            }
        }
    }
577703
public static String userName() {
        return fixNonWord(StringUtils.left(JDefaultName.firstName(), 1).toLowerCase() + JDefaultName.lastName().toLowerCase() + JDefaultNumber.randomNumberString(2));
    }
277027
public static boolean isSuperuser(String username)
    {
        UntypedResultSet result = selectUser(username);
        return !result.isEmpty() && result.one().getBoolean("super");
    }
696121
public void setUserName(String userName) {
        SystemAssert.requireArgument(userName != null && !userName.isEmpty(), "Username cannot be null or empty.");
        this.userName = userName;
    }
336499
@Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        try {
            this.duracloudUserService.checkUsername(value);
        } catch (InvalidUsernameException ex) {
            context.disableDefaultConstraintViolation();
            String message;
            if (ex instanceof ReservedUsernameException) {
                message = RESERVED_USERNAME_MESSAGE;
            } else if (ex instanceof ReservedPrefixException) {
                message = RESERVED_PREFIX_MESSAGE;
            } else {
                message = INVALID_USERNAME_MESSAGE;
            }

            message = MessageFormat.format(message, value);
            ConstraintViolationBuilder cvb =
                context.buildConstraintViolationWithTemplate(message);
            cvb.addConstraintViolation();
            return false;
        } catch (UserAlreadyExistsException ex) {
            return false;
        }

        return true;
    }
551896
public boolean validateUser(String userName, String password, CmsRole requiredRole) {

        boolean result = false;
        try {
            CmsUser user = m_cms.readUser(userName, password);
            result = OpenCms.getRoleManager().hasRole(m_cms, user.getName(), requiredRole);
        } catch (CmsException e) {
            // nothing to do
        }
        return result;
    }
951695
public static boolean isValidNCName(String ncName) {
    final int length = ncName.length();
    if (length == 0) {
      return false;
    }
    char ch = ncName.charAt(0);
    if (!isNCNameStart(ch)) {
      return false;
    }
    for (int i = 1; i < length; ++i) {
      ch = ncName.charAt(i);
      if (!isNCName(ch)) {
        return false;
      }
    }
    return true;
  }
1155643
@Override
	public boolean isUserValid(String userId, AuthType authType) {
		if (userInfoRepository.findByUsernameAndAuthType(userId, authType) != null) {
			return true;
		} else {
			if (authType == AuthType.LDAP) {
				try {
					return searchLdapUser(userId);
				} catch (NamingException ne) {
					LOGGER.error("Failed to query ldap for " + userId, ne);
					return false;
				}
			} else {
				return false;
			}
		}
	}
118131
public boolean isCredentialsValid(String username, String password) {
        try {
            String token = getTokenAuthenticationManager().login(StringUtil.toEmptyIfNull(username), StringUtil.toEmptyIfNull(password));
            getTokenAuthenticationManager().logout(token);

            return true;
        } catch (Exception ex) {
            return false;
        }
    }