Search in sources :

Example 6 with Credentials

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 NetconfTopologyRPCProvider method handleEncryption.

private Credentials handleEncryption(final Credentials credentials) {
    if (credentials instanceof LoginPw) {
        final LoginPassword loginPassword = ((LoginPw) credentials).getLoginPassword();
        final String encryptedPassword = encryptionService.encrypt(loginPassword.getPassword());
        return new LoginPwBuilder().setLoginPassword(new LoginPasswordBuilder().setPassword(encryptedPassword).setUsername(loginPassword.getUsername()).build()).build();
    }
    // nothing else needs to be encrypted
    return credentials;
}
Also used : LoginPw(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPw) LoginPwBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwBuilder) LoginPasswordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.LoginPasswordBuilder) LoginPassword(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.LoginPassword)

Example 7 with Credentials

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 getInput.

private static CreateDeviceInput getInput(final boolean encrypt) {
    CreateDeviceInputBuilder builder = new CreateDeviceInputBuilder();
    final Credentials credentials;
    if (encrypt) {
        credentials = new LoginPwBuilder().setLoginPassword(new LoginPasswordBuilder().setUsername("test").setPassword(TEST_PWD).build()).build();
    } else {
        credentials = new LoginPwUnencryptedBuilder().setLoginPasswordUnencrypted(new LoginPasswordUnencryptedBuilder().setUsername("test").setPassword(TEST_PWD).build()).build();
    }
    return builder.setCredentials(credentials).setHost(new Host(new IpAddress(new Ipv4Address("10.18.16.188")))).setPort(new PortNumber(Uint16.valueOf(830))).setTcpOnly(Boolean.FALSE).setNodeId(NODE_ID.toString()).build();
}
Also used : LoginPwBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwBuilder) CreateDeviceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.CreateDeviceInputBuilder) LoginPasswordUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.unencrypted.LoginPasswordUnencryptedBuilder) LoginPasswordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.LoginPasswordBuilder) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Credentials(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials) LoginPwUnencryptedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwUnencryptedBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Example 8 with Credentials

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 NetconfTopologyImplTest method hideCredentialsTest.

@Test
public void hideCredentialsTest() {
    final String userName = "admin";
    final String password = "pa$$word";
    final Node node = new NodeBuilder().addAugmentation(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)).setKeepaliveDelay(Uint32.valueOf(1000)).setTcpOnly(false).setProtocol(new ProtocolBuilder().setName(Name.TLS).build()).setCredentials(new LoginPasswordBuilder().setUsername(userName).setPassword(password).build()).build()).setNodeId(NodeId.getDefaultInstance("junos")).build();
    final String transformedNetconfNode = AbstractNetconfTopology.hideCredentials(node);
    assertTrue(transformedNetconfNode.contains("credentials=***"));
    assertFalse(transformedNetconfNode.contains(userName));
    assertFalse(transformedNetconfNode.contains(password));
}
Also used : NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) ProtocolBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) LoginPasswordBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 9 with Credentials

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 CallHomeAuthProviderImpl method provideAuth.

@Override
public CallHomeAuthorization provideAuth(final SocketAddress remoteAddress, final PublicKey serverKey) {
    Device deviceSpecific = deviceConfig.get(serverKey);
    String sessionName;
    Credentials deviceCred;
    if (deviceSpecific != null) {
        sessionName = deviceSpecific.getUniqueId();
        if (deviceSpecific.getTransport() instanceof Ssh) {
            final SshClientParams clientParams = ((Ssh) deviceSpecific.getTransport()).getSshClientParams();
            deviceCred = clientParams.getCredentials();
        } else {
            deviceCred = deviceSpecific.getCredentials();
        }
    } else {
        String syntheticId = fromRemoteAddress(remoteAddress);
        if (globalConfig.allowedUnknownKeys()) {
            sessionName = syntheticId;
            deviceCred = null;
            statusReporter.asForceListedDevice(syntheticId, serverKey);
        } else {
            Device opDevice = deviceOp.get(serverKey);
            if (opDevice == null) {
                statusReporter.asUnlistedDevice(syntheticId, serverKey);
            } else {
                LOG.info("Repeating rejection of unlisted device with id of {}", opDevice.getUniqueId());
            }
            return CallHomeAuthorization.rejected();
        }
    }
    final Credentials credentials = deviceCred != null ? deviceCred : globalConfig.getCredentials();
    if (credentials == null) {
        LOG.info("No credentials found for {}, rejecting.", remoteAddress);
        return CallHomeAuthorization.rejected();
    }
    Builder authBuilder = CallHomeAuthorization.serverAccepted(sessionName, credentials.getUsername());
    for (String password : credentials.getPasswords()) {
        authBuilder.addPassword(password);
    }
    return authBuilder.build();
}
Also used : SshClientParams(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams) Device(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device) Builder(org.opendaylight.netconf.callhome.protocol.CallHomeAuthorization.Builder) Ssh(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.Ssh) Credentials(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.credentials.Credentials)

Example 10 with Credentials

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 CallhomeStatusReporter method newDevice.

private static Device newDevice(final String id, final PublicKey serverKey, final Device1.DeviceStatus status) {
    // used only for netconf devices that are connected via SSH transport and global credentials
    String sshEncodedKey = serverKey.toString();
    try {
        sshEncodedKey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
    } catch (IOException e) {
        LOG.warn("Unable to encode public key to ssh format.", e);
    }
    final SshClientParams sshParams = new SshClientParamsBuilder().setHostKey(sshEncodedKey).build();
    final Transport transport = new SshBuilder().setSshClientParams(sshParams).build();
    return new DeviceBuilder().setUniqueId(id).withKey(new DeviceKey(id)).setTransport(transport).addAugmentation(new Device1Builder().setDeviceStatus(status).build()).build();
}
Also used : DeviceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.DeviceBuilder) SshClientParams(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams) SshClientParamsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParamsBuilder) SshBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.SshBuilder) Device1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.callhome.device.status.rev170112.Device1Builder) IOException(java.io.IOException) DeviceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.DeviceKey) Transport(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport)

Aggregations

Credentials (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.Credentials)5 Test (org.junit.Test)4 Host (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host)4 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4 PortNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber)4 NetconfNode (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode)4 NetconfNodeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder)3 LoginPasswordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder)3 ProtocolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.parameters.ProtocolBuilder)2 LoginPw (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPw)2 LoginPwBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPwBuilder)2 LoginPasswordBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.login.pw.LoginPasswordBuilder)2 SshClientParams (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams)2 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)2 NodeBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 Builder (org.opendaylight.netconf.callhome.protocol.CallHomeAuthorization.Builder)1 DefaultSchemaResourceManager (org.opendaylight.netconf.sal.connect.impl.DefaultSchemaResourceManager)1