BAEL-311 add jasyp module
This commit is contained in:
parent
8617faf9cf
commit
a23eaf3323
34
jasypt/pom.xml
Normal file
34
jasypt/pom.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?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>
|
27
jasypt/src/test/java/org/baeldung/jasypt/JasyptTest.java
Normal file
27
jasypt/src/test/java/org/baeldung/jasypt/JasyptTest.java
Normal file
@ -0,0 +1,27 @@
|
||||
package org.baeldung.jasypt;
|
||||
|
||||
|
||||
import org.jasypt.util.text.BasicTextEncryptor;
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertNotSame;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
public class JasyptTest {
|
||||
|
||||
@Test
|
||||
public void givenTextPassword_whenDecrypt_shouldCompareToEncrypted() {
|
||||
//given
|
||||
BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
|
||||
String password = "secret-pass";
|
||||
textEncryptor.setPasswordCharArray(password.toCharArray());
|
||||
|
||||
//when
|
||||
String myEncryptedText = textEncryptor.encrypt("secret-pass");
|
||||
assertNotSame("secret-pass", myEncryptedText); //myEncryptedText can be save in db
|
||||
|
||||
//then
|
||||
String plainText = textEncryptor.decrypt(myEncryptedText);
|
||||
assertEquals(plainText, "secret-pass");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user