I have followed the [documentation][1] and I cannot get FLE to work in my SpringBoot Java application..
Whenever I attempt to use an @Encrypted
annotation, it responds with the following Exception:
Request processing failed: java.lang.IllegalArgumentException: cryptoManager needed to encrypt/decrypt but it is null. Override needed for cryptoManager() method of org.springframework.data.couchbase.core.convert.AbstractCouchbaseConverter
Code is shown below:
@Configuration
@EnableCouchbaseRepositories("my.repo.under.here")
public class EncryptionConfig extends AbstractCouchbaseConfiguration {
// Usual Setup
@Override public String getConnectionString() { return "localhost"; }
@Override public String getUserName() { return "Administrator"; }
@Override public String getPassword() { return "admin123"; }
@Override public String getBucketName() { return "my_bucket"; }
/* provide a cryptoManager */
@Override
protected CryptoManager cryptoManager() {
try {
// Load the Java KeyStore
KeyStore keyStore = KeyStore.getInstance("JCEKS");
FileInputStream keyStoreStream = new FileInputStream("/Users/asd1983/my-keystore.jceks");
keyStore.load(keyStoreStream, "test123".toCharArray());
// Initialize the Keyring with the KeyStore
Keyring keyring = new KeyStoreKeyring(keyStore, alias -> "keypassword");
// AES-256 authenticated with HMAC SHA-512. Requires a 64-byte key.
AeadAes256CbcHmacSha512Provider provider = AeadAes256CbcHmacSha512Provider.builder().keyring(keyring).build();
CryptoManager cryptoManager = DefaultCryptoManager.builder().decrypter(provider.decrypter())
.defaultEncrypter(provider.encrypterForKey("my-key")).build();
return cryptoManager;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@Document
public class Data {
@Id
private String id;
@Encrypted
private String password;
}
package my.repo.under.here;
@Repository
public interface DataRepository extends CouchbaseRepository<Data, String> { }
[1]: https://docs.spring.io/spring-data/couchbase/reference/couchbase/fieldlevelencryption.html
Yeah it turned out to just be a slight configuration issues and it is working well now 👍