@Test public void establishPrivateKeyFileWithPassword() throws JSchException { RemoteSecureCopyInputs remoteSecureCopyInputs = getRemoteSecureCopyInputs(); remoteSecureCopyInputs.setSrcPassword(SRC_PASS); scpCopier = new SCPCopier(remoteSecureCopyInputs); scpCopier.establishPrivateKeyFile(null, jSchMock, sessionMock, true); verify(sessionMock).setPassword(remoteSecureCopyInputs.getSrcPassword()); }
protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) throws JSchException { if (keyFile == null) { if (usesSrcPrivateKeyFile){ session.setPassword(remoteSecureCopyInputs.getSrcPassword()); } else{ session.setPassword(remoteSecureCopyInputs.getDestPassword()); } } else { String keyFilePath = keyFile.getKeyFilePath(); String passPhrase = keyFile.getPassPhrase(); if (passPhrase != null){ jsch.addIdentity(keyFilePath, passPhrase); } else { jsch.addIdentity(keyFilePath); } } }
SCPCopier { protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) throws JSchException { if (keyFile == null) { if (usesSrcPrivateKeyFile){ session.setPassword(remoteSecureCopyInputs.getSrcPassword()); } else{ session.setPassword(remoteSecureCopyInputs.getDestPassword()); } } else { String keyFilePath = keyFile.getKeyFilePath(); String passPhrase = keyFile.getPassPhrase(); if (passPhrase != null){ jsch.addIdentity(keyFilePath, passPhrase); } else { jsch.addIdentity(keyFilePath); } } } }
SCPCopier { protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) throws JSchException { if (keyFile == null) { if (usesSrcPrivateKeyFile){ session.setPassword(remoteSecureCopyInputs.getSrcPassword()); } else{ session.setPassword(remoteSecureCopyInputs.getDestPassword()); } } else { String keyFilePath = keyFile.getKeyFilePath(); String passPhrase = keyFile.getPassPhrase(); if (passPhrase != null){ jsch.addIdentity(keyFilePath, passPhrase); } else { jsch.addIdentity(keyFilePath); } } } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); }
SCPCopier { protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) throws JSchException { if (keyFile == null) { if (usesSrcPrivateKeyFile){ session.setPassword(remoteSecureCopyInputs.getSrcPassword()); } else{ session.setPassword(remoteSecureCopyInputs.getDestPassword()); } } else { String keyFilePath = keyFile.getKeyFilePath(); String passPhrase = keyFile.getPassPhrase(); if (passPhrase != null){ jsch.addIdentity(keyFilePath, passPhrase); } else { jsch.addIdentity(keyFilePath); } } } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); boolean copyFromRemoteToRemote(); boolean copyFromLocalToRemote(); boolean copyFromRemoteToLocal(); }
SCPCopier { protected void establishPrivateKeyFile(KeyFile keyFile, JSch jsch, Session session, boolean usesSrcPrivateKeyFile) throws JSchException { if (keyFile == null) { if (usesSrcPrivateKeyFile){ session.setPassword(remoteSecureCopyInputs.getSrcPassword()); } else{ session.setPassword(remoteSecureCopyInputs.getDestPassword()); } } else { String keyFilePath = keyFile.getKeyFilePath(); String passPhrase = keyFile.getPassPhrase(); if (passPhrase != null){ jsch.addIdentity(keyFilePath, passPhrase); } else { jsch.addIdentity(keyFilePath); } } } SCPCopier(RemoteSecureCopyInputs remoteSecureCopyInputs); boolean copyFromRemoteToRemote(); boolean copyFromLocalToRemote(); boolean copyFromRemoteToLocal();  }