You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by sg...@apache.org on 2005/10/03 19:04:24 UTC
svn commit: r293394 [1/8] - in /jakarta/turbine/fulcrum/trunk/yaafi: ./
contrib/ src/java/org/apache/fulcrum/jce/crypto/
src/java/org/apache/fulcrum/yaafi/cli/
src/java/org/apache/fulcrum/yaafi/framework/component/
src/java/org/apache/fulcrum/yaafi/fra...
Author: sgoeschl
Date: Mon Oct 3 10:03:11 2005
New Revision: 293394
URL: http://svn.apache.org/viewcvs?rev=293394&view=rev
Log:
Synchronizing the SVN repository with my development CVS. The commit covers the following changes
+) Updating to avalon-framework-api/impl-4.3.0.jar
+) Adding interceptor services to YAAFI
+) Using ReadWriteLocks for reconfiguring YAAFI on the fly
+) Added a "logger" attribute to the role configuration
+) Using parent logger during service initialization
+) Updated the documentation
Added:
jakarta/turbine/fulcrum/trunk/yaafi/contrib/log4j.properties
jakarta/turbine/fulcrum/trunk/yaafi/contrib/readme.txt
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/context/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/context/AvalonToYaafiContextMapper.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/context/YaafiToAvalonContextMapper.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorContext.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorContextImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorService.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/AvalonLoggerFacade.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/GenericLock.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/LockException.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/LoggerFacade.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/MultiLevelLock.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/MultiLevelLock2.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/ReadWriteLock.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/tls/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/tls/ThreadLocalStorage.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/tls/ThreadLocalStorageImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ExceptionUtils.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ReadWriteLock.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/StringUtils.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ToStringBuilder.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/baseservice/BaseInterceptorServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorService.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/logging/LoggingInterceptorServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorService.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/performance/PerformanceInterceptorServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/MethodToStringBuilder.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/StopWatch.java
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/logginginterceptor.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/performance.csv
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/performanceinterceptor.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/interceptors/tracing.csv
Modified:
jakarta/turbine/fulcrum/trunk/yaafi/project.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoStreamFactoryImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoUtil.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/HexConverter.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/Main.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/PasswordFactory.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStream.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Main.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Shutdown.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponent.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentLifecycle.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonFortressConstants.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonMerlinConstants.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonPhoenixConstants.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceConstants.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainer.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManager.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerConfiguration.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactory.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/reflection/Clazz.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleConfigurationParserImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntry.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/role/RoleEntryImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/InputStreamLocator.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/Validate.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/baseservice/BaseServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationEntry.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/reconfiguration/ReconfigurationServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/servicemanager/ServiceManagerService.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/servicemanager/ServiceManagerServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/shutdown/Shutdown.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/shutdown/ShutdownEntry.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/shutdown/ShutdownServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/systemproperty/SystemPropertyServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestComponentConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestFortressContainerConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestMerlinContainerConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestPhoenixContainerConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestReconfigurationConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestRoleConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/TestYaafiContainerConfig.xml
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/jce/crypto/CryptoUtilTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStreamTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponent.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/TestComponentTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceImpl.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/cli/MainTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java
jakarta/turbine/fulcrum/trunk/yaafi/src/test/org/apache/fulcrum/yaafi/testcontainer/Container.java
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/changes.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/configuration.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/cryptography.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/howto.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/lifecycle/decommission.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/lifecycle/incarnation.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/lifecycle/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/lifecycle/reconfiguration.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/navigation.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/services/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/services/reconfigurationservice.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/services/servicemanagerservice.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/services/shutdownservice.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/services/systempropertyservice.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/component.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/container.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/context.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/lifecycle.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/specification/role.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/todo.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/index.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/step1.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/step2.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/step3.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/step4.xml
jakarta/turbine/fulcrum/trunk/yaafi/xdocs/tutorial/step5.xml
Added: jakarta/turbine/fulcrum/trunk/yaafi/contrib/log4j.properties
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/contrib/log4j.properties?rev=293394&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/contrib/log4j.properties (added)
+++ jakarta/turbine/fulcrum/trunk/yaafi/contrib/log4j.properties Mon Oct 3 10:03:11 2005
@@ -0,0 +1,59 @@
+#
+# create two appenders
+#
+
+log4j.rootLogger=DEBUG, stdout, file
+
+#
+# custom logfiles
+#
+
+log4j.category.yaafi.tracing = DEBUG, tracing
+log4j.additivity.yaafi.tracing = false
+log4j.category.yaafi.performance = DEBUG, performance
+log4j.additivity.yaafi.performance = false
+
+#
+# configure the stdout appender to go to the console
+#
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+#
+# File Appender
+#
+
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=./temp/it20one-signature-service.log
+log4j.appender.file.MaxFileSize=1000KB
+log4j.appender.file.MaxBackupIndex=2
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
+
+#
+# Tracing Appender
+#
+
+log4j.appender.tracing = org.apache.log4j.FileAppender
+log4j.appender.tracing.file = ./temp/tracing.csv
+log4j.appender.tracing.layout = org.apache.log4j.PatternLayout
+log4j.appender.tracing.layout.conversionPattern = %d;%m%n
+log4j.appender.tracing.append = true
+
+#
+# Performance Appender
+#
+
+log4j.appender.performance = org.apache.log4j.FileAppender
+log4j.appender.performance.file = ./temp/performance.csv
+log4j.appender.performance.layout = org.apache.log4j.PatternLayout
+log4j.appender.performance.layout.conversionPattern = %d;%m%n
+log4j.appender.performance.append = true
+
+#
+# Additional settings for supressing unwanted logging
+#
+
+log4j.logger.yaafi=DEBUG
Added: jakarta/turbine/fulcrum/trunk/yaafi/contrib/readme.txt
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/contrib/readme.txt?rev=293394&view=auto
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/contrib/readme.txt (added)
+++ jakarta/turbine/fulcrum/trunk/yaafi/contrib/readme.txt Mon Oct 3 10:03:11 2005
@@ -0,0 +1,8 @@
+This folder contains files which are not directly supported
+
+log4j.properties
+=============================================================================
+
+A Log4J configuration file showing a sample configuration where the
+output of the LoggingInterceptorService and PerformanceInterceptorService
+are written into a seperate CSV file instead of the standard logfile
\ No newline at end of file
Modified: jakarta/turbine/fulcrum/trunk/yaafi/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/project.xml?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/project.xml (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/project.xml Mon Oct 3 10:03:11 2005
@@ -3,7 +3,7 @@
<extend>${basedir}/../project.xml</extend>
<id>fulcrum-yaafi</id>
<name>Fulcrum's YAAFI</name>
- <currentVersion>1.0.4</currentVersion>
+ <currentVersion>1.0.5-dev</currentVersion>
<versions>
<version>
<id>1.0.4</id>
@@ -16,7 +16,7 @@
<tag>FULCRUM_YAAFI_1_0_3</tag>
</version>
</versions>
- <dependencies>
+ <dependencies>
</dependencies>
@@ -28,7 +28,7 @@
<include>**/*.xinfo</include>
</includes>
</resource>
- </resources>
+ </resources>
<unitTest>
<includes>
<include>**/*Test.java</include>
@@ -36,7 +36,7 @@
<excludes>
<exclude>**/BaseUnitTest.java</exclude>
</excludes>
- </unitTest>
+ </unitTest>
</build>
</project>
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoStreamFactoryImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoStreamFactoryImpl.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoStreamFactoryImpl.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoStreamFactoryImpl.java Mon Oct 3 10:03:11 2005
@@ -35,18 +35,18 @@
* implementation uses the JCE (Java Crypto Extension) either supplied
* by SUN (using SunJCE 1.42) or an custom provider such as BouncyCastle
* or the newer Cryptix libraries.
- *
+ *
* The implementation uses as PBEWithMD5AndTripleDES for encryption which
* should be sufficent for most applications.
- *
+ *
* The implementation also supplies a default password in the case that
* the programmer don't want to have additional hassles. It is easy to
* reengineer the password being used but much better than a hard-coded
* password in the application.
- *
+ *
* The code uses parts from Markus Hahn's Blowfish library found at
* http://blowfishj.sourceforge.net/
- *
+ *
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
* @author <a href="mailto:maakus@earthlink.net">Markus Hahn</a>
*/
@@ -55,16 +55,16 @@
{
/** the salt for the PBE algorithm */
private byte[] salt;
-
+
/** the count paramter for the PBE algorithm */
private int count;
-
+
/** the name of the JCE provider */
private String providerName;
-
+
/** the algorithm to use */
private String algorithm;
-
+
/** the default instance */
private static CryptoStreamFactory instance;
@@ -83,7 +83,7 @@
}
}
}
-
+
return instance;
}
@@ -95,12 +95,12 @@
{
CryptoStreamFactoryImpl.instance = instance;
}
-
+
/**
* Constructor
*/
public CryptoStreamFactoryImpl()
- {
+ {
this.salt = CryptoParameters.SALT;
this.count = CryptoParameters.COUNT;
this.providerName = CryptoParameters.PROVIDERNAME;
@@ -109,48 +109,48 @@
/**
* Constructor
- *
- * @param salt the salt for the PBE algorithm
+ *
+ * @param salt the salt for the PBE algorithm
* @param count the iteration for PBEParameterSpec
* @param algorithm the algorithm to be used
* @param providerName the name of the JCE provide to b used
*/
- public CryptoStreamFactoryImpl(
- byte[] salt,
- int count,
- String algorithm,
+ public CryptoStreamFactoryImpl(
+ byte[] salt,
+ int count,
+ String algorithm,
String providerName )
- {
+ {
this.salt = salt;
this.count = count;
this.algorithm = algorithm;
- this.providerName = providerName;
+ this.providerName = providerName;
}
/**
* @param is the input stream to be wrapped
* @return a decrypting input stream
*/
- public InputStream getInputStream( InputStream is )
- throws GeneralSecurityException, IOException
- {
+ public InputStream getInputStream( InputStream is )
+ throws GeneralSecurityException, IOException
+ {
Cipher cipher = this.createCipher( Cipher.DECRYPT_MODE, PasswordFactory.create() );
- CipherInputStream cis = new CipherInputStream( is, cipher );
+ CipherInputStream cis = new CipherInputStream( is, cipher );
return cis;
- }
-
+ }
+
/**
* @param is the input stream to be wrapped
* @param password the password for decryption
* @return a decrypting input stream
*/
- public InputStream getInputStream( InputStream is, char[] password )
- throws GeneralSecurityException, IOException
- {
+ public InputStream getInputStream( InputStream is, char[] password )
+ throws GeneralSecurityException, IOException
+ {
Cipher cipher = this.createCipher( Cipher.DECRYPT_MODE, password );
- CipherInputStream cis = new CipherInputStream( is, cipher );
+ CipherInputStream cis = new CipherInputStream( is, cipher );
return cis;
- }
+ }
/**
* @see org.apache.fulcrum.jce.crypto.CryptoStreamFactory#getSmartInputStream(java.io.InputStream)
@@ -161,7 +161,7 @@
return this.getSmartInputStream(
is,
PasswordFactory.create()
- );
+ );
}
/**
@@ -171,31 +171,31 @@
throws GeneralSecurityException, IOException
{
SmartDecryptingInputStream result = null;
-
+
result = new SmartDecryptingInputStream(
getInstance(),
is,
- password
- );
-
+ password
+ );
+
return result;
}
-
+
/**
* @param os the output stream to be wrapped
* @param password the password for encryption
- *
+ *
* @return a encrypting output stream
*/
- public OutputStream getOutputStream( OutputStream os, char[] password )
- throws GeneralSecurityException, IOException
- {
+ public OutputStream getOutputStream( OutputStream os, char[] password )
+ throws GeneralSecurityException, IOException
+ {
Cipher cipher = this.createCipher( Cipher.ENCRYPT_MODE, password );
- CipherOutputStream cos = new CipherOutputStream( os, cipher );
- return cos;
- }
-
+ CipherOutputStream cos = new CipherOutputStream( os, cipher );
+ return cos;
+ }
+
/**
* @return Returns the algorithm.
*/
@@ -203,7 +203,7 @@
{
return algorithm;
}
-
+
/**
* @return Returns the count.
*/
@@ -211,7 +211,7 @@
{
return count;
}
-
+
/**
* @return Returns the providerName.
*/
@@ -219,7 +219,7 @@
{
return providerName;
}
-
+
/**
* @return Returns the salt.
*/
@@ -227,59 +227,59 @@
{
return salt;
}
-
+
/**
* Create a PBE key.
- *
+ *
* @param password the password to use.
* @return the key
* @throws NoSuchAlgorithmException
* @throws InvalidKeySpecException
*/
private final Key createKey( char[] password )
- throws GeneralSecurityException
+ throws GeneralSecurityException
{
SecretKeyFactory keyFactory = null;
- String algorithm = this.getAlgorithm();
- PBEKeySpec keySpec = new PBEKeySpec(password);
-
- if( this.getProviderName() == null )
- {
- keyFactory = SecretKeyFactory.getInstance( algorithm );
- }
- else
- {
- keyFactory = SecretKeyFactory.getInstance( algorithm, this.getProviderName() );
- }
-
- Key key = keyFactory.generateSecret(keySpec);
- return key;
+ String algorithm = this.getAlgorithm();
+ PBEKeySpec keySpec = new PBEKeySpec(password);
+
+ if( this.getProviderName() == null )
+ {
+ keyFactory = SecretKeyFactory.getInstance( algorithm );
+ }
+ else
+ {
+ keyFactory = SecretKeyFactory.getInstance( algorithm, this.getProviderName() );
+ }
+
+ Key key = keyFactory.generateSecret(keySpec);
+ return key;
}
-
+
/**
- * Create a Cipher.
- *
+ * Create a Cipher.
+ *
* @param mode the cipher mode
* @param password the password
* @return an instance of a cipher
*/
private final Cipher createCipher( int mode, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
Cipher cipher = null;
- PBEParameterSpec paramSpec = new PBEParameterSpec( this.getSalt(), this.getCount() );
- Key key = this.createKey( password );
-
- if( this.getProviderName() == null )
- {
- cipher = Cipher.getInstance( this.getAlgorithm() );
- }
- else
- {
- cipher = Cipher.getInstance( this.getAlgorithm(), this.getProviderName() );
- }
-
- cipher.init( mode, key, paramSpec );
- return cipher;
- }
+ PBEParameterSpec paramSpec = new PBEParameterSpec( this.getSalt(), this.getCount() );
+ Key key = this.createKey( password );
+
+ if( this.getProviderName() == null )
+ {
+ cipher = Cipher.getInstance( this.getAlgorithm() );
+ }
+ else
+ {
+ cipher = Cipher.getInstance( this.getAlgorithm(), this.getProviderName() );
+ }
+
+ cipher.init( mode, key, paramSpec );
+ return cipher;
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoUtil.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoUtil.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoUtil.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/CryptoUtil.java Mon Oct 3 10:03:11 2005
@@ -29,19 +29,19 @@
/**
* Helper class to provde generic functions to work with CryptoStreams.
- *
+ *
* The code uses parts from Markus Hahn's Blowfish library found at
* http://blowfishj.sourceforge.net/
- *
+ *
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
* @author <a href="mailto:maakus@earthlink.net">Markus Hahn</a>
*/
public final class CryptoUtil
-{
+{
/** the size of the internal buffer to copy streams */
private static final int BUFFER_SIZE = 1024;
-
+
/**
* Copies from a source to a target object using encryption
*
@@ -50,21 +50,21 @@
* @param password the password to use for encryption
* @throws GeneralSecurityException accessing JCE failed
* @throws IOException accessing the souce failed
- *
+ *
*/
public static void encrypt( Object source, Object target, char[] password )
throws GeneralSecurityException, IOException
{
- CryptoUtil.encrypt(
- CryptoUtil.getCryptoStreamFactory(),
- source,
- target,
- password
+ CryptoUtil.encrypt(
+ CryptoUtil.getCryptoStreamFactory(),
+ source,
+ target,
+ password
);
}
/**
- * Copies from a source to a target object using encryption and a
+ * Copies from a source to a target object using encryption and a
* caller supplied CryptoStreamFactory.
*
* @param factory the factory to create the crypto streams
@@ -72,15 +72,15 @@
* @param target the target object
* @param password the password to use for encryption
* @throws GeneralSecurityException accessing JCE failed
- * @throws IOException accessing the souce failed
+ * @throws IOException accessing the souce failed
*/
- public static void encrypt(
+ public static void encrypt(
CryptoStreamFactory factory, Object source, Object target, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
InputStream is = CryptoUtil.createInputStream( source );
OutputStream os = CryptoUtil.createOutputStream( target );
- OutputStream eos = factory.getOutputStream( os, password );
+ OutputStream eos = factory.getOutputStream( os, password );
CryptoUtil.copy( is, eos );
}
@@ -91,12 +91,12 @@
* @param target the target object
* @param password the password to use for decryption
* @throws GeneralSecurityException accessing JCE failed
- * @throws IOException accessing the souce failed
+ * @throws IOException accessing the souce failed
*/
public static void decrypt( Object source, Object target, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
- CryptoUtil.decrypt(
+ CryptoUtil.decrypt(
CryptoUtil.getCryptoStreamFactory(),
source,
target,
@@ -105,9 +105,9 @@
}
/**
- * Copies from a source to a target object using decryption and a
+ * Copies from a source to a target object using decryption and a
* caller-suppier CryptoStreamFactory.
- *
+ *
* @param factory the factory to create the crypto streams
* @param source the source object
* @param target the target object
@@ -115,19 +115,19 @@
* @throws GeneralSecurityException accessing JCE failed
* @throws IOException accessing the souce failed
*/
- public static void decrypt(
+ public static void decrypt(
CryptoStreamFactory factory, Object source, Object target, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
InputStream is = CryptoUtil.createInputStream( source );
- OutputStream os = CryptoUtil.createOutputStream( target );
+ OutputStream os = CryptoUtil.createOutputStream( target );
InputStream dis = factory.getInputStream( is, password );
CryptoUtil.copy( dis, os );
}
/**
* Encrypts a string into a hex string.
- *
+ *
* @param plainText the plain text to be encrypted
* @param password the password for encryption
* @return the encrypted string
@@ -135,18 +135,18 @@
* @throws IOException accessing the souce failed
*/
public static String encryptString( String plainText, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
- return CryptoUtil.encryptString(
+ return CryptoUtil.encryptString(
CryptoUtil.getCryptoStreamFactory(),
plainText,
password
- );
+ );
}
/**
* Encrypts a string into a hex string.
- *
+ *
* @param factory the factory to create the crypto streams
* @param plainText the plain text to be encrypted
* @param password the password for encryption
@@ -154,11 +154,11 @@
* @throws GeneralSecurityException accessing JCE failed
* @throws IOException accessing the souce failed
*/
- public static String encryptString(
+ public static String encryptString(
CryptoStreamFactory factory, String plainText, char[] password )
- throws GeneralSecurityException, IOException
+ throws GeneralSecurityException, IOException
{
- ByteArrayOutputStream bais = new ByteArrayOutputStream();
+ ByteArrayOutputStream bais = new ByteArrayOutputStream();
CryptoUtil.encrypt( factory, plainText, bais, password );
return HexConverter.toString( bais.toByteArray() );
}
@@ -166,7 +166,7 @@
/**
* Decrypts an encrypted string into the plain text. The encrypted
* string must be a hex string created by encryptString.
- *
+ *
* @param cipherText the encrypted text to be decrypted
* @param password the password for decryption
* @return the decrypted string
@@ -174,19 +174,19 @@
* @throws IOException accessing the souce failed
*/
public static String decryptString( String cipherText, char[] password )
- throws GeneralSecurityException, IOException
- {
- return CryptoUtil.decryptString(
+ throws GeneralSecurityException, IOException
+ {
+ return CryptoUtil.decryptString(
CryptoUtil.getCryptoStreamFactory(),
cipherText,
password
);
- }
+ }
/**
* Decrypts an encrypted string into the plain text. The encrypted
* string must be a hex string created by encryptString.
- *
+ *
* @param factory the factory to create the crypto streams
* @param cipherText the encrypted text to be decrypted
* @param password the password for decryption
@@ -194,28 +194,28 @@
* @throws GeneralSecurityException accessing JCE failed
* @throws IOException accessing the souce failed
*/
- public static String decryptString(
+ public static String decryptString(
CryptoStreamFactory factory, String cipherText, char[] password )
- throws GeneralSecurityException, IOException
- {
- byte[] buffer = HexConverter.toBytes( cipherText );
- ByteArrayOutputStream bais = new ByteArrayOutputStream();
- CryptoUtil.decrypt( factory, buffer, bais, password );
- return new String( bais.toByteArray(), "utf-8" );
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Private Implementation
- ///////////////////////////////////////////////////////////////////////////
-
+ throws GeneralSecurityException, IOException
+ {
+ byte[] buffer = HexConverter.toBytes( cipherText );
+ ByteArrayOutputStream bais = new ByteArrayOutputStream();
+ CryptoUtil.decrypt( factory, buffer, bais, password );
+ return new String( bais.toByteArray(), "utf-8" );
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Private Implementation
+ ///////////////////////////////////////////////////////////////////////////
+
/**
* Create an input stream supporting the following types
- *
+ *
* <ul>
- * <li>String</li>
+ * <li>String</li>
* <li>File</li>
- * <li>byte[]</li>
- * <li>char[]</li>
+ * <li>byte[]</li>
+ * <li>char[]</li>
* <li>ByteArrayOutputStream</li>
* <li>InputStream</li>
* </ul>
@@ -260,9 +260,9 @@
/**
* Create an output stream supporting the following types
- *
+ *
* <ul>
- * <li>File</li>
+ * <li>File</li>
* <li>OutputStream</li>
* </ul>
*/
@@ -282,7 +282,7 @@
return os;
}
-
+
/**
* Pumps the input stream to the output stream.
*
@@ -304,10 +304,10 @@
}
is.close();
-
+
os.flush();
os.close();
- }
+ }
/**
* @return the CryptoStreamFactory to be used
@@ -315,5 +315,5 @@
public static CryptoStreamFactory getCryptoStreamFactory()
{
return CryptoStreamFactoryImpl.getInstance();
- }
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/HexConverter.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/HexConverter.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/HexConverter.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/HexConverter.java Mon Oct 3 10:03:11 2005
@@ -20,153 +20,153 @@
/**
* Helper class to for HEX conversion.
- *
+ *
* The code uses parts from Markus Hahn's Blowfish library found at
* http://blowfishj.sourceforge.net/
- *
+ *
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
* @author <a href="mailto:maakus@earthlink.net">Markus Hahn</a>
*/
public final class HexConverter
-{
+{
/**
* Table for byte to hex conversion
*/
- final private static char[] HEXTAB =
- {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
- };
-
- /**
- * Converts a byte array to a hex string.
- *
- * @param data the byte array
- * @return the hex string
- */
- public final static String toString( byte[] data )
- {
- return bytesToHexStr(data, 0, data.length);
- }
-
- /**
- * Converts a hex string into a byte[]
- *
- * @param data the hex string
- * @return the byte[]
- */
-
- public final static byte[] toBytes( String data )
- {
- byte[] result = new byte[data.length()/2];
- hexStrToBytes( data, result, 0, 0, result.length );
- return result;
- }
-
- /**
- * Converts a byte array to a hex string.
- * @param data the byte array
- * @param nOfs start index where to get the bytes
- * @param nLen number of bytes to convert
- * @return the hex string
- */
- private final static String bytesToHexStr(
- byte[] data,
- int nOfs,
- int nLen)
- {
- StringBuffer sbuf;
-
- sbuf = new StringBuffer();
- sbuf.setLength(nLen << 1);
-
- int nPos = 0;
- int nC = nOfs + nLen;
-
- while (nOfs < nC)
- {
- sbuf.setCharAt(nPos++, HEXTAB[(data[nOfs ] >> 4) & 0x0f]);
- sbuf.setCharAt(nPos++, HEXTAB[ data[nOfs++] & 0x0f]);
- }
-
- return sbuf.toString();
- }
-
- /**
- * Converts a hex string back into a byte array (invalid codes will be
- * skipped).
- * @param sHex hex string
- * @param data the target array
- * @param nSrcOfs from which character in the string the conversion should
- * begin, remember that (nSrcPos modulo 2) should equals 0 normally
- * @param nDstOfs to store the bytes from which position in the array
- * @param nLen number of bytes to extract
- * @return number of extracted bytes
- */
- private final static int hexStrToBytes(
- String sHex,
- byte[] data,
- int nSrcOfs,
- int nDstOfs,
- int nLen)
- {
- int nI, nJ, nStrLen, nAvailBytes, nDstOfsBak;
- byte bActByte;
- boolean blConvertOK;
-
- // check for correct ranges
-
- nStrLen = sHex.length();
-
- nAvailBytes = (nStrLen - nSrcOfs) >> 1;
- if (nAvailBytes < nLen)
- {
- nLen = nAvailBytes;
- }
-
- int nOutputCapacity = data.length - nDstOfs;
- if (nLen > nOutputCapacity)
- {
- nLen = nOutputCapacity;
- }
-
- // convert now
-
- nDstOfsBak = nDstOfs;
-
- for (nI = 0; nI < nLen; nI++)
- {
- bActByte = 0;
- blConvertOK = true;
-
- for (nJ = 0; nJ < 2; nJ++)
- {
- bActByte <<= 4;
- char cActChar = sHex.charAt(nSrcOfs++);
-
- if ((cActChar >= 'a') && (cActChar <= 'f'))
- {
- bActByte |= (byte) (cActChar - 'a') + 10;
- }
- else
- {
- if ((cActChar >= '0') && (cActChar <= '9'))
- {
- bActByte |= (byte) (cActChar - '0');
- }
- else
- {
- blConvertOK = false;
- }
- }
- }
- if (blConvertOK)
- {
- data[nDstOfs++] = bActByte;
- }
- }
+ final private static char[] HEXTAB =
+ {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+ };
- return (nDstOfs - nDstOfsBak);
- }
+ /**
+ * Converts a byte array to a hex string.
+ *
+ * @param data the byte array
+ * @return the hex string
+ */
+ public final static String toString( byte[] data )
+ {
+ return bytesToHexStr(data, 0, data.length);
+ }
+
+ /**
+ * Converts a hex string into a byte[]
+ *
+ * @param data the hex string
+ * @return the byte[]
+ */
+
+ public final static byte[] toBytes( String data )
+ {
+ byte[] result = new byte[data.length()/2];
+ hexStrToBytes( data, result, 0, 0, result.length );
+ return result;
+ }
+
+ /**
+ * Converts a byte array to a hex string.
+ * @param data the byte array
+ * @param nOfs start index where to get the bytes
+ * @param nLen number of bytes to convert
+ * @return the hex string
+ */
+ private final static String bytesToHexStr(
+ byte[] data,
+ int nOfs,
+ int nLen)
+ {
+ StringBuffer sbuf;
+
+ sbuf = new StringBuffer();
+ sbuf.setLength(nLen << 1);
+
+ int nPos = 0;
+ int nC = nOfs + nLen;
+
+ while (nOfs < nC)
+ {
+ sbuf.setCharAt(nPos++, HEXTAB[(data[nOfs ] >> 4) & 0x0f]);
+ sbuf.setCharAt(nPos++, HEXTAB[ data[nOfs++] & 0x0f]);
+ }
+
+ return sbuf.toString();
+ }
+
+ /**
+ * Converts a hex string back into a byte array (invalid codes will be
+ * skipped).
+ * @param sHex hex string
+ * @param data the target array
+ * @param nSrcOfs from which character in the string the conversion should
+ * begin, remember that (nSrcPos modulo 2) should equals 0 normally
+ * @param nDstOfs to store the bytes from which position in the array
+ * @param nLen number of bytes to extract
+ * @return number of extracted bytes
+ */
+ private final static int hexStrToBytes(
+ String sHex,
+ byte[] data,
+ int nSrcOfs,
+ int nDstOfs,
+ int nLen)
+ {
+ int nI, nJ, nStrLen, nAvailBytes, nDstOfsBak;
+ byte bActByte;
+ boolean blConvertOK;
+
+ // check for correct ranges
+
+ nStrLen = sHex.length();
+
+ nAvailBytes = (nStrLen - nSrcOfs) >> 1;
+ if (nAvailBytes < nLen)
+ {
+ nLen = nAvailBytes;
+ }
+
+ int nOutputCapacity = data.length - nDstOfs;
+ if (nLen > nOutputCapacity)
+ {
+ nLen = nOutputCapacity;
+ }
+
+ // convert now
+
+ nDstOfsBak = nDstOfs;
+
+ for (nI = 0; nI < nLen; nI++)
+ {
+ bActByte = 0;
+ blConvertOK = true;
+
+ for (nJ = 0; nJ < 2; nJ++)
+ {
+ bActByte <<= 4;
+ char cActChar = sHex.charAt(nSrcOfs++);
+
+ if ((cActChar >= 'a') && (cActChar <= 'f'))
+ {
+ bActByte |= (byte) (cActChar - 'a') + 10;
+ }
+ else
+ {
+ if ((cActChar >= '0') && (cActChar <= '9'))
+ {
+ bActByte |= (byte) (cActChar - '0');
+ }
+ else
+ {
+ blConvertOK = false;
+ }
+ }
+ }
+ if (blConvertOK)
+ {
+ data[nDstOfs++] = bActByte;
+ }
+ }
+
+ return (nDstOfs - nDstOfsBak);
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/Main.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/Main.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/Main.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/Main.java Mon Oct 3 10:03:11 2005
@@ -1,13 +1,5 @@
package org.apache.fulcrum.jce.crypto;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
/*
* Copyright 2004 Apache Software Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,17 +17,22 @@
* limitations under the License.
*/
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
/**
* Command line tool for encrypting/decrypting files
- *
+ *
* file [enc|dec] passwd [file]*
* string [enc|dec] passwd plaintext
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class Main
+public class Main
{
/**
* Allows testing on the command lnie
@@ -49,17 +46,17 @@
{
printHelp();
throw new IllegalArgumentException("Invalid command line");
- }
-
+ }
+
String operationMode = args[0];
-
+
if( operationMode.equals("file") )
{
- processFiles(args);
+ processFiles(args);
}
else if( operationMode.equals("string") )
{
- processString(args);
+ processString(args);
}
}
@@ -68,82 +65,85 @@
System.out.println(e.getMessage());
}
}
-
+
/**
* Prints usage information.
*/
public static void printHelp()
{
- System.out.println("Main file [enc|dec|auto] passwd [file]*");
+ System.out.println("Main file [enc|dec] passwd source [target]");
System.out.println("Main string [enc|dec] passwd ");
}
-
+
/**
* Decrypt/encrypt a list of files
* @param args the command line
* @throws Exception the operation failed
*/
public static void processFiles(String[] args)
- throws Exception
- {
- String cipherMode = args[1];
- char[] password = args[2].toCharArray();
-
- for( int i=3; i<args.length; i++ )
- {
- File file = new File(args[i]);
- processFile(cipherMode,password,file);
- }
- }
+ throws Exception
+ {
+ String cipherMode = args[1];
+ char[] password = args[2].toCharArray();
+ File sourceFile = new File(args[3]);
+ File targetFile = null;
+
+ if( args.length == 4 )
+ {
+ targetFile = sourceFile;
+ }
+ else
+ {
+ targetFile = new File(args[4]);
+ }
+
+ processFile(cipherMode,password,sourceFile,targetFile);
+ }
/**
* Decrypt/encrypt a single file
* @param cipherMode the mode
- * @param password the passwors
- * @param file the file to process
+ * @param password the passwors
+ * @param sourceFile the file to process
+ * @param targetFile the targetf file
* @throws Exception the operation failed
*/
- public static void processFile(String cipherMode, char[] password, File file)
- throws Exception
- {
- FileInputStream fis = new FileInputStream(file);
+ public static void processFile(String cipherMode, char[] password, File sourceFile, File targetFile)
+ throws Exception
+ {
+ FileInputStream fis = new FileInputStream(sourceFile);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
+
if( cipherMode.equals("dec") )
{
- System.out.println("Decrypting " + file.getAbsolutePath() );
- InputStream cis = CryptoUtil.getCryptoStreamFactory().getInputStream(fis,password);
- CryptoUtil.copy(cis,baos);
- cis.close();
+ System.out.println("Decrypting " + sourceFile.getAbsolutePath() );
+ CryptoUtil.decrypt( fis, baos, password );
fis.close();
- }
- else if( cipherMode.equals("auto") )
- {
- System.out.println("Auto-decrypting " + file.getAbsolutePath() );
- InputStream cis = CryptoUtil.getCryptoStreamFactory().getSmartInputStream(fis,password);
- CryptoUtil.copy(cis,baos);
- cis.close();
- fis.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ FileOutputStream fos = new FileOutputStream(targetFile);
+ CryptoUtil.copy(bais,fos);
+ bais.close();
+ fos.close();
}
else if( cipherMode.equals("enc") )
{
- System.out.println("Enrypting " + file.getAbsolutePath() );
- OutputStream cos = CryptoUtil.getCryptoStreamFactory().getOutputStream(baos,password);
- CryptoUtil.copy(fis,cos);
- cos.close();
+ System.out.println("Enrypting " + sourceFile.getAbsolutePath() );
+ CryptoUtil.encrypt( fis, baos, password );
fis.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ FileOutputStream fos = new FileOutputStream(targetFile);
+ CryptoUtil.copy(bais,fos);
+ bais.close();
+ fos.close();
}
else
{
String msg = "Don't know what to do with : " + cipherMode;
throw new IllegalArgumentException(msg);
}
-
- FileOutputStream fos = new FileOutputStream(file);
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- CryptoUtil.copy(bais,fos);
- fos.close();
- }
+ }
/**
* Decrypt/encrypt a string
@@ -151,22 +151,22 @@
* @throws Exception the operation failed
*/
public static void processString(String[] args)
- throws Exception
- {
+ throws Exception
+ {
String cipherMode = args[1];
- char[] password = args[2].toCharArray();
- String value = args[3];
- String result = null;
-
- if( cipherMode.equals("dec") )
- {
- result = CryptoUtil.decryptString(value,password);
- }
- else
- {
- result = CryptoUtil.encryptString(value,password);
- }
-
- System.out.println( result );
- }
+ char[] password = args[2].toCharArray();
+ String value = args[3];
+ String result = null;
+
+ if( cipherMode.equals("dec") )
+ {
+ result = CryptoUtil.decryptString(value,password);
+ }
+ else
+ {
+ result = CryptoUtil.encryptString(value,password);
+ }
+
+ System.out.println( result );
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/PasswordFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/PasswordFactory.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/PasswordFactory.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/PasswordFactory.java Mon Oct 3 10:03:11 2005
@@ -21,63 +21,63 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-/**
+/**
* The implementation supplies a default password in the case that
* the programmer don't want to have additional hassles. It is easy to
* reengineer the password being used but much better than a hard-coded
* password in the application.
- *
+ *
* The code uses parts from Markus Hahn's Blowfish library found at
* http://blowfishj.sourceforge.net/
- *
+ *
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl </a>
* @author <a href="mailto:maakus@earthlink.net">Markus Hahn</a>
*/
public class PasswordFactory implements PasswordParameters
-{
+{
/**
* @return a default password using "xxxx-xxxx-xxxx-xxxxx"
*/
- public static final char[] create()
- throws NoSuchAlgorithmException, UnsupportedEncodingException
- {
- return create(
+ public static final char[] create()
+ throws NoSuchAlgorithmException, UnsupportedEncodingException
+ {
+ return create(
PasswordParameters.DEFAULTPASSWORD,
PasswordParameters.SALT,
PasswordParameters.COUNT
);
- }
+ }
/**
* @param seed the default password supplied by the caller
* @return a password using "xxxx-xxxx-xxxx-xxxxx"
*/
- public static final char[] create( String seed )
- throws NoSuchAlgorithmException, UnsupportedEncodingException
- {
- return create(
+ public static final char[] create( String seed )
+ throws NoSuchAlgorithmException, UnsupportedEncodingException
+ {
+ return create(
seed.toCharArray()
);
- }
+ }
/**
* @param seed the default password supplied by the caller
* @return a password using "xxxx-xxxx-xxxx-xxxxx"
*/
- public static final char[] create( char[] seed )
- throws NoSuchAlgorithmException, UnsupportedEncodingException
- {
- return create(
+ public static final char[] create( char[] seed )
+ throws NoSuchAlgorithmException, UnsupportedEncodingException
+ {
+ return create(
seed,
PasswordParameters.SALT,
PasswordParameters.COUNT
);
- }
+ }
/**
* Creates a default password using "xxxx-xxxx-xxxx-xxxxx".
- *
+ *
* @param salt the password salt
* @param password the default password
* @param count number of MessageDigest iterations
@@ -86,15 +86,15 @@
* @throws NoSuchAlgorithmException
* @throws UnsupportedEncodingException
*/
- public static final char [] create( char[] password, byte[] salt, int count )
- throws NoSuchAlgorithmException, UnsupportedEncodingException
+ public static final char [] create( char[] password, byte[] salt, int count )
+ throws NoSuchAlgorithmException, UnsupportedEncodingException
{
char [] result = null;
MessageDigest sha1 = MessageDigest.getInstance( "SHA1" );
byte [] passwordMask = new String( password ).getBytes( "UTF-8" );
byte [] temp = new byte[salt.length + passwordMask.length];
byte [] digest = null;
-
+
StringBuffer stringBuffer = new StringBuffer();
// combine the password with the salt string into a byte[9
@@ -112,7 +112,7 @@
digest = sha1.digest();
}
- // build a well-formed password string to be usable
+ // build a well-formed password string to be usable
// by a human
long long1 = createLong( digest, 0 );
@@ -149,21 +149,21 @@
/**
* Gets bytes from an array into a long.
- *
+ *
* @param buf where to get the bytes
* @param nOfs index from where to read the data
* @return the 64bit integer
*/
private static final long createLong(byte [] buf, int nOfs)
{
- return
- ((long)(( buf[nOfs ] << 24) |
- ((buf[nOfs + 1] & 0x0ff) << 16) |
- ((buf[nOfs + 2] & 0x0ff) << 8) |
- ( buf[nOfs + 3] & 0x0ff )) << 32) |
- ((long)(( buf[nOfs + 4] << 24) |
- ((buf[nOfs + 5] & 0x0ff) << 16) |
- ((buf[nOfs + 6] & 0x0ff) << 8) |
- ( buf[nOfs + 7] & 0x0ff )) & 0x0ffffffffL);
- }
+ return
+ ((long)(( buf[nOfs ] << 24) |
+ ((buf[nOfs + 1] & 0x0ff) << 16) |
+ ((buf[nOfs + 2] & 0x0ff) << 8) |
+ ( buf[nOfs + 3] & 0x0ff )) << 32) |
+ ((long)(( buf[nOfs + 4] << 24) |
+ ((buf[nOfs + 5] & 0x0ff) << 16) |
+ ((buf[nOfs + 6] & 0x0ff) << 8) |
+ ( buf[nOfs + 7] & 0x0ff )) & 0x0ffffffffL);
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStream.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStream.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/jce/crypto/SmartDecryptingInputStream.java Mon Oct 3 10:03:11 2005
@@ -1,13 +1,14 @@
+package org.apache.fulcrum.jce.crypto;
/*
- * Copyright 2004 Markus Hahn
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Copyright 2004 Markus Hahn
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,8 +16,6 @@
* limitations under the License.
*/
-package org.apache.fulcrum.jce.crypto;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -28,139 +27,139 @@
/**
* An input stream that determine if the originating input stream
* was encrypted or not. This magic only works for text files though.
- *
+ *
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
public class SmartDecryptingInputStream extends ByteArrayInputStream
{
/** The encodings to be checked for XML */
private static final String[] ENCODINGS = { "ISO-8859-1", "UTF-8", "UTF-16" };
-
- /**
- * Constructor
- *
- * @param cryptoStreamFactory the CryptoStreamFactory for creating a cipher stream
- * @param is the input stream to be decrypted
- */
- public SmartDecryptingInputStream(
- CryptoStreamFactory cryptoStreamFactory,
- InputStream is )
- throws IOException, GeneralSecurityException
- {
- this( cryptoStreamFactory, is, null );
- }
-
- /**
- * Constructor
- *
- * @param cryptoStreamFactory the CryptoStreamFactory for creating a cipher stream
- * @param is the input stream to be decrypted
- * @param password the password for decryption
- */
- public SmartDecryptingInputStream(
- CryptoStreamFactory cryptoStreamFactory,
- InputStream is,
- char[] password )
- throws IOException, GeneralSecurityException
- {
- super( new byte[0] );
-
- byte[] content = null;
- byte[] plain = null;
-
- // store the data from the input stream
-
- ByteArrayOutputStream baosCipher = new ByteArrayOutputStream();
- ByteArrayOutputStream baosPlain = new ByteArrayOutputStream();
- this.copy( is, baosCipher );
-
- content = baosCipher.toByteArray();
- plain = content;
-
- if( this.isEncrypted(content) == true )
- {
- InputStream cis = null;
- ByteArrayInputStream bais = new ByteArrayInputStream(content);
-
- if( ( password != null ) && ( password.length > 0 ) )
- {
- cis = cryptoStreamFactory.getInputStream( bais, password );
- }
- else
- {
- cis = cryptoStreamFactory.getInputStream( bais );
- }
-
- copy( cis, baosPlain );
- plain = baosPlain.toByteArray();
- }
-
- // initialize the inherited instance
-
- if( plain != null )
- {
- this.buf = plain;
- this.pos = 0;
- this.count = buf.length;
- }
- }
-
- /**
- * Determine if the content is encrypted. We are
- * using our knowledge about block lenght, check
- * for XML, ZIP and PDF files and at the end of
- * the day we are just guessing.
- *
- * @param content the data to be examined
- * @return true if this is an encrypted file
- */
- private boolean isEncrypted( byte[] content )
- throws IOException
- {
- if( content.length == 0 )
- {
- return false;
- }
- else if( ( content.length % 8 ) != 0 )
- {
- // the block length is 8 bytes - if the length
- // is not a multipe of 8 then the content was
- // definitely not encrypted
- return false;
- }
- else if( this.isPDF(content) )
- {
- return false;
- }
- else if( this.isXML(content) )
- {
- return false;
- }
- else if( this.isZip(content) )
- {
- return false;
- }
- else if( this.isUtf16Text(content) )
- {
- return false;
- }
- else
- {
- for( int i=0; i<content.length; i++ )
- {
- // do we have control characters in it?
-
- char ch = (char) content[i];
-
- if( this.isAsciiControl(ch) )
- {
- return true;
- }
- }
-
+
+ /**
+ * Constructor
+ *
+ * @param cryptoStreamFactory the CryptoStreamFactory for creating a cipher stream
+ * @param is the input stream to be decrypted
+ */
+ public SmartDecryptingInputStream(
+ CryptoStreamFactory cryptoStreamFactory,
+ InputStream is )
+ throws IOException, GeneralSecurityException
+ {
+ this( cryptoStreamFactory, is, null );
+ }
+
+ /**
+ * Constructor
+ *
+ * @param cryptoStreamFactory the CryptoStreamFactory for creating a cipher stream
+ * @param is the input stream to be decrypted
+ * @param password the password for decryption
+ */
+ public SmartDecryptingInputStream(
+ CryptoStreamFactory cryptoStreamFactory,
+ InputStream is,
+ char[] password )
+ throws IOException, GeneralSecurityException
+ {
+ super( new byte[0] );
+
+ byte[] content = null;
+ byte[] plain = null;
+
+ // store the data from the input stream
+
+ ByteArrayOutputStream baosCipher = new ByteArrayOutputStream();
+ ByteArrayOutputStream baosPlain = new ByteArrayOutputStream();
+ this.copy( is, baosCipher );
+
+ content = baosCipher.toByteArray();
+ plain = content;
+
+ if( this.isEncrypted(content) == true )
+ {
+ InputStream cis = null;
+ ByteArrayInputStream bais = new ByteArrayInputStream(content);
+
+ if( ( password != null ) && ( password.length > 0 ) )
+ {
+ cis = cryptoStreamFactory.getInputStream( bais, password );
+ }
+ else
+ {
+ cis = cryptoStreamFactory.getInputStream( bais );
+ }
+
+ copy( cis, baosPlain );
+ plain = baosPlain.toByteArray();
+ }
+
+ // initialize the inherited instance
+
+ if( plain != null )
+ {
+ this.buf = plain;
+ this.pos = 0;
+ this.count = buf.length;
+ }
+ }
+
+ /**
+ * Determine if the content is encrypted. We are
+ * using our knowledge about block lenght, check
+ * for XML, ZIP and PDF files and at the end of
+ * the day we are just guessing.
+ *
+ * @param content the data to be examined
+ * @return true if this is an encrypted file
+ */
+ private boolean isEncrypted( byte[] content )
+ throws IOException
+ {
+ if( content.length == 0 )
+ {
+ return false;
+ }
+ else if( ( content.length % 8 ) != 0 )
+ {
+ // the block length is 8 bytes - if the length
+ // is not a multipe of 8 then the content was
+ // definitely not encrypted
+ return false;
+ }
+ else if( this.isPDF(content) )
+ {
return false;
- }
- }
+ }
+ else if( this.isXML(content) )
+ {
+ return false;
+ }
+ else if( this.isZip(content) )
+ {
+ return false;
+ }
+ else if( this.isUtf16Text(content) )
+ {
+ return false;
+ }
+ else
+ {
+ for( int i=0; i<content.length; i++ )
+ {
+ // do we have control characters in it?
+
+ char ch = (char) content[i];
+
+ if( this.isAsciiControl(ch) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
/**
* Pumps the input stream to the output stream.
@@ -183,11 +182,11 @@
}
is.close();
-
+
os.flush();
os.close();
- }
-
+ }
+
/**
* Count the number of occurences for the given value
* @param content the content to examine
@@ -197,7 +196,7 @@
private int count( byte[] content, byte value )
{
int result = 0;
-
+
for( int i=0; i<content.length; i++ )
{
if( content[i] == value )
@@ -205,10 +204,10 @@
result++;
}
}
-
+
return result;
}
-
+
/**
* Detect the BOM of an UTF-16 (mandatory) or UTF-8 document (optional)
* @param content the content to examine
@@ -229,7 +228,7 @@
/**
* Check this is a UTF-16 text document.
- *
+ *
* @param content the content to examine
* @return true if it is a XML document
* @throws IOException
@@ -243,10 +242,10 @@
if( this.hasByteOrderMark(content) == true )
{
- // we should have plenty of 0x00 in a text file
+ // we should have plenty of 0x00 in a text file
int estimate = (content.length-2)/3;
-
+
if( this.count(content,(byte)0) > estimate )
{
return true;
@@ -259,7 +258,7 @@
/**
* Check various encondings to determine if "<?xml"
* and "?>" appears in the data.
- *
+ *
* @param content the content to examine
* @return true if it is a XML document
* @throws IOException
@@ -270,25 +269,25 @@
{
return false;
}
-
- for( int i=0; i<ENCODINGS.length; i++ )
- {
- String currEncoding = ENCODINGS[i];
-
- String temp = new String( content, currEncoding );
-
- if( ( temp.indexOf("<?xml") >= 0 ) && ( temp.indexOf("?>") > 0 ) )
- {
- return true;
- }
- }
-
- return false;
+
+ for( int i=0; i<ENCODINGS.length; i++ )
+ {
+ String currEncoding = ENCODINGS[i];
+
+ String temp = new String( content, currEncoding );
+
+ if( ( temp.indexOf("<?xml") >= 0 ) && ( temp.indexOf("?>") > 0 ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
}
-
- /**
+
+ /**
* Check if this is a ZIP document
- *
+ *
* @param content the content to examine
* @return true if it is a PDF document
* @throws IOException
@@ -303,8 +302,8 @@
else
{
// A ZIP starts with Hex: "50 4B 03 04"
-
- if( ( content[0] == (byte) 0x50 ) &&
+
+ if( ( content[0] == (byte) 0x50 ) &&
( content[1] == (byte) 0x4B ) &&
( content[2] == (byte) 0x03 ) &&
( content[3] == (byte) 0x04 ) )
@@ -317,10 +316,10 @@
}
}
}
-
- /**
+
+ /**
* Check if this is a PDF document
- *
+ *
* @param content the content to examine
* @return true if it is a PDF document
* @throws IOException
@@ -333,9 +332,9 @@
}
else
{
- // A PDF starts with HEX "25 50 44 46 2D 31 2E"
-
- if( ( content[0] == (byte) 0x25 ) &&
+ // A PDF starts with HEX "25 50 44 46 2D 31 2E"
+
+ if( ( content[0] == (byte) 0x25 ) &&
( content[1] == (byte) 0x50 ) &&
( content[2] == (byte) 0x44 ) &&
( content[3] == (byte) 0x46 ) &&
@@ -351,11 +350,11 @@
}
}
}
-
+
/**
* Is this an ASCII control character
*/
- private boolean isAsciiControl(char ch)
+ private boolean isAsciiControl(char ch)
{
if( ( ch >= 0x0000 ) && ( ch <= 0x001F) )
{
@@ -365,5 +364,5 @@
{
return true;
}
- }
+ }
}
Modified: jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java
URL: http://svn.apache.org/viewcvs/jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java?rev=293394&r1=293393&r2=293394&view=diff
==============================================================================
--- jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java (original)
+++ jakarta/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/cli/Getopt.java Mon Oct 3 10:03:11 2005
@@ -25,39 +25,39 @@
{
/** the prefix for determining command line parameters, e.g "-" or "--" */
private String prefix;
-
+
/** the command line parameters */
- private String[] args;
+ private String[] args;
+
+ /**
+ * Constructor
+ * @param args the command line parameters
+ */
+ public Getopt( String[] args )
+ {
+ this(args,"--");
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param args the command line parameters
+ * @param prefix the prefix for command line paramters
+ */
+ public Getopt( String[] args, String prefix )
+ {
+ this.prefix = prefix;
+
+ if( args == null )
+ {
+ this.args = new String[0];
+ }
+ else
+ {
+ this.args = args;
+ }
+ }
- /**
- * Constructor
- * @param args the command line parameters
- */
- public Getopt( String[] args )
- {
- this(args,"--");
- }
-
- /**
- * Constructor.
- *
- * @param args the command line parameters
- * @param prefix the prefix for command line paramters
- */
- public Getopt( String[] args, String prefix )
- {
- this.prefix = prefix;
-
- if( args == null )
- {
- this.args = new String[0];
- }
- else
- {
- this.args = args;
- }
- }
-
/**
* @param option the option we are looking for
* @return is the given option contained in the command line arguments?
@@ -68,14 +68,14 @@
return( this.find(option) >= 0 ? true : false );
}
- /**
+ /**
* @return the number of command line arguments
*/
public int length()
{
return this.args.length;
}
-
+
/**
* Returns the string value for the given option.
* @param option the option
@@ -123,15 +123,15 @@
/**
* Get the given argument.
* @param index the index of the command line argument
- * @return the commandl ine argument
+ * @return the commandl ine argument
*/
private String getArg( int index )
{
return this.args[index];
}
-
+
/**
- * @option the option
+ * @option the option
* @return the index of the give option or -1 otherwise
*/
private int find( String option )
@@ -152,7 +152,7 @@
}
/**
- * Determines if a value is defined for the given option
+ * Determines if a value is defined for the given option
* @param option the given option
* @return true if a value is defined
*/
@@ -162,18 +162,18 @@
}
/**
- * Determines if a value is defined for the given option
+ * Determines if a value is defined for the given option
* @param option the given option
* @return true if a value is defined
*/
private boolean hasValue( int index )
{
String value = null;
-
+
if( (index+1) < this.length() )
{
value = this.getArg(index+1);
-
+
if( value.startsWith(this.prefix) )
{
return false;
@@ -186,7 +186,7 @@
else
{
return false;
- }
+ }
}
/**
@@ -198,7 +198,7 @@
private String getValue( String option )
{
String value = this.getValue(option,null);
-
+
if( value == null )
{
// the options is there but no value was defined by the caller
@@ -210,7 +210,7 @@
return value;
}
}
-
+
/**
* Get the value of a command line option
* @param option the option
@@ -220,13 +220,13 @@
private String getValue( String option, String defaultValue )
{
int index = this.find(option);
-
+
if( index < 0 )
{
// the option is not found
return defaultValue;
}
-
+
if( this.hasValue(index) )
{
// a value is available for this option
@@ -238,6 +238,6 @@
String msg = "No value supplied for " + this.prefix + option;
throw new IllegalArgumentException( msg );
}
- }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org