Code Monkey home page Code Monkey logo

Comments (3)

wimdeblauwe avatar wimdeblauwe commented on May 21, 2024

Never mind. Just found it myself.

First declare a @Bean in a @Configuration class like this:

    @Value("${jasypt.encryptor.password}")
    private String jasyptPassword;

 @Bean
    public HibernatePBEStringEncryptor hibernateIntegerEncryptor() {
        HibernatePBEStringEncryptor hibernatePBEStringEncryptor = new HibernatePBEStringEncryptor();
        hibernatePBEStringEncryptor.setRegisteredName("hibernateIntegerEncryptor");
        hibernatePBEStringEncryptor.setPassword(jasyptPassword);
        return hibernatePBEStringEncryptor;
    }

Then change the @TypeDef annotation to:

@TypeDef(
        name = "encryptedInteger",
        typeClass = EncryptedIntegerAsStringType.class,
        parameters= {
                @Parameter(name="encryptorRegisteredName", value="hibernateIntegerEncryptor")
        }
)

Then in your entity:

    @Type(type = "encryptedInteger")
    private int x;

from jasypt-spring-boot.

ulisesbocchio avatar ulisesbocchio commented on May 21, 2024

Cool, so it allows you to reference the encryptor by name in the TypeDef but, what picks it up from the Spring Context? Just curious, since you are using "setRegisteredName" it seems that there's a registry being kept somewhere.

from jasypt-spring-boot.

wimdeblauwe avatar wimdeblauwe commented on May 21, 2024

I have no idea how it works internally. I used the documentation about the hibernate integration on the Jasypt website to come to this.

from jasypt-spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.