diff --git a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java index 45ba2b785d6..e65b89e0b89 100644 --- a/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java +++ b/kura/org.eclipse.kura.nm/src/main/java/org/eclipse/kura/nm/configuration/NMSettingsConverter.java @@ -190,16 +190,21 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map deviceId); settings.put("client-cert", new Variant<>(clientCert.getEncoded())); } catch (CertificateEncodingException e) { - logger.error("Unable to find or decode Client Certificate"); + logger.error("Unable to decode Client Certificate"); + } catch (ClassCastException e) { + logger.error("Unable to find Client Certificate"); } - PrivateKey privateKey = props.get(PrivateKey.class, "net.interface.%s.config.802-1x.private-key-name", - deviceId); - - if (privateKey.getEncoded() != null) { - settings.put("private-key", new Variant<>(privateKey.getEncoded())); - } else { - logger.error("Unable to find or decode Private Key"); + try { + PrivateKey privateKey = props.get(PrivateKey.class, "net.interface.%s.config.802-1x.private-key-name", + deviceId); + if (privateKey.getEncoded() != null) { + settings.put("private-key", new Variant<>(privateKey.getEncoded())); + } else { + logger.error("Unable to find or decode Private Key"); + } + } catch (ClassCastException e) { + logger.error("Unable to find Private Key"); } Optional privateKeyPassword = props.getOpt(Password.class, @@ -306,7 +311,7 @@ public static Map> buildIpv4Settings(NetworkProperties props, return settings; } - public static Map> buildIpv6Settings(NetworkProperties props, String deviceId, + public static Map> buildIpv6Settings(NetworkProperties props, String deviceId, SemanticVersion nmVersion) { // buildIpv6Settings doesn't support Unmanaged status. Therefore if ip6.status @@ -404,9 +409,9 @@ public static Map> buildIpv6Settings(NetworkProperties props, logger.warn("Unexpected ip status received: \"{}\". Ignoring", ip6Status); } - Optional mtu = props.getOpt(Integer.class, "net.interface.%s.config.ip6.mtu", deviceId); + Optional mtu = props.getOpt(Integer.class, "net.interface.%s.config.ip6.mtu", deviceId); if (nmVersion.isGreaterEqualThan("1.40")) { - //ipv6.mtu only supported in NetworkManager 1.40 and above + // ipv6.mtu only supported in NetworkManager 1.40 and above mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value)))); } else { logger.warn("Ignoring parameter ipv6.mtu: NetworkManager 1.40 or above is required"); @@ -440,7 +445,7 @@ public static Map> build80211WirelessSettings(NetworkProperti Optional mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId); mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value)))); - + return settings; } @@ -536,7 +541,7 @@ public static Map> buildGsmSettings(NetworkProperties props, Optional mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId); mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value)))); - + return settings; } @@ -572,12 +577,12 @@ public static Map> buildVlanSettings(NetworkProperties props, settings.put("egress-priority-map", new Variant<>(egressMap.orElse(new ArrayList<>()), listType)); return settings; } - + public static Map> buildEthernetSettings(NetworkProperties props, String deviceId) { Map> settings = new HashMap<>(); Optional mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId); mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value)))); - return settings; + return settings; } public static Map> buildConnectionSettings(Optional connection, String iface,