Skip to content
Snippets Groups Projects
Commit 1dc258d7 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

fixes for scp login

parent 0d4e75da
No related branches found
No related tags found
No related merge requests found
......@@ -176,8 +176,8 @@ public class HaaSClient {
try (ScpClient scpClient = getScpClient(ft)) {
for (String fileName : getFileTransfer().listChangedFilesForJob(jobId, getSessionID())) {
fileName=fileName.replaceAll("/", "");
Path rFile = workDirectory.resolve(fileName);
System.out.println("Downloading file: " + fileName);
scpClient.download(ft.getSharedBasepath() + "//" + fileName, rFile);
}
}
......
......@@ -2,7 +2,7 @@ package cz.it4i.fiji.haas_java_client;
import java.nio.file.Paths;
import java.rmi.RemoteException;
import java.util.Collections;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
......@@ -18,7 +18,7 @@ public class TestHaaSJavaClient {
Map<String, String> params = new HashMap<>();
params.put("inputParam", "someStringParam");
HaaSClient client = new HaaSClient(Paths.get("/home/koz01/aaa"));
long jobId = client.start(Collections.emptyList(), "TestOutRedirect", 1, params.entrySet());
long jobId = client.start(Arrays.asList(Paths.get("/home/koz01/aaa/vecmath.jar")), "TestOutRedirect", 1, params.entrySet());
JobInfo info;
do {
try {
......
......@@ -35,7 +35,12 @@ class ByteIdentity implements Identity{
@Override
public String getAlgName() {
return null;
if(keyPair.getKeyType() == KeyPair.RSA) {
return "ssh-rsa";
} else if(keyPair.getKeyType() == KeyPair.DSA) {
return "ssh-dsa";
}
throw new UnsupportedOperationException("Key type:" + keyPair.getKeyType() + " not supported.");
}
@Override
......
package cz.it4i.fiji.scpclient;
import com.jcraft.jsch.Identity;
import com.jcraft.jsch.IdentityRepository;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
class IdentityFile implements Identity{
private KeyPair kpair;
private String identity;
static IdentityFile newInstance(String prvfile, String pubfile, JSch jsch) throws JSchException{
KeyPair kpair = KeyPair.load(jsch, prvfile, pubfile);
return new IdentityFile(jsch, prvfile, kpair);
}
static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, JSch jsch) throws JSchException{
KeyPair kpair = KeyPair.load(jsch, prvkey, pubkey);
return new IdentityFile(jsch, name, kpair);
}
private IdentityFile(JSch jsch, String name, KeyPair kpair) throws JSchException{
this.identity = name;
this.kpair = kpair;
}
/**
* Decrypts this identity with the specified pass-phrase.
* @param passphrase the pass-phrase for this identity.
* @return <tt>true</tt> if the decryption is succeeded
* or this identity is not cyphered.
*/
public boolean setPassphrase(byte[] passphrase) throws JSchException{
return kpair.decrypt(passphrase);
}
/**
* Returns the public-key blob.
* @return the public-key blob
*/
public byte[] getPublicKeyBlob(){
return kpair.getPublicKeyBlob();
}
/**
* Signs on data with this identity, and returns the result.
* @param data data to be signed
* @return the signature
*/
public byte[] getSignature(byte[] data){
return kpair.getSignature(data);
}
/**
* @deprecated This method should not be invoked.
* @see #setPassphrase(byte[] passphrase)
*/
public boolean decrypt(){
throw new RuntimeException("not implemented");
}
/**
* Returns the name of the key algorithm.
* @return "ssh-rsa" or "ssh-dss"
*/
public String getAlgName(){
return new String("ssh-rsa");
}
/**
* Returns the name of this identity.
* It will be useful to identify this object in the {@link IdentityRepository}.
*/
public String getName(){
return identity;
}
/**
* Returns <tt>true</tt> if this identity is cyphered.
* @return <tt>true</tt> if this identity is cyphered.
*/
public boolean isEncrypted(){
return kpair.isEncrypted();
}
/**
* Disposes internally allocated data, like byte array for the private key.
*/
public void clear(){
kpair.dispose();
kpair = null;
}
/**
* Returns an instance of {@link KeyPair} used in this {@link Identity}.
* @return an instance of {@link KeyPair} used in this {@link Identity}.
*/
public KeyPair getKeyPair(){
return kpair;
}
class IdentityFile implements Identity {
private KeyPair kpair;
private String identity;
static IdentityFile newInstance(String prvfile, String pubfile, JSch jsch) throws JSchException {
KeyPair kpair = KeyPair.load(jsch, prvfile, pubfile);
return new IdentityFile(jsch, prvfile, kpair);
}
static IdentityFile newInstance(String name, byte[] prvkey, byte[] pubkey, JSch jsch) throws JSchException {
KeyPair kpair = KeyPair.load(jsch, prvkey, pubkey);
return new IdentityFile(jsch, name, kpair);
}
private IdentityFile(JSch jsch, String name, KeyPair kpair) throws JSchException {
this.identity = name;
this.kpair = kpair;
}
/**
* Decrypts this identity with the specified pass-phrase.
*
* @param passphrase
* the pass-phrase for this identity.
* @return <tt>true</tt> if the decryption is succeeded or this identity is not
* cyphered.
*/
public boolean setPassphrase(byte[] passphrase) throws JSchException {
return kpair.decrypt(passphrase);
}
/**
* Returns the public-key blob.
*
* @return the public-key blob
*/
public byte[] getPublicKeyBlob() {
return kpair.getPublicKeyBlob();
}
/**
* Signs on data with this identity, and returns the result.
*
* @param data
* data to be signed
* @return the signature
*/
public byte[] getSignature(byte[] data) {
return kpair.getSignature(data);
}
/**
* @deprecated This method should not be invoked.
* @see #setPassphrase(byte[] passphrase)
*/
public boolean decrypt() {
throw new RuntimeException("not implemented");
}
/**
* Returns the name of the key algorithm.
*
* @return "ssh-rsa" or "ssh-dss"
*/
public String getAlgName() {
if (kpair.getKeyType() == KeyPair.RSA) {
return "ssh-rsa";
} else if (kpair.getKeyType() == KeyPair.DSA) {
return "ssh-dsa";
}
throw new UnsupportedOperationException("Key type:" + kpair.getKeyType() + " not supported.");
}
/**
* Returns the name of this identity. It will be useful to identify this object
* in the {@link IdentityRepository}.
*/
public String getName() {
return identity;
}
/**
* Returns <tt>true</tt> if this identity is cyphered.
*
* @return <tt>true</tt> if this identity is cyphered.
*/
public boolean isEncrypted() {
return kpair.isEncrypted();
}
/**
* Disposes internally allocated data, like byte array for the private key.
*/
public void clear() {
kpair.dispose();
kpair = null;
}
/**
* Returns an instance of {@link KeyPair} used in this {@link Identity}.
*
* @return an instance of {@link KeyPair} used in this {@link Identity}.
*/
public KeyPair getKeyPair() {
return kpair;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment