diff --git a/pom.xml b/pom.xml index 6782cc6d6..dccb3a6e9 100644 --- a/pom.xml +++ b/pom.xml @@ -391,6 +391,9 @@ ${gpg.passphrase} --> + + elasticsearch >= ${elasticsearch.version} + @@ -486,7 +489,7 @@ - /etc/sysconfig/ + /etc/sysconfig false root root diff --git a/src/main/java/org/codelibs/fess/Constants.java b/src/main/java/org/codelibs/fess/Constants.java index 1538fd6be..c11958dae 100644 --- a/src/main/java/org/codelibs/fess/Constants.java +++ b/src/main/java/org/codelibs/fess/Constants.java @@ -353,4 +353,6 @@ public class Constants extends CoreLibConstants { public static final String DEFAULT_FIELD = "_default"; public static final Integer DEFAULT_DAY_FOR_CLEANUP = 3; + + public static final String FESS_CONF_PATH = "fess.conf.path"; } diff --git a/src/main/java/org/codelibs/fess/FessBoot.java b/src/main/java/org/codelibs/fess/FessBoot.java index 9a1cc0362..edfe41686 100644 --- a/src/main/java/org/codelibs/fess/FessBoot.java +++ b/src/main/java/org/codelibs/fess/FessBoot.java @@ -15,6 +15,8 @@ */ package org.codelibs.fess; +// DO NOT DEPEND OTHER JARs + import java.io.File; import org.dbflute.tomcat.TomcatBoot; diff --git a/src/main/java/org/codelibs/fess/app/web/admin/wizard/AdminWizardAction.java b/src/main/java/org/codelibs/fess/app/web/admin/wizard/AdminWizardAction.java index 1c3fbefcf..0e7d07569 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/wizard/AdminWizardAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/wizard/AdminWizardAction.java @@ -28,7 +28,6 @@ import org.codelibs.fess.Constants; import org.codelibs.fess.app.service.FileConfigService; import org.codelibs.fess.app.service.ScheduledJobService; import org.codelibs.fess.app.service.WebConfigService; -import org.codelibs.fess.app.web.admin.dashboard.AdminDashboardAction; import org.codelibs.fess.app.web.base.FessAdminAction; import org.codelibs.fess.crawler.util.CharUtil; import org.codelibs.fess.es.config.exentity.FileConfig; @@ -299,6 +298,6 @@ public class AdminWizardAction extends FessAdminAction { } else { saveError(messages -> messages.addErrorsFailedToStartCrawlProcess(GLOBAL)); } - return redirect(AdminDashboardAction.class); + return redirect(AdminWizardAction.class); } } \ No newline at end of file diff --git a/src/main/java/org/codelibs/fess/es/config/exentity/DataConfig.java b/src/main/java/org/codelibs/fess/es/config/exentity/DataConfig.java index b569c7aa2..c225258c2 100644 --- a/src/main/java/org/codelibs/fess/es/config/exentity/DataConfig.java +++ b/src/main/java/org/codelibs/fess/es/config/exentity/DataConfig.java @@ -115,7 +115,7 @@ public class DataConfig extends BsDataConfig implements CrawlingConfig { labelIdList.add(mapping.getLabelTypeId()); } final LabelTypeBhv labelTypeBhv = ComponentUtil.getComponent(LabelTypeBhv.class); - labelTypeList = labelTypeBhv.selectList(cb -> { + labelTypeList = labelIdList.isEmpty() ? Collections.emptyList() : labelTypeBhv.selectList(cb -> { cb.query().setId_InScope(labelIdList); cb.query().addOrderBy_SortOrder_Asc(); }); diff --git a/src/main/java/org/codelibs/fess/es/config/exentity/FileConfig.java b/src/main/java/org/codelibs/fess/es/config/exentity/FileConfig.java index 9f83c676d..9814f6861 100644 --- a/src/main/java/org/codelibs/fess/es/config/exentity/FileConfig.java +++ b/src/main/java/org/codelibs/fess/es/config/exentity/FileConfig.java @@ -90,7 +90,7 @@ public class FileConfig extends BsFileConfig implements CrawlingConfig { labelIdList.add(mapping.getLabelTypeId()); } final LabelTypeBhv labelTypeBhv = ComponentUtil.getComponent(LabelTypeBhv.class); - labelTypeList = labelTypeBhv.selectList(cb -> { + labelTypeList = labelIdList.isEmpty() ? Collections.emptyList() : labelTypeBhv.selectList(cb -> { cb.query().setId_InScope(labelIdList); cb.query().addOrderBy_SortOrder_Asc(); }); diff --git a/src/main/java/org/codelibs/fess/job/CrawlJob.java b/src/main/java/org/codelibs/fess/job/CrawlJob.java index 536bcb620..dc0447269 100644 --- a/src/main/java/org/codelibs/fess/job/CrawlJob.java +++ b/src/main/java/org/codelibs/fess/job/CrawlJob.java @@ -234,7 +234,7 @@ public class CrawlJob { // -cp crawlerCmdList.add("-cp"); final StringBuilder buf = new StringBuilder(); - final String confPath = System.getProperty("fess.conf.path"); + final String confPath = System.getProperty(Constants.FESS_CONF_PATH); if (StringUtil.isNotBlank(confPath)) { buf.append(confPath); buf.append(cpSeparator); diff --git a/src/main/java/org/codelibs/fess/job/SuggestJob.java b/src/main/java/org/codelibs/fess/job/SuggestJob.java index 08ad46963..adae1e71a 100644 --- a/src/main/java/org/codelibs/fess/job/SuggestJob.java +++ b/src/main/java/org/codelibs/fess/job/SuggestJob.java @@ -104,7 +104,7 @@ public class SuggestJob { // -cp suggestCreatorCmdList.add("-cp"); final StringBuilder buf = new StringBuilder(); - final String confPath = System.getProperty("fess.conf.path"); + final String confPath = System.getProperty(Constants.FESS_CONF_PATH); if (StringUtil.isNotBlank(confPath)) { buf.append(confPath); buf.append(cpSeparator); diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index e8e08a1f1..8ff958199 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -31,6 +31,15 @@ public interface FessConfig extends FessEnv { /** The key of the configuration. e.g. http://localhost:9201 */ String ELASTICSEARCH_HTTP_URL = "elasticsearch.http.url"; + /** The key of the configuration. e.g. aes */ + String APP_CIPHER_ALGORISM = "app.cipher.algorism"; + + /** The key of the configuration. e.g. __change_me__ */ + String APP_CIPHER_KEY = "app.cipher.key"; + + /** The key of the configuration. e.g. sha256 */ + String APP_DIGEST_ALGORISM = "app.digest.algorism"; + /** The key of the configuration. e.g. false */ String CRAWLER_DOCUMENT_CACHE_ENABLE = "crawler.document.cache.enable"; @@ -322,7 +331,7 @@ public interface FessConfig extends FessEnv { /** * Get the value for the key 'elasticsearch.cluster.name'.
* The value is, e.g. elasticsearch
- * comment: elasticsearch + * comment: Elasticsearch * @return The value of found property. (NotNull: if not found, exception but basically no way) */ String getElasticsearchClusterName(); @@ -334,6 +343,28 @@ public interface FessConfig extends FessEnv { */ String getElasticsearchHttpUrl(); + /** + * Get the value for the key 'app.cipher.algorism'.
+ * The value is, e.g. aes
+ * comment: Cryptographer + * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getAppCipherAlgorism(); + + /** + * Get the value for the key 'app.cipher.key'.
+ * The value is, e.g. __change_me__
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getAppCipherKey(); + + /** + * Get the value for the key 'app.digest.algorism'.
+ * The value is, e.g. sha256
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getAppDigestAlgorism(); + /** * Get the value for the key 'crawler.document.cache.enable'.
* The value is, e.g. false
@@ -1163,6 +1194,18 @@ public interface FessConfig extends FessEnv { return get(FessConfig.ELASTICSEARCH_HTTP_URL); } + public String getAppCipherAlgorism() { + return get(FessConfig.APP_CIPHER_ALGORISM); + } + + public String getAppCipherKey() { + return get(FessConfig.APP_CIPHER_KEY); + } + + public String getAppDigestAlgorism() { + return get(FessConfig.APP_DIGEST_ALGORISM); + } + public String getCrawlerDocumentCacheEnable() { return get(FessConfig.CRAWLER_DOCUMENT_CACHE_ENABLE); } diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessFwAssistantDirector.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessFwAssistantDirector.java index f461726c7..fa36a1881 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessFwAssistantDirector.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessFwAssistantDirector.java @@ -92,9 +92,29 @@ public class FessFwAssistantDirector extends CachedFwAssistantDirector { return new FessCurtainFinallyHook(); } - protected FessSecurityResourceProvider createSecurityResourceProvider() { // #change_it_first - final InvertibleCryptographer inver = InvertibleCryptographer.createAesCipher("*unused@"); - final OneWayCryptographer oneWay = OneWayCryptographer.createSha256Cryptographer(); + protected FessSecurityResourceProvider createSecurityResourceProvider() { + final InvertibleCryptographer inver; + final String cipherAlgorism = fessConfig.getAppCipherAlgorism(); + if ("blowfish".equalsIgnoreCase(cipherAlgorism)) { + inver = InvertibleCryptographer.createBlowfishCipher(fessConfig.getAppCipherKey()); + } else if ("des".equalsIgnoreCase(cipherAlgorism)) { + inver = InvertibleCryptographer.createDesCipher(fessConfig.getAppCipherKey()); + } else if ("rsa".equalsIgnoreCase(cipherAlgorism)) { + inver = InvertibleCryptographer.createRsaCipher(fessConfig.getAppCipherKey()); + } else { + inver = InvertibleCryptographer.createAesCipher(fessConfig.getAppCipherKey()); + } + + final OneWayCryptographer oneWay; + final String digestAlgorism = fessConfig.getAppDigestAlgorism(); + if ("sha512".equalsIgnoreCase(digestAlgorism)) { + oneWay = OneWayCryptographer.createSha512Cryptographer(); + } else if ("md5".equalsIgnoreCase(digestAlgorism)) { + oneWay = new OneWayCryptographer("MD5", OneWayCryptographer.ENCODING_UTF8); + } else { + oneWay = OneWayCryptographer.createSha256Cryptographer(); + } + return new FessSecurityResourceProvider(inver, oneWay); } diff --git a/src/main/java/org/codelibs/fess/util/ResourceUtil.java b/src/main/java/org/codelibs/fess/util/ResourceUtil.java index f88a4673a..7b2b7bef8 100644 --- a/src/main/java/org/codelibs/fess/util/ResourceUtil.java +++ b/src/main/java/org/codelibs/fess/util/ResourceUtil.java @@ -26,6 +26,7 @@ import java.util.regex.Pattern; import javax.servlet.ServletContext; import org.codelibs.core.lang.StringUtil; +import org.codelibs.fess.Constants; import org.codelibs.fess.mylasta.direction.FessConfig; import org.lastaflute.di.core.SingletonLaContainer; import org.lastaflute.web.util.LaServletContextUtil; @@ -45,6 +46,10 @@ public class ResourceUtil { } public static Path getConfPath(final String... names) { + final String confPath = System.getProperty(Constants.FESS_CONF_PATH); + if (StringUtil.isNotBlank(confPath)) { + return Paths.get(confPath, names); + } return getPath("conf", names); } diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index 48330d284..b00c9bbbb 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -8,10 +8,15 @@ # The title of domain the application for logging domain.title = Fess -# elasticsearch +# Elasticsearch elasticsearch.cluster.name=elasticsearch elasticsearch.http.url=http://localhost:9201 +# Cryptographer +app.cipher.algorism=aes +app.cipher.key=__change_me__ +app.digest.algorism=sha256 + # ======================================================================================== # Index # ====