/*
 * Copyright (c) 2010, James Leigh Some rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package org.callimachusproject.behaviours;

import java.security.SecureRandom;
import java.util.Random;

/**
 * Generates a random alphanumeric string with some punctuation that can be used
 * as a password.
 * 
 * @author James Leigh
 * 
 */
public class PasswordGenerator {
	private static final Random rnd = new SecureRandom();
	private static final int LENGTH_MIN = 6;
	private static final int LENGTH_MAX = 10;
	private static final char[] CHAR_POOL = { 'a', 'b', 'c', 'd', 'e', 'f',
			'g', 'h', 'k', 'm', 'n', 'p', 'r', 'w', 'x', 'y', 'A', 'B', 'C',
			'D', 'E', 'F', 'G', 'H', 'L', 'M', 'N', 'R', 'S', 'T', '2', '3',
			'4', '5', '6', '7', '8', '!', '^', '*', '-', '_', '=', '.' };

	public String generatePassword() {
		int length = LENGTH_MIN + rnd.nextInt(LENGTH_MAX - LENGTH_MIN + 1);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < length; ++i) {
			sb.append(CHAR_POOL[rnd.nextInt(CHAR_POOL.length)]);
		}
		return sb.toString();
	}
}

@@ -988,17 +988,17 @@
 H_MIN = 
-6
+8
 ;%0A%09priva
@@ -1031,17 +1031,17 @@
 _MAX = 1
-0
+6
 ;%0A%09priva
@@ -1141,17 +1141,32 @@
 , 'p', '
-r
+q', 'r', 't', 'u
 ', 'w', 
@@ -1174,17 +1174,20 @@
 x', 'y',
- 
+%0A%09%09%09
 'A', 'B'
@@ -1192,20 +1192,17 @@
 B', 'C',
-%0A%09%09%09
+ 
 'D', 'E'
@@ -1238,12 +1238,20 @@
 ', '
-R', 
+P', 'R',%0A%09%09%09
 'S',
@@ -1255,16 +1255,21 @@
 S', 'T',
+ 'Z',
  '2', '3
@@ -1270,20 +1270,17 @@
 2', '3',
-%0A%09%09%09
+ 
 '4', '5'
@@ -1295,16 +1295,21 @@
 7', '8',
+ '9',
  '!', '%5E
@@ -1310,17 +1310,20 @@
 !', '%5E',
- 
+%0A%09%09%09
 '*', '-'
@@ -1337,16 +1337,41 @@
 '=', '.'
+, '~', '%5B', '%5D', ';', ','
  %7D;%0A%0A%09pu

Increase length of generated password