Skip to content
Browse files

add fix for encoding problems

  • Loading branch information...
1 parent e9de91e commit 6ccec0eaefb9844d3cb83e57bdc155ec16f2e6c0 @kreyssel committed Jul 12, 2011
View
56 pom.xml
@@ -23,6 +23,16 @@
</distributionManagement>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.9</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
@@ -31,6 +41,52 @@
<target>1.5</target>
</configuration>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>always</forkMode>
+ </configuration>
+ <executions>
+ <execution>
+ <id>utf8</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <file.encoding>utf8</file.encoding>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>iso8859-1</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <file.encoding>iso8859-1</file.encoding>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ <execution>
+ <id>cp1252</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <file.encoding>cp1252</file.encoding>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
View
2 src/main/java/org/sonatype/plexus/components/cipher/PBECipher.java
@@ -120,7 +120,7 @@ public String encrypt64( final String clearText, final String password )
{
try
{
- byte[] clearBytes = clearText.getBytes();
+ byte[] clearBytes = clearText.getBytes( STRING_ENCODING );
byte[] salt = getSalt( SALT_SIZE );
View
20 src/test/java/org/sonatype/plexus/components/cipher/PBECipherTest.java
@@ -19,6 +19,9 @@ Licensed to the Apache Software Foundation (ASF) under one
package org.sonatype.plexus.components.cipher;
+import java.util.Arrays;
+import java.util.Properties;
+
import org.sonatype.guice.bean.containers.InjectedTestCase;
/**
@@ -68,4 +71,21 @@ public void testDecrypt()
assertEquals( _cleatText, clear );
}
+
+ public void testEncoding()
+ throws Exception
+ {
+ Properties props = System.getProperties();
+ Object[] keys = props.keySet().toArray();
+ Arrays.sort(keys);
+ for(Object key: keys){
+ Object value = props.get(key);
+ System.out.println(key+"="+value);
+ }
+
+ String pwd = "ÄÜÖß!\"§üöäß\\(/&$";
+ String encPwd = _cipher.encrypt64(pwd, pwd);
+ String decPwd = _cipher.decrypt64(encPwd, pwd);
+ assertEquals(pwd, decPwd);
+ }
}

0 comments on commit 6ccec0e

Please sign in to comment.
Something went wrong with that request. Please try again.