Jasypt Users Forum

Help : My data is not being encrypted

View: New views
1 Messages — Rating Filter:   Alert me  

Help : My data is not being encrypted

by Tazz786 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

+------------------------+
  Jasypt Users List      
  http://www.jasypt.org 
+------------------------+

Hi.

I have posted a topic, but now joined the mailing list, so am reposting it. I am trying to decrypt data in a MySQL database in a JBoss Seam and JSF application. What has been done thus far. I added the following jars in the application.xl file
lib/jasypt-1.5.jar
lib/commons-lang-2.1.jar
lib/commons-codec-1.3.jar
lib/icu4j-3.4.4.jar

The initializer class has also been added to the start up. The code as follows :

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentPBEConfig;
import org.jasypt.hibernate.encryptor.HibernatePBEEncryptorRegistry;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.log.Log;

@Name("initializer")
public class Initializer {

     @Logger Log log;
    
     @Observer("org.jboss.seam.postInitialization")
     public void initializeJasypt() {
     try {
             log.info("Initializing Jasypt String Encryptor");      
             StandardPBEStringEncryptor strongEncryptor =
                 new StandardPBEStringEncryptor();
             EnvironmentPBEConfig config = new EnvironmentPBEConfig();
             config.setPasswordEnvName("jasypt_password");
             strongEncryptor.setConfig(config);
             HibernatePBEEncryptorRegistry registry =
                 HibernatePBEEncryptorRegistry.getInstance();
             registry.registerPBEStringEncryptor("myHibernateStringEncryptor", strongEncryptor);
     } catch (Exception e) {
        e.printStackTrace();
    }

        }
}

And in my entity, just to test, I have done on one field (usually the requirement would be to encrypt the whole database)

@TypeDef(
        name="encryptedString",
        typeClass=EncryptedStringType.class,
        parameters={@Parameter(name="encryptorRegisteredName",
                               value="myHibernateStringEncryptor")}
    )

@NotNull(message="Name is required")
    @Length(min=2, max=45, message="Name must be 2 to 45 characters long")
    @Column(name="name")
    @Type(type="encryptedString") 
    public String getName() {
        return name;
    }

I put the following in the run.sh of jboss.
# export jasypt_password="mysecretpassword"

since I am starting jboss up using the eclipse "Server".

I have deleted all the data in the entity mentioned above. When I create the entry in the database, the field is not encrypted.

any help with this would be highly appreciated.

Thanks

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
jasypt-users mailing list
jasypt-users@...
https://lists.sourceforge.net/lists/listinfo/jasypt-users