Search in sources :

Example 1 with EncryptingPersistenceManager

use of org.apache.felix.cm.file.EncryptingPersistenceManager in project fabric8 by jboss-fuse.

the class EncryptedPropertyResolver method initialize.

/**
 * When {@link FabricService} becomes available, we can initialize this {@link PlaceholderResolver}
 * @param fabricService
 */
public void initialize(FabricService fabricService) {
    this.fabricService = fabricService;
    encryptor = getEncryptor(fabricService);
    if (bundleContext != null) {
        seRegistration = bundleContext.registerService(PBEStringEncryptor.class, encryptor, null);
        BundleContext context = FrameworkUtil.getBundle(PersistenceManager.class).getBundleContext();
        encryptingPersistenceManager = new EncryptingPersistenceManager(context, context.getProperty(ConfigurationManager.CM_CONFIG_DIR), encryptor);
        originalPersistenceManager = inject(configAdmin, encryptingPersistenceManager);
        passwordNodeCache = new NodeCacheExtended(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_PASSWORD.getPath());
        passwordNodeCache.getListenable().addListener(this);
        alogrithmNodeCache = new NodeCacheExtended(fabricService.adapt(CuratorFramework.class), AUTHENTICATION_CRYPT_ALGORITHM.getPath());
        alogrithmNodeCache.getListenable().addListener(this);
        try {
            passwordNodeCache.start();
            alogrithmNodeCache.start();
        } catch (Exception e) {
            throw new FabricException(e);
        }
    }
}
Also used : NodeCacheExtended(org.apache.curator.framework.recipes.cache.NodeCacheExtended) EncryptingPersistenceManager(org.apache.felix.cm.file.EncryptingPersistenceManager) PersistenceManager(org.apache.felix.cm.PersistenceManager) FabricException(io.fabric8.api.FabricException) PBEStringEncryptor(org.jasypt.encryption.pbe.PBEStringEncryptor) StandardPBEStringEncryptor(org.jasypt.encryption.pbe.StandardPBEStringEncryptor) EncryptingPersistenceManager(org.apache.felix.cm.file.EncryptingPersistenceManager) FabricException(io.fabric8.api.FabricException) IOException(java.io.IOException) EncryptionOperationNotPossibleException(org.jasypt.exceptions.EncryptionOperationNotPossibleException) BundleContext(org.osgi.framework.BundleContext)

Aggregations

FabricException (io.fabric8.api.FabricException)1 IOException (java.io.IOException)1 NodeCacheExtended (org.apache.curator.framework.recipes.cache.NodeCacheExtended)1 PersistenceManager (org.apache.felix.cm.PersistenceManager)1 EncryptingPersistenceManager (org.apache.felix.cm.file.EncryptingPersistenceManager)1 PBEStringEncryptor (org.jasypt.encryption.pbe.PBEStringEncryptor)1 StandardPBEStringEncryptor (org.jasypt.encryption.pbe.StandardPBEStringEncryptor)1 EncryptionOperationNotPossibleException (org.jasypt.exceptions.EncryptionOperationNotPossibleException)1 BundleContext (org.osgi.framework.BundleContext)1