@Override public void copy(InputStream input, String targetPath, String targetName, long size, int permission, @Nullable Long lastAccessTime, @Nullable Long lastModifiedTime) throws IOException { getDelegate().copy(input, targetPath, targetName, size, permission, lastAccessTime, lastModifiedTime); }
@Override public void copy(InputStream input, String targetPath, String targetName, long size, int permission, @Nullable Long lastAccessTime, @Nullable Long lastModifiedTime) throws IOException { getDelegate().copy(input, targetPath, targetName, size, permission, lastAccessTime, lastModifiedTime); }
@Override public void copy(Path sourceFile, String targetPath) throws IOException { getDelegate().copy(sourceFile, targetPath); }
@Override public void copy(Path sourceFile, String targetPath) throws IOException { getDelegate().copy(sourceFile, targetPath); }
/** * Localize key store files to the remote host. */ private void localizeKeyStores(SSHSession session, String targetPath) throws Exception { // Copy the server keystore for the runtime monitor server ByteArrayOutputStream bos = new ByteArrayOutputStream(); serverKeyStore.store(bos, "".toCharArray()); //noinspection OctalInteger session.copy(new ByteArrayInputStream(bos.toByteArray()), targetPath, co.cask.cdap.common.conf.Constants.RuntimeMonitor.SERVER_KEYSTORE, bos.size(), 0600, null, null); // Creates a trust store from the client keystore KeyStore trustStore = KeyStores.createTrustStore(clientKeyStore); // Copy the trust store for the runtime monitor server to use for verifying client connections bos.reset(); trustStore.store(bos, "".toCharArray()); //noinspection OctalInteger session.copy(new ByteArrayInputStream(bos.toByteArray()), targetPath, co.cask.cdap.common.conf.Constants.RuntimeMonitor.CLIENT_KEYSTORE, bos.size(), 0600, null, null); } }
/** * Localize key store files to the remote host. */ private void localizeKeyStores(SSHSession session, String targetPath) throws Exception { // Copy the server keystore for the runtime monitor server ByteArrayOutputStream bos = new ByteArrayOutputStream(); serverKeyStore.store(bos, "".toCharArray()); //noinspection OctalInteger session.copy(new ByteArrayInputStream(bos.toByteArray()), targetPath, co.cask.cdap.common.conf.Constants.RuntimeMonitor.SERVER_KEYSTORE, bos.size(), 0600, null, null); // Creates a trust store from the client keystore KeyStore trustStore = KeyStores.createTrustStore(clientKeyStore); // Copy the trust store for the runtime monitor server to use for verifying client connections bos.reset(); trustStore.store(bos, "".toCharArray()); //noinspection OctalInteger session.copy(new ByteArrayInputStream(bos.toByteArray()), targetPath, co.cask.cdap.common.conf.Constants.RuntimeMonitor.CLIENT_KEYSTORE, bos.size(), 0600, null, null); } }
LOG.debug("Upload file {} to {}@{}:{}", uri, session.getUsername(), session.getAddress(), localizedFile); session.copy(inputStream, localizedDir, fileName, localFile.getSize(), 0644, localFile.getLastModified(), localFile.getLastModified());
LOG.debug("Upload file {} to {}@{}:{}", uri, session.getUsername(), session.getAddress(), localizedFile); session.copy(inputStream, localizedDir, fileName, localFile.getSize(), 0644, localFile.getLastModified(), localFile.getLastModified());
@Test public void testScp() throws Exception { SSHConfig config = getSSHConfig(); // Generate some content File file = TEMP_FOLDER.newFile(); try (BufferedWriter writer = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { for (int i = 0; i < 10; i++) { writer.write("Message " + i); writer.newLine(); } } // SCP the file to the given directory File targetFolder = TEMP_FOLDER.newFolder(); try (SSHSession session = new DefaultSSHSession(config)) { session.copy(file.toPath(), targetFolder.getAbsolutePath()); } // Verify File uploadedFile = new File(targetFolder, file.getName()); Assert.assertTrue(uploadedFile.exists()); Assert.assertArrayEquals(Files.readAllBytes(file.toPath()), Files.readAllBytes(uploadedFile.toPath())); }
runnableName, memory).getBytes(StandardCharsets.UTF_8); session.copy(new ByteArrayInputStream(scriptContent), targetPath, "launcher.sh", scriptContent.length, 0755, null, null);
runnableName, memory).getBytes(StandardCharsets.UTF_8); session.copy(new ByteArrayInputStream(scriptContent), targetPath, "launcher.sh", scriptContent.length, 0755, null, null);