add samba id filter
This commit is contained in:
parent
9bcc5667ec
commit
54cd81601c
7 changed files with 65 additions and 5 deletions
|
@ -90,7 +90,10 @@ public class FessCrawlerThread extends CrawlerThread {
|
|||
if (aces != null) {
|
||||
for (final ACE item : aces) {
|
||||
final SID sid = item.getSID();
|
||||
roleTypeList.add(sambaHelper.getAccountId(sid));
|
||||
final String accountId = sambaHelper.getAccountId(sid);
|
||||
if (accountId != null) {
|
||||
roleTypeList.add(accountId);
|
||||
}
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("smbUrl:" + responseData.getUrl() + " roleType:" + roleTypeList.toString());
|
||||
|
|
|
@ -276,7 +276,10 @@ public abstract class AbstractFessFileTransformer extends AbstractTransformer im
|
|||
if (aces != null) {
|
||||
for (final ACE item : aces) {
|
||||
final SID sid = item.getSID();
|
||||
roleTypeList.add(sambaHelper.getAccountId(sid));
|
||||
final String accountId = sambaHelper.getAccountId(sid);
|
||||
if (accountId != null) {
|
||||
roleTypeList.add(accountId);
|
||||
}
|
||||
}
|
||||
if (getLogger().isDebugEnabled()) {
|
||||
getLogger().debug("smbUrl:" + responseData.getUrl() + " roleType:" + roleTypeList.toString());
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
*/
|
||||
package org.codelibs.fess.helper;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
import jcifs.smb.SID;
|
||||
|
||||
public class SambaHelper {
|
||||
|
@ -37,15 +42,25 @@ public class SambaHelper {
|
|||
|
||||
public static final int SID_TYPE_WKN_GRP = 5;
|
||||
|
||||
private FessConfig fessConfig;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
fessConfig = ComponentUtil.getFessConfig();
|
||||
}
|
||||
|
||||
public String getAccountId(final SID sid) {
|
||||
return convert(sid.getType(), sid.getAccountName());
|
||||
if (fessConfig.isAvailableSmbSidType(sid.getType())) {
|
||||
return convert(sid.getType(), sid.getAccountName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRoleByUser(final String name) {
|
||||
return convert(SID_TYPE_USER, name);
|
||||
}
|
||||
|
||||
public String getRoleByGroup(final String name) {
|
||||
public String getRoleByDomainGroup(final String name) {
|
||||
return convert(SID_TYPE_DOM_GRP, name);
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ public class LdapManager {
|
|||
strTmp = strTmp.substring(strStart, strEnd);
|
||||
|
||||
if (fessConfig.isSmbRoleAsGroup()) {
|
||||
roleList.add(sambaHelper.getRoleByGroup(strTmp));
|
||||
roleList.add(sambaHelper.getRoleByDomainGroup(strTmp));
|
||||
} else {
|
||||
roleList.add(strTmp);
|
||||
}
|
||||
|
|
|
@ -276,6 +276,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
/** The key of the configuration. e.g. true */
|
||||
String SMB_ROLE_AS_GROUP = "smb.role.as.group";
|
||||
|
||||
/** The key of the configuration. e.g. 1,2 */
|
||||
String SMB_AVAILABLE_SID_TYPES = "smb.available.sid.types";
|
||||
|
||||
/** The key of the configuration. e.g. .fess_config,.fess_user */
|
||||
String INDEX_BACKUP_TARGETS = "index.backup.targets";
|
||||
|
||||
|
@ -1308,6 +1311,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
*/
|
||||
boolean isSmbRoleAsGroup();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'smb.available.sid.types'. <br>
|
||||
* The value is, e.g. 1,2 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
*/
|
||||
String getSmbAvailableSidTypes();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'smb.available.sid.types' as {@link Integer}. <br>
|
||||
* The value is, e.g. 1,2 <br>
|
||||
* @return The value of found property. (NotNull: if not found, exception but basically no way)
|
||||
* @throws NumberFormatException When the property is not integer.
|
||||
*/
|
||||
Integer getSmbAvailableSidTypesAsInteger();
|
||||
|
||||
/**
|
||||
* Get the value for the key 'index.backup.targets'. <br>
|
||||
* The value is, e.g. .fess_config,.fess_user <br>
|
||||
|
@ -2443,6 +2461,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
|
|||
return is(FessConfig.SMB_ROLE_AS_GROUP);
|
||||
}
|
||||
|
||||
public String getSmbAvailableSidTypes() {
|
||||
return get(FessConfig.SMB_AVAILABLE_SID_TYPES);
|
||||
}
|
||||
|
||||
public Integer getSmbAvailableSidTypesAsInteger() {
|
||||
return getAsInteger(FessConfig.SMB_AVAILABLE_SID_TYPES);
|
||||
}
|
||||
|
||||
public String getIndexBackupTargets() {
|
||||
return get(FessConfig.INDEX_BACKUP_TARGETS);
|
||||
}
|
||||
|
|
|
@ -138,4 +138,16 @@ public interface FessProp {
|
|||
}
|
||||
return StreamUtil.of(getJobSystemJobIds().split(",")).anyMatch(s -> s.equals(id));
|
||||
}
|
||||
|
||||
String getSmbAvailableSidTypes();
|
||||
|
||||
public default boolean isAvailableSmbSidType(int sidType) {
|
||||
if (StringUtil.isBlank(getSmbAvailableSidTypes())) {
|
||||
return false;
|
||||
}
|
||||
final String value = Integer.toString(sidType);
|
||||
return StreamUtil.of(getSmbAvailableSidTypes().split(",")).anyMatch(s -> {
|
||||
return s.equals(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,6 +142,7 @@ query.boost.content.lang=1.3
|
|||
smb.role.from.file=true
|
||||
smb.role.as.user=true
|
||||
smb.role.as.group=true
|
||||
smb.available.sid.types=1,2
|
||||
|
||||
# backup
|
||||
index.backup.targets=.fess_config,.fess_user
|
||||
|
|
Loading…
Add table
Reference in a new issue