-
Notifications
You must be signed in to change notification settings - Fork 192
FLE implementation with property value converter. #1554
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
FLE implementation with property value converter. #1554
Conversation
Closes #763.
…se into datacouch_763_fle_implementation_with_property_value_converter
} | ||
|
||
/* TODO needed later |
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 'diff' gets confusing here. I removed a commented-out convertToCouchbaseType() method here and added a new convertForWriteIfNeeded() (above) that has three args vs. the existing one that had only one arg (below).
|
||
boolean wasString = false; | ||
List<Exception> exceptionList = new LinkedList<>(); | ||
String decryptedString = new String(decrypted); |
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.
I'm not really happy with the following code that takes the decrypted string and turns it into a simple type. But it seems to do the job.
Class<?> targetType = conversions.getCustomWriteTarget(context.getProperty().getType()).orElse(null); | ||
|
||
value = ctx.getConverter().getPotentiallyConvertedSimpleWrite(property, ctx.getAccessor(), false); | ||
if (conversions.isSimpleType(sourceType)) { |
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.
Similar comment to above - I'm not really happy with this code that converts the value into a string for decryptiing. But it seems to work.
@@ -204,7 +205,7 @@ public enum NumberToDateTimeConverter implements Converter<Number, DateTime> { | |||
|
|||
@Override | |||
public DateTime convert(Number source) { | |||
return source == null ? null : new DateTime(source.longValue()); | |||
return source == null ? null : new DateTime(source.longValue(), DateTimeZone.UTC); |
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.
This change is to make the Couchbase deserialization compatible with the SDK (via jackson-jodatime) which is in UTC (vs. local time zone).
} | ||
|
||
@Override | ||
protected 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.
This is the method the user will need to override.
} | ||
|
||
@Version protected long version; | ||
@Encrypted public String encryptedField; |
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.
Normally spring-data would use an @ValueConverter annotation for this. But my CouchbaseValueConverterFactory also recognizes Couchbase @Encrypted
13f0e30
to
270b720
Compare
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.
+2, after the improvements we chatted about today
270b720
to
fe2eeae
Compare
fe2eeae
to
ea3e0b6
Compare
Closes #763