![JAR search and dependency download from the Maven repository](/logo.png)
protoj.util.ScpTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protoj-jdk6 Show documentation
Show all versions of protoj-jdk6 Show documentation
ProtoJ: the pure java build library with maximum dependencies
The newest version!
/**
* Copyright 2009 Ashley Williams
*
* Licensed under the Apache License, Version 2.0 (the "License"); you
* may not use this file except in compliance with the License. You may
* obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package protoj.util;
import java.io.File;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.optional.ssh.Scp;
/**
* A convenience class for performing a secure copy. Use the constructors to
* specify the minimal and most widely anticipated configuration and the
* initXXX
methods for the less common configuration options.
*
* @author Ashley Williams
*
*/
public final class ScpTask {
private AntTarget target = new AntTarget("protoj-task");
/**
* The underlying ant implementation.
*/
private Scp task;
/**
* Please consult the man page for task for information about these
* parameters.
*/
public ScpTask() {
task = new Scp();
task.setTaskName("task");
target.addTask(task);
task.setTrust(true);
}
/**
* Convenience method.
*
* @param localFile
* @param remoteToDir
*/
public void initCopyLocalToRemote(File localFile, String remoteToDir) {
task.setRemoteTodir(remoteToDir);
task.setLocalFile(localFile.getAbsolutePath());
}
/**
* Enables logging to the specified log file at Project.MSG_INFO level.
*/
public void initLogging() {
target.initLogging(Project.MSG_INFO);
}
/**
* Call this method to when using key authentication.
*
* @param passphrase
* @param keyFile
*/
public void initKeyAuthentication(String passphrase, String keyFile) {
task.setPassphrase(passphrase);
task.setKeyfile(keyFile);
}
/**
* Call this method when using simple password authentication.
*
* @param password
*/
public void initPasswordAuthentication(String password) {
task.setPassword(password);
}
/**
* The underlying ant task.
*
* @return
*/
public Scp getTask() {
return task;
}
public void execute() {
target.execute();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy