2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.bgpcep.pcep.topology.provider.config;
10 import java.nio.charset.StandardCharsets;
11 import java.util.List;
12 import org.opendaylight.controller.config.yang.pcep.topology.provider.Client;
13 import org.opendaylight.protocol.concepts.KeyMapping;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
17 public final class PCEPTopologyProviderUtil {
18 private PCEPTopologyProviderUtil() {
19 throw new UnsupportedOperationException();
22 public static KeyMapping contructKeys(final List<Client> clients) {
23 final KeyMapping ret = KeyMapping.getKeyMapping();
25 if (clients != null) {
26 clients.stream().filter(client -> client != null && client.getPassword() != null &&
27 !client.getPassword().getValue().isEmpty())
29 final Rfc2385Key rfc2385KeyPassword = mr.getPassword();
30 ret.put(IetfInetUtil.INSTANCE.inetAddressFor(mr.getAddress()),
31 rfc2385KeyPassword.getValue().getBytes(StandardCharsets.US_ASCII));