use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class AdminPageBuilder method createInterceptorVisualization.
private void createInterceptorVisualization(Interceptor i, int columnSpan, String id, boolean noMarginTop) {
td().style("padding:0px;");
if (columnSpan > 1)
colspan("" + columnSpan);
if (i == null) {
div().style("padding:2px 5px; margin: 10px; width: 299px;");
raw(" ");
end();
} else {
String shortDescription = i.getShortDescription();
String longDescription = i.getLongDescription();
boolean same = longDescription.equals(shortDescription);
if (!TextUtil.isValidXMLSnippet(shortDescription)) {
shortDescription = StringEscapeUtils.escapeHtml(shortDescription).replace("\n", "<br/>");
if (same)
longDescription = shortDescription;
}
if (!same && !TextUtil.isValidXMLSnippet(longDescription)) {
longDescription = StringEscapeUtils.escapeHtml(longDescription).replace("\n", "<br/>");
}
shortDescription = shortDescription.replaceAll("\"/admin", "\"" + relativeRootPath + "/admin");
longDescription = longDescription.replaceAll("\"/admin", "\"" + relativeRootPath + "/admin");
String did = "d" + id;
div().id(did).style("border: 1px solid black; padding:8px 5px; margin: 10px;overflow-x: auto; background-color: #FFC04F;" + (columnSpan == 1 ? "width: 299px;" : "width: 630px;") + (noMarginTop ? "margin-top: 0px;" : ""));
String iid = "i" + id;
div().id("i" + id);
createHelpIcon(i, id);
if (shortDescription.length() > 0 && !longDescription.equals(shortDescription)) {
createExpandIcon(i, id);
}
end();
createShowIconsScript(did, iid);
div().classAttr("name");
text(i.getDisplayName());
end();
if (shortDescription.length() > 0) {
div().style("padding-top: 4px;");
String sid = "s" + id;
div().id(sid);
raw(shortDescription);
if (!longDescription.equals(shortDescription)) {
String aid = "a" + id;
String lid = "l" + id;
String eid = "e" + id;
String cid = "c" + id;
a().id(aid).href("#").text("...").end();
end();
div().id(lid).style("margin: 0px;");
raw(longDescription);
end();
script();
raw("jQuery(document).ready(function() {\r\n" + " jQuery(\"#" + eid + "\").css('cursor', 'pointer');\r\n" + " jQuery(\"#" + cid + "\").css('cursor', 'pointer');\r\n" + " jQuery(\"#" + lid + "\").hide();\r\n" + " jQuery(\"#" + cid + "\").hide();\r\n" + " jQuery(\"#" + eid + "\").click(function()\r\n" + " {\r\n" + " jQuery(\"#" + sid + "\").hide();\r\n" + " jQuery(\"#" + lid + "\").slideToggle(500);\r\n" + " jQuery(\"#" + eid + "\").hide();\r\n" + " jQuery(\"#" + cid + "\").show();\r\n" + " });\r\n" + " jQuery(\"#" + aid + "\").click(function()\r\n" + " {\r\n" + " jQuery(\"#" + sid + "\").hide();\r\n" + " jQuery(\"#" + lid + "\").slideToggle(500);\r\n" + " jQuery(\"#" + eid + "\").hide();\r\n" + " jQuery(\"#" + cid + "\").show();\r\n" + " });\r\n" + " jQuery(\"#" + cid + "\").click(function()\r\n" + " {\r\n" + " jQuery(\"#" + sid + "\").show();\r\n" + " jQuery(\"#" + lid + "\").slideToggle(500);\r\n" + " jQuery(\"#" + cid + "\").hide();\r\n" + " jQuery(\"#" + eid + "\").show();\r\n" + " });\r\n" + "});\r\n" + "</script>\r\n" + "\r\n" + "");
}
end();
end();
}
end();
}
end();
}
use of com.predic8.membrane.core.interceptor.Interceptor 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.Interceptor 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();
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class FormValidationInterceptorTest method testValidation.
@Test
public void testValidation() throws Exception {
FormValidationInterceptor interceptor = new FormValidationInterceptor();
interceptor.init(new HttpRouter());
Field article = new Field();
article.setName("article");
article.setRegex("banana|apple");
Field amount = new Field();
amount.setName("amount");
amount.setRegex("\\d+");
List<Field> fields = new ArrayList<Field>();
fields.add(amount);
fields.add(article);
interceptor.setFields(fields);
Exchange exc = getExchange("/buy?article=pizza&amount=five");
assertEquals(Outcome.ABORT, interceptor.handleRequest(exc));
assertEquals(400, exc.getResponse().getStatusCode());
exc = getExchange("/buy?article=pizza&amount=2");
assertEquals(Outcome.ABORT, interceptor.handleRequest(exc));
assertEquals(400, exc.getResponse().getStatusCode());
exc = getExchange("/buy?article=banana&amount=five");
assertEquals(Outcome.ABORT, interceptor.handleRequest(exc));
assertEquals(400, exc.getResponse().getStatusCode());
exc = getExchange("/buy?article=banana&amount=5");
assertEquals(Outcome.CONTINUE, interceptor.handleRequest(exc));
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class AccessControlInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
router = new HttpRouter();
interceptor = new AccessControlInterceptor();
interceptor.setFile("classpath:/acl/acl.xml");
Rule rule4000 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 4000), "oio.de", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule4000);
router.addUserFeatureInterceptor(interceptor);
router.init();
}
Aggregations