use of com.predic8.membrane.core.transport.ssl.SSLContext in project service-proxy by membrane.
the class RuleManager method openPorts.
public synchronized void openPorts() throws IOException {
HashMap<IpPort, SSLProvider> sslProviders;
try {
HashMap<IpPort, SSLContextCollection.Builder> sslContexts = new HashMap<IpPort, SSLContextCollection.Builder>();
for (Rule rule : rules) {
SSLContext sslContext = rule.getSslInboundContext();
if (sslContext != null) {
IpPort ipPort = new IpPort(rule.getKey().getIp(), rule.getKey().getPort());
SSLContextCollection.Builder builder = sslContexts.get(ipPort);
if (builder == null) {
builder = new SSLContextCollection.Builder();
sslContexts.put(ipPort, builder);
}
builder.add(sslContext);
}
}
sslProviders = new HashMap<IpPort, SSLProvider>();
for (Map.Entry<IpPort, SSLContextCollection.Builder> entry : sslContexts.entrySet()) sslProviders.put(entry.getKey(), entry.getValue().build());
} catch (ConfigurationException e) {
throw new IOException(e);
}
for (Rule rule : rules) {
IpPort ipPort = new IpPort(rule.getKey().getIp(), rule.getKey().getPort());
router.getTransport().openPort(rule.getKey().getIp(), rule.getKey().getPort(), sslProviders.get(ipPort));
}
}
Aggregations