Package org.saidone.repository
Class EncryptedMongoNodeRepositoryImpl
java.lang.Object
org.saidone.component.BaseComponent
org.saidone.repository.MongoNodeRepositoryImpl
org.saidone.repository.EncryptedMongoNodeRepositoryImpl
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.data.mongodb.repository.MongoRepository<NodeWrapper,
,String> org.springframework.data.repository.CrudRepository<NodeWrapper,
,String> org.springframework.data.repository.ListCrudRepository<NodeWrapper,
,String> org.springframework.data.repository.ListPagingAndSortingRepository<NodeWrapper,
,String> org.springframework.data.repository.PagingAndSortingRepository<NodeWrapper,
,String> org.springframework.data.repository.query.QueryByExampleExecutor<NodeWrapper>
,org.springframework.data.repository.Repository<NodeWrapper,
String>
@Repository
@ConditionalOnProperty(name={"application.service.vault.encryption.enabled","application.service.vault.encryption.metadata"},
havingValue="true")
public class EncryptedMongoNodeRepositoryImpl
extends MongoNodeRepositoryImpl
Repository implementation that encrypts node data before saving to MongoDB
and decrypts it when retrieving. The bean is activated only when both
application.service.vault.encryption.enabled
and
application.service.vault.encryption.metadata
are set to
true
in the application properties.-
Constructor Summary
ConstructorsConstructorDescriptionEncryptedMongoNodeRepositoryImpl
(org.springframework.data.mongodb.core.MongoOperations mongoOperations, CryptoService cryptoService) Constructs an EncryptedMongoNodeRepositoryImpl with the given MongoOperations and CryptoService. -
Method Summary
Modifier and TypeMethodDescription@NonNull Optional
<NodeWrapper> Finds a node by its ID and decrypts its JSON content if it is encrypted.<S extends NodeWrapper>
Ssave
(S entity) Saves the given node entity after encrypting its JSON content.Methods inherited from class org.saidone.repository.MongoNodeRepositoryImpl
count, count, delete, deleteAll, deleteAll, deleteAllById, deleteById, exists, existsById, findAll, findAll, findAll, findAll, findAll, findAll, findAllById, findBy, findOne, init, insert, insert, saveAll
Methods inherited from class org.saidone.component.BaseComponent
setApplicationContext, shutDown, stop
-
Constructor Details
-
EncryptedMongoNodeRepositoryImpl
public EncryptedMongoNodeRepositoryImpl(org.springframework.data.mongodb.core.MongoOperations mongoOperations, CryptoService cryptoService) Constructs an EncryptedMongoNodeRepositoryImpl with the given MongoOperations and CryptoService.- Parameters:
mongoOperations
- the MongoDB operations instancecryptoService
- the service used for encryption and decryption
-
-
Method Details
-
save
Saves the given node entity after encrypting its JSON content.- Specified by:
save
in interfaceorg.springframework.data.repository.CrudRepository<NodeWrapper,
String> - Overrides:
save
in classMongoNodeRepositoryImpl
- Type Parameters:
S
- the type of the node entity- Parameters:
entity
- the node entity to save- Returns:
- the saved node entity
-
findById
Finds a node by its ID and decrypts its JSON content if it is encrypted.- Specified by:
findById
in interfaceorg.springframework.data.repository.CrudRepository<NodeWrapper,
String> - Overrides:
findById
in classMongoNodeRepositoryImpl
- Parameters:
s
- the ID of the node to find- Returns:
- an Optional containing the found node, or empty if not found
-