use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials in project netconf by opendaylight.
the class RemoteDeviceConnectorImplTest method testKeapAliveFacade.
@SuppressWarnings("unchecked")
@Test
public void testKeapAliveFacade() {
final Credentials credentials = new LoginPasswordBuilder().setPassword("admin").setUsername("admin").build();
final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(new Host(new IpAddress(new Ipv4Address("127.0.0.1")))).setPort(new PortNumber(Uint16.valueOf(9999))).setReconnectOnChangedSchema(true).setDefaultRequestTimeoutMillis(Uint32.valueOf(1000)).setBetweenAttemptsTimeoutMillis(Uint16.valueOf(100)).setSchemaless(false).setTcpOnly(false).setCredentials(credentials).setKeepaliveDelay(Uint32.ONE).build();
final Node node = new NodeBuilder().setNodeId(NODE_ID).addAugmentation(netconfNode).build();
builder.setSchemaResourceDTO(new DefaultSchemaResourceManager(new DefaultYangParserFactory()).getSchemaResources(netconfNode, "foo"));
final RemoteDeviceConnectorImpl remoteDeviceConnection = new RemoteDeviceConnectorImpl(builder.build(), remoteDeviceId, deviceActionFactory);
final RemoteDeviceHandler<NetconfSessionPreferences> salFacade = mock(RemoteDeviceHandler.class);
final NetconfConnectorDTO connectorDTO = remoteDeviceConnection.createDeviceCommunicator(NODE_ID, netconfNode, salFacade);
assertTrue(connectorDTO.getFacade() instanceof KeepaliveSalFacade);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials in project netconf by opendaylight.
the class AbstractNetconfTopology method hideCredentials.
/**
* Hiding of private credentials from node configuration (credentials data is replaced by asterisks).
*
* @param nodeConfiguration Node configuration container.
* @return String representation of node configuration with credentials replaced by asterisks.
*/
@VisibleForTesting
public static String hideCredentials(final Node nodeConfiguration) {
final NetconfNode netconfNodeAugmentation = nodeConfiguration.augmentation(NetconfNode.class);
final String nodeCredentials = netconfNodeAugmentation.getCredentials().toString();
final String nodeConfigurationString = nodeConfiguration.toString();
return nodeConfigurationString.replace(nodeCredentials, "***");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials in project netconf by opendaylight.
the class NetconfTopologyRPCProviderTest method testEncryptPassword.
@Test
public void testEncryptPassword() {
final NetconfNode encryptedPwNode = rpcProvider.encryptPassword(getInput(true));
final Credentials credentials = encryptedPwNode.getCredentials();
assertTrue(credentials instanceof LoginPw);
final LoginPw loginPw = (LoginPw) credentials;
assertEquals(ENC_PWD, loginPw.getLoginPassword().getPassword());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials in project netconf by opendaylight.
the class NetconfTopologyRPCProviderTest method testNoEncryption.
@Test
public void testNoEncryption() {
final NetconfNode encryptedPwNode = rpcProvider.encryptPassword(getInput(false));
final Credentials credentials = encryptedPwNode.getCredentials();
assertTrue(credentials instanceof LoginPwUnencrypted);
final LoginPwUnencrypted loginPw = (LoginPwUnencrypted) credentials;
assertEquals(TEST_PWD, loginPw.getLoginPasswordUnencrypted().getPassword());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials in project netconf by opendaylight.
the class NetconfConnectDeviceCommand method execute.
@Override
public Object execute() {
if (!NetconfCommandUtils.isIpValid(deviceIp) || !NetconfCommandUtils.isPortValid(devicePort)) {
return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
final boolean isTcpOnly = connectionType.equals("true");
final boolean isSchemaless = schemaless.equals("true");
final NetconfNodeBuilder netconfNodeBuilder = new NetconfNodeBuilder();
netconfNodeBuilder.setHost(new Host(new IpAddress(new Ipv4Address(deviceIp)))).setPort(new PortNumber(Uint16.valueOf(Integer.decode(devicePort)))).setTcpOnly(isTcpOnly).setSchemaless(isSchemaless);
if (isTcpOnly || protocol.equalsIgnoreCase("ssh")) {
if (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password)) {
return "Empty Username:" + username + " or Password:" + password + ". In TCP or SSH mode, you must provide valid username and password.";
}
final Credentials credentials = new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
netconfNodeBuilder.setCredentials(credentials);
if (!isTcpOnly) {
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.SSH).build());
}
} else if (protocol.equalsIgnoreCase("tls")) {
TlsCase tlsCase = null;
if (!Strings.isNullOrEmpty(excludedTlsVersions)) {
tlsCase = new TlsCaseBuilder().setTls(new TlsBuilder().setExcludedVersions(Arrays.asList(excludedTlsVersions.split(","))).build()).build();
}
netconfNodeBuilder.setProtocol(new ProtocolBuilder().setName(Name.TLS).setSpecification(tlsCase).build());
} else {
return "Invalid protocol: " + protocol + ". Only SSH and TLS are supported.";
}
service.connectDevice(netconfNodeBuilder.build(), deviceId);
final String message = "Netconf connector added succesfully";
return message;
}
Aggregations