Search in sources :

Example 1 with SID

use of jcifs.SID in project fess by codelibs.

the class PermissionHelper method getSmbRoleTypeList.

public List<String> getSmbRoleTypeList(final ResponseData responseData) {
    final List<String> roleTypeList = new ArrayList<>();
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    if (fessConfig.isSmbRoleFromFile()) {
        final SambaHelper sambaHelper = ComponentUtil.getSambaHelper();
        final Map<String, Object> metaDataMap = responseData.getMetaDataMap();
        if (responseData.getUrl().startsWith("smb:")) {
            final SID[] allowedSids = (SID[]) metaDataMap.get(SmbClient.SMB_ALLOWED_SID_ENTRIES);
            if (allowedSids != null) {
                for (final SID sid : allowedSids) {
                    final String accountId = sambaHelper.getAccountId(sid);
                    if (accountId != null) {
                        roleTypeList.add(accountId);
                    }
                }
            }
            final SID[] deniedSids = (SID[]) metaDataMap.get(SmbClient.SMB_DENIED_SID_ENTRIES);
            if (deniedSids != null) {
                for (final SID sid : deniedSids) {
                    final String accountId = sambaHelper.getAccountId(sid);
                    if (accountId != null) {
                        roleTypeList.add(fessConfig.getRoleSearchDeniedPrefix() + accountId);
                    }
                }
            }
            if (logger.isDebugEnabled()) {
                logger.debug("smbUrl:{} roleType:{}", responseData.getUrl(), roleTypeList);
            }
        } else if (responseData.getUrl().startsWith("smb1:")) {
            final jcifs.smb1.smb1.SID[] allowedSids = (jcifs.smb1.smb1.SID[]) metaDataMap.get(org.codelibs.fess.crawler.client.smb1.SmbClient.SMB_ALLOWED_SID_ENTRIES);
            if (allowedSids != null) {
                for (final jcifs.smb1.smb1.SID sid : allowedSids) {
                    final String accountId = sambaHelper.getAccountId(sid);
                    if (accountId != null) {
                        roleTypeList.add(accountId);
                    }
                }
            }
            final jcifs.smb1.smb1.SID[] deniedSids = (jcifs.smb1.smb1.SID[]) metaDataMap.get(org.codelibs.fess.crawler.client.smb1.SmbClient.SMB_DENIED_SID_ENTRIES);
            if (deniedSids != null) {
                for (final jcifs.smb1.smb1.SID sid : deniedSids) {
                    final String accountId = sambaHelper.getAccountId(sid);
                    if (accountId != null) {
                        roleTypeList.add(fessConfig.getRoleSearchDeniedPrefix() + accountId);
                    }
                }
            }
            if (logger.isDebugEnabled()) {
                logger.debug("smb1Url:{} roleType:{}", responseData.getUrl(), roleTypeList);
            }
        }
    }
    return roleTypeList;
}
Also used : ArrayList(java.util.ArrayList) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) SID(jcifs.SID)

Aggregations

ArrayList (java.util.ArrayList)1 SID (jcifs.SID)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1