diff --git a/haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/HaaSClient.java b/haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/HaaSClient.java index 6303a27a2569911934467092ec5d4ae170a4c8d7..b6c011cf9a27809cfe3bee1b02da3a7c65bb3322 100644 --- a/haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/HaaSClient.java +++ b/haas-java-client/src/main/java/cz/it4i/fiji/haas_java_client/HaaSClient.java @@ -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); } } diff --git a/haas-java-client/src/test/java/cz/it4i/fiji/haas_java_client/TestHaaSJavaClient.java b/haas-java-client/src/test/java/cz/it4i/fiji/haas_java_client/TestHaaSJavaClient.java index a061a0d3b33baee0f216179d11c0d1416472a4ff..7e1ffaf0204d2e55c9c3dc02b2aca9a9cc3d7af9 100644 --- a/haas-java-client/src/test/java/cz/it4i/fiji/haas_java_client/TestHaaSJavaClient.java +++ b/haas-java-client/src/test/java/cz/it4i/fiji/haas_java_client/TestHaaSJavaClient.java @@ -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 { diff --git a/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/ByteIdentity.java b/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/ByteIdentity.java index 35ce918e2014cd2b584b745f76550d7ee409f143..f0e2b728afd0fc5577f63cbb475d72338e8c0259 100644 --- a/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/ByteIdentity.java +++ b/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/ByteIdentity.java @@ -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 diff --git a/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/IdentityFile.java b/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/IdentityFile.java index c9c4bb9a766eac42e6f63bab657ee1b8a81e536b..7d7e65a1b016100d6bce3c5874faceac992771fb 100644 --- a/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/IdentityFile.java +++ b/java-scpclient/src/main/java/cz/it4i/fiji/scpclient/IdentityFile.java @@ -1,105 +1,117 @@ 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; + } }