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 b44db89c9b9..74bd5478d49 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 @@ -194,21 +194,17 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map Certificate clientCert = props.get(Certificate.class, "net.interface.%s.config.802-1x.client-cert-name", deviceId); settings.put("client-cert", new Variant<>(clientCert.getEncoded())); - } catch (CertificateEncodingException | ClassCastException e) { + } catch (CertificateEncodingException e) { throw new NoSuchElementException( - String.format("Unable to find or decode Client Certificate for interface \"%s\"", deviceId)); + String.format("Unable to decode Client Certificate for interface \"%s\"", deviceId)); } - 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<>(convertToPem(privateKey.getEncoded()))); - } else { - throw new NoSuchElementException("Unable to find or decode Private Key"); - } - } catch (ClassCastException e) { - throw new NoSuchElementException("Unable to find Private Key"); + 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<>(convertToPem(privateKey.getEncoded()))); + } else { + throw new NoSuchElementException("Unable to decode Private Key"); } Optional privateKeyPassword = props.getOpt(Password.class, @@ -229,9 +225,9 @@ private static void create8021xCaCertAndAnonIdentity(NetworkProperties props, St try { Certificate caCert = props.get(Certificate.class, "net.interface.%s.config.802-1x.ca-cert-name", deviceId); settings.put("ca-cert", new Variant<>(caCert.getEncoded())); - } catch (CertificateEncodingException | ClassCastException e) { + } catch (CertificateEncodingException e) { throw new NoSuchElementException( - String.format("Unable to find or decode CA Certificate for interface %s", deviceId)); + String.format("Unable to decode CA Certificate for interface %s", deviceId)); } Optional caCertPassword = props.getOpt(Password.class,