summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup/ldap/LDAPProperties.java
blob: 3f48935f09336b7439fe7c55a00a4ba585bc415c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Directory Lookup Service
*/

package com.c2kernel.lookup.ldap;

import java.math.BigInteger;
import java.security.SecureRandom;

import com.c2kernel.process.Gateway;

/**
 * @version $Revision: 1.16 $ $Date: 2005/10/12 12:51:54 $
 * @author  $Author: abranson $
 */
public class LDAPProperties
{
    public String mGlobalPath = null;     //o=cern.ch
    public String mRootPath = null;     //cn=cristal2
    public String mLocalPath = null;    //cn=lab27
    public Integer mPort = null;
    public String mHost = null;
    public String mUser = null;
    public String mPassword = null;
    public static String mGeneratedPassword = null;
    public String mDbPath = null;

    public LDAPProperties()
    {
        mGlobalPath   = Gateway.getProperty( "LDAP.GlobalPath" );
        mRootPath     = Gateway.getProperty( "LDAP.RootPath" );
        mLocalPath    = Gateway.getProperty( "LDAP.LocalPath" );
        mPort         = Integer.valueOf(Gateway.getProperty( "LDAP.port", "389" ));
        mHost         = Gateway.getProperty( "LDAP.host" );
        mUser         = Gateway.getProperty( "LDAP.user" );
        mPassword     = Gateway.getProperty( "LDAP.password" );
        mDbPath		  = Gateway.getProperty( "LDAP.dbPath" );

        mRootPath    += "," + mGlobalPath;
        mLocalPath   += "," + mRootPath;

    }
    

    public void generateRootPassword() {
    	if (mPassword == null) {
    		if (mGeneratedPassword == null) {
    	    	SecureRandom random = new SecureRandom();
    	    	mGeneratedPassword = new BigInteger(130, random).toString(32);
    		}
    		mPassword = mGeneratedPassword;
    	}
    }
}