public void checkPassword(String password) throws BadRequestException {
  if (password == null) {
    throw new BadRequestException("Password required");
  }
  if (password.length() < 8) {
    throw new BadRequestException("Password should contain at least 8 characters");
  }
  int numOfLetters=0;
  int numOfDigits=0;
  for (  char passwordChar : password.toCharArray()) {
    if (Character.isDigit(passwordChar)) {
      numOfDigits++;
    }
 else     if (Character.isLetter(passwordChar)) {
      numOfLetters++;
    }
  }
  if (numOfDigits == 0 || numOfLetters == 0) {
    throw new BadRequestException("Password should contain letters and digits");
  }
}

public void checkPassword ( String password ) throws BadRequestException { if ( password == null ) { throw new BadRequestException ( "Password required" ) ; } if ( password . length ( ) < 8 ) { throw new BadRequestException ( "Password should contain at least 8 characters" ) ; } int numOfLetters = 0 ; int numOfDigits = 0 ; for ( char passwordChar : password . toCharArray ( ) ) { if ( Character . isDigit ( passwordChar ) ) { numOfDigits ++ ; } else if ( Character . isLetter ( passwordChar ) ) { numOfLetters ++ ; } } if ( numOfDigits == 0 || numOfLetters == 0 ) { throw new BadRequestException ( "Password should contain letters and digits" ) ; } }
checks whether password is ok .
