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>
|
||||
<version>${cglib.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jasypt</groupId>
|
||||
<artifactId>jasypt</artifactId>
|
||||
<version>${jasypt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -42,6 +47,7 @@
|
|||
<properties>
|
||||
<cglib.version>3.2.4</cglib.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<jasypt.version>1.9.2</jasypt.version>
|
||||
</properties>
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jasypt;
|
||||
package com.baeldung.jasypt;
|
||||
|
||||
|
||||
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
||||
|
@ -8,27 +8,25 @@ import org.jasypt.util.text.BasicTextEncryptor;
|
|||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotSame;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.*;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
public class JasyptTest {
|
||||
|
||||
@Test
|
||||
public void givenTextPassword_whenDecrypt_thenCompareToEncrypted() {
|
||||
public void givenTextPrivateData_whenDecrypt_thenCompareToEncrypted() {
|
||||
//given
|
||||
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
|
||||
String password = "secret-pass";
|
||||
textEncryptor.setPasswordCharArray("some-random-password".toCharArray());
|
||||
String privateData = "secret-data";
|
||||
textEncryptor.setPasswordCharArray("some-random-data".toCharArray());
|
||||
|
||||
//when
|
||||
String myEncryptedText = textEncryptor.encrypt(password);
|
||||
assertNotSame(password, myEncryptedText); //myEncryptedText can be save in db
|
||||
String myEncryptedText = textEncryptor.encrypt(privateData);
|
||||
assertNotSame(privateData, myEncryptedText); //myEncryptedText can be save in db
|
||||
|
||||
//then
|
||||
String plainText = textEncryptor.decrypt(myEncryptedText);
|
||||
assertEquals(plainText, password);
|
||||
assertEquals(plainText, privateData);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,38 +59,38 @@ public class JasyptTest {
|
|||
|
||||
@Test
|
||||
@Ignore("should have installed local_policy.jar")
|
||||
public void givenTextPassword_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() {
|
||||
public void givenTextPrivateData_whenDecrypt_thenCompareToEncryptedWithCustomAlgorithm() {
|
||||
//given
|
||||
StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
|
||||
String password = "secret-pass";
|
||||
encryptor.setPassword("secret-pass");
|
||||
String privateData = "secret-data";
|
||||
encryptor.setPassword("some-random-data");
|
||||
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
||||
|
||||
//when
|
||||
String encryptedText = encryptor.encrypt("secret-pass");
|
||||
assertNotSame(password, encryptedText);
|
||||
assertNotSame(privateData, encryptedText);
|
||||
|
||||
//then
|
||||
String plainText = encryptor.decrypt(encryptedText);
|
||||
assertEquals(plainText, password);
|
||||
assertEquals(plainText, privateData);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("should have installed local_policy.jar")
|
||||
public void givenTextPassword_whenDecryptOnHighPerformance_thenDecrypt(){
|
||||
public void givenTextPrivateData_whenDecryptOnHighPerformance_thenDecrypt(){
|
||||
//given
|
||||
String password = "secret-pass";
|
||||
String privateData = "secret-data";
|
||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||
encryptor.setPoolSize(4);
|
||||
encryptor.setPassword(password);
|
||||
encryptor.setPassword("some-random-data");
|
||||
encryptor.setAlgorithm("PBEWithMD5AndTripleDES");
|
||||
|
||||
//when
|
||||
String encryptedText = encryptor.encrypt(password);
|
||||
assertNotSame(password, encryptedText);
|
||||
String encryptedText = encryptor.encrypt(privateData);
|
||||
assertNotSame(privateData, encryptedText);
|
||||
|
||||
//then
|
||||
String plainText = encryptor.decrypt(encryptedText);
|
||||
assertEquals(plainText, password);
|
||||
assertEquals(plainText, privateData);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue