Bonjour,
je souhaiterais crypter des donnees se trouvant dans mon fichier properties en utilisant jasypt.
J'ai procédé de la manière suivante :
pour generer mont mot de opasse crypté :
Code:
1 2 3
|
BasicPasswordEncryptor bpe = new BasicPasswordEncryptor();
Strinc pwd_encode= bpe.encryptPassword("unTest")); |
Dams mon fichier properties :
test-password-encrypted = ENC(MqUF9zygE6FSavb468aIQfa5jziNUQ/t)
Ensuite, pour lire ce mot de passe :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
Properties props = new EncryptableProperties(encryptor);
try {
props.load(new FileInputStream("..../config.properties"));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String datasourceUsername = props.getProperty("test-password");
System.out.println("dataSource without encryption : " + datasourceUsername );
String datasourcePassword = props.getProperty("test-password-encrypted");
System.out.println("dataSource Password : " + datasourcePassword );
} |
J'ai ajouté au classpath les bibliotheques :
commoncs-code-1.1.jar
commons-lang-2-1.jar
icu4j-4_2_1.jar
jasypt-1.5.jar
J'utilise Java 1.4 :
En lancant tout ca, j'obtiens
Code:
1 2 3 4 5 6 7 8 9 10
|
org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:801)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:639)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.properties.EncryptableProperties.decode(EncryptableProperties.java:210)
at org.jasypt.properties.EncryptableProperties.getProperty(EncryptableProperties.java:167)
at jdbc.testEncryptor.<init>(testEncryptor.java:44)
at jdbc.testEncryptor.main(testEncryptor.java:51)
Exception in thread "main" |
d'ou mon problème !
Si quelqu'un a une idée ... Merci d'avance !
Cordialement