Selaa lähdekoodia

fix file crawling problem, add cryptographer parameters, modify search path for crawler.properties, add requires for rpm

Shinsuke Sugaya 9 vuotta sitten
vanhempi
commit
0cbec074ae

+ 4 - 1
pom.xml

@@ -391,6 +391,9 @@
 						<passphrase>${gpg.passphrase}</passphrase>
 					</keyPassphrase>
 					-->
+					<requires>
+						<require>elasticsearch &gt;= ${elasticsearch.version}</require>
+					</requires>
 					<mappings>
 						<!-- fess home -->
 						<mapping>
@@ -486,7 +489,7 @@
 						</mapping>
 						<!-- Add environment vars file -->
 						<mapping>
-							<directory>/etc/sysconfig/</directory>
+							<directory>/etc/sysconfig</directory>
 							<directoryIncluded>false</directoryIncluded>
 							<username>root</username>
 							<groupname>root</groupname>

+ 2 - 0
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";
 }

+ 2 - 0
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;

+ 1 - 2
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);
     }
 }

+ 1 - 1
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();
                     });

+ 1 - 1
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();
                     });

+ 1 - 1
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);

+ 1 - 1
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);

+ 44 - 1
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'. <br>
      * The value is, e.g. elasticsearch <br>
-     * 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'. <br>
+     * The value is, e.g. aes <br>
+     * 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'. <br>
+     * The value is, e.g. __change_me__ <br>
+     * @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'. <br>
+     * The value is, e.g. sha256 <br>
+     * @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'. <br>
      * The value is, e.g. false <br>
@@ -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);
         }

+ 23 - 3
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);
     }
 

+ 5 - 0
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);
     }
 

+ 6 - 1
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
 #                                                                                     ====