Spring4 Jasypt1.9.2 Integration

阅读更多

1.add jasypt with maven

       

       

            org.jasypt

            jasypt-spring3

            ${jasypt.version}

 

       

2.Download jasypt to encrypt passwod on tomcat server

   1)execute command under folder bin to list available algorithms

      ./listAlgorithms.sh

   2)select a algorithm listed above to encrypt database password

     ./encrypt.sh input=dbpasword algorithm=PBEWITHSHA1ANDRC2_40 password=jasypt_is_cool

 

  note:----ERROR-----------------------

 

          Operation not possible (Bad input or parameters)

 

           Please select another algorithm  

   

3.add properties file:spring.properties

 

   jdbc.driverClassName=oracle.jdbc.driver.OracleDriver

   jdbc.url=jdbc:oracle:thin:@192.168.88.230:1521:xe

   jdbc.username=cms

 

   jdbc.password=ENC(xBpvib/4aRiUz0nH5besvA==)

 

4.add the following information in spring configuration file

 

  

      class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"

      p:algorithm="PBEWITHSHA1ANDRC2_40"

      p:passwordEnvName="JASYPT"/>

 

      class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"

      p:config-ref="jasyptConfiguration"/>

      

   

     

   

     

   

 

 

5. Set environment variable in /etc/init.d/tomcat8 file

    JASYPT="dbpassword"

    export JASYPT

6. Restart tomcat

 

你可能感兴趣的:(Security)