code: public static String generateRandomPassword(final CharacterTypes characterTypes, final int length)
      {
          final StringBuffer buffer = new StringBuffer();
          String characters = "";
  
          switch (characterTypes)
          {
  
              case ALPHA:
                  characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
                  break;
  
              case ALPHANUMERIC:
                  characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
                  break;
  
              case ALPHANUMERICSYMBOL:
                  characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()";
                  break;
  
              case NUMERIC:
                  characters = "1234567890";
                  break;
          }
  
          final int charactersLength = characters.length();
          final SecureRandom rnd = new SecureRandom();
  
          for (int i = 0; i < length; i++)
          {
              final double index = rnd.nextInt(charactersLength);
              buffer.append(characters.charAt((int) index));
          }
          return buffer.toString();
      }
docs: Generates a random password of the specified length with the specified characters.
  
  @param characterTypes the types of characters to include in the password
  @param length         the length of the password
  @return the password