Skip to content
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 support for EncryptionContext overrides to the DynamoDBEncryptor #60

Merged
merged 3 commits into from
Dec 3, 2018
Merged

Conversation

johnwalker
Copy link
Contributor

There are people asking for overrides, and it would be better if they didn't
need to wait for longer term, internal refactors before they are able to use
overrides. This adds optional operators that give the client the last say on the
EncryptionContext's value.

Note: I haven't tested the example, since I didn't figure out a way to run them.
How are we running example code? If we don't have a suggested way yet, I can
figure something out and document it.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

There are people asking for overrides, and it would be better if they didn't
need to wait for longer term, internal refactors before they are able to use
overrides. This adds optional operators that give the client the last say on the
EncryptionContext's value.

Note: I haven't tested the example, since I didn't figure out a way to run them.
How are we running example code? If we don't have a suggested way yet, I can
figure something out and document it.
shutdown must be called on ddb and kms to threads to exit when using mvn
exec:java to run commands, otherwise maven will pause for a configurable (by
default 15s) timeout to join daemon threads.
@johnwalker
Copy link
Contributor Author

Figured out how to run examples.

mvn exec:java -Dexec.mainClass="com.amazonaws.examples.EncryptionContextOverridesWithDynamoDBMapper"  -Dexec.arguments="cmkArn","us-east-1","tableOverride" -q

@johnwalker johnwalker changed the base branch from pitr-dev to master November 27, 2018 23:30
@@ -81,7 +81,8 @@
private final String signingAlgorithmHeader;

public static final String DEFAULT_SIGNING_ALGORITHM_HEADER = DEFAULT_DESCRIPTION_BASE + "signingAlg";

private Function<EncryptionContext, EncryptionContext> encryptionContextOverrideOperator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a UnaryOperator here and throughout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have liked UnaryOperator as well, but the chaining methods inherited from Function<T,T> returns a Function<T,T> instead of an UnaryOperator. Ex. calling .andThen on an UnaryOperator<T> returns a Function<T, T>.

I'm tempted to drop UnaryOperator completely and instead use Function<T,T> throughout, but also think that returning a more specific object from a helper class is acceptable. What do you think?

Update the AWS SDK to latest in order to get access to SaveBehavior.PUT for
examples.

Update tests to use the more general Function<T, T> instead of
UnaryOperator<T>.

Make it so EncryptionContextOperators can't be instantiated by adding a private
constructor.
@SalusaSecondus SalusaSecondus merged commit f89ea4b into aws:master Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants