use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.
the class KeyConstructorUtil method constructKeys.
public static KeyMapping constructKeys(final List<MonitoredRouter> mrs) {
final KeyMapping ret = KeyMapping.getKeyMapping();
if (mrs != null) {
mrs.stream().filter(Objects::nonNull).filter(KeyConstructorUtil::isNotNullorEmpty).forEach(mr -> {
final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
ret.put(IetfInetUtil.INSTANCE.inetAddressFor(mr.getAddress()), rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
});
}
return ret;
}
use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.
the class PCEPDispatcherImplTest method testCustomizeBootstrap.
@Test
public void testCustomizeBootstrap() {
final int port = InetSocketAddressUtil.getRandomPort();
final InetSocketAddress clientAddr1 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
final InetSocketAddress clientAddr2 = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(port);
final KeyMapping keys = KeyMapping.getKeyMapping(clientAddr1.getAddress(), "CLIENT1_ADDRESS");
keys.put(clientAddr2.getAddress(), "CLIENT2_ADDRESS".getBytes());
doReturn(new InetSocketAddress("0.0.0.0", port)).when(this.dispatcherDependencies).getAddress();
doReturn(this.listenerFactory).when(this.dispatcherDependencies).getListenerFactory();
doReturn(new SimpleSessionListener()).when(this.listenerFactory).getSessionListener();
final ChannelFuture futureChannel = this.disp2Spy.createServer(this.dispatcherDependencies);
waitFutureSuccess(futureChannel);
Mockito.verify(this.disp2Spy).createServerBootstrap(any(PCEPDispatcherImpl.ChannelPipelineInitializer.class));
}
use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.
the class BmpMonitoringStationImpl method connectMonitoredRouters.
private void connectMonitoredRouters(final BmpDispatcher pdispatcher) {
if (this.monitoredRouters != null) {
for (final MonitoredRouter mr : this.monitoredRouters) {
if (mr.isActive()) {
requireNonNull(mr.getAddress());
requireNonNull(mr.getPort());
final String s = mr.getAddress().getIpv4Address().getValue();
final InetAddress addr = InetAddresses.forString(s);
final KeyMapping ret;
final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
ret = KeyMapping.getKeyMapping(addr, rfc2385KeyPassword.getValue());
pdispatcher.createClient(Ipv4Util.toInetSocketAddress(mr.getAddress(), mr.getPort()), this.sessionManager, ret);
}
}
}
}
use of org.opendaylight.protocol.concepts.KeyMapping in project bgpcep by opendaylight.
the class PCEPTopologyProviderUtil method contructKeys.
static KeyMapping contructKeys(@Nonnull final Topology topology) {
final KeyMapping ret = KeyMapping.getKeyMapping();
topology.getNode().stream().filter(Objects::nonNull).filter(node -> node.getAugmentation(PcepNodeConfig.class) != null).filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig() != null).filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig().getPassword() != null).filter(node -> !node.getAugmentation(PcepNodeConfig.class).getSessionConfig().getPassword().getValue().isEmpty()).forEach(node -> {
final PcepNodeConfig config = node.getAugmentation(PcepNodeConfig.class);
final Rfc2385Key rfc2385KeyPassword = config.getSessionConfig().getPassword();
final InetAddress address = InetAddresses.forString(node.getNodeId().getValue());
ret.put(address, rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));
});
return ret;
}
Aggregations