Acosix / alfresco-simple-content-stores

Addon to provide a set of common content store implementations and easy-to-use configuration (no Spring config)
Apache License 2.0
44 stars 19 forks source link

Encrypting Store #18

Closed maciass2008 closed 3 years ago

maciass2008 commented 5 years ago

Hi, I want to encrypt content store and i have used configuration given by wiki.

simpleContentStores.enabled=true simpleContentStores.customStores=myEncryptingStore,defaultTenantFileContentStore simpleContentStores.rootStore=myEncryptingStore simpleContentStores.customStore.myEncryptingStore.type=encryptingFacadeStore simpleContentStores.customStore.myEncryptingStore.ref.backingStore=defaultTenantFileContentStore simpleContentStores.customStore.myEncryptingStore.value.keyStorePath=classpath:keystore.jks simpleContentStores.customStore.myEncryptingStore.value.keyStorePassword=encrypt simpleContentStores.customStore.myEncryptingStore.value.masterKeyAlias=encrypt simpleContentStores.customStore.myEncryptingStore.value.masterKeyPassword=encrypt simpleContentStores.customStore.myEncryptingStore.value.masterKeyStoreId=SimpleContentStores

i receive this error in the log file

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simpleContentStoresTemplate-standardCachingStore' defined in file [D:\Alfresco\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\ContentStore\simple-content-stores\content-store-templates-context.xml]: Invocation of init method failed; nested exception is org.alfresco.error.AlfrescoRuntimeException: 00260001 Property 'cacheName' has not been set: de.acosix.alfresco.simplecontentstores.repo.beans.CachingContentStoreFactoryBean@6ded7019 (class de.acosix.alfresco.simplecontentstores.repo.beans.CachingContentStoreFactoryBean)

Any suggestion? N.B : im using alfresco 5.0 community edition

vojkog commented 5 years ago

I had a similar problem and error was caused by mismatched masterKeyAlias in configuration and keystore.jks. For your example configuration keystore generation should be something like this:

keytool -genkey -alias encrypt -keystore keystore.jks -keypass encrypt -storepass encrypt
vojkog commented 5 years ago

Exception is non informative because real exception here https://github.com/Acosix/alfresco-simple-content-stores/blob/260ec2f85e5ff9f49bb6a8539898856454c018df/src/main/java/de/acosix/alfresco/simplecontentstores/repo/store/facade/EncryptingContentStore.java#L437

is NO-OPed.

AFaust commented 5 years ago

My project load has kept me quite busy this year, so I could not attend the issues from this project sooner. Fortunately, I currently have a customer who wants to see this project formally released, so I have spent some time the last couple of days to set up and expand integration tests and fix some issues along the way.

The error message in the OP description was an accidental side effect, caused by using a prototype bean instead of an abstract parent bean for the caching store template. This would get triggered even if no caching content store was configured. This has been addressed in commit https://github.com/Acosix/alfresco-simple-content-stores/commit/0276991fe12172803902c24fd6a79774223fa5a0.

Now as to the mentioned no-op exception handling, this is actually not the case. The only part of the logic that was covered by the no-op handling of IOException was the closing of the input stream, when all other operations had already completed / failed. This is quite a common practice, as any error on closing the input stream at this point won't have any impact on the previous operations, unless they are not caught at all. Any error with a mismatched master key alias should be / have been handled by the outer try-catch construct specfically aimed at catching issues with the keystore (catch-block).

Nevertheless, I will try to find some time to do a test with an explicitely mismatched alias.

AFaust commented 3 years ago

The master key management has been completely reworked for version 1.2 - see https://github.com/Acosix/alfresco-simple-content-stores/commit/3bd896875a0a430f8eddad0f9df80dfe56678426 or updated documentation for details. Since the new version consolidates key management in a central component and allows multiple keys/aliases to be defined, an error to load a single alias / key will be logged, but only cause the startup to fail if - as a result - there are no active, usable keys once all keys have been loaded.

Note: Support for Alfresco versions before 5.2 has been dropped with version 1.2 of this project. These are simply too old and rarely used nowadays.