-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new payload converter sample using jackson-json-crypto #229
Comments
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. |
// 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); |
@mapoulos thanks for the info! |
@mapoulos will have to use jackson-json-crypto:1.1.0 |
Add new sample for encrypting/decrypting json payloads
that uses jackson-json-crypto module
The text was updated successfully, but these errors were encountered: