mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-15 09:21:06 +02:00
ONOS-6020 RolledBack and deprecated a method in NetconfDeviceInfo to not break backwards compatibility
Change-Id: Ie029f6b1d3688d428130b76ed2e06c760d9a390a
This commit is contained in:
parent
c201ae4c64
commit
e7006dca2a
@ -22,6 +22,7 @@ import org.onosproject.net.DeviceId;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -39,6 +40,8 @@ public class NetconfDeviceInfo {
|
|||||||
private IpAddress ipAddress;
|
private IpAddress ipAddress;
|
||||||
private int port;
|
private int port;
|
||||||
private char[] key;
|
private char[] key;
|
||||||
|
//File keyFile @deprecated 1.9.0
|
||||||
|
private File keyFile;
|
||||||
private DeviceId deviceId;
|
private DeviceId deviceId;
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +71,12 @@ public class NetconfDeviceInfo {
|
|||||||
* @param password the password for the device
|
* @param password the password for the device
|
||||||
* @param ipAddress the ip address
|
* @param ipAddress the ip address
|
||||||
* @param port the tcp port
|
* @param port the tcp port
|
||||||
* @param keyString the string containing the key.
|
* @param keyString the string containing a DSA or RSA private key
|
||||||
|
* of the user in OpenSSH key format
|
||||||
|
* <br>
|
||||||
|
* (Pre 1.9.0 behaviour: {@code keyString} can be file path
|
||||||
|
* to a file containing DSA or RSA private key of the user
|
||||||
|
* in OpenSSH key format)
|
||||||
*/
|
*/
|
||||||
public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
|
public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
|
||||||
int port, String keyString) {
|
int port, String keyString) {
|
||||||
@ -80,6 +88,7 @@ public class NetconfDeviceInfo {
|
|||||||
this.ipAddress = ipAddress;
|
this.ipAddress = ipAddress;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.key = keyString.toCharArray();
|
this.key = keyString.toCharArray();
|
||||||
|
this.keyFile = new File(keyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,18 +130,34 @@ public class NetconfDeviceInfo {
|
|||||||
/**
|
/**
|
||||||
* Exposes the key of the controller.
|
* Exposes the key of the controller.
|
||||||
*
|
*
|
||||||
* @return int port address
|
* @return {@code char[]} containing a DSA or RSA private key of the user
|
||||||
|
* in OpenSSH key format
|
||||||
|
* or null if device is not configured to use public key authentication
|
||||||
*/
|
*/
|
||||||
public char[] getKey() {
|
public char[] getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exposes the keyFile of the controller.
|
||||||
|
*
|
||||||
|
* @return File object pointing to a file containing a DSA or RSA
|
||||||
|
* private key of the user in OpenSSH key format,
|
||||||
|
* or null if device is not configured to use public key authentication
|
||||||
|
* @deprecated 1.9.0
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public File getKeyFile() {
|
||||||
|
return keyFile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the info about the device in a string.
|
* Return the info about the device in a string.
|
||||||
* String format: "netconf:name@ip:port"
|
* String format: "netconf:name@ip:port"
|
||||||
*
|
*
|
||||||
* @return String device info
|
* @return String device info
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "netconf:" + name + "@" + ipAddress + ":" + port;
|
return "netconf:" + name + "@" + ipAddress + ":" + port;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,13 @@ public class NetconfSessionImpl implements NetconfSession {
|
|||||||
}
|
}
|
||||||
boolean isAuthenticated;
|
boolean isAuthenticated;
|
||||||
try {
|
try {
|
||||||
if (deviceInfo.getKey() != null) {
|
if (deviceInfo.getKeyFile() != null && deviceInfo.getKeyFile().canRead()) {
|
||||||
|
log.debug("Authenticating with key file to device {} with username {}",
|
||||||
|
deviceInfo.getDeviceId(), deviceInfo.name());
|
||||||
|
isAuthenticated = netconfConnection.authenticateWithPublicKey(
|
||||||
|
deviceInfo.name(), deviceInfo.getKeyFile(),
|
||||||
|
deviceInfo.password().equals("") ? null : deviceInfo.password());
|
||||||
|
} else if (deviceInfo.getKey() != null) {
|
||||||
log.debug("Authenticating with key to device {} with username {}",
|
log.debug("Authenticating with key to device {} with username {}",
|
||||||
deviceInfo.getDeviceId(), deviceInfo.name());
|
deviceInfo.getDeviceId(), deviceInfo.name());
|
||||||
isAuthenticated = netconfConnection.authenticateWithPublicKey(
|
isAuthenticated = netconfConnection.authenticateWithPublicKey(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user