public static String randomString(int length) {
        if (length < 1) {
            return null;
        }
        // Create a char buffer to put random letters and numbers in.
        char[] randBuffer = new char[length];
        for (int i = 0; i < randBuffer.length; i++) {
            randBuffer[i] = numbersAndLetters[randGen.nextInt(numbersAndLetters.length)];
        }
        return new String(randBuffer);
    }
Returns a random String of numbers and letters (lower and upper case)
of the specified length. The method uses a cryptographically strong
random number generator as provided by {@link SecureRandom}
<p>
The specified length must be at least one. If not, the method will return
null.</p>

@param length the desired length of the random String to return.
@return a random String of numbers and letters of the specified length.
xmppserver/src/main/java/org/jivesoftware/util/StringUtils.java