From c9b9cea6d6c59107ab3a6a67a81e8e3862b41fce Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 1 Aug 2012 10:26:51 +0200 Subject: LDAP properties: Integer port and support for generating secure admin passwords for embedded LDAP servers. --- .../java/com/c2kernel/lookup/LDAPProperties.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/LDAPProperties.java') diff --git a/src/main/java/com/c2kernel/lookup/LDAPProperties.java b/src/main/java/com/c2kernel/lookup/LDAPProperties.java index e884a54..a9ae699 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPProperties.java +++ b/src/main/java/com/c2kernel/lookup/LDAPProperties.java @@ -4,6 +4,9 @@ package com.c2kernel.lookup; +import java.math.BigInteger; +import java.security.SecureRandom; + import com.c2kernel.process.Gateway; /** @@ -15,24 +18,38 @@ public class LDAPProperties public String mGlobalPath = null; //o=cern.ch public String mRootPath = null; //cn=cristal2 public String mLocalPath = null; //cn=lab27 - public String mPort = null; + 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 = Gateway.getProperty( "LDAP.port" ); + 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; + } + } } -- cgit v1.2.3