org.jasypt.Ausnahmen.EncryptionOperationNotPossibleException

Ich bin mit Jasypt-1.9.0 mit Frühjahr 3.1 und Hibernate 4.0.1. Ich habe eine Anforderung, die in meiner Anwendung die Verbindung zur Datenbank, deren Passwort(root) werden in der verschlüsselten form in der property-Datei innerhalb der Anwendung.

Ich schaute online und fand die Art und Weise mit folgenden links:

  1. http://www.jasypt.org/spring31.html

  2. http://www.jasypt.org/hibernate.html

  3. http://www.jasypt.org/encrypting-configuration.html

Habe ich getan, mit folgenden Schritten-Konfiguration für meine Anforderung:

  • Hinzugefügt jasypt-1.9.0 und jasypt-hibernate4-1.9.0 im build-Pfad.
  • Hinzugefügt, die folgenden in meinem dispatcher-servlet Datei:

< bean id="propertyConfigurer"
class="org.jasypt.spring31.Eigenschaften.EncryptablePropertyPlaceholderConfigurer">

   < constructor-arg ref="configurationEncryptor" />
   < property name="locations">
     < list>
       < value>classpath:database.properties< /value>
     < /list>
   < /property>
 < /bean>

 < bean id="configurationEncryptor"
     class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
   < property name="config" ref="environmentVariablesConfiguration" />
 < /bean>

 < bean id="environmentVariablesConfiguration"
class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
< property name="algorithm" value="PBEWithMD5AndDES" />
< property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
</bean>
  • Mit CLI-tool von Jasypt 1.9.0, ich habe das Passwort generiert
    unten(angehängte snapshot CLI)

org.jasypt.Ausnahmen.EncryptionOperationNotPossibleException
- Es wurde eine neue Environment Variable als APP_ENCRYPTION_PASSWORD mit dem Wert root

  • Hinzugefügt, die das verschlüsselte Kennwort in Datenbank.Eigenschaften Datei
db.driverClassName=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/db1
db.username=root
db.password=ENC(bmfeQmgP/hJrh+mj6NANKA==)

Nun, wenn ich meine Anwendung folgende exception:

org.jasypt.exceptions.EncryptionOperationNotPossibleException
    at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
    at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
    at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
InformationsquelleAutor Arun Kumar | 2013-03-21
Schreibe einen Kommentar