BAEL-311 move jasypt to libraries module (#1309)
* BEEL-311 move jasypt to libraries module * BAEL-9: README.md file updated (#1310) * BAEL-278: Updated README.md * BAEL-554: Add and update README.md files * BAEL-345: fixed assertion * BAEL-109: Updated README.md * BAEL-345: Added README.md * Reinstating reactor-core module in root-level pom * BAEL-393: Adding guide-intro module to root pom * BAEL-9: Updated README.md * Guide to "when" block in Kotlin pull request (#1296) * Char array to string and string to char array test cases added * Minor code renames * Added groupingBy collector unit tests * Added test case for int summary calculation on grouped results * Added the grouping by classes to the main source path * Reverting char array to string test class * Reverting char array to string test class * Reverting char array to string test class * Reverting char array to string test class * Unit test class for Kotlin when block + required types * Minor changes to kotlin when block tests * Minor change * Minor change * Bael 655 (#1256) BAEL-655 hbase * Remove unnecessary files and update .gitignore (#1313) * BAEL-311 Removed jasypt module from parent pom (moved into libraries module)
This commit is contained in:
parent
9f94f9f789
commit
e1d136368b
@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>parent-modules</artifactId>
|
|
||||||
<groupId>com.baeldung</groupId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>jasypt</artifactId>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jasypt</groupId>
|
|
||||||
<artifactId>jasypt</artifactId>
|
|
||||||
<version>${jasypt.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>${junit.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<jasypt.version>1.9.2</jasypt.version>
|
|
||||||
<junit.version>4.12</junit.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
|
@ -31,6 +31,11 @@
|
|||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>${cglib.version}</version>
|
<version>${cglib.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jasypt</groupId>
|
||||||
|
<artifactId>jasypt</artifactId>
|
||||||
|
<version>${jasypt.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
@ -42,6 +47,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<cglib.version>3.2.4</cglib.version>
|
<cglib.version>3.2.4</cglib.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
|
<jasypt.version>1.9.2</jasypt.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.baeldung.jasypt;
|
package com.baeldung.jasypt;
|
||||||
|
|
||||||
|
|
||||||
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
||||||
@ -8,27 +8,25 @@ import org.jasypt.util.text.BasicTextEncryptor;
|
|||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static junit.framework.Assert.*;
|
||||||
import static junit.framework.Assert.assertNotSame;
|
|
||||||
import static junit.framework.Assert.assertTrue;
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
public class JasyptTest {
|
public class JasyptTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTextPassword_whenDecrypt_thenCompareToEncrypted() {
|
public void givenTextPrivateData_whenDecrypt_thenCompareToEncrypted() {
|
||||||
//given
|
//given
|
||||||
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
|
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
|
||||||
String password = "secret-pass";
|
String privateData = "secret-data";
|
||||||
textEncryptor.setPasswordCharArray("some-random-password".toCharArray());
|
textEncryptor.setPasswordCharArray("some-random-data".toCharArray());
|
||||||
|
|
||||||
//when
|
//when
|
||||||
String myEncryptedText = textEncryptor.encrypt(password);
|
String myEncryptedText = textEncryptor.encrypt(privateData);
|
||||||
assertNotSame(password, myEncryptedText); //myEncryptedText can be save in db
|
assertNotSame(privateData, myEncryptedText); //myEncryptedText can be save in db
|
||||||
|
|
||||||
//then
|
//then
|
||||||
String plainText = textEncryptor.decrypt(myEncryptedText);
|
String plainText = textEncryptor.decrypt(myEncryptedText);
|
||||||
assertEquals(plainText, password);
|
assertEquals(plainText, privateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -61,38 +59,38 @@ public class JasyptTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("should have installed local_policy.jar")
|
@Ignore("should have installed local_policy.jar")
|
||||||
public void givenTextPassword_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() {
|
public void givenTextPrivateData_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() {
|
||||||
//given
|
//given
|
||||||
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
|
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
|
||||||
String password = "secret-pass";
|
String privateData = "secret-data";
|
||||||
encryptor.setPassword("secret-pass");
|
encryptor.setPassword("some-random-data");
|
||||||
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
||||||
|
|
||||||
//when
|
//when
|
||||||
String encryptedText = encryptor.encrypt("secret-pass");
|
String encryptedText = encryptor.encrypt("secret-pass");
|
||||||
assertNotSame(password, encryptedText);
|
assertNotSame(privateData, encryptedText);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
String plainText = encryptor.decrypt(encryptedText);
|
String plainText = encryptor.decrypt(encryptedText);
|
||||||
assertEquals(plainText, password);
|
assertEquals(plainText, privateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("should have installed local_policy.jar")
|
@Ignore("should have installed local_policy.jar")
|
||||||
public void givenTextPassword_whenDecryptOnHighPerformance_thenDecrypt(){
|
public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt(){
|
||||||
//given
|
//given
|
||||||
String password = "secret-pass";
|
String privateData = "secret-data";
|
||||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||||
encryptor.setPoolSize(4);
|
encryptor.setPoolSize(4);
|
||||||
encryptor.setPassword(password);
|
encryptor.setPassword("some-random-data");
|
||||||
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
||||||
|
|
||||||
//when
|
//when
|
||||||
String encryptedText = encryptor.encrypt(password);
|
String encryptedText = encryptor.encrypt(privateData);
|
||||||
assertNotSame(password, encryptedText);
|
assertNotSame(privateData, encryptedText);
|
||||||
|
|
||||||
//then
|
//then
|
||||||
String plainText = encryptor.decrypt(encryptedText);
|
String plainText = encryptor.decrypt(encryptedText);
|
||||||
assertEquals(plainText, password);
|
assertEquals(plainText, privateData);
|
||||||
}
|
}
|
||||||
}
|
}
|
1
pom.xml
1
pom.xml
@ -63,7 +63,6 @@
|
|||||||
<module>javaslang</module>
|
<module>javaslang</module>
|
||||||
<module>javax-servlets</module>
|
<module>javax-servlets</module>
|
||||||
<module>javaxval</module>
|
<module>javaxval</module>
|
||||||
<module>jasypt</module>
|
|
||||||
<module>jaxb</module>
|
<module>jaxb</module>
|
||||||
<module>jee7</module>
|
<module>jee7</module>
|
||||||
<module>jjwt</module>
|
<module>jjwt</module>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user