You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/10/20 21:57:50 UTC

svn commit: r706394 - /mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java

Author: ngn
Date: Mon Oct 20 12:57:50 2008
New Revision: 706394

URL: http://svn.apache.org/viewvc?rev=706394&view=rev
Log:
Enable key and trust stores to be fallback loaded from the classpath

Modified:
    mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java

Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java?rev=706394&r1=706393&r2=706394&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ssl/SslConfigurationFactory.java Mon Oct 20 12:57:50 2008
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.security.GeneralSecurityException;
 import java.security.KeyStore;
 
@@ -283,9 +284,20 @@
 
     private KeyStore loadStore(File storeFile, String storeType,
             String storePass) throws IOException, GeneralSecurityException {
-        FileInputStream fin = null;
+        InputStream fin = null;
         try {
-            fin = new FileInputStream(storeFile);
+            if(storeFile.exists()) {
+                LOG.debug("Trying to load store from file");
+                fin = new FileInputStream(storeFile);
+            } else {
+                LOG.debug("Trying to load store from classpath");
+                fin = getClass().getClassLoader().getResourceAsStream(storeFile.getPath());
+                
+                if(fin == null) {
+                    throw new FtpServerConfigurationException("Key store could not be loaded from " + storeFile.getPath());
+                }
+            }
+            
             KeyStore store = KeyStore.getInstance(storeType);
             store.load(fin, storePass.toCharArray());