use of com.predic8.membrane.core.config.Path in project irontest by zheng-wang.
the class WSDLResource method getOperationInfo.
@GET
@Path("/{wsdlUrl}/bindings/{bindingName}/operations/{operationName}")
public SOAPOperationInfo getOperationInfo(@PathParam("wsdlUrl") String wsdlUrl, @PathParam("bindingName") String bindingName, @PathParam("operationName") String operationName) {
SOAPOperationInfo info = new SOAPOperationInfo();
WSDLParser parser = new WSDLParser();
Definitions definition = parser.parse(wsdlUrl);
StringWriter writer = new StringWriter();
SOARequestCreator creator = new SOARequestCreator(definition, new RequestTemplateCreator(), new MarkupBuilder(writer));
creator.createRequest(null, operationName, bindingName);
info.setSampleRequest(writer.toString());
return info;
}
use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.
the class IndexInterceptor method getServiceInfo.
private ServiceInfo getServiceInfo(Exchange exc, AbstractServiceProxy sp) {
if (sp.getInterceptors().size() == 1 && sp.getInterceptors().get(0) instanceof IndexInterceptor)
return null;
ServiceProxyKey k = (ServiceProxyKey) sp.getKey();
ServiceInfo ri = new ServiceInfo();
ri.method = k.getMethod();
// NOTE: when running as servlet, we have no idea what the protocol was
ri.ssl = sp.getSslInboundContext() != null;
String protocol = ri.ssl ? "https" : "http";
String host = k.isHostWildcard() ? new HostColonPort(ri.ssl, exc.getRequest().getHeader().getHost()).host : fullfillRegexp(ServiceProxyKey.createHostPattern(k.getHost()));
if (host == null || host.length() == 0)
host = exc.getHandler().getLocalAddress().getHostAddress().toString();
int port = k.getPort();
if (port == -1 || !exc.getHandler().isMatchLocalPort())
port = exc.getHandler().getLocalPort();
String path;
if (!k.isUsePathPattern()) {
path = "/";
} else if (k.isPathRegExp()) {
path = fullfillRegexp(k.getPath());
} else {
path = "/" + StringUtils.removeStart(k.getPath(), "/");
}
if (!"".equals(exc.getHandler().getContextPath(exc))) {
path = StringUtils.removeEnd(exc.getHandler().getContextPath(exc), "/") + "/" + StringUtils.removeStart(path, "/");
}
ri.name = sp.getName();
if (path != null)
ri.url = protocol + "://" + host + ":" + port + path;
ri.host = k.isHostWildcard() ? "" : StringEscapeUtils.escapeHtml(k.getHost());
ri.port = k.getPort() == -1 ? "" : "" + k.getPort();
ri.path = k.isUsePathPattern() ? "<tt>" + StringEscapeUtils.escapeHtml(k.getPath()) + "</tt>" + (k.isPathRegExp() ? " (regex)" : "") : "";
return ri;
}
use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.
the class OAuth2AuthorizationServerInterceptor method init.
@Override
public void init(Router router) throws Exception {
name = "OAuth 2 Authorization Server";
setFlow(Flow.Set.REQUEST_RESPONSE);
this.setRouter(router);
addSupportedAuthorizationGrants();
getWellknownFile().init(router, this);
getConsentPageFile().init(router, getConsentFile());
if (userDataProvider == null)
throw new Exception("No userDataProvider configured. - Cannot work without one.");
if (getClientList() == null)
throw new Exception("No clientList configured. - Cannot work without one.");
if (getClaimList() == null)
throw new Exception("No scopeList configured. - Cannot work without one");
if (getLocation() == null) {
log.warn("===========================================================================================");
log.warn("IMPORTANT: No location configured - Authorization code and implicit flows are not available");
log.warn("===========================================================================================");
loginViewDisabled = true;
}
if (getConsentFile() == null && !isLoginViewDisabled()) {
log.warn("==============================================================================================");
log.warn("IMPORTANT: No consentFile configured - Authorization code and implicit flows are not available");
log.warn("==============================================================================================");
loginViewDisabled = true;
}
if (getPath() == null)
throw new Exception("No path configured. - Cannot work without one");
userDataProvider.init(router);
getClientList().init(router);
getClaimList().init(router);
jwtGenerator = new JwtGenerator();
sessionManager.init(router);
statistics = new OAuth2Statistics();
addDefaultProcessors();
new CleanupThread(sessionManager, accountBlocker).start();
}
use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.
the class RESTInterceptor method dispatchRequest.
private Outcome dispatchRequest(Exchange exc) throws Exception {
String path = router.getUriFactory().create(exc.getDestinations().get(0)).getPath();
for (Method m : getClass().getMethods()) {
Mapping a = m.getAnnotation(Mapping.class);
if (a == null)
continue;
Matcher matcher = Pattern.compile(a.value()).matcher(path);
if (matcher.matches()) {
Object[] parameters;
switch(m.getParameterTypes().length) {
case 2:
parameters = new Object[] { new QueryParameter(URLParamUtil.getParams(router.getUriFactory(), exc), matcher), getRelativeRootPath(path) };
break;
case 3:
parameters = new Object[] { new QueryParameter(URLParamUtil.getParams(router.getUriFactory(), exc), matcher), getRelativeRootPath(path), exc };
break;
default:
throw new InvalidParameterException("@Mapping is supposed to annotate a 2-parameter method.");
}
exc.setResponse((Response) m.invoke(this, parameters));
return Outcome.RETURN;
}
}
return Outcome.CONTINUE;
}
use of com.predic8.membrane.core.config.Path in project service-proxy by membrane.
the class WSDLPublisherInterceptor method handleRequest.
@Override
public Outcome handleRequest(final Exchange exc) throws Exception {
if (!"GET".equals(exc.getRequest().getMethod()))
return Outcome.CONTINUE;
try {
String resource = null;
if (exc.getRequestURI().endsWith("?wsdl") || exc.getRequestURI().endsWith("?WSDL")) {
processDocuments(exc);
exc.setResponse(WebServerInterceptor.createResponse(router.getResolverMap(), resource = wsdl));
exc.getResponse().getHeader().setContentType(MimeType.TEXT_XML);
}
if (exc.getRequestURI().contains("?xsd=")) {
Map<String, String> params = URLParamUtil.getParams(router.getUriFactory(), exc);
if (params.containsKey("xsd")) {
int n = Integer.parseInt(params.get("xsd"));
String path;
processDocuments(exc);
synchronized (paths) {
if (!paths.containsKey(n)) {
exc.setResponse(Response.forbidden("Unknown parameter. You may only retrieve documents referenced by the WSDL.").build());
return Outcome.ABORT;
}
path = paths.get(n);
}
exc.setResponse(WebServerInterceptor.createResponse(router.getResolverMap(), resource = path));
exc.getResponse().getHeader().setContentType(MimeType.TEXT_XML);
}
}
if (resource != null) {
WSDLInterceptor wi = new WSDLInterceptor();
wi.setRewriteEndpoint(false);
wi.setPathRewriter(new RelativePathRewriter(exc, resource));
wi.handleResponse(exc);
return Outcome.RETURN;
}
} catch (NumberFormatException e) {
exc.setResponse(HttpUtil.setHTMLErrorResponse(Response.internalServerError(), "Bad parameter format.", ""));
return Outcome.ABORT;
} catch (ResourceRetrievalException e) {
exc.setResponse(Response.notFound().build());
return Outcome.ABORT;
}
return Outcome.CONTINUE;
}
Aggregations