Package ch.inftec.ju.security

Examples of ch.inftec.ju.security.JuTextEncryptor.decrypt()


        .password("secret")
        .createTextEncryptor();
   
    String encryptedString = encryptor.encrypt("String"); // The encrypted String will not be constant...
    Assert.assertNotNull(encryptor.encrypt("String"));
    Assert.assertEquals("String", encryptor.decrypt(encryptedString));
  }
 
  @Test
  public void canDencryptText_usingBasicEncryptor() {
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("secret").createTextEncryptor();
View Full Code Here


  }
 
  @Test
  public void canDencryptText_usingBasicEncryptor() {
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("secret").createTextEncryptor();
    Assert.assertEquals("String", encryptor.decrypt("8vu+etsGrzZK30MCEBjTzg=="));
  }
 
  @Test(expected=EncryptionOperationNotPossibleException.class)
  public void throwsException_usingBasicEncryptor_withWrongPassword() {
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("wrongSecret").createTextEncryptor();
View Full Code Here

  }
 
  @Test(expected=EncryptionOperationNotPossibleException.class)
  public void throwsException_usingBasicEncryptor_withWrongPassword() {
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("wrongSecret").createTextEncryptor();
    Assert.assertEquals("String", encryptor.decrypt("8vu+etsGrzZK30MCEBjTzg=="));
  }
 
  @Test
  public void decryptTaggedValueIfNecessary_decryptsEncryptedString() {
    JuTextEncryptor encryptor = JuSecurityUtils.buildEncryptor().password("secret").createTextEncryptor();
View Full Code Here

    Assert.assertEquals("# This is my little secret file...", lines.get(2));
    Assert.assertTrue(lines.get(3).startsWith("secretProperty=ENC("));
   
    // Check encrypted value
    String encryptedVal = new RegexUtil(".*ENC\\((.*)\\)").getMatches(lines.get(3))[0].getGroups()[0];
    Assert.assertEquals("myPrecious", encryptor.decrypt(encryptedVal));
   
    // Make sure already encrypted values are not changed
    Assert.assertEquals("anoterSecret=ENC(alreadyEncrypted)", lines.get(4));
  }
 
View Full Code Here

    Assert.assertEquals(";;", lines.get(2));
    Assert.assertTrue(lines.get(3).startsWith("#Come Comment;ENC(alreadyEncrypted);"));
   
    // Check encrypted value
    String encryptedVal = new RegexUtil(".*ENC\\((.*)\\)$").getMatches(lines.get(3))[0].getGroups()[0];
    Assert.assertEquals("myPrecious", encryptor.decrypt(encryptedVal));
  }
 
  @Test
  public void canEncrypt_complexCsvFile() throws Exception {
    URL srcCsv = JuUrl.resource("ch/inftec/ju/util/security/JuSecurityUtilsTest_toBeEncrypted_complex.csv");
View Full Code Here

   
    // Check first encrypted value
    Assert.assertTrue(lines.get(1).startsWith("\"ENC("));
    Assert.assertTrue(lines.get(1).endsWith(")\";another value"));
    String encryptedVal1 = new RegexUtil("\"ENC\\((.*)\\)").getMatches(lines.get(1))[0].getGroups()[0];
    Assert.assertEquals("secret(;)", encryptor.decrypt(encryptedVal1));
   
    // Check second encrypted value
    Assert.assertTrue(lines.get(2).startsWith("\"ENC("));
    Assert.assertTrue(lines.get(2).endsWith(")\";"));
    String encryptedVal2 = new RegexUtil("\"ENC\\((.*)\\)").getMatches(lines.get(2))[0].getGroups()[0];
 
View Full Code Here

   
    // Check second encrypted value
    Assert.assertTrue(lines.get(2).startsWith("\"ENC("));
    Assert.assertTrue(lines.get(2).endsWith(")\";"));
    String encryptedVal2 = new RegexUtil("\"ENC\\((.*)\\)").getMatches(lines.get(2))[0].getGroups()[0];
    Assert.assertEquals("\"secret;\"", encryptor.decrypt(encryptedVal2));
   
  }
 
  @Test
  public void canEncrypt_toSourceFile() throws Exception {
View Full Code Here

        .password("secret")
        .createTextEncryptor();
   
    String encryptedString = encryptor.encrypt("String"); // The encrypted String will not be constant...
    Assert.assertNotNull(encryptor.encrypt("String"));
    Assert.assertEquals("String", encryptor.decrypt(encryptedString));
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.