use of org.opendaylight.netconf.callhome.protocol.AuthorizedKeysDecoder in project netconf by opendaylight.
the class CallhomeStatusReporter method reportFailedAuth.
@Override
public void reportFailedAuth(final PublicKey sshKey) {
AuthorizedKeysDecoder decoder = new AuthorizedKeysDecoder();
for (final Device device : getDevicesAsList()) {
final String keyString;
if (device.getTransport() instanceof Ssh) {
keyString = ((Ssh) device.getTransport()).getSshClientParams().getHostKey();
} else {
keyString = device.getSshHostKey();
}
if (keyString == null) {
LOG.info("Whitelist device {} does not have a host key, skipping it", device.getUniqueId());
continue;
}
try {
PublicKey pubKey = decoder.decodePublicKey(keyString);
if (sshKey.getAlgorithm().equals(pubKey.getAlgorithm()) && sshKey.equals(pubKey)) {
Device failedDevice = withFailedAuthStatus(device);
if (failedDevice == null) {
return;
}
LOG.info("Setting auth failed status for callhome device id:{}.", failedDevice.getUniqueId());
setDeviceStatus(failedDevice);
return;
}
} catch (GeneralSecurityException e) {
LOG.error("Failed decoding a device key with host key: {}", keyString, e);
return;
}
}
LOG.error("No match found for the failed auth device (should have been filtered by whitelist). Key: {}", sshKey);
}
Aggregations