Forráskód Böngészése

add ldap support and minor fixes

Shinsuke Sugaya 9 éve
szülő
commit
bb3311ddd5
23 módosított fájl, 276 hozzáadás és 30 törlés
  1. 1 1
      pom.xml
  2. 8 0
      src/main/java/org/codelibs/fess/Constants.java
  3. 4 0
      src/main/java/org/codelibs/fess/app/web/admin/general/AdminGeneralAction.java
  4. 5 0
      src/main/java/org/codelibs/fess/app/web/admin/general/EditForm.java
  5. 0 1
      src/main/java/org/codelibs/fess/app/web/base/FessSearchAction.java
  6. 10 0
      src/main/java/org/codelibs/fess/app/web/base/login/FessLoginAssist.java
  7. 12 4
      src/main/java/org/codelibs/fess/app/web/login/LoginAction.java
  8. 1 0
      src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java
  9. 1 0
      src/main/java/org/codelibs/fess/helper/AdRoleHelper.java
  10. 71 0
      src/main/java/org/codelibs/fess/ldap/LdapManager.java
  11. 28 0
      src/main/java/org/codelibs/fess/ldap/LdapUser.java
  12. 19 4
      src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java
  13. 3 3
      src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
  14. 1 1
      src/main/java/org/codelibs/fess/mylasta/direction/FessEnv.java
  15. 46 0
      src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java
  16. 7 0
      src/main/java/org/codelibs/fess/util/ComponentUtil.java
  17. 1 1
      src/main/resources/app.xml
  18. 1 1
      src/main/resources/fess_config.properties
  19. 9 4
      src/main/resources/fess_label.properties
  20. 9 5
      src/main/resources/fess_label_en.properties
  21. 10 5
      src/main/resources/fess_label_ja.properties
  22. 7 0
      src/main/resources/fess_ldap.xml
  23. 22 0
      src/main/webapp/WEB-INF/view/admin/general/admin_general.jsp

+ 1 - 1
pom.xml

@@ -41,7 +41,7 @@
 
 
 		<!-- Main Framework -->
 		<!-- Main Framework -->
 		<dbflute.version>1.1.0-sp9</dbflute.version>
 		<dbflute.version>1.1.0-sp9</dbflute.version>
-		<lastaflute.version>0.7.1</lastaflute.version>
+		<lastaflute.version>0.7.2</lastaflute.version>
 		<lasta.taglib.version>0.6.6</lasta.taglib.version>
 		<lasta.taglib.version>0.6.6</lasta.taglib.version>
 		<servlet.version>3.1.0</servlet.version>
 		<servlet.version>3.1.0</servlet.version>
 		<jsp.version>2.3.1</jsp.version>
 		<jsp.version>2.3.1</jsp.version>

+ 8 - 0
src/main/java/org/codelibs/fess/Constants.java

@@ -358,4 +358,12 @@ public class Constants extends CoreLibConstants {
     public static final String FESS_CONF_PATH = "fess.conf.path";
     public static final String FESS_CONF_PATH = "fess.conf.path";
 
 
     public static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");
     public static final TimeZone TIMEZONE_UTC = TimeZone.getTimeZone("UTC");
+
+    public static final String LDAP_SECURITY_PRINCIPAL = "ldap.security.principal";
+
+    public static final String LDAP_PROVIDER_URL = "ldap.provider.url";
+
+    public static final String LDAP_SECURITY_AUTHENTICATION = "ldap.security.authentication";
+
+    public static final String LDAP_INITIAL_CONTEXT_FACTORY = "ldap.initial.context.factory";
 }
 }

+ 4 - 0
src/main/java/org/codelibs/fess/app/web/admin/general/AdminGeneralAction.java

@@ -160,6 +160,8 @@ public class AdminGeneralAction extends FessAdminAction {
         updateProperty(Constants.SUGGEST_DOCUMENTS_PROPERTY,
         updateProperty(Constants.SUGGEST_DOCUMENTS_PROPERTY,
                 form.suggestDocuments != null && Constants.ON.equalsIgnoreCase(form.suggestDocuments) ? Constants.TRUE : Constants.FALSE);
                 form.suggestDocuments != null && Constants.ON.equalsIgnoreCase(form.suggestDocuments) ? Constants.TRUE : Constants.FALSE);
         updateProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, form.purgeSuggestSearchLogDay.toString());
         updateProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY, form.purgeSuggestSearchLogDay.toString());
+        updateProperty(Constants.LDAP_PROVIDER_URL, form.ldapProviderUrl);
+        updateProperty(Constants.LDAP_SECURITY_PRINCIPAL, form.ldapSecurityPrincipal);
 
 
         crawlerProperties.store();
         crawlerProperties.store();
         saveInfo(messages -> messages.addSuccessUpdateCrawlerParams(GLOBAL));
         saveInfo(messages -> messages.addSuccessUpdateCrawlerParams(GLOBAL));
@@ -195,6 +197,8 @@ public class AdminGeneralAction extends FessAdminAction {
         form.purgeSuggestSearchLogDay =
         form.purgeSuggestSearchLogDay =
                 Integer.parseInt(crawlerProperties.getProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY,
                 Integer.parseInt(crawlerProperties.getProperty(Constants.PURGE_SUGGEST_SEARCH_LOG_DAY_PROPERTY,
                         Constants.DEFAULT_SUGGEST_PURGE_DAY));
                         Constants.DEFAULT_SUGGEST_PURGE_DAY));
+        form.ldapProviderUrl = crawlerProperties.getProperty(Constants.LDAP_PROVIDER_URL, StringUtil.EMPTY);
+        form.ldapSecurityPrincipal = crawlerProperties.getProperty(Constants.LDAP_SECURITY_PRINCIPAL, StringUtil.EMPTY);
     }
     }
 
 
     private void updateProperty(final String key, final String value) {
     private void updateProperty(final String key, final String value) {

+ 5 - 0
src/main/java/org/codelibs/fess/app/web/admin/general/EditForm.java

@@ -116,4 +116,9 @@ public class EditForm implements Serializable {
     @ValidateTypeFailure
     @ValidateTypeFailure
     public Integer purgeSuggestSearchLogDay;
     public Integer purgeSuggestSearchLogDay;
 
 
+    @Size(max = 1000)
+    public String ldapProviderUrl;
+
+    @Size(max = 1000)
+    public String ldapSecurityPrincipal;
 }
 }

+ 0 - 1
src/main/java/org/codelibs/fess/app/web/base/FessSearchAction.java

@@ -193,6 +193,5 @@ public abstract class FessSearchAction extends FessBaseAction {
     protected HtmlResponse redirectToRoot() {
     protected HtmlResponse redirectToRoot() {
         final String contextPath = request.getServletContext().getContextPath();
         final String contextPath = request.getServletContext().getContextPath();
         return newHtmlResponseAsRediect(StringUtil.isBlank(contextPath) ? "/" : contextPath);
         return newHtmlResponseAsRediect(StringUtil.isBlank(contextPath) ? "/" : contextPath);
-
     }
     }
 }
 }

+ 10 - 0
src/main/java/org/codelibs/fess/app/web/base/login/FessLoginAssist.java

@@ -25,6 +25,7 @@ import org.codelibs.fess.es.user.exentity.User;
 import org.codelibs.fess.exception.UserRoleLoginException;
 import org.codelibs.fess.exception.UserRoleLoginException;
 import org.codelibs.fess.mylasta.action.FessUserBean;
 import org.codelibs.fess.mylasta.action.FessUserBean;
 import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.codelibs.fess.mylasta.direction.FessConfig;
+import org.codelibs.fess.util.ComponentUtil;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalEntity;
 import org.dbflute.optional.OptionalThing;
 import org.dbflute.optional.OptionalThing;
 import org.lastaflute.core.magic.async.AsyncManager;
 import org.lastaflute.core.magic.async.AsyncManager;
@@ -65,6 +66,15 @@ public class FessLoginAssist extends TypicalLoginAssist<String, FessUserBean, Us
         }) > 0;
         }) > 0;
     }
     }
 
 
+    @Override
+    public OptionalEntity<User> findLoginUser(String username, String password) {
+        OptionalEntity<User> ldapUser = ComponentUtil.getLdapManager().login(username, password);
+        if (ldapUser.isPresent()) {
+            return ldapUser;
+        }
+        return doFindLoginUser(username, encryptPassword(password));
+    }
+
     @Override
     @Override
     protected OptionalEntity<User> doFindLoginUser(final String username, final String cipheredPassword) {
     protected OptionalEntity<User> doFindLoginUser(final String username, final String cipheredPassword) {
         return userBhv.selectEntity(cb -> {
         return userBhv.selectEntity(cb -> {

+ 12 - 4
src/main/java/org/codelibs/fess/app/web/login/LoginAction.java

@@ -17,6 +17,7 @@ package org.codelibs.fess.app.web.login;
 
 
 import org.codelibs.fess.app.web.admin.dashboard.AdminDashboardAction;
 import org.codelibs.fess.app.web.admin.dashboard.AdminDashboardAction;
 import org.codelibs.fess.app.web.base.FessSearchAction;
 import org.codelibs.fess.app.web.base.FessSearchAction;
+import org.codelibs.fess.mylasta.action.FessUserBean;
 import org.lastaflute.web.Execute;
 import org.lastaflute.web.Execute;
 import org.lastaflute.web.login.exception.LoginFailureException;
 import org.lastaflute.web.login.exception.LoginFailureException;
 import org.lastaflute.web.response.HtmlResponse;
 import org.lastaflute.web.response.HtmlResponse;
@@ -44,10 +45,6 @@ public class LoginAction extends FessSearchAction {
         return getHtmlResponse().useForm(LoginForm.class);
         return getHtmlResponse().useForm(LoginForm.class);
     }
     }
 
 
-    private HtmlResponse getHtmlResponse() {
-        return getUserBean().map(user -> redirect(AdminDashboardAction.class)).orElse(asHtml(path_Login_IndexJsp));
-    }
-
     @Execute
     @Execute
     public HtmlResponse login(final LoginForm form) {
     public HtmlResponse login(final LoginForm form) {
         validate(form, messages -> {}, () -> {
         validate(form, messages -> {}, () -> {
@@ -67,4 +64,15 @@ public class LoginAction extends FessSearchAction {
         return redirect(getClass());
         return redirect(getClass());
     }
     }
 
 
+    private HtmlResponse getHtmlResponse() {
+        return getUserBean().map(user -> redirectByUser(user)).orElse(asHtml(path_Login_IndexJsp));
+    }
+
+    private HtmlResponse redirectByUser(FessUserBean user) {
+        if (!user.hasRoles(fessConfig.getAuthenticationAdminRoles().split(","))) {
+            return redirectToRoot();
+        }
+        return redirect(AdminDashboardAction.class);
+    }
+
 }
 }

+ 1 - 0
src/main/java/org/codelibs/fess/filter/AdLoginInfoFilter.java

@@ -38,6 +38,7 @@ import org.codelibs.fess.util.ComponentUtil;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
+// TODO refactoring
 public class AdLoginInfoFilter implements Filter {
 public class AdLoginInfoFilter implements Filter {
     private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class);
     private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class);
 
 

+ 1 - 0
src/main/java/org/codelibs/fess/helper/AdRoleHelper.java

@@ -31,6 +31,7 @@ import javax.naming.directory.SearchResult;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
+// TODO refactoring
 public class AdRoleHelper {
 public class AdRoleHelper {
     private static final Logger logger = LoggerFactory.getLogger(AdRoleHelper.class);
     private static final Logger logger = LoggerFactory.getLogger(AdRoleHelper.class);
 
 

+ 71 - 0
src/main/java/org/codelibs/fess/ldap/LdapManager.java

@@ -0,0 +1,71 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.ldap;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+import org.codelibs.core.lang.StringUtil;
+import org.codelibs.fess.es.user.exentity.User;
+import org.codelibs.fess.filter.AdLoginInfoFilter;
+import org.codelibs.fess.mylasta.direction.FessConfig;
+import org.codelibs.fess.util.ComponentUtil;
+import org.dbflute.optional.OptionalEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LdapManager {
+    private static final Logger logger = LoggerFactory.getLogger(AdLoginInfoFilter.class);
+
+    public OptionalEntity<User> login(String username, String password) {
+        FessConfig fessConfig = ComponentUtil.getFessConfig();
+        String providerUrl = fessConfig.getLdapProviderUrl();
+
+        if (StringUtil.isBlank(providerUrl)) {
+            return OptionalEntity.empty();
+        }
+
+        DirContext ctx = null;
+        try {
+            Hashtable<String, String> env = new Hashtable<>();
+            env.put(Context.INITIAL_CONTEXT_FACTORY, fessConfig.getLdapInitialContextFactory());
+            env.put(Context.SECURITY_AUTHENTICATION, fessConfig.getLdapSecurityAuthentication());
+            env.put(Context.PROVIDER_URL, providerUrl);
+            env.put(Context.SECURITY_PRINCIPAL, fessConfig.getLdapSecurityPrincipal(username));
+            env.put(Context.SECURITY_CREDENTIALS, password);
+            ctx = new InitialDirContext(env);
+            if (logger.isDebugEnabled()) {
+                logger.debug("Logged in.", ctx);
+            }
+            return OptionalEntity.of(new LdapUser(username));
+        } catch (NamingException e) {
+            logger.warn("Login failed.", e);
+        } finally {
+            if (ctx != null) {
+                try {
+                    ctx.close();
+                } catch (NamingException e) {
+                    // ignore
+                }
+            }
+        }
+        return OptionalEntity.empty();
+    }
+}

+ 28 - 0
src/main/java/org/codelibs/fess/ldap/LdapUser.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.ldap;
+
+import org.codelibs.fess.es.user.exentity.User;
+
+public class LdapUser extends User {
+
+    private static final long serialVersionUID = 1L;
+
+    public LdapUser(String username) {
+        setId(username);
+    }
+
+}

+ 19 - 4
src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java

@@ -197,7 +197,7 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Failure Count */
     /** The key of the message: Failure Count */
     public static final String LABELS_FAILURE_COUNT_THRESHOLD = "{labels.failureCountThreshold}";
     public static final String LABELS_FAILURE_COUNT_THRESHOLD = "{labels.failureCountThreshold}";
 
 
-    /** The key of the message: FS Config Name */
+    /** The key of the message: File System Config Name */
     public static final String LABELS_FILE_CONFIG_NAME = "{labels.fileConfigName}";
     public static final String LABELS_FILE_CONFIG_NAME = "{labels.fileConfigName}";
 
 
     /** The key of the message: File name */
     /** The key of the message: File name */
@@ -425,6 +425,12 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Extended Query */
     /** The key of the message: Extended Query */
     public static final String LABELS_ex_q = "{labels.ex_q}";
     public static final String LABELS_ex_q = "{labels.ex_q}";
 
 
+    /** The key of the message: LDAP URL */
+    public static final String LABELS_LDAP_PROVIDER_URL = "{labels.ldapProviderUrl}";
+
+    /** The key of the message: LDAP Principal */
+    public static final String LABELS_LDAP_SECURITY_PRINCIPAL = "{labels.ldapSecurityPrincipal}";
+
     /** The key of the message: System */
     /** The key of the message: System */
     public static final String LABELS_menu_system = "{labels.menu_system}";
     public static final String LABELS_menu_system = "{labels.menu_system}";
 
 
@@ -1307,10 +1313,10 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Back */
     /** The key of the message: Back */
     public static final String LABELS_design_button_back = "{labels.design_button_back}";
     public static final String LABELS_design_button_back = "{labels.design_button_back}";
 
 
-    /** The key of the message: Data Crawling */
+    /** The key of the message: Data Store Crawling */
     public static final String LABELS_data_crawling_configuration = "{labels.data_crawling_configuration}";
     public static final String LABELS_data_crawling_configuration = "{labels.data_crawling_configuration}";
 
 
-    /** The key of the message: Data Crawling Configuration */
+    /** The key of the message: Data Store Crawling Configuration */
     public static final String LABELS_data_crawling_title_details = "{labels.data_crawling_title_details}";
     public static final String LABELS_data_crawling_title_details = "{labels.data_crawling_title_details}";
 
 
     /** The key of the message: Handler Name */
     /** The key of the message: Handler Name */
@@ -1518,7 +1524,7 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Parameters */
     /** The key of the message: Parameters */
     public static final String LABELS_file_auth_parameters = "{labels.file_auth_parameters}";
     public static final String LABELS_file_auth_parameters = "{labels.file_auth_parameters}";
 
 
-    /** The key of the message: FS Config */
+    /** The key of the message: File System Config */
     public static final String LABELS_file_auth_file_crawling_config = "{labels.file_auth_file_crawling_config}";
     public static final String LABELS_file_auth_file_crawling_config = "{labels.file_auth_file_crawling_config}";
 
 
     /** The key of the message: Samba */
     /** The key of the message: Samba */
@@ -1974,6 +1980,15 @@ public class FessLabels extends ActionMessages {
     /** The key of the message: Suggest */
     /** The key of the message: Suggest */
     public static final String LABELS_general_menu_suggest = "{labels.general_menu_suggest}";
     public static final String LABELS_general_menu_suggest = "{labels.general_menu_suggest}";
 
 
+    /** The key of the message: LDAP */
+    public static final String LABELS_general_menu_ldap = "{labels.general_menu_ldap}";
+
+    /** The key of the message: LDAP URL */
+    public static final String LABELS_ldap_provider_url = "{labels.ldap_provider_url}";
+
+    /** The key of the message: LDAP Principal */
+    public static final String LABELS_ldap_security_principal = "{labels.ldap_security_principal}";
+
     /** The key of the message: Send TestMail */
     /** The key of the message: Send TestMail */
     public static final String LABELS_send_testmail = "{labels.send_testmail}";
     public static final String LABELS_send_testmail = "{labels.send_testmail}";
 
 

+ 3 - 3
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -174,7 +174,7 @@ public interface FessConfig extends FessEnv {
     /** The key of the configuration. e.g. 1.3 */
     /** The key of the configuration. e.g. 1.3 */
     String QUERY_BOOST_CONTENT_LANG = "query.boost.content.lang";
     String QUERY_BOOST_CONTENT_LANG = "query.boost.content.lang";
 
 
-    /** The key of the configuration. e.g. false */
+    /** The key of the configuration. e.g. true */
     String ACL_AS_ROLE = "acl.as.role";
     String ACL_AS_ROLE = "acl.as.role";
 
 
     /** The key of the configuration. e.g. admin */
     /** The key of the configuration. e.g. admin */
@@ -775,7 +775,7 @@ public interface FessConfig extends FessEnv {
 
 
     /**
     /**
      * Get the value for the key 'acl.as.role'. <br>
      * Get the value for the key 'acl.as.role'. <br>
-     * The value is, e.g. false <br>
+     * The value is, e.g. true <br>
      * comment: acl
      * comment: acl
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      * @return The value of found property. (NotNull: if not found, exception but basically no way)
      */
      */
@@ -783,7 +783,7 @@ public interface FessConfig extends FessEnv {
 
 
     /**
     /**
      * Is the property for the key 'acl.as.role' true? <br>
      * Is the property for the key 'acl.as.role' true? <br>
-     * The value is, e.g. false <br>
+     * The value is, e.g. true <br>
      * comment: acl
      * comment: acl
      * @return The determination, true or false. (if not found, exception but basically no way)
      * @return The determination, true or false. (if not found, exception but basically no way)
      */
      */

+ 1 - 1
src/main/java/org/codelibs/fess/mylasta/direction/FessEnv.java

@@ -21,7 +21,7 @@ import org.lastaflute.core.direction.exception.ConfigPropertyNotFoundException;
 /**
 /**
  * @author FreeGen
  * @author FreeGen
  */
  */
-public interface FessEnv {
+public interface FessEnv extends FessProp {
 
 
     /** The key of the configuration. e.g. hot */
     /** The key of the configuration. e.g. hot */
     String lasta_di_SMART_DEPLOY_MODE = "lasta_di.smart.deploy.mode";
     String lasta_di_SMART_DEPLOY_MODE = "lasta_di.smart.deploy.mode";

+ 46 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessProp.java

@@ -0,0 +1,46 @@
+/*
+ * Copyright 2012-2015 CodeLibs Project and the Others.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.codelibs.fess.mylasta.direction;
+
+import org.codelibs.core.lang.StringUtil;
+import org.codelibs.fess.Constants;
+import org.codelibs.fess.util.ComponentUtil;
+
+public interface FessProp {
+    public default String getProperty(String key) {
+        return ComponentUtil.getCrawlerProperties().getProperty(key);
+    }
+
+    public default String getProperty(String key, String defaultValue) {
+        return ComponentUtil.getCrawlerProperties().getProperty(key, defaultValue);
+    }
+
+    public default String getLdapInitialContextFactory() {
+        return getProperty(Constants.LDAP_INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+    }
+
+    public default String getLdapSecurityAuthentication() {
+        return getProperty(Constants.LDAP_SECURITY_AUTHENTICATION, "simple");
+    }
+
+    public default String getLdapProviderUrl() {
+        return getProperty(Constants.LDAP_PROVIDER_URL);
+    }
+
+    public default String getLdapSecurityPrincipal(String username) {
+        return String.format(getProperty(Constants.LDAP_SECURITY_PRINCIPAL, StringUtil.EMPTY), username);
+    }
+}

+ 7 - 0
src/main/java/org/codelibs/fess/util/ComponentUtil.java

@@ -47,12 +47,15 @@ import org.codelibs.fess.helper.UserInfoHelper;
 import org.codelibs.fess.helper.ViewHelper;
 import org.codelibs.fess.helper.ViewHelper;
 import org.codelibs.fess.indexer.IndexUpdater;
 import org.codelibs.fess.indexer.IndexUpdater;
 import org.codelibs.fess.job.JobExecutor;
 import org.codelibs.fess.job.JobExecutor;
+import org.codelibs.fess.ldap.LdapManager;
 import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.codelibs.fess.mylasta.direction.FessConfig;
 import org.lastaflute.core.message.MessageManager;
 import org.lastaflute.core.message.MessageManager;
 import org.lastaflute.di.core.SingletonLaContainer;
 import org.lastaflute.di.core.SingletonLaContainer;
 import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
 import org.lastaflute.di.core.factory.SingletonLaContainerFactory;
 
 
 public final class ComponentUtil {
 public final class ComponentUtil {
+    private static final String LDAP_MANAGER = "ldapManager";
+
     private static final String ROLE_QUERY_HELPER = "roleQueryHelper";
     private static final String ROLE_QUERY_HELPER = "roleQueryHelper";
 
 
     private static final String SUGGEST_HELPER = "suggestHelper";
     private static final String SUGGEST_HELPER = "suggestHelper";
@@ -278,6 +281,10 @@ public final class ComponentUtil {
         return SingletonLaContainer.getComponent(ROLE_QUERY_HELPER);
         return SingletonLaContainer.getComponent(ROLE_QUERY_HELPER);
     }
     }
 
 
+    public static LdapManager getLdapManager() {
+        return SingletonLaContainer.getComponent(LDAP_MANAGER);
+    }
+
     public static boolean hasQueryHelper() {
     public static boolean hasQueryHelper() {
         return SingletonLaContainerFactory.getContainer().hasComponentDef(QUERY_HELPER);
         return SingletonLaContainerFactory.getContainer().hasComponentDef(QUERY_HELPER);
     }
     }

+ 1 - 1
src/main/resources/app.xml

@@ -6,7 +6,7 @@
 	<include path="lastaflute.xml"/>
 	<include path="lastaflute.xml"/>
 
 
 	<include path="fess.xml"/>
 	<include path="fess.xml"/>
-	<include path="fess_ad.xml"/>
+	<include path="fess_ldap.xml"/>
 	<include path="fess_api.xml"/>
 	<include path="fess_api.xml"/>
 	<include path="fess_dict.xml"/>
 	<include path="fess_dict.xml"/>
 	<include path="fess_job.xml"/>
 	<include path="fess_job.xml"/>

+ 1 - 1
src/main/resources/fess_config.properties

@@ -96,7 +96,7 @@ query.boost.content=1.0
 query.boost.content.lang=1.3
 query.boost.content.lang=1.3
 
 
 # acl
 # acl
-acl.as.role=false
+acl.as.role=true
 
 
 # ========================================================================================
 # ========================================================================================
 #                                                                                     Web
 #                                                                                     Web

+ 9 - 4
src/main/resources/fess_label.properties

@@ -55,7 +55,7 @@ labels.errorLog=Error Log
 labels.errorName=Error Name
 labels.errorName=Error Name
 labels.expiredTime=Expired
 labels.expiredTime=Expired
 labels.failureCountThreshold=Failure Count
 labels.failureCountThreshold=Failure Count
-labels.fileConfigName=FS Config Name
+labels.fileConfigName=File System Config Name
 labels.fileName=File name
 labels.fileName=File name
 labels.handlerName=Handler Name
 labels.handlerName=Handler Name
 labels.handlerParameter=Parameters
 labels.handlerParameter=Parameters
@@ -133,6 +133,8 @@ labels.term=Term
 labels.searchParams=Search Parameters
 labels.searchParams=Search Parameters
 labels.fields=Fields
 labels.fields=Fields
 labels.ex_q=Extended Query
 labels.ex_q=Extended Query
+labels.ldapProviderUrl=LDAP URL
+labels.ldapSecurityPrincipal=LDAP Principal
 
 
 labels.menu_system=System
 labels.menu_system=System
 labels.menu_wizard=Wizard
 labels.menu_wizard=Wizard
@@ -431,8 +433,8 @@ labels.design_file_errorBadRequest=Error Page (BadRequest)
 labels.design_title_edit_content=Edit JSP File
 labels.design_title_edit_content=Edit JSP File
 labels.design_button_update=Update
 labels.design_button_update=Update
 labels.design_button_back=Back
 labels.design_button_back=Back
-labels.data_crawling_configuration=Data Crawling
-labels.data_crawling_title_details=Data Crawling Configuration
+labels.data_crawling_configuration=Data\u3000Store Crawling
+labels.data_crawling_title_details=Data\u3000Store Crawling Configuration
 labels.handler_name=Handler Name
 labels.handler_name=Handler Name
 labels.handler_parameter=Parameter
 labels.handler_parameter=Parameter
 labels.handler_script=Script
 labels.handler_script=Script
@@ -502,7 +504,7 @@ labels.file_auth_scheme=Scheme
 labels.file_auth_username=Username
 labels.file_auth_username=Username
 labels.file_auth_password=Password
 labels.file_auth_password=Password
 labels.file_auth_parameters=Parameters
 labels.file_auth_parameters=Parameters
-labels.file_auth_file_crawling_config=FS Config
+labels.file_auth_file_crawling_config=File System Config
 labels.file_auth_scheme_samba=Samba
 labels.file_auth_scheme_samba=Samba
 labels.pagination_page_guide_msg={0}/{1} ({2} items)
 labels.pagination_page_guide_msg={0}/{1} ({2} items)
 labels.list_could_not_find_crud_table=No data.
 labels.list_could_not_find_crud_table=No data.
@@ -654,4 +656,7 @@ labels.general_menu_system=System
 labels.general_menu_crawler=Crawler
 labels.general_menu_crawler=Crawler
 labels.general_menu_logging=Logging
 labels.general_menu_logging=Logging
 labels.general_menu_suggest=Suggest
 labels.general_menu_suggest=Suggest
+labels.general_menu_ldap=LDAP
+labels.ldap_provider_url=LDAP URL
+labels.ldap_security_principal=LDAP Principal
 labels.send_testmail=Send TestMail
 labels.send_testmail=Send TestMail

+ 9 - 5
src/main/resources/fess_label_en.properties

@@ -55,7 +55,7 @@ labels.errorLog=Error Log
 labels.errorName=Error Name
 labels.errorName=Error Name
 labels.expiredTime=Expired
 labels.expiredTime=Expired
 labels.failureCountThreshold=Failure Count
 labels.failureCountThreshold=Failure Count
-labels.fileConfigName=FS Config Name
+labels.fileConfigName=File System Config Name
 labels.fileName=File name
 labels.fileName=File name
 labels.handlerName=Handler Name
 labels.handlerName=Handler Name
 labels.handlerParameter=Parameters
 labels.handlerParameter=Parameters
@@ -133,6 +133,8 @@ labels.term=Term
 labels.searchParams=Search Parameters
 labels.searchParams=Search Parameters
 labels.fields=Fields
 labels.fields=Fields
 labels.ex_q=Extended Query
 labels.ex_q=Extended Query
+labels.ldapProviderUrl=LDAP URL
+labels.ldapSecurityPrincipal=LDAP Principal
 
 
 labels.menu_system=System
 labels.menu_system=System
 labels.menu_wizard=Wizard
 labels.menu_wizard=Wizard
@@ -431,8 +433,8 @@ labels.design_file_errorBadRequest=Error Page (BadRequest)
 labels.design_title_edit_content=Edit JSP File
 labels.design_title_edit_content=Edit JSP File
 labels.design_button_update=Update
 labels.design_button_update=Update
 labels.design_button_back=Back
 labels.design_button_back=Back
-labels.data_crawling_configuration=Data Crawling
-labels.data_crawling_title_details=Data Crawling Configuration
+labels.data_crawling_configuration=Data\u3000Store Crawling
+labels.data_crawling_title_details=Data\u3000Store Crawling Configuration
 labels.handler_name=Handler Name
 labels.handler_name=Handler Name
 labels.handler_parameter=Parameter
 labels.handler_parameter=Parameter
 labels.handler_script=Script
 labels.handler_script=Script
@@ -502,7 +504,7 @@ labels.file_auth_scheme=Scheme
 labels.file_auth_username=Username
 labels.file_auth_username=Username
 labels.file_auth_password=Password
 labels.file_auth_password=Password
 labels.file_auth_parameters=Parameters
 labels.file_auth_parameters=Parameters
-labels.file_auth_file_crawling_config=FS Config
+labels.file_auth_file_crawling_config=File System Config
 labels.file_auth_scheme_samba=Samba
 labels.file_auth_scheme_samba=Samba
 labels.pagination_page_guide_msg={0}/{1} ({2} items)
 labels.pagination_page_guide_msg={0}/{1} ({2} items)
 labels.list_could_not_find_crud_table=No data.
 labels.list_could_not_find_crud_table=No data.
@@ -654,5 +656,7 @@ labels.general_menu_system=System
 labels.general_menu_crawler=Crawler
 labels.general_menu_crawler=Crawler
 labels.general_menu_logging=Logging
 labels.general_menu_logging=Logging
 labels.general_menu_suggest=Suggest
 labels.general_menu_suggest=Suggest
+labels.general_menu_ldap=LDAP
+labels.ldap_provider_url=LDAP URL
+labels.ldap_security_principal=LDAP Principal
 labels.send_testmail=Send TestMail
 labels.send_testmail=Send TestMail
-

+ 10 - 5
src/main/resources/fess_label_ja.properties

@@ -273,7 +273,7 @@ labels.role_type = \u30ed\u30fc\u30eb
 labels.label_type = \u30e9\u30d9\u30eb
 labels.label_type = \u30e9\u30d9\u30eb
 labels.file_crawling_button_create = \u4f5c\u6210
 labels.file_crawling_button_create = \u4f5c\u6210
 labels.file_crawling_button_create_job = \u65b0\u3057\u3044\u30b8\u30e7\u30d6\u306e\u4f5c\u6210
 labels.file_crawling_button_create_job = \u65b0\u3057\u3044\u30b8\u30e7\u30d6\u306e\u4f5c\u6210
-labels.web_crawling_configuration = \u30a6\u30a7\u30d6\u30af\u30ed\u30fc\u30ea\u30f3\u30b0
+labels.web_crawling_configuration = \u30a6\u30a7\u30d6\u306e\u30af\u30ed\u30fc\u30eb
 labels.web_crawling_title_details = \u30a6\u30a7\u30d6\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a
 labels.web_crawling_title_details = \u30a6\u30a7\u30d6\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a
 labels.included_urls = \u30af\u30ed\u30fc\u30eb\u5bfe\u8c61\u3068\u3059\u308bURL
 labels.included_urls = \u30af\u30ed\u30fc\u30eb\u5bfe\u8c61\u3068\u3059\u308bURL
 labels.excluded_urls = \u30af\u30ed\u30fc\u30eb\u5bfe\u8c61\u304b\u3089\u9664\u5916\u3059\u308bURL
 labels.excluded_urls = \u30af\u30ed\u30fc\u30eb\u5bfe\u8c61\u304b\u3089\u9664\u5916\u3059\u308bURL
@@ -428,8 +428,8 @@ labels.design_file_errorBadRequest = \u30a8\u30e9\u30fc\u30da\u30fc\u30b8 (BadRe
 labels.design_title_edit_content = \u30da\u30fc\u30b8\u306e\u7de8\u96c6\u30d5\u30a1\u30a4\u30eb\u306e\u8868\u793a
 labels.design_title_edit_content = \u30da\u30fc\u30b8\u306e\u7de8\u96c6\u30d5\u30a1\u30a4\u30eb\u306e\u8868\u793a
 labels.design_button_update = \u66f4\u65b0
 labels.design_button_update = \u66f4\u65b0
 labels.design_button_back = \u623b\u308b
 labels.design_button_back = \u623b\u308b
-labels.data_crawling_configuration = \u30c7\u30fc\u30bf\u306e\u30af\u30ed\u30fc\u30eb
-labels.data_crawling_title_details = \u30c7\u30fc\u30bf\u306e\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a
+labels.data_crawling_configuration = \u30c7\u30fc\u30bf\u30b9\u30c8\u30a2\u306e\u30af\u30ed\u30fc\u30eb
+labels.data_crawling_title_details = \u30c7\u30fc\u30bf\u30b9\u30c8\u30a2\u306e\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a
 labels.handler_name = \u30cf\u30f3\u30c9\u30e9\u540d
 labels.handler_name = \u30cf\u30f3\u30c9\u30e9\u540d
 labels.handler_parameter = \u30d1\u30e9\u30e1\u30fc\u30bf
 labels.handler_parameter = \u30d1\u30e9\u30e1\u30fc\u30bf
 labels.handler_script = \u30b9\u30af\u30ea\u30d7\u30c8
 labels.handler_script = \u30b9\u30af\u30ea\u30d7\u30c8
@@ -487,7 +487,7 @@ labels.file_auth_configuration = \u30d5\u30a1\u30a4\u30eb\u8a8d\u8a3c
 labels.file_auth_list_hostname = \u30db\u30b9\u30c8\u540d
 labels.file_auth_list_hostname = \u30db\u30b9\u30c8\u540d
 labels.file_auth_list_file_crawling_config = \u8a2d\u5b9a\u540d
 labels.file_auth_list_file_crawling_config = \u8a2d\u5b9a\u540d
 labels.file_auth_any = \u4efb\u610f
 labels.file_auth_any = \u4efb\u610f
-labels.file_auth_create_file_config = \u65b0\u3057\u3044FS\u8a2d\u5b9a\u306e\u4f5c\u6210
+labels.file_auth_create_file_config = \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a\u306e\u4f5c\u6210
 labels.file_auth_title_details = \u30d5\u30a1\u30a4\u30eb\u8a8d\u8a3c
 labels.file_auth_title_details = \u30d5\u30a1\u30a4\u30eb\u8a8d\u8a3c
 labels.file_auth_hostname = \u30db\u30b9\u30c8\u540d
 labels.file_auth_hostname = \u30db\u30b9\u30c8\u540d
 labels.file_auth_port = \u30dd\u30fc\u30c8
 labels.file_auth_port = \u30dd\u30fc\u30c8
@@ -495,7 +495,7 @@ labels.file_auth_scheme = \u30b9\u30ad\u30fc\u30e0
 labels.file_auth_username = \u30e6\u30fc\u30b6\u30fc\u540d
 labels.file_auth_username = \u30e6\u30fc\u30b6\u30fc\u540d
 labels.file_auth_password = \u30d1\u30b9\u30ef\u30fc\u30c9
 labels.file_auth_password = \u30d1\u30b9\u30ef\u30fc\u30c9
 labels.file_auth_parameters = \u30d1\u30e9\u30e1\u30fc\u30bf
 labels.file_auth_parameters = \u30d1\u30e9\u30e1\u30fc\u30bf
-labels.file_auth_file_crawling_config = FS\u8a2d\u5b9a
+labels.file_auth_file_crawling_config = \u30d5\u30a1\u30a4\u30eb\u30af\u30ed\u30fc\u30eb\u8a2d\u5b9a
 labels.file_auth_scheme_samba = Samba
 labels.file_auth_scheme_samba = Samba
 labels.pagination_page_guide_msg = {0}/{1} ({2} \u4ef6)
 labels.pagination_page_guide_msg = {0}/{1} ({2} \u4ef6)
 labels.list_could_not_find_crud_table = \u767b\u9332\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002
 labels.list_could_not_find_crud_table = \u767b\u9332\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002
@@ -645,3 +645,8 @@ labels.general_menu_crawler = \u30af\u30ed\u30fc\u30e9
 labels.general_menu_logging = \u30ed\u30ae\u30f3\u30b0
 labels.general_menu_logging = \u30ed\u30ae\u30f3\u30b0
 labels.general_menu_suggest = \u30b5\u30b8\u30a7\u30b9\u30c8
 labels.general_menu_suggest = \u30b5\u30b8\u30a7\u30b9\u30c8
 labels.send_testmail=\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\u306e\u9001\u4fe1
 labels.send_testmail=\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\u306e\u9001\u4fe1
+labels.ldapProviderUrl=LDAP URL
+labels.ldapSecurityPrincipal=LDAP \u30d7\u30ea\u30f3\u30b7\u30d1\u30eb
+labels.general_menu_ldap=LDAP
+labels.ldap_provider_url=LDAP URL
+labels.ldap_security_principal=LDAP \u30d7\u30ea\u30f3\u30b7\u30d1\u30eb

+ 7 - 0
src/main/resources/fess_ldap.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//DBFLUTE//DTD LastaDi 1.0//EN"
+	"http://dbflute.org/meta/lastadi10.dtd">
+<components>
+	<component name="ldapManager" class="org.codelibs.fess.ldap.LdapManager">
+	</component>
+</components>

+ 22 - 0
src/main/webapp/WEB-INF/view/admin/general/admin_general.jsp

@@ -288,6 +288,28 @@
 											<la:message key="labels.day" />
 											<la:message key="labels.day" />
 										</div>
 										</div>
 									</div>
 									</div>
+									<%-- LDAP --%>
+									<h4><la:message key="labels.general_menu_ldap" /></h4>
+									<div class="form-group">
+										<label for="ldapProviderUrl"
+											class="col-sm-3 control-label"><la:message
+												key="labels.ldapProviderUrl" /></label>
+										<div class="form-inline col-sm-9">
+											<la:errors property="ldapProviderUrl" />
+											<la:text property="ldapProviderUrl"
+												styleClass="form-control" />
+										</div>
+									</div>
+									<div class="form-group">
+										<label for="ldapSecurityPrincipal"
+											class="col-sm-3 control-label"><la:message
+												key="labels.ldapSecurityPrincipal" /></label>
+										<div class="form-inline col-sm-9">
+											<la:errors property="ldapSecurityPrincipal" />
+											<la:text property="ldapSecurityPrincipal"
+												styleClass="form-control" />
+										</div>
+									</div>
 								</div>
 								</div>
 								<!-- /.box-body -->
 								<!-- /.box-body -->
 								<div class="box-footer">
 								<div class="box-footer">