Search in sources :

Example 1 with WhiteListStrategy

use of com.pamirs.pradar.pressurement.mock.WhiteListStrategy in project LinkAgent by shulieTech.

the class ArbiterHttpExit method getRpcPassedCache.

private static MatchConfig getRpcPassedCache(String name) {
    if (!PradarSwitcher.whiteListSwitchOn()) {
        return MatchConfig.success(new WhiteListStrategy());
    }
    if (StringUtils.isBlank(name)) {
        return failure();
    }
    MatchConfig config = new MatchConfig();
    config.setUrl(name);
    Set<MatchConfig> rpcNameList = GlobalConfig.getInstance().getRpcNameWhiteList();
    if (rpcNameList == null) {
        return failure();
    }
    Iterator<MatchConfig> iterator = rpcNameList.iterator();
    while (iterator.hasNext()) {
        MatchConfig next = iterator.next();
        if (next.equals(config)) {
            return next;
        }
    }
    if (StringUtils.indexOf(name, '#') != -1) {
        return failure();
    } else {
        for (MatchConfig matchConfig : rpcNameList) {
            String value = matchConfig.getUrl();
            final int index = StringUtils.indexOf(value, '#');
            if (index == -1) {
                if (StringUtils.equals(value, name)) {
                    return matchConfig;
                }
            } else {
                // 如果白名单包含 # ,则取出类名进行比较
                String className = StringUtils.substring(value, index);
                if (StringUtils.equals(value, className)) {
                    return matchConfig;
                }
            }
        }
    }
    return failure();
}
Also used : MatchConfig(com.pamirs.pradar.internal.config.MatchConfig) WhiteListStrategy(com.pamirs.pradar.pressurement.mock.WhiteListStrategy)

Aggregations

MatchConfig (com.pamirs.pradar.internal.config.MatchConfig)1 WhiteListStrategy (com.pamirs.pradar.pressurement.mock.WhiteListStrategy)1