Author: sgoeschl
Date: Mon Sep 29 14:33:23 2008
New Revision: 700265
URL: http://svn.apache.org/viewvc?rev=700265&view=rev
Log:
Making transparent decryption of configuration files really optional - this
makes me and Gump happy
Modified:
turbine/fulcrum/trunk/yaafi/pom.xml
turbine/fulcrum/trunk/yaafi/project.xml
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
Modified: turbine/fulcrum/trunk/yaafi/pom.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/pom.xml?rev=700265&r1=700264&r2=700265&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/pom.xml (original)
+++ turbine/fulcrum/trunk/yaafi/pom.xml Mon Sep 29 14:33:23 2008
@@ -116,12 +116,14 @@
</exclusions>
</dependency>
<!-- Optional decrytpion of configuration files -->
- <dependency>
+ <!--
+ <dependency>
<groupId>fulcrum</groupId>
<artifactId>fulcrum-yaafi-crypto</artifactId>
<version>1.0.6-SNAPSHOT</version>
<optional>true</optional>
- </dependency>
+ </dependency>
+ -->
<!-- Interceptor dependencies -->
<dependency>
<groupId>com.jamonapi</groupId>
Modified: turbine/fulcrum/trunk/yaafi/project.xml
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/project.xml?rev=700265&r1=700264&r2=700265&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/project.xml (original)
+++ turbine/fulcrum/trunk/yaafi/project.xml Mon Sep 29 14:33:23 2008
@@ -41,7 +41,8 @@
</versions>
<dependencies>
- <!-- run time dependency on decryption of transparent configuration files
-->
+ <!-- run-time dependency on decryption of transparent configuration files
-->
+ <!--
<dependency>
<groupId>fulcrum</groupId>
<artifactId>fulcrum-yaafi-crypto</artifactId>
@@ -52,7 +53,8 @@
<ear.bundle>true</ear.bundle>
</properties>
</dependency>
- <!-- compile time dependency on JAMon for interceptors -->
+ -->
+ <!-- compile time dependency on JAMon for interceptors -->
<dependency>
<groupId>com.jamonapi</groupId>
<artifactId>jamon</artifactId>
Modified:
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
URL:
http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java?rev=700265&r1=700264&r2=700265&view=diff
==============================================================================
---
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
(original)
+++
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
Mon Sep 29 14:33:23 2008
@@ -25,7 +25,9 @@
/**
* Factory class to get a decrypting input stream for reading configuration
- * files.
+ * files. The implementation uses dynamic class loading to make decryption
+ * an optional feature which is highly desirable when avoiding the ECCN
+ * export code problems.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Siegfried Goeschl </a>
*/
@@ -42,11 +44,12 @@
private static String className =
"org.apache.fulcrum.jce.crypto.CryptoStreamFactoryImpl";
/**
- * Create a decrypting input stream using the default password.
+ * Create a (potentially) decrypting input stream using the default
+ * password.
*
* @param is the input stream to be decrypted
* @param isEncrypted the encryption mode (true|false|auto)
- * @return an decrypting input stream
+ * @return a decrypting input stream
* @throws Exception reading the input stream failed
*/
public static InputStream getDecryptingInputStream( InputStream is, String
isEncrypted )
@@ -56,14 +59,22 @@
if( isEncrypted.equalsIgnoreCase("true") )
{
+ // a decrypting input stream was requested
result = createDecryptingInputStream(is, "getInputStream");
}
- else if( isEncrypted.equalsIgnoreCase("auto") )
+ else if( isEncrypted.equalsIgnoreCase("auto") &&
hasCryptoStreamFactory())
{
+ // no user-supplied preferences but crypto stream is available
result = createDecryptingInputStream(is, "getSmartInputStream");
}
+ else if( isEncrypted.equalsIgnoreCase("auto") &&
!hasCryptoStreamFactory())
+ {
+ // no user-supplied perferences so we fall back to normal input
stream
+ result = is;
+ }
else if( isEncrypted.equalsIgnoreCase("false") )
{
+ // just use normal input stream
result = is;
}
else
@@ -76,8 +87,13 @@
/**
* Factory method to create a decrypting input stream.
+ *
+ * @param is the input stream to be decrypted
+ * @param factoryMethodName the name of the factory method
+ * @return a decrypting input stream
+ * @throws Exception creating the decrypting input stream failed
*/
- private static InputStream createDecryptingInputStream( InputStream is,
String methodName )
+ private static InputStream createDecryptingInputStream( InputStream is,
String factoryMethodName )
throws Exception
{
Class[] signature = {InputStream.class};
@@ -90,7 +106,7 @@
}
else
{
- return (InputStream) Clazz.invoke(cryptoStreamFactory, methodName,
signature, args);
+ return (InputStream) Clazz.invoke(cryptoStreamFactory,
factoryMethodName, signature, args);
}
}
@@ -116,4 +132,13 @@
return cryptoStreamFactory;
}
+
+ /**
+ * @return true if a CryptoStreamFactory is available
+ */
+ private static boolean hasCryptoStreamFactory()
+ throws Exception
+ {
+ return ( getCryptoStreamFactory() != null );
+ }
}