-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ClassCastException when reading (decrypting) using @ExplicitEncrypted on custom type instead of simple type #4432
Comments
It is hard to tell what's the problem here. The related test seems to work as expected. Please help us triage the issue and take the time to provide a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
Please start the The Then, a csfldebug.zip |
@christianblust thanks for the reproducer! |
In this case, since the driver is aware of the encryption configuration, the driver already decrypts the array field internally before it is even handed to the converter, which leads to the mentioned |
Thanks for looking into it! I just noticed the same happening for |
it is. you can try @Bean
fun encryptingConverter(): MongoEncryptionConverter{
val encryption = MongoClientEncryption.just(clientEncryption)
val keyResolver = EncryptionKeyResolver.annotated{ _ -> EncryptionKey.keyAltName("demo-data-key")}
return object : MongoEncryptionConverter(encryption, keyResolver) {
override fun decrypt(encryptedValue: Any, context: EncryptionContext): Any {
return context.read(encryptedValue, context.property.typeInformation)
}
}
} |
This helps a bit, no exception! However, the result-type after reading or decrypting I also tested skipping the
So,
|
Hi all,
I am currently trying to implement explicit client side field level encryption according to https://docs.spring.io/spring-data/mongodb/docs/current/reference/html/#mongo.encryption.explicit
It works when I annotate simple types like String. However if I annotate a custom "Address" like type encryption works and my object is saved encrypted to mongo db. Although trying to read it results in a
ClassCastException
in theMongoEncryptionConverter
:Probably relevant code parts:
Here reading (or decrypting) fails with the mentioned ClassCastException
This works:
Sorry if you are also scanning stackoverflow, then this is probably redundant. However I am not sure if I stumbled upon a bug or if I just misconfigured something.
The text was updated successfully, but these errors were encountered: