KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > util > PasswordGenerator


1 package org.tigris.scarab.util;
2 /* ================================================================
3  * Copyright (c) 2000-2002 CollabNet. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * 3. The end-user documentation included with the redistribution, if
17  * any, must include the following acknowlegement: "This product includes
18  * software developed by Collab.Net <http://www.Collab.Net/>."
19  * Alternately, this acknowlegement may appear in the software itself, if
20  * and wherever such third-party acknowlegements normally appear.
21  *
22  * 4. The hosted project names must not be used to endorse or promote
23  * products derived from this software without prior written
24  * permission. For written permission, please contact info@collab.net.
25  *
26  * 5. Products derived from this software may not use the "Tigris" or
27  * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without
28  * prior written permission of Collab.Net.
29  *
30  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
31  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33  * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
34  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
36  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
38  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
40  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41  *
42  * ====================================================================
43  *
44  * This software consists of voluntary contributions made by many
45  * individuals on behalf of Collab.Net.
46  */

47
48 import org.apache.commons.lang.RandomStringUtils;
49
50 /**
51  * Utility for generating unique passwords.
52  *
53  * @author <a HREF="mailto:dabbous@saxess.com">Hussayn Dabbous</a>
54  * @version $Id: PasswordGenerator.java 9313 2004-12-09 22:31:21Z dabbous $
55  */

56 public class PasswordGenerator
57 {
58     /**
59     The maximum length for the unique identifier used for the password.
60     */

61    private static final int UNIQUE_ID_MAX_LEN = 10;
62
63    /**
64     * generate a unique password.
65     * @return
66     */

67    public static String JavaDoc generate()
68    {
69        String JavaDoc tempPassword = RandomStringUtils
70        .randomAlphanumeric(UNIQUE_ID_MAX_LEN);
71        return tempPassword;
72    }
73    
74 }
75
Popular Tags