use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class DialogAddProxyExcludedDomain method performAction.
@Override
protected void performAction() {
String value = getDomainTextField().getText();
if (getRegexCheckBox().isSelected()) {
Pattern pattern = DomainMatcher.createPattern(value);
proxyExcludedDomain = new DomainMatcher(pattern);
} else {
proxyExcludedDomain = new DomainMatcher(value);
}
proxyExcludedDomain.setEnabled(getEnabledCheckBox().isSelected());
}
use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class ConnectionParam method loadProxyExcludedDomains.
private void loadProxyExcludedDomains() {
List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()).configurationsAt(ALL_PROXY_EXCLUDED_DOMAINS_KEY);
this.proxyExcludedDomains = new ArrayList<>(fields.size());
ArrayList<DomainMatcher> excludedDomainsEnabled = new ArrayList<>(fields.size());
for (HierarchicalConfiguration sub : fields) {
String value = sub.getString(PROXY_EXCLUDED_DOMAIN_VALUE_KEY, "");
if (value.isEmpty()) {
log.warn("Failed to read an outgoing proxy excluded domain entry, required value is empty.");
continue;
}
DomainMatcher excludedDomain = null;
boolean regex = sub.getBoolean(PROXY_EXCLUDED_DOMAIN_REGEX_KEY, false);
if (regex) {
try {
Pattern pattern = DomainMatcher.createPattern(value);
excludedDomain = new DomainMatcher(pattern);
} catch (IllegalArgumentException e) {
log.error("Failed to read an outgoing proxy excluded domain entry with regex: " + value, e);
}
} else {
excludedDomain = new DomainMatcher(value);
}
if (excludedDomain != null) {
excludedDomain.setEnabled(sub.getBoolean(PROXY_EXCLUDED_DOMAIN_ENABLED_KEY, true));
proxyExcludedDomains.add(excludedDomain);
if (excludedDomain.isEnabled()) {
excludedDomainsEnabled.add(excludedDomain);
}
}
}
excludedDomainsEnabled.trimToSize();
this.proxyExcludedDomainsEnabled = excludedDomainsEnabled;
}
Aggregations