Skip to content

Commit

Permalink
fix: error throwing for private key
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryIvo committed Nov 28, 2023
1 parent 57ee0d3 commit ebcc14e
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@ private static void create8021xTls(NetworkProperties props, String deviceId, Map
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 Client Certificate");
}

Optional<Password> privateKeyPassword = props.getOpt(Password.class,
Expand Down Expand Up @@ -308,7 +311,7 @@ public static Map<String, Variant<?>> buildIpv4Settings(NetworkProperties props,
return settings;
}

public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props, String deviceId,
public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props, String deviceId,
SemanticVersion nmVersion) {

// buildIpv6Settings doesn't support Unmanaged status. Therefore if ip6.status
Expand Down Expand Up @@ -406,9 +409,9 @@ public static Map<String, Variant<?>> buildIpv6Settings(NetworkProperties props,
logger.warn("Unexpected ip status received: \"{}\". Ignoring", ip6Status);
}

Optional<Integer> mtu = props.getOpt(Integer.class, "net.interface.%s.config.ip6.mtu", deviceId);
Optional<Integer> 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");
Expand Down Expand Up @@ -442,7 +445,7 @@ public static Map<String, Variant<?>> build80211WirelessSettings(NetworkProperti

Optional<Integer> mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId);
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));

return settings;
}

Expand Down Expand Up @@ -538,7 +541,7 @@ public static Map<String, Variant<?>> buildGsmSettings(NetworkProperties props,

Optional<Integer> mtu = props.getOpt(Integer.class, KURA_PROPS_IPV4_MTU, deviceId);
mtu.ifPresent(value -> settings.put("mtu", new Variant<>(new UInt32(value))));

return settings;
}

Expand Down Expand Up @@ -574,12 +577,12 @@ public static Map<String, Variant<?>> buildVlanSettings(NetworkProperties props,
settings.put("egress-priority-map", new Variant<>(egressMap.orElse(new ArrayList<>()), listType));
return settings;
}

public static Map<String, Variant<?>> buildEthernetSettings(NetworkProperties props, String deviceId) {
Map<String, Variant<?>> settings = new HashMap<>();
Optional<Integer> 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<String, Variant<?>> buildConnectionSettings(Optional<Connection> connection, String iface,
Expand Down

0 comments on commit ebcc14e

Please sign in to comment.