Skip to content

Commit

Permalink
Update encryption example for updated encryption module
Browse files Browse the repository at this point in the history
The encryption module has been updated in paulcwarren/spring-content#2240
  • Loading branch information
vierbergenlars committed Jan 21, 2025
1 parent b93dfee commit ec12893
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package gettingstarted;

import org.springframework.content.commons.repository.ContentStore;

import org.springframework.content.encryption.EncryptingContentStore;
import org.springframework.content.commons.store.ContentStore;
import org.springframework.content.encryption.store.EncryptingContentStore;
import org.springframework.content.rest.StoreRestResource;

@StoreRestResource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package gettingstarted;

import internal.org.springframework.content.fragments.EncryptingContentStoreConfiguration;
import internal.org.springframework.content.fragments.EncryptingContentStoreConfigurer;
import java.util.List;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.content.encryption.EnvelopeEncryptionService;
import org.springframework.content.encryption.config.EncryptingContentStoreConfiguration;
import org.springframework.content.encryption.config.EncryptingContentStoreConfigurer;
import org.springframework.content.encryption.keys.VaultTransitDataEncryptionKeyWrapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.vault.authentication.ClientAuthentication;
Expand Down Expand Up @@ -40,16 +41,14 @@ public ClientAuthentication clientAuthentication() {
}

@Bean
public EnvelopeEncryptionService encrypter(VaultOperations vaultOperations) {
return new EnvelopeEncryptionService(vaultOperations);
}

@Bean
public EncryptingContentStoreConfigurer config() {
public EncryptingContentStoreConfigurer<FileContentStore> config(VaultOperations vaultOperations) {
return new EncryptingContentStoreConfigurer<FileContentStore>() {
@Override
public void configure(EncryptingContentStoreConfiguration config) {
config.keyring("fsfile").encryptionKeyContentProperty("key");
config.dataEncryptionKeyWrappers(List.of(
new VaultTransitDataEncryptionKeyWrapper(vaultOperations.opsForTransit(), "fsfile")
))
.encryptionKeyContentProperty("key");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.content.encryption.EnvelopeEncryptionService;
import org.springframework.content.fs.io.FileSystemResourceLoader;
import org.springframework.vault.core.VaultOperations;
import org.springframework.web.context.WebApplicationContext;

import java.io.FileInputStream;
Expand All @@ -35,12 +33,6 @@ public class GettingStartedTest {
@Autowired
private FileSystemResourceLoader storeLoader;

@Autowired
private EnvelopeEncryptionService encrypter;

@Autowired
private VaultOperations vaultOperations;

private File f;

{
Expand Down

0 comments on commit ec12893

Please sign in to comment.