use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class PermissionHelper method getFtpRoleTypeList.
public List<String> getFtpRoleTypeList(final ResponseData responseData) {
final List<String> roleTypeList = new ArrayList<>();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (fessConfig.isFtpRoleFromFile() && responseData.getUrl().startsWith("ftp:")) {
final String owner = (String) responseData.getMetaDataMap().get(FtpClient.FTP_FILE_USER);
if (owner != null) {
roleTypeList.add(systemHelper.getSearchRoleByUser(owner));
}
final String group = (String) responseData.getMetaDataMap().get(FtpClient.FTP_FILE_GROUP);
if (group != null) {
roleTypeList.add(systemHelper.getSearchRoleByGroup(group));
}
if (logger.isDebugEnabled()) {
logger.debug("ftpUrl:{} roleType:{}", responseData.getUrl(), roleTypeList);
}
}
return roleTypeList;
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class PermissionHelper method getFileRoleTypeList.
public List<String> getFileRoleTypeList(final ResponseData responseData) {
final List<String> roleTypeList = new ArrayList<>();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (fessConfig.isFileRoleFromFile() && responseData.getUrl().startsWith("file:")) {
final String owner = (String) responseData.getMetaDataMap().get(FileSystemClient.FS_FILE_USER);
if (owner != null) {
roleTypeList.add(systemHelper.getSearchRoleByUser(owner));
}
final String[] groups = (String[]) responseData.getMetaDataMap().get(FileSystemClient.FS_FILE_GROUPS);
roleTypeList.addAll(stream(groups).get(stream -> stream.map(systemHelper::getSearchRoleByGroup).collect(Collectors.toList())));
if (logger.isDebugEnabled()) {
logger.debug("fileUrl:{} roleType:{}", responseData.getUrl(), roleTypeList);
}
}
return roleTypeList;
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class CurlHelper method init.
@PostConstruct
public void init() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final String authorities = fessConfig.getElasticsearchHttpSslCertificateAuthorities();
if (StringUtil.isNotBlank(authorities)) {
if (logger.isDebugEnabled()) {
logger.debug("Loading certificate_authorities: {}", authorities);
}
try (final InputStream in = new FileInputStream(authorities)) {
final Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(in);
final KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("server", certificate);
final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init(keyStore);
final SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustManagerFactory.getTrustManagers(), null);
sslSocketFactory = sslContext.getSocketFactory();
} catch (final Exception e) {
logger.warn("Failed to load {}", authorities, e);
}
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class KeyMatchHelper method getBoostedDocumentList.
public List<Map<String, Object>> getBoostedDocumentList(final KeyMatch keyMatch) {
final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
String virtualHost = keyMatch.getVirtualHost();
if (StringUtil.isBlank(virtualHost)) {
virtualHost = StringUtil.EMPTY;
}
final List<Tuple3<String, QueryBuilder, ScoreFunctionBuilder<?>>> boostList = getQueryMap(virtualHost).get(toLowerCase(keyMatch.getTerm()));
if (boostList == null) {
return Collections.emptyList();
}
for (final Tuple3<String, QueryBuilder, ScoreFunctionBuilder<?>> pair : boostList) {
if (!keyMatch.getId().equals(pair.getValue1())) {
continue;
}
final FessConfig fessConfig = ComponentUtil.getFessConfig();
return searchEngineClient.getDocumentList(fessConfig.getIndexDocumentSearchIndex(), searchRequestBuilder -> {
searchRequestBuilder.setPreference(Constants.SEARCH_PREFERENCE_LOCAL).setQuery(pair.getValue2()).setSize(keyMatch.getMaxSize());
return true;
});
}
return Collections.emptyList();
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class User method getPermissions.
@Override
public String[] getPermissions() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final List<String> list = new ArrayList<>();
list.add(fessConfig.getRoleSearchUserPrefix() + getName());
stream(getRoles()).of(stream -> stream.forEach(s -> list.add(fessConfig.getRoleSearchRolePrefix() + decode(s))));
stream(getGroups()).of(stream -> stream.forEach(s -> list.add(fessConfig.getRoleSearchGroupPrefix() + decode(s))));
return list.toArray(new String[list.size()]);
}
Aggregations