Package com.jcraft.jsch

Examples of com.jcraft.jsch.JSch.addIdentity()


        }

        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: {}", sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyPassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyPassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }
View Full Code Here


        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: {}", sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyPassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyPassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }

        if (sftpConfig.getPrivateKey() != null) {
            LOG.debug("Using private key information from byte array");
View Full Code Here

                    passphrase = sftpConfig.getPrivateKeyPassphrase().getBytes("UTF-8");
                } catch (UnsupportedEncodingException e) {
                    throw new JSchException("Cannot transform passphrase to byte[]", e);
                }
            }
            jsch.addIdentity("ID", sftpConfig.getPrivateKey(), null, passphrase);
        }

        if (sftpConfig.getPrivateKeyUri() != null) {
            LOG.debug("Using private key uri : {}", sftpConfig.getPrivateKeyUri());
            byte[] passphrase = null;
View Full Code Here

            }
            try {
                InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(endpoint.getCamelContext().getClassResolver(), sftpConfig.getPrivateKeyUri());
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                IOHelper.copyAndCloseInput(is, bos);
                jsch.addIdentity("ID", bos.toByteArray(), null, passphrase);
            } catch (IOException e) {
                throw new JSchException("Cannot read resource: " + sftpConfig.getPrivateKeyUri(), e);
            }
        }
View Full Code Here

        if (sftpConfig.getKeyPair() != null) {
            LOG.debug("Using private key information from key pair");
            KeyPair keyPair = sftpConfig.getKeyPair();
            if (keyPair.getPrivate() != null && keyPair.getPublic() != null) {
                if (keyPair.getPrivate() instanceof RSAPrivateKey && keyPair.getPublic() instanceof RSAPublicKey) {
                    jsch.addIdentity(new RSAKeyPairIdentity("ID", keyPair), null);
                } else if (keyPair.getPrivate() instanceof DSAPrivateKey && keyPair.getPublic() instanceof DSAPublicKey) {
                    jsch.addIdentity(new DSAKeyPairIdentity("ID", keyPair), null);
                } else {
                    LOG.warn("Only RSA and DSA key pairs are supported");
                }
View Full Code Here

            KeyPair keyPair = sftpConfig.getKeyPair();
            if (keyPair.getPrivate() != null && keyPair.getPublic() != null) {
                if (keyPair.getPrivate() instanceof RSAPrivateKey && keyPair.getPublic() instanceof RSAPublicKey) {
                    jsch.addIdentity(new RSAKeyPairIdentity("ID", keyPair), null);
                } else if (keyPair.getPrivate() instanceof DSAPrivateKey && keyPair.getPublic() instanceof DSAPublicKey) {
                    jsch.addIdentity(new DSAKeyPairIdentity("ID", keyPair), null);
                } else {
                    LOG.warn("Only RSA and DSA key pairs are supported");
                }
            } else {
                LOG.warn("PrivateKey and PublicKey in the KeyPair must be filled");
View Full Code Here

    private static Session openSession() throws JSchException {
        JSch jsch = new JSch();
        Session session = jsch.getSession("integration",
                "websphereportal8.devnet.vaadin.com", 22);
        jsch.addIdentity("~/.ssh/id_dsa");
        session.setConfig("StrictHostKeyChecking", "no");

        session.connect();
        return session;
    }
View Full Code Here

        }
        this.profile = profile;
        this.command = buildCommand(commandLineTokens, profile.getEnvironmentVariables());
        try {
            JSch jsch = new JSch();
            jsch.addIdentity(profile.getPrivateKey(), profile.getPassPhrase());
            session = jsch.getSession(profile.getUser(), profile.getHost(), profile.getPort());
            session.setConfig("StrictHostKeyChecking", "no");
            session.setServerAliveInterval((int) TimeUnit.SECONDS.toMillis(10));
            session.setTimeout((int) TimeUnit.SECONDS.toMillis(60));
View Full Code Here

            if (definition.getKnownHostPath() != null) {
                jsch.setKnownHosts(definition.getKnownHostPath());
            }

            if (definition.getPrivateKeyPath() != null) {
                jsch.addIdentity(definition.getPrivateKeyPath(), definition.getPrivateKeyPassphrase());
            }

            return processConnection(jsch, definition, nodeAddress, effectiveCommand);
        } catch (Exception e) {
            LOGGER.debug("Fail to execute command", e);
View Full Code Here

        }

        if (isNotEmpty(sftpConfig.getPrivateKeyFile())) {
            LOG.debug("Using private keyfile: {}", sftpConfig.getPrivateKeyFile());
            if (isNotEmpty(sftpConfig.getPrivateKeyPassphrase())) {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile(), sftpConfig.getPrivateKeyPassphrase());
            } else {
                jsch.addIdentity(sftpConfig.getPrivateKeyFile());
            }
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.