fix #1888
This commit is contained in:
parent
ce6fad38d1
commit
369bad035f
3 changed files with 46 additions and 7 deletions
|
@ -19,11 +19,15 @@ import javax.annotation.PostConstruct;
|
|||
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import jcifs.SID;
|
||||
|
||||
public class SambaHelper {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SambaHelper.class);
|
||||
|
||||
public static final int SID_TYPE_ALIAS = 4;
|
||||
|
||||
public static final int SID_TYPE_DELETED = 6;
|
||||
|
@ -50,8 +54,11 @@ public class SambaHelper {
|
|||
}
|
||||
|
||||
public String getAccountId(final SID sid) {
|
||||
if (fessConfig.isAvailableSmbSidType(sid.getType())) {
|
||||
return createSearchRole(sid.getType(), sid.getAccountName());
|
||||
final Integer sidType = fessConfig.getAvailableSmbSidType(sid.getType());
|
||||
if (sidType != null) {
|
||||
return createSearchRole(sidType, sid.getAccountName());
|
||||
} else if (logger.isDebugEnabled()) {
|
||||
logger.debug("Ignore SID: {}", sid);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ import org.lastaflute.web.validation.theme.typed.LongTypeValidator;
|
|||
|
||||
public interface FessProp {
|
||||
|
||||
String SMB_AVAILABLE_SID_TYPES = "smbAvailableSidTypes";
|
||||
|
||||
String LOGGING_SEARCH_DOCS_FIELDS = "loggingSearchDocsFields";
|
||||
|
||||
String API_SEARCH_ACCEPT_REFERERS = "apiSearchAcceptReferers";
|
||||
|
@ -775,12 +777,25 @@ public interface FessProp {
|
|||
|
||||
String getSmbAvailableSidTypes();
|
||||
|
||||
default boolean isAvailableSmbSidType(final int sidType) {
|
||||
if (StringUtil.isBlank(getSmbAvailableSidTypes())) {
|
||||
return false;
|
||||
default Integer getAvailableSmbSidType(final int sidType) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Integer, Integer> params = (Map<Integer, Integer>) propMap.get(SMB_AVAILABLE_SID_TYPES);
|
||||
if (params == null) {
|
||||
params = split(getSmbAvailableSidTypes(), ",").get(stream -> stream.map(s -> {
|
||||
final String[] v = s.split(":");
|
||||
if (v.length == 1) {
|
||||
final int x = Integer.parseInt(v[0].trim());
|
||||
return new Pair<>(x, x);
|
||||
} else if (v.length == 2) {
|
||||
final int x = Integer.parseInt(v[0].trim());
|
||||
final int y = Integer.parseInt(v[1].trim());
|
||||
return new Pair<>(x, y);
|
||||
}
|
||||
return null;
|
||||
}).filter(v -> v != null).collect(Collectors.toMap(e -> e.getFirst(), e -> e.getSecond())));
|
||||
propMap.put(SMB_AVAILABLE_SID_TYPES, params);
|
||||
}
|
||||
final String value = Integer.toString(sidType);
|
||||
return split(getSmbAvailableSidTypes(), ",").get(stream -> stream.anyMatch(s -> s.equals(value)));
|
||||
return params.get(sidType);
|
||||
}
|
||||
|
||||
String getSupportedLanguages();
|
||||
|
|
|
@ -167,6 +167,23 @@ public class FessPropTest extends UnitFessTestCase {
|
|||
assertFalse(matchesTag(tags[4], "<div x-y=\"a 0\"></div>"));
|
||||
}
|
||||
|
||||
public void test_getAvailableSmbSidType() throws Exception {
|
||||
FessProp.propMap.clear();
|
||||
FessConfig fessConfig = new FessConfig.SimpleImpl() {
|
||||
@Override
|
||||
public String getSmbAvailableSidTypes() {
|
||||
return "1,2,5:2";
|
||||
}
|
||||
};
|
||||
|
||||
assertNull(fessConfig.getAvailableSmbSidType(0));
|
||||
assertEquals(1, fessConfig.getAvailableSmbSidType(1));
|
||||
assertEquals(2, fessConfig.getAvailableSmbSidType(2));
|
||||
assertNull(fessConfig.getAvailableSmbSidType(3));
|
||||
assertNull(fessConfig.getAvailableSmbSidType(4));
|
||||
assertEquals(2, fessConfig.getAvailableSmbSidType(5));
|
||||
}
|
||||
|
||||
private boolean matchesTag(final PrunedTag tag, final String text) throws Exception {
|
||||
final DOMParser parser = new DOMParser();
|
||||
final String html = "<html><body>" + text + "</body></html>";
|
||||
|
|
Loading…
Add table
Reference in a new issue