Giter Club home page Giter Club logo

Comments (4)

mapoulos avatar mapoulos commented on August 25, 2024 1
        // overwrite the default mapper to support Java Optional and Encrypting of Sensitive fields
        var objectMapper = new ObjectMapper();
        objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
        objectMapper.registerModule(new JavaTimeModule());
        objectMapper.registerModule(new Jdk8Module());
        objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);

        // It seems like the key derivation at 256 takes a long time, so we reduce it here to 128.
        var passwordCryptoContext = new PasswordCryptoContext(this.encryptionPassword, this.encryptionPassword, "AES/CBC/PKCS5Padding", "PBKDF2WithHmacSHA512", 5000, 128, "AES");
        var encryptionService = new EncryptionService(objectMapper, passwordCryptoContext);
        objectMapper.registerModule(new CryptoModule().addEncryptionService(encryptionService));
        var jacksonJsonPayloadConverter = new JacksonJsonPayloadConverter(objectMapper);

        // override the jackson converter
        var defaultDataConverter = DefaultDataConverter.newDefaultInstance().withPayloadConverterOverrides(jacksonJsonPayloadConverter);

        // instantiate the workflow service, which connects to the temporal cluster
        var serviceOptions = WorkflowServiceStubsOptions.newBuilder()
                .setTarget(target)
                .setEnableHttps(useSSL)
                .build();
        workflowService = WorkflowServiceStubs.newInstance(serviceOptions);

        // instatiate the workflow client, which specifies the temporal namespace
        // and the data converter
        var clientOptions = WorkflowClientOptions
            .newBuilder()
            .setNamespace(namespace)
            .setDataConverter(defaultDataConverter)
            .build();
        workflowClient = WorkflowClient.newInstance(workflowService, clientOptions);

from samples-java.

tsurdilo avatar tsurdilo commented on August 25, 2024 1

@mapoulos will have to use jackson-json-crypto:1.1.0
cause our samples are built with java 1.8 (jackson-json-crypto after 2.x seems to require java 11) just fyi

from samples-java.

mapoulos avatar mapoulos commented on August 25, 2024

One thing I noticed: I had very bad performance with the default settings (256 key length). I think it was running the key generation for each decrypt and temporal was complaining about the thread not yielding within a second. Decreasing this down to 128 helped.

from samples-java.

tsurdilo avatar tsurdilo commented on August 25, 2024

@mapoulos thanks for the info!

from samples-java.

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.