Load SecureStore implementation from site lib dir
This approach shares core ideas of the servlet filter and is alternative approach to secure store plugin. To use this extension additional jar file needs to be put in $site_path/lib directory and gerrit.secureStoreClass property needs to be added to gerrit.config file. This property must contain fully qualified class name that implements com.google.gerrit.server.securestore.SecureStore interface. During Gerrit start up the class configured with the gerrit.secureStoreClass will be loaded and the SecureStore interface will be bound to it. Change-Id: I90972d28ecab0818d782c3d43acb8c70ba598d12 Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.config;
|
||||
|
||||
import com.google.gerrit.server.securestore.SecureStore;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.ProvisionException;
|
||||
@@ -33,10 +34,12 @@ class GerritServerConfigProvider implements Provider<Config> {
|
||||
LoggerFactory.getLogger(GerritServerConfigProvider.class);
|
||||
|
||||
private final SitePaths site;
|
||||
private final SecureStore secureStore;
|
||||
|
||||
@Inject
|
||||
GerritServerConfigProvider(final SitePaths site) {
|
||||
GerritServerConfigProvider(final SitePaths site, final SecureStore secureStore) {
|
||||
this.site = site;
|
||||
this.secureStore = secureStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +49,7 @@ class GerritServerConfigProvider implements Provider<Config> {
|
||||
if (!cfg.getFile().exists()) {
|
||||
log.info("No " + site.gerrit_config.getAbsolutePath()
|
||||
+ "; assuming defaults");
|
||||
return cfg;
|
||||
return new GerritConfig(cfg, secureStore);
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -57,17 +60,6 @@ class GerritServerConfigProvider implements Provider<Config> {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (site.secure_config.exists()) {
|
||||
cfg = new FileBasedConfig(cfg, site.secure_config, FS.DETECTED);
|
||||
try {
|
||||
cfg.load();
|
||||
} catch (IOException e) {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
} catch (ConfigInvalidException e) {
|
||||
throw new ProvisionException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
return cfg;
|
||||
return new GerritConfig(cfg, secureStore);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user