-
Notifications
You must be signed in to change notification settings - Fork 192
Field Level Encryption Support. #1546
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
Conversation
9ac4347
to
0f02d5f
Compare
Note that an @Encrypted property object that contains an @Encrypted property is not supported and will result in an exception. Closes #763.
0f02d5f
to
5490b21
Compare
public CustomConversions customConversions() { | ||
return new CouchbaseCustomConversions(Collections.emptyList()); | ||
public CustomConversions customConversions(CryptoManager... cryptoManagerOptional) { | ||
assert (cryptoManagerOptional == null || cryptoManagerOptional.length <= 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of these alternatives suggested by StackOverflow users?
public CustomConversions customConversions(
Optional<CryptoManager> cryptoManagerOptional
)
Or this:
public CustomConversions customConversions(
@Autowired(required = false) CryptoManager cryptoManager
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one changes a public API so is not possible.
I have doubts about using @Autowired in the configuration class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing foo()
to foo(T...)
is a source-compatible change, but I suspect it's not binary-compatible. (Maybe binary compatibility is not a concern?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I missed the deadline -- sorry!
com.couchbase.client.java.encryption.annotation.Encrypted ann = sourceType | ||
.getAnnotation(com.couchbase.client.java.encryption.annotation.Encrypted.class); | ||
Map<Object, Object> result = new HashMap<>(); | ||
result.putAll(cryptoManager.encrypt(source.toString().getBytes(), ann.encrypter())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify charset?
.getBytes(StandardCharsets.UTF_8)
|
||
@Override | ||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { | ||
return source == null? null : new String(cryptoManager.decrypt(((CouchbaseDocument) source).getContent())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify charset?
new String(..., StandardCharsets.UTF_8)
com.couchbase.client.java.encryption.annotation.Encrypted ann = sourceType | ||
.getAnnotation(com.couchbase.client.java.encryption.annotation.Encrypted.class); | ||
Map<Object, Object> result = new HashMap<>(); | ||
result.putAll(cryptoManager.encrypt(source.toString().getBytes(), ann.encrypter())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does source.toString() always return JSON? (Asking because I'm wondering about interoperability with apps that don't use SDC)
@Override | ||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { | ||
if (source == null) { | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean null values don't get encrypted? Shouldn't a JSON "null" should get encrypted like any other value?
public CustomConversions customConversions() { | ||
return new CouchbaseCustomConversions(Collections.emptyList()); | ||
public CustomConversions customConversions(CryptoManager... cryptoManagerOptional) { | ||
assert (cryptoManagerOptional == null || cryptoManagerOptional.length <= 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing foo()
to foo(T...)
is a source-compatible change, but I suspect it's not binary-compatible. (Maybe binary compatibility is not a concern?)
Note that an @Encrypted property object that contains an @Encrypted property is
not supported and will result in an exception.
Closes #763.