directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1125902 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
Date Sun, 22 May 2011 10:41:07 GMT
Author: kayyagari
Date: Sun May 22 10:41:07 2011
New Revision: 1125902

URL: http://svn.apache.org/viewvc?rev=1125902&view=rev
Log:
o use the keystore if provided

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java?rev=1125902&r1=1125901&r2=1125902&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
Sun May 22 10:41:07 2011
@@ -20,6 +20,8 @@
 package org.apache.directory.server.ldap.handlers.extended;
 
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.security.KeyStore;
 import java.security.Provider;
 import java.security.SecureRandom;
@@ -143,14 +145,26 @@ public class StartTlsHandler implements 
         LOG.debug( "Setting LDAP Service" );
         Provider provider = Security.getProvider( "SUN" );
         LOG.debug( "provider = {}", provider );
-        CoreKeyStoreSpi coreKeyStoreSpi = new CoreKeyStoreSpi( ldapServer.getDirectoryService()
);
-        KeyStore keyStore = new KeyStore( coreKeyStoreSpi, provider, "JKS" )
-        {
-        };
+        
+        KeyStore keyStore = null;
+        
 
         try
         {
-            keyStore.load( null, null );
+            if ( ldapServer.getKeystoreFile() == null )
+            {
+                CoreKeyStoreSpi coreKeyStoreSpi = new CoreKeyStoreSpi( ldapServer.getDirectoryService()
);
+                keyStore = new KeyStore( coreKeyStoreSpi, provider, "JKS" )
+                {
+                };
+                
+                keyStore.load( null, null );
+            }
+            else
+            {
+                keyStore = KeyStore.getInstance( "JKS" );
+                keyStore.load( new FileInputStream( new File( ldapServer.getKeystoreFile()
) ), null );
+            }
         }
         catch ( Exception e1 )
         {
@@ -169,7 +183,14 @@ public class StartTlsHandler implements 
 
         try
         {
-            keyManagerFactory.init( keyStore, null );
+            char[] password = null;
+            
+            if ( ldapServer.getKeystoreFile() != null )
+            {
+                password = ldapServer.getCertificatePassword().toCharArray();
+            }
+            
+            keyManagerFactory.init( keyStore, password );
         }
         catch ( Exception e )
         {



Mime
View raw message