Merge branch '10.3.x'

This commit is contained in:
Shinsuke Sugaya 2016-10-15 07:23:09 +09:00
commit b00bf82ec9
14 changed files with 68 additions and 19 deletions

View file

@ -375,6 +375,8 @@ public class Constants extends CoreLibConstants {
public static final String LDAP_ACCOUNT_FILTER = "ldap.account.filter";
public static final String LDAP_MEMBEROF_ATTRIBUTE = "ldap.memberof.attribute";
public static final String NOTIFICATION_LOGIN = "notification.login";
public static final String NOTIFICATION_SEARCH_TOP = "notification.search.top";

View file

@ -152,10 +152,12 @@ public class AdminGeneralAction extends FessAdminAction {
}
fessConfig.setLdapBaseDn(form.ldapBaseDn);
fessConfig.setLdapAccountFilter(form.ldapAccountFilter);
fessConfig.setLdapMemberofAttribute(form.ldapMemberofAttribute);
fessConfig.setNotificationLogin(form.notificationLogin);
fessConfig.setNotificationSearchTop(form.notificationSearchTop);
fessConfig.storeSystemProperties();
ComponentUtil.getLdapManager().updateConfig();
saveInfo(messages -> messages.addSuccessUpdateCrawlerParams(GLOBAL));
return redirect(getClass());
}
@ -192,6 +194,7 @@ public class AdminGeneralAction extends FessAdminAction {
form.ldapAdminSecurityCredentials = DUMMY_PASSWORD;//fessConfig.getLdapAdminSecurityCredentials();
form.ldapBaseDn = fessConfig.getLdapBaseDn();
form.ldapAccountFilter = fessConfig.getLdapAccountFilter();
form.ldapMemberofAttribute = fessConfig.getLdapMemberofAttribute();
form.notificationLogin = fessConfig.getNotificationLogin();
form.notificationSearchTop = fessConfig.getNotificationSearchTop();
}

View file

@ -139,6 +139,9 @@ public class EditForm {
@Size(max = 1000)
public String ldapAccountFilter;
@Size(max = 100)
public String ldapMemberofAttribute;
@Size(max = 3000)
public String notificationLogin;

View file

@ -301,6 +301,7 @@ public class SystemHelper {
ComponentUtil.getSuggestHelper().init();
ComponentUtil.getPopularWordHelper().init();
ComponentUtil.getJobManager().reboot();
ComponentUtil.getLdapManager().updateConfig();
}
public String generateAccessToken() {

View file

@ -61,6 +61,8 @@ public class LdapManager {
protected ThreadLocal<DirContextHolder> contextLocal = new ThreadLocal<>();
protected volatile boolean isBind = false;
protected Hashtable<String, String> createEnvironment(final String initialContextFactory, final String securityAuthentication,
final String providerUrl, final String principal, final String credntials) {
final Hashtable<String, String> env = new Hashtable<>();
@ -99,6 +101,26 @@ public class LdapManager {
fessConfig.getLdapAdminSecurityCredentials());
}
public void updateConfig() {
isBind = false;
}
protected boolean validate() {
if (!isBind) {
final Hashtable<String, String> env = createAdminEnv();
try (DirContextHolder holder = getDirContext(() -> env)) {
final DirContext context = holder.get();
if (logger.isDebugEnabled()) {
logger.debug("Logged in as Bind DN.", context);
}
isBind = true;
} catch (final Exception e) {
logger.warn("LDAP configuration is wrong.", e);
}
}
return isBind;
}
public OptionalEntity<FessUser> login(final String username, final String password) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
@ -106,6 +128,10 @@ public class LdapManager {
return OptionalEntity.empty();
}
if (!validate()) {
return OptionalEntity.empty();
}
final Hashtable<String, String> env = createSearchEnv(username, password);
try (DirContextHolder holder = getDirContext(() -> env)) {
final DirContext context = holder.get();

View file

@ -458,6 +458,9 @@ public class FessLabels extends UserMessages {
/** The key of the message: Account Filter */
public static final String LABELS_LDAP_ACCOUNT_FILTER = "{labels.ldapAccountFilter}";
/** The key of the message: memberOf Attribute */
public static final String LABELS_LDAP_MEMBEROF_ATTRIBUTE = "{labels.ldapMemberofAttribute}";
/** The key of the message: Current Password */
public static final String LABELS_OLD_PASSWORD = "{labels.oldPassword}";
@ -2349,6 +2352,9 @@ public class FessLabels extends UserMessages {
/** The key of the message: Account Filter */
public static final String LABELS_ldap_account_filter = "{labels.ldap_account_filter}";
/** The key of the message: memberOf Attribute */
public static final String LABELS_ldap_memberof_attribute = "{labels.ldap_memberof_attribute}";
/** The key of the message: Login page */
public static final String LABELS_notification_login = "{labels.notification_login}";

View file

@ -868,9 +868,6 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
/** The key of the configuration. e.g. -1 */
String LDAP_MAX_USERNAME_LENGTH = "ldap.max.username.length";
/** The key of the configuration. e.g. memberOf */
String LDAP_MEMBEROF_ATTRIBUTE = "ldap.memberof.attribute";
/** The key of the configuration. e.g. true */
String LDAP_ROLE_SEARCH_USER_ENABLED = "ldap.role.search.user.enabled";
@ -3793,14 +3790,6 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
*/
Integer getLdapMaxUsernameLengthAsInteger();
/**
* Get the value for the key 'ldap.memberof.attribute'. <br>
* The value is, e.g. memberOf <br>
* comment: Active Directory
* @return The value of found property. (NotNull: if not found, exception but basically no way)
*/
String getLdapMemberofAttribute();
/**
* Get the value for the key 'ldap.role.search.user.enabled'. <br>
* The value is, e.g. true <br>
@ -5739,10 +5728,6 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
return getAsInteger(FessConfig.LDAP_MAX_USERNAME_LENGTH);
}
public String getLdapMemberofAttribute() {
return get(FessConfig.LDAP_MEMBEROF_ATTRIBUTE);
}
public String getLdapRoleSearchUserEnabled() {
return get(FessConfig.LDAP_ROLE_SEARCH_USER_ENABLED);
}

View file

@ -473,6 +473,14 @@ public interface FessProp {
setSystemProperty(Constants.LDAP_SECURITY_PRINCIPAL, value);
}
public default String getLdapMemberofAttribute() {
return getSystemProperty(Constants.LDAP_MEMBEROF_ATTRIBUTE, "memberOf");
}
public default void setLdapMemberofAttribute(final String value) {
setSystemProperty(Constants.LDAP_MEMBEROF_ATTRIBUTE, value);
}
Integer getLdapMaxUsernameLengthAsInteger();
public default String getLdapSecurityPrincipal(final String username) {

View file

@ -446,10 +446,6 @@ ldap.admin.group.object.classes=groupOfNames
ldap.admin.sync.password=true
ldap.max.username.length=-1
# Active Directory
ldap.memberof.attribute=memberOf
# OpenDJ
#ldap.memberof.attribute=isMemberOf
ldap.role.search.user.enabled=true
ldap.role.search.group.enabled=true

View file

@ -142,6 +142,7 @@ labels.ldapAdminSecurityPrincipal=Bind DN
labels.ldapAdminSecurityCredentials=Password
labels.ldapBaseDn=Base DN
labels.ldapAccountFilter=Account Filter
labels.ldapMemberofAttribute=memberOf Attribute
labels.oldPassword=Current Password
labels.newPassword=New Password
labels.confirmNewPassword=New Password(Confirm)
@ -773,6 +774,7 @@ labels.ldap_admin_security_principal=Bind DN
labels.ldap_admin_security_credentials=Password
labels.ldap_base_dn=Base DN
labels.ldap_account_filter=Account Filter
labels.ldap_memberof_attribute=memberOf Attribute
labels.notification_login=Login page
labels.notification_search_top=Search top page
labels.send_testmail=Send TestMail

View file

@ -142,6 +142,7 @@ labels.ldapAdminSecurityPrincipal=Bind DN
labels.ldapAdminSecurityCredentials=Password
labels.ldapBaseDn=Base DN
labels.ldapAccountFilter=Account Filter
labels.ldapMemberofAttribute=memberOf Attribute
labels.oldPassword=Current Password
labels.newPassword=New Password
labels.confirmNewPassword=New Password(Confirm)
@ -773,6 +774,7 @@ labels.ldap_admin_security_principal=Bind DN
labels.ldap_admin_security_credentials=Password
labels.ldap_base_dn=Base DN
labels.ldap_account_filter=Account Filter
labels.ldap_memberof_attribute=memberOf Attribute
labels.notification_login=Login page
labels.notification_search_top=Search top page
labels.send_testmail=Send TestMail

View file

@ -774,7 +774,9 @@ labels.ldap_admin_security_principal=Bind DN
labels.ldap_admin_security_credentials=\u30d1\u30b9\u30ef\u30fc\u30c9
labels.ldap_base_dn=Base DN
labels.ldapAccountFilter=\u30a2\u30ab\u30a6\u30f3\u30c8\u30d5\u30a3\u30eb\u30bf
labels.ldapMemberofAttribute=memberOf\u5c5e\u6027
labels.ldap_account_filter=\u30a2\u30ab\u30a6\u30f3\u30c8\u30d5\u30a3\u30eb\u30bf
labels.ldap_memberof_attribute=memberOf\u5c5e\u6027
labels.notification_login=\u30ed\u30b0\u30a4\u30f3\u30da\u30fc\u30b8
labels.notification_search_top=\u691c\u7d22\u30c8\u30c3\u30d7\u30da\u30fc\u30b8
labels.send_testmail=\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb\u306e\u9001\u4fe1

View file

@ -382,6 +382,16 @@
styleClass="form-control" />
</div>
</div>
<div class="form-group">
<label for="ldapMemberofAttribute"
class="col-sm-3 control-label"><la:message
key="labels.ldap_memberof_attribute" /></label>
<div class="col-sm-9">
<la:errors property="ldapMemberofAttribute" />
<la:text property="ldapMemberofAttribute"
styleClass="form-control" />
</div>
</div>
<%-- Nortification --%>
<h4><la:message key="labels.general_menu_notification" /></h4>
<div class="form-group">

View file

@ -16,6 +16,7 @@ ${packaging.scripts.header}
# Sets the default values for fess variables used in this script
FESS_USER="${packaging.fess.user}"
FESS_GROUP="${packaging.fess.group}"
FESS_USER_HOME="${packaging.fess.var.dir}"
# Source the default env file
FESS_ENV_FILE="${packaging.env.file}"
@ -44,6 +45,7 @@ case "$1" in
--ingroup "$FESS_GROUP" \
--disabled-password \
--shell /bin/false \
-d "$FESS_USER_HOME" \
"$FESS_USER"
echo " OK"
fi
@ -69,6 +71,7 @@ case "$1" in
--gid "$FESS_GROUP" \
--shell /sbin/nologin \
--comment "fess user" \
-d "$FESS_USER_HOME" \
"$FESS_USER"
echo " OK"
fi