use of com.predic8.membrane.core.interceptor.apimanagement.Key in project service-proxy by membrane.
the class OAuth2ResourceInterceptor method setPublicURL.
private void setPublicURL(Exchange exc) {
String xForwardedProto = exc.getRequest().getHeader().getFirstValue(Header.X_FORWARDED_PROTO);
boolean isHTTPS = xForwardedProto != null ? "https".equals(xForwardedProto) : exc.getRule().getSslInboundContext() != null;
publicURL = (isHTTPS ? "https://" : "http://") + exc.getOriginalHostHeader();
RuleKey key = exc.getRule().getKey();
if (!key.isPathRegExp() && key.getPath() != null)
publicURL += key.getPath();
normalizePublicURL();
initPublicURLOnFirstExchange = false;
}
use of com.predic8.membrane.core.interceptor.apimanagement.Key in project service-proxy by membrane.
the class NamespaceInfo method writeInfo.
public void writeInfo(Model m) {
try {
FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", "META-INF/membrane.namespaces");
OutputStream oo = o.openOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(oo);
try {
Properties p = new Properties();
int i = 1;
for (MainInfo mi : m.getMains()) {
String key = "schema" + (i++);
p.put(key + "-targetNamespace", mi.getAnnotation().targetNamespace());
p.put(key + "-outputPackage", mi.getAnnotation().outputPackage());
p.put(key + "-outputName", mi.getAnnotation().outputName());
}
p.store(bos, "Autogenerated by " + getClass().getName());
} finally {
bos.close();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.predic8.membrane.core.interceptor.apimanagement.Key in project service-proxy by membrane.
the class RuleManager method getMatchingRule.
public Rule getMatchingRule(String hostHeader, String method, String uri, String version, int port, String localIP) {
for (Rule rule : rules) {
RuleKey key = rule.getKey();
log.debug("Host from rule: " + key.getHost() + "; Host from parameter rule key: " + hostHeader);
if (!rule.isActive())
continue;
if (!key.matchesVersion(version))
continue;
if (key.getIp() != null && !key.getIp().equals(localIP))
continue;
if (!key.matchesHostHeader(hostHeader))
continue;
if (key.getPort() != -1 && port != -1 && key.getPort() != port)
continue;
if (!key.getMethod().equals(method) && !key.isMethodWildcard())
continue;
if (key.isUsePathPattern() && !key.matchesPath(uri))
continue;
if (!key.complexMatch(hostHeader, method, uri, version, port, localIP))
continue;
return rule;
}
return null;
}
use of com.predic8.membrane.core.interceptor.apimanagement.Key in project service-proxy by membrane.
the class AbstractExchange method getPublicUrl.
public String getPublicUrl() {
String xForwardedProto = getRequest().getHeader().getFirstValue(Header.X_FORWARDED_PROTO);
boolean isHTTPS = xForwardedProto != null ? "https".equals(xForwardedProto) : getRule().getSslInboundContext() != null;
String publicURL = (isHTTPS ? "https://" : "http://") + getRequest().getHeader().getHost().replaceFirst(".*:", "");
RuleKey key = getRule().getKey();
if (!key.isPathRegExp() && key.getPath() != null)
publicURL += key.getPath();
return publicURL;
}
use of com.predic8.membrane.core.interceptor.apimanagement.Key in project service-proxy by membrane.
the class ApiManagementConfiguration method parseExpiration.
private void parseExpiration(LinkedHashMap<String, Object> keyYaml, Key key) {
String expirationString = parseString(keyYaml.get("expires"), null);
Instant expiration = null;
if (expirationString != null)
try {
expiration = Instant.parse(expirationString);
} catch (Exception e) {
log.error("Could not read expiration");
}
key.setExpiration(expiration);
}
Aggregations