use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class MemoryExchangeStore method removeAllExchanges.
public void removeAllExchanges(Rule rule) {
AbstractExchange[] exchanges = getExchanges(rule.getKey());
exchangesMap.remove(rule.getKey());
totals.removeAll(Arrays.asList(exchanges));
for (IExchangesStoreListener listener : exchangesStoreListeners) {
listener.removeExchanges(rule, exchanges);
}
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class RuleMatchingInterceptor method getRule.
private Rule getRule(Exchange exc) {
Request request = exc.getRequest();
AbstractHttpHandler handler = exc.getHandler();
// retrieve value to match
String hostHeader = request.getHeader().getHost();
String method = request.getMethod();
String uri = request.getUri();
String version = request.getVersion();
int port = handler.isMatchLocalPort() ? handler.getLocalPort() : -1;
String localIP = handler.getLocalAddress().getHostAddress();
// match it
Rule rule = router.getRuleManager().getMatchingRule(hostHeader, method, uri, version, port, localIP);
if (rule != null) {
if (log.isDebugEnabled())
log.debug("Matching Rule found for RuleKey " + hostHeader + " " + method + " " + uri + " " + port + " " + localIP);
return rule;
}
return findProxyRule(exc);
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class RuleMatchingInterceptor method handleRequest.
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
if (exc.getRule() != null)
return Outcome.CONTINUE;
Rule rule = getRule(exc);
exc.setRule(rule);
if (exc.getRule().getSslOutboundContext() != null) {
exc.setProperty(Exchange.SSL_CONTEXT, exc.getRule().getSslOutboundContext());
}
if (rule instanceof NullRule) {
handleNoRuleFound(exc);
return Outcome.ABORT;
}
if (xForwardedForEnabled && (rule instanceof AbstractServiceProxy))
insertXForwardedFor(exc);
return Outcome.CONTINUE;
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class BasicAuthenticationInterceptorIntegrationTest method setup.
@Before
public void setup() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3001), "thomas-bayer.com", 80);
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
BasicAuthenticationInterceptor interceptor = new BasicAuthenticationInterceptor();
List<User> users = new ArrayList<User>();
users.add(new User("admin", "admin"));
interceptor.setUsers(users);
router.addUserFeatureInterceptor(interceptor);
router.init();
}
use of com.predic8.membrane.core.interceptor.HeaderFilterInterceptor.Rule in project service-proxy by membrane.
the class ClusterNotificationInterceptorTest method setUp.
@Override
@Before
public void setUp() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3002), "thomas-bayer.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
interceptor = new ClusterNotificationInterceptor();
router.addUserFeatureInterceptor(interceptor);
lbi = new LoadBalancingInterceptor();
lbi.setName("Default");
Rule rule2 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3003), "thomas-bayer.com", 80);
router.getRuleManager().addProxyAndOpenPortIfNew(rule2);
rule2.getInterceptors().add(lbi);
router.init();
}
Aggregations