http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/GlobusTlsClient.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/GlobusTlsClient.java b/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/GlobusTlsClient.java deleted file mode 100644 index 0b91af8..0000000 --- a/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/GlobusTlsClient.java +++ /dev/null @@ -1,247 +0,0 @@ -///* -// * -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you 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 edu.illinois.ncsa.BCGSS; -// -////import edu.illinois.ncsa.bouncycastle.crypto.tls.*; -////import edu.illinois.ncsa.bouncycastle.asn1.*; -////import edu.illinois.ncsa.bouncycastle.asn1.x509.*; -//import org.globus.common.CoGProperties; -//import org.globus.gsi.CredentialException; -//import org.globus.gsi.X509Credential; -//import org.globus.gsi.X509ProxyCertPathParameters; -//import org.globus.gsi.provider.GlobusProvider; -//import org.globus.gsi.provider.KeyStoreParametersFactory; -//import org.globus.gsi.stores.ResourceCertStoreParameters; -//import org.globus.gsi.stores.ResourceSigningPolicyStore; -//import org.globus.gsi.stores.ResourceSigningPolicyStoreParameters; -//import org.globus.gsi.trustmanager.X509ProxyCertPathValidator; -//import org.globus.gsi.util.CertificateUtil; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -//import javax.crypto.Cipher; -//import java.io.ByteArrayInputStream; -//import java.io.IOException; -//import java.io.InputStream; -//import java.security.KeyStore; -//import java.security.PrivateKey; -//import java.security.cert.CertStore; -//import java.security.cert.CertificateException; -//import java.security.cert.CertificateFactory; -//import java.security.cert.X509Certificate; -// -//public class GlobusTlsClient extends DefaultTlsClient -//{ -// private Certificate clientCert = new Certificate(new X509CertificateStructure[0]); -// private PrivateKey clientPrivateKey = null; -// private X509Certificate[] peerCerts = null; -// private static final Logger logger = LoggerFactory.getLogger(GlobusTlsClient.class); -// -// public X509Certificate[] getPeerCerts() { -// return peerCerts; -// } -// -// public GlobusTlsClient(X509Credential cred, GlobusTlsCipherFactory factory) -// throws IOException, CertificateException, CredentialException { -// super(factory); -// if (cred == null) { -// throw new IllegalArgumentException("'cred' cannot be null"); -// } -// -// clientCert = new Certificate( -// X509CertArrayToStructArray(cred.getCertificateChain())); -// clientPrivateKey = cred.getPrivateKey(); -// -// if (clientCert.getCerts().length == 0) { -// throw new IllegalArgumentException( -// "'cred' contains no certificates"); -// } -// -// if (clientPrivateKey == null) { -// throw new IllegalArgumentException("'clientPrivateKey' cannot be null"); -// } -// } -// -// public TlsAuthentication getAuthentication() throws IOException { -// return new GlobusTlsAuth(); -// } -// -// public int[] getCipherSuites() { -// return new int[] { -// CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA, -// CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA, -// CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA, -// }; -// } -// -// public class GlobusTlsAuth implements TlsAuthentication { -// -// /** -// * Validates the server's certificate -// * @param certificate received from server -// * @throws IOException -// */ -// public void notifyServerCertificate(Certificate certificate) -// throws IOException { -// try { -// peerCerts = X509CertStructArrayToCertArray(certificate.getCerts()); -// -// String caCertsLocation = -// "file:" + CoGProperties.getDefault().getCaCertLocations(); -// String crlPattern = caCertsLocation + "/*.r*"; -// String sigPolPattern = caCertsLocation + "/*.signing_policy"; -// -// KeyStore keyStore = KeyStore.getInstance( -// GlobusProvider.KEYSTORE_TYPE, GlobusProvider.PROVIDER_NAME); -// CertStore crlStore = CertStore.getInstance( -// GlobusProvider.CERTSTORE_TYPE, -// new ResourceCertStoreParameters(null, crlPattern)); -// ResourceSigningPolicyStore sigPolStore = -// new ResourceSigningPolicyStore( -// new ResourceSigningPolicyStoreParameters( -// sigPolPattern)); -// keyStore.load( -// KeyStoreParametersFactory.createTrustStoreParameters( -// caCertsLocation)); -// X509ProxyCertPathParameters parameters = -// new X509ProxyCertPathParameters(keyStore, crlStore, -// sigPolStore, false); -// X509ProxyCertPathValidator validator = -// new X509ProxyCertPathValidator(); -// if (validator.engineValidate(CertificateUtil.getCertPath(peerCerts), -// parameters) == null) { -// throw new Exception("X509ProxyCertPathValidator did not return a result"); -// } -// } catch (Exception e) { -// logger.error(e.getMessage(), e); -// throw new TlsFatalAlert(AlertDescription.user_canceled); -// } -// } -// -// /** -// * Returns an object representing the client's credentials -// * @param request -// * @return the client's credentials -// * @throws IOException -// */ -// public TlsCredentials getClientCredentials(CertificateRequest request) -// throws IOException { -// return new GlobusTlsCred(); -// } -// } -// -// public class GlobusTlsCred implements TlsSignerCredentials { -// /** -// * Encrypts a hash with the client's private key, producing a signature -// * @param md5andsha1 the hash to encrypt -// * @return an array of bytes containing the signature -// * @throws IOException -// */ -// public byte[] generateCertificateSignature(byte[] md5andsha1) -// throws IOException { -// // encrypt the input hash with the private key to produce signature -// try { -// Cipher cipher = Cipher.getInstance(clientPrivateKey.getAlgorithm()); -// cipher.init(Cipher.ENCRYPT_MODE, clientPrivateKey); -// return cipher.doFinal(md5andsha1); -// } catch (Exception e) { -// logger.error(e.getMessage(), e); -// throw new IOException(e); -// } -// } -// -// public Certificate getCertificate() { -// return clientCert; -// } -// } -// -// /** -// * -// * @param struct -// * @return -// * @throws CertificateException -// * @throws IOException -// */ -// public static X509Certificate X509CertStructToCert( -// X509CertificateStructure struct) throws CertificateException, -// IOException { -// CertificateFactory cf = CertificateFactory.getInstance("X.509"); -// InputStream is = new ByteArrayInputStream(struct.getEncoded()); -// X509Certificate cert = (X509Certificate) cf.generateCertificate(is); -// is.close(); -// return cert; -// } -// -// /** -// * -// * @param structs -// * @return -// * @throws java.io.IOException -// * @throws java.security.cert.CertificateException -// */ -// public static X509Certificate[] X509CertStructArrayToCertArray( -// X509CertificateStructure[] structs) throws IOException, -// CertificateException { -// X509Certificate[] certChain = new X509Certificate[structs.length]; -// -// for (int i = 0; i < structs.length; ++i) { -// certChain[i] = X509CertStructToCert(structs[i]); -// } -// -// return certChain; -// } -// -// /** -// * -// * @param c -// * @return -// * @throws CertificateException -// * @throws IOException -// */ -// public static X509CertificateStructure X509CertToStruct(X509Certificate c) -// throws CertificateException, IOException { -// ASN1InputStream is = new ASN1InputStream(c.getEncoded()); -// DERObject o = is.readObject(); -// return X509CertificateStructure.getInstance(o); -// } -// -// -// /** -// * -// * @param certs -// * @return -// * @throws CertificateException -// * @throws IOException -// */ -// public static X509CertificateStructure[] X509CertArrayToStructArray( -// X509Certificate[] certs) throws CertificateException, IOException { -// X509CertificateStructure[] structs = -// new X509CertificateStructure[certs.length]; -// -// for (int i = 0; i < certs.length; ++i) { -// structs[i] = X509CertToStruct(certs[i]); -// } -// -// return structs; -// } -//} -//
http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/TlsHandlerUtil.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/TlsHandlerUtil.java b/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/TlsHandlerUtil.java deleted file mode 100644 index 36eec77..0000000 --- a/tools/gsissh/src/main/java/edu/illinois/ncsa/BCGSS/TlsHandlerUtil.java +++ /dev/null @@ -1,282 +0,0 @@ -///* -// * -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you 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 edu.illinois.ncsa.BCGSS; -////import edu.illinois.ncsa.bouncycastle.crypto.tls.*; -// -//import java.io.*; -// -//public class TlsHandlerUtil { -// private TlsProtocolHandler tlsHandler; -// private TlsClient tlsClient; -// private CircularByteBuffer netInStream; -// private ByteArrayOutputStream netOutStream; -// private boolean connectionThreadStarted = false; -// private IOException connectionThreadException = null; -// -// /* -// public TlsHandlerUtil(TlsClient client) { -// this(client, new TlsProtocolVersion[] {TlsProtocolVersion.TLSv10, -// TlsProtocolVersion.SSLv3}); -// } -// */ -// -// //public TlsHandlerUtil(TlsClient client, TlsProtocolVersion[] protocols) { -// public TlsHandlerUtil(TlsClient client) { -// this.tlsClient = client; -// -// this.netInStream = new CircularByteBuffer( -// CircularByteBuffer.INFINITE_SIZE); -// -// //TODO: set a good initial size of buffer? -// this.netOutStream = new ByteArrayOutputStream(); -// -// this.tlsHandler = new TlsProtocolHandler( -// netInStream.getInputStream(), netOutStream); -// //this.tlsHandler.setEnabledProtocols(protocols); -// } -// -// /** -// * -// * @param inNetBuf -// * @return -// */ -// public byte[] nextHandshakeToken(byte[] inNetBuf) throws IOException { -// return nextHandshakeToken(inNetBuf, 0, inNetBuf.length); -// } -// -// /** -// * -// * @param inNetBuf -// * @param off -// * @param len -// * @return -// * @throws java.io.IOException -// */ -// public byte[] nextHandshakeToken(byte[] inNetBuf, int off, int len) -// throws IOException { -// if (isHandshakeFinished()) { -// return null; -// } -// -// if (! isConnectionThreadStarted()) { -// (new ConnectionThread()).start(); -// } -// -// -// if (tlsHandler.getHandshakeBlocking() > 0) { -// tlsHandler.decHandshakeBlocking(inNetBuf.length); -// } -// -// netInStream.getOutputStream().write(inNetBuf, off, len); -// -// // block until the TlsProtocolHandler's record stream blocks -// // or until the handshake is finished. After either, a handshake -// // token may have been produced -// while (tlsHandler.getHandshakeBlocking() == 0 && -// ! isHandshakeFinished()) { -// -// IOException e = getConnectionThreadException(); -// if (e != null) { -// throw new IOException("TLS connection thread exception", e); -// } -// -// try { -// Thread.sleep(25); -// } catch (InterruptedException e1) { -// throw new IOException("Handshake interrupted while waiting " + -// "for new network data to be processed", e1); -// } -// } -// -// byte[] token = drainNetOutStream(); -// -// if (token.length > 0) { -// return token; -// } -// -// if (tlsHandler.getHandshakeBlocking() > 0) { -// // no token produced; need more data -// return null; -// } -// -// if (isHandshakeFinished()) { -// return null; -// } else { -// throw new IOException("No handshake data available, but the " + -// "record stream is not blocking and wasn't interrupted"); -// } -// } -// -// /** -// * -// * @param appData -// * @return -// * @throws IOException -// */ -// public byte[] wrap(byte[] appData) throws IOException { -// return wrap(appData, 0, appData.length); -// } -// -// /** -// * -// * @param appData -// * @param off -// * @param len -// * @return -// * @throws IOException -// */ -// public byte[] wrap(byte[] appData, int off, int len) throws IOException { -// if (! isHandshakeFinished()) { -// return null; -// } -// -// tlsHandler.getOutputStream().write(appData, off, len); -// return drainNetOutStream(); -// } -// -// /** -// * -// * @param netData -// * @return -// * @throws IOException -// */ -// public byte[] unwrap(byte[] netData) throws IOException { -// return unwrap(netData, 0, netData.length); -// } -// -// /** -// * -// * @param netData -// * @param off -// * @param len -// * @return -// * @throws IOException -// */ -// public byte[] unwrap(byte[] netData, int off, int len) throws IOException { -// if (! isHandshakeFinished()) { -// return null; -// } -// -// if (netData.length == 0) { -// return null; -// } -// -// netInStream.getOutputStream().write(netData, off, len); -// -// // Force the record to be processed in order to put an unknown -// // amount of data in the application queue. It's assumed that -// // the netData parameter is a full SSL record; if it's not, then -// // this method will block indefinitely -// byte[] tmp = new byte[1]; -// tlsHandler.getInputStream().read(tmp, 0, 1); -// -// int avail = tlsHandler.getApplicationDataQueueSize(); -// -// if (avail == 0) { -// return tmp; -// } -// -// byte[] appBuf = new byte[avail + 1]; -// appBuf[0] = tmp[0]; -// tlsHandler.getInputStream().read(appBuf, 1, avail); -// -// return appBuf; -// } -// -// /** -// * -// * @return -// * @throws java.io.IOException -// */ -// public byte[] close() throws IOException { -// tlsHandler.close(); -// return drainNetOutStream(); -// } -// -// /** -// * -// * @return -// */ -// public boolean isHandshakeFinished() { -// return this.tlsHandler.isHandshakeFinished(); -// } -// -// /** -// * -// * @return -// */ -// private byte[] drainNetOutStream() { -// byte[] rval = netOutStream.toByteArray(); -// netOutStream.reset(); -// return rval; -// } -// -// /** -// * -// * @param b -// */ -// private synchronized void setConnectionThreadStarted(boolean b) { -// connectionThreadStarted = b; -// } -// -// /** -// * -// * @return -// */ -// private synchronized boolean isConnectionThreadStarted() { -// return connectionThreadStarted; -// } -// -// /** -// * -// * @return -// */ -// private IOException getConnectionThreadException() { -// return connectionThreadException; -// } -// -// /** -// * -// * @param e -// */ -// private void setConnectionThreadException(IOException e) { -// this.connectionThreadException = e; -// } -// -// /** -// * -// */ -// private class ConnectionThread extends Thread { -// /** -// * -// */ -// public void run() { -// setConnectionThreadStarted(true); -// try { -// tlsHandler.connect(tlsClient); -// } catch (IOException e) { -// setConnectionThreadException(e); -// } -// //System.out.println("TLS connection thread done"); -// } -// } -//} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java deleted file mode 100644 index 1c07a39..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh; - - -import java.io.File; -import java.io.FileInputStream; -import java.net.InetAddress; -import java.net.UnknownHostException; - -import org.globus.common.CoGProperties; -import org.globus.gsi.gssapi.auth.HostAuthorization; -import org.gridforum.jgss.ExtendedGSSCredential; -import org.gridforum.jgss.ExtendedGSSManager; -import org.ietf.jgss.GSSContext; -import org.ietf.jgss.GSSCredential; -import org.ietf.jgss.GSSException; -import org.ietf.jgss.GSSName; -import org.ietf.jgss.MessageProp; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.jcraft.jsch.JSchException; - -/** - * This class is based on GSSContextKrb5; it substitutes the globus - * ExtendedGSSManager and uses the SecurityUtils method to get the credential if - * one is not passed in from memory. - * - */ -public class GSSContextX509 implements com.jcraft.jsch.GSSContext { - - private GSSContext context = null; - private GSSCredential credential; - private static final Logger logger = LoggerFactory.getLogger(GSSContextX509.class); - - public void create(String user, String host) throws JSchException { - try { -// ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance(); - - if (credential == null) { - try { - credential = getCredential(); - } catch (SecurityException t) { - System.out.printf("Could not get proxy: %s: %s\n", t.getClass().getSimpleName(), t.getMessage()); - throw new JSchException(t.toString()); - } - } - - String cname = host; - - try { - cname = InetAddress.getByName(cname).getCanonicalHostName(); - } catch (UnknownHostException e) { - } - - GSSName name = HostAuthorization.getInstance().getExpectedName(credential, cname); - -// context = manager.createContext(name, null, credential, GSSContext.DEFAULT_LIFETIME); -// -// // RFC4462 3.4. GSS-API Session -// // -// // When calling GSS_Init_sec_context(), the client MUST set -// // integ_req_flag to "true" to request that per-message integrity -// // protection be supported for this context. In addition, -// // deleg_req_flag MAY be set to "true" to request access delegation, -// // if -// // requested by the user. -// // -// // Since the user authentication process by its nature authenticates -// // only the client, the setting of mutual_req_flag is not needed for -// // this process. This flag SHOULD be set to "false". -// -// // TODO: OpenSSH's sshd does accept 'false' for mutual_req_flag -// // context.requestMutualAuth(false); -// context.requestMutualAuth(true); -// context.requestConf(true); -// context.requestInteg(true); // for MIC -// context.requestCredDeleg(true); -// context.requestAnonymity(false); - -// context = new BCGSSContextImpl(name, (GlobusGSSCredentialImpl) credential); -// context.requestLifetime(GSSCredential.DEFAULT_LIFETIME); -// context.requestCredDeleg(true); -// context.requestMutualAuth(true); -// context.requestReplayDet(true); -// context.requestSequenceDet(true); -// context.requestConf(false); -// context.requestInteg(true); -// ((ExtendedGSSContext)context).setOption(GSSConstants.DELEGATION_TYPE, GSIConstants.DELEGATION_TYPE_FULL); - - return; - } catch (GSSException ex) { - throw new JSchException(ex.toString()); - } - } - - private static GSSCredential getProxy() { - return getProxy(null, GSSCredential.DEFAULT_LIFETIME); - } - - /** - * @param x509_USER_PROXY - * path to the proxy. - * @param credentialLifetime - * in seconds. - * @return valid credential. - * if proxy task throws exception (or if proxy cannot be found). - */ - private static GSSCredential getProxy(String x509_USER_PROXY, int credentialLifetime) throws SecurityException { - if (x509_USER_PROXY == null) - x509_USER_PROXY = System.getProperty("x509.user.proxy"); - -// if (x509_USER_PROXY == null) { -// SystemUtils.envToProperties(); -// x509_USER_PROXY = System.getProperty("x509.user.proxy"); -// } - - if (x509_USER_PROXY == null || "".equals(x509_USER_PROXY)) - x509_USER_PROXY = CoGProperties.getDefault().getProxyFile(); - - if (x509_USER_PROXY == null) - throw new SecurityException("could not get credential; no location defined"); - - ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance(); - - // file...load file into a buffer - try { - File f = new File(x509_USER_PROXY); - byte[] data = new byte[(int) f.length()]; - FileInputStream in = new FileInputStream(f); - // read in the credential data - in.read(data); - in.close(); - return manager.createCredential(data, ExtendedGSSCredential.IMPEXP_OPAQUE, credentialLifetime, null, // use - // default - // mechanism - // - - // GSI - GSSCredential.INITIATE_AND_ACCEPT); - } catch (Throwable t) { - throw new SecurityException("could not get credential from " + x509_USER_PROXY, t); - } - } - - public boolean isEstablished() { - // this must check to see if the call returned GSS_S_COMPLETE - if (context != null){ - return context.isEstablished(); - } - return false; - } - - public byte[] init(byte[] token, int s, int l) throws JSchException { - try { - if (context != null){ - return context.initSecContext(token, s, l); - }else { - throw new JSchException("Context is null.."); - } - } catch (GSSException ex) { - throw new JSchException(ex.toString()); - } - } - - public byte[] getMIC(byte[] message, int s, int l) { - try { - MessageProp prop = new MessageProp(0, false); - return context.getMIC(message, s, l, prop); - } catch (GSSException ex) { - logger.error(ex.getMessage(), ex); - return null; - } - } - - public void dispose() { - try { - context.dispose(); - } catch (GSSException ex) { - } - } - - public void setCredential(GSSCredential credential) { - this.credential = credential; - } - - public GSSCredential getCredential() { - return credential; - } -} - http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java deleted file mode 100644 index beb5b37..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Cluster.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api; - -import java.util.List; -import java.util.Map; - -import org.apache.airavata.gfac.ssh.api.job.JobDescriptor; -import org.apache.airavata.gfac.ssh.impl.JobStatus; - -import com.jcraft.jsch.Session; - -/** - * This interface represents a Cluster machine - * End users of the API can implement this and come up with their own - * implementations, but mostly this interface is for internal usage. - */ -public interface Cluster { - - /** - * This will submit a job to the cluster with a given pbs file and some parameters - * - * @param pbsFilePath path of the pbs file - * @param workingDirectory working directory where pbs should has to copy - * @return jobId after successful job submission - * @throws SSHApiException throws exception during error - */ - public String submitBatchJobWithScript(String pbsFilePath, String workingDirectory) throws SSHApiException; - - /** - * This will submit the given job and not performing any monitoring - * - * @param jobDescriptor job descriptor to submit to cluster, this contains all the parameter - * @return jobID after successful job submission. - * @throws SSHApiException throws exception during error - */ - public String submitBatchJob(JobDescriptor jobDescriptor) throws SSHApiException; - - /** - * This will copy the localFile to remoteFile location in configured cluster - * - * @param remoteFile remote file location, this can be a directory too - * @param localFile local file path of the file which needs to copy to remote location - * @throws SSHApiException throws exception during error - */ - public void scpTo(String remoteFile, String localFile) throws SSHApiException; - - /** - * This will copy a remote file in path rFile to local file lFile - * @param remoteFile remote file path, this has to be a full qualified path - * @param localFile This is the local file to copy, this can be a directory too - * @throws SSHApiException - */ - public void scpFrom(String remoteFile, String localFile) throws SSHApiException; - - /** - * This will copy a remote file in path rFile to local file lFile - * @param remoteFile remote file path, this has to be a full qualified path - * @param localFile This is the local file to copy, this can be a directory too - * @throws SSHApiException - */ - public void scpThirdParty(String remoteFileSorce, String remoteFileTarget) throws SSHApiException; - - /** - * This will create directories in computing resources - * @param directoryPath the full qualified path for the directory user wants to create - * @throws SSHApiException throws during error - */ - public void makeDirectory(String directoryPath) throws SSHApiException; - - - /** - * This will get the job description of a job which is there in the cluster - * if jbo is not available with the given ID it returns - * @param jobID jobId has to pass - * @return Returns full job description of the job which submitted successfully - * @throws SSHApiException throws exception during error - */ - public JobDescriptor getJobDescriptorById(String jobID) throws SSHApiException; - - /** - * This will delete the given job from the queue - * - * @param jobID jobId of the job which user wants to delete - * @return return the description of the deleted job - * @throws SSHApiException throws exception during error - */ - public JobDescriptor cancelJob(String jobID) throws SSHApiException; - - /** - * This will get the job status of the the job associated with this jobId - * - * @param jobID jobId of the job user want to get the status - * @return job status of the given jobID - * @throws SSHApiException throws exception during error - */ - public JobStatus getJobStatus(String jobID) throws SSHApiException; - /** - * This will get the job status of the the job associated with this jobId - * - * @param jobName jobName of the job user want to get the status - * @return jobId of the given jobName - * @throws SSHApiException throws exception during error - */ - public String getJobIdByJobName(String jobName, String userName) throws SSHApiException; - - /** - * This method can be used to poll the jobstatuses based on the given - * user but we should pass the jobID list otherwise we will get unwanted - * job statuses which submitted by different middleware outside apache - * airavata with the same uername which we are not considering - * @param userName userName of the jobs which required to get the status - * @param jobIDs precises set of jobIDs - * @return - */ - public void getJobStatuses(String userName,Map<String,JobStatus> jobIDs)throws SSHApiException; - /** - * This will list directories in computing resources - * @param directoryPath the full qualified path for the directory user wants to create - * @throws SSHApiException throws during error - */ - public List<String> listDirectory(String directoryPath) throws SSHApiException; - - /** - * This method can be used to get created ssh session - * to reuse the created session. - * @throws SSHApiException - */ - public Session getSession() throws SSHApiException; - - /** - * This method can be used to close the connections initialized - * to handle graceful shutdown of the system - * @throws SSHApiException - */ - public void disconnect() throws SSHApiException; - - /** - * This gives the server Info - * @return - */ - public ServerInfo getServerInfo(); - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java deleted file mode 100644 index 024c53d..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api; - -import com.jcraft.jsch.*; -import org.apache.airavata.gfac.ssh.api.authentication.*; -import org.apache.airavata.gfac.ssh.config.ConfigReader; -import org.apache.airavata.gfac.ssh.jsch.ExtendedJSch; -import org.apache.airavata.gfac.ssh.util.SSHAPIUIKeyboardInteractive; -import org.apache.airavata.gfac.ssh.util.SSHKeyPasswordHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * This is a generic class which take care of command execution - * in a shell, this is used through out the other places of the API. - */ -public class CommandExecutor { - static { - JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gfac.ssh.GSSContextX509"); - JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials"); - JSch jSch = new JSch(); - } - - private static final Logger log = LoggerFactory.getLogger(CommandExecutor.class); - public static final String X509_CERT_DIR = "X509_CERT_DIR"; - - /** - * This will execute the given command with given session and session is not closed at the end. - * - * @param commandInfo - * @param session - * @param commandOutput - * @throws SSHApiException - */ - public static Session executeCommand(CommandInfo commandInfo, Session session, - CommandOutput commandOutput) throws SSHApiException { - - String command = commandInfo.getCommand(); - - Channel channel = null; - try { - if (!session.isConnected()) { - session.connect(); - } - channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - } catch (JSchException e) { -// session.disconnect(); - - throw new SSHApiException("Unable to execute command - ", e); - } - - channel.setInputStream(null); - ((ChannelExec) channel).setErrStream(commandOutput.getStandardError()); - try { - channel.connect(); - } catch (JSchException e) { - - channel.disconnect(); -// session.disconnect(); - throw new SSHApiException("Unable to retrieve command output. Command - " + command, e); - } - - - commandOutput.onOutput(channel); - //Only disconnecting the channel, session can be reused - channel.disconnect(); - return session; - } - - /** - * This will not reuse any session, it will create the session and close it at the end - * - * @param commandInfo Encapsulated information about command. E.g :- executable name - * parameters etc ... - * @param serverInfo The SSHing server information. - * @param authenticationInfo Security data needs to be communicated with remote server. - * @param commandOutput The output of the command. - * @param configReader configuration required for ssh/gshissh connection - * @throws SSHApiException throw exception when error occurs - */ - public static void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo, - AuthenticationInfo authenticationInfo, - CommandOutput commandOutput, ConfigReader configReader) throws SSHApiException { - - if (authenticationInfo instanceof GSIAuthenticationInfo) { - System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties(). - get("X509_CERT_DIR")); - } - - - JSch jsch = new ExtendedJSch(); - - log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - " - + serverInfo.getUserName()); - - Session session; - - try { - session = jsch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort()); - } catch (JSchException e) { - throw new SSHApiException("An exception occurred while creating SSH session." + - "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName(), e); - } - - java.util.Properties config = configReader.getProperties(); - session.setConfig(config); - - //============================================================= - // Handling vanilla SSH pieces - //============================================================= - if (authenticationInfo instanceof SSHPasswordAuthentication) { - String password = ((SSHPasswordAuthentication) authenticationInfo). - getPassword(serverInfo.getUserName(), serverInfo.getHost()); - - session.setUserInfo(new SSHAPIUIKeyboardInteractive(password)); - - // TODO figure out why we need to set password to session - session.setPassword(password); - - } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) { - SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication - = (SSHPublicKeyFileAuthentication)authenticationInfo; - - String privateKeyFile = sshPublicKeyFileAuthentication. - getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost()); - - logDebug("The private key file for vanilla SSH " + privateKeyFile); - - String publicKeyFile = sshPublicKeyFileAuthentication. - getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost()); - - logDebug("The public key file for vanilla SSH " + publicKeyFile); - - Identity identityFile; - - try { - identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jsch); - } catch (JSchException e) { - throw new SSHApiException("An exception occurred while initializing keys using files. " + - "(private key and public key)." + - "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " + - publicKeyFile, e); - } - - // Add identity to identity repository - GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch); - identityRepository.add(identityFile); - - // Set repository to session - session.setIdentityRepository(identityRepository); - - // Set the user info - SSHKeyPasswordHandler sshKeyPasswordHandler - = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo); - - session.setUserInfo(sshKeyPasswordHandler); - - } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) { - - SSHPublicKeyAuthentication sshPublicKeyAuthentication - = (SSHPublicKeyAuthentication)authenticationInfo; - - Identity identityFile; - - try { - String name = serverInfo.getUserName() + "_" + serverInfo.getHost(); - identityFile = GSISSHIdentityFile.newInstance(name, - sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()), - sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jsch); - } catch (JSchException e) { - throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " + - "(private key and public key)." + - "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName(), e); - } - - // Add identity to identity repository - GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch); - identityRepository.add(identityFile); - - // Set repository to session - session.setIdentityRepository(identityRepository); - - // Set the user info - SSHKeyPasswordHandler sshKeyPasswordHandler - = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo); - - session.setUserInfo(sshKeyPasswordHandler); - - } - - // Not a good way, but we dont have any choice - if (session instanceof ExtendedSession) { - if (authenticationInfo instanceof GSIAuthenticationInfo) { - ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo)authenticationInfo); - } - } - - try { - session.connect(); - } catch (JSchException e) { - throw new SSHApiException("An exception occurred while connecting to server." + - "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName(), e); - } - - String command = commandInfo.getCommand(); - - Channel channel; - try { - channel = session.openChannel("exec"); - ((ChannelExec) channel).setCommand(command); - } catch (JSchException e) { -// session.disconnect(); - - throw new SSHApiException("Unable to execute command - " + command + - " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName(), e); - } - - - channel.setInputStream(null); - ((ChannelExec) channel).setErrStream(commandOutput.getStandardError()); - - try { - channel.connect(); - } catch (JSchException e) { - - channel.disconnect(); -// session.disconnect(); - - throw new SSHApiException("Unable to retrieve command output. Command - " + command + - " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + - " connecting user name - " - + serverInfo.getUserName(), e); - } - - commandOutput.onOutput(channel); - - channel.disconnect(); -// session.disconnect(); - } - - private static void logDebug(String message) { - if (log.isDebugEnabled()) { - log.debug(message); - } - } - - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java deleted file mode 100644 index e6797ce..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandInfo.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.apache.airavata.gfac.ssh.api;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -/** - * Encapsulates information about - */ -public interface CommandInfo { - - /** - * Gets the executable command as a string. - * @return String encoded command. Should be able to execute - * directly on remote shell. Should includes appropriate parameters. - */ - String getCommand(); - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java deleted file mode 100644 index f275ff0..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandOutput.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.airavata.gfac.ssh.api;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - - -import com.jcraft.jsch.Channel; - -import java.io.OutputStream; - -/** - * Output of a certain command. TODO rethink - */ -public interface CommandOutput { - - /** - * Gets the output of the command as a stream. - * @param channel Command output as a stream. - */ - void onOutput(Channel channel); - - /** - * Gets standard error as a output stream. - * @return Command error as a stream. - */ - OutputStream getStandardError(); - - /** - * The command exit code. - * @param code The program exit code - */ - void exitCode(int code); -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java deleted file mode 100644 index 67dd043..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Core.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api; - -import org.apache.airavata.gfac.ssh.api.job.JobDescriptor; - -/** - * This represents a CPU core of a machine in the cluster - */ -public class Core { - private JobDescriptor job; - private String id; - - public Core(String id) { - this.id = id; - this.job = null; - } - - /** - * @return core's id - */ - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - /** - * @return job running on the core - */ - public JobDescriptor getJob() { - return job; - } - - public void setJob(JobDescriptor job) { - this.job = job; - } - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java deleted file mode 100644 index 1515f39..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/Node.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api; - -import java.util.HashMap; - -public class Node { - private String Name; - private Core[] Cores; - private String state; - private HashMap<String, String> status; - private String np; - private String ntype; - - /** - * @return the machine's name - */ - public String getName() { - return Name; - } - - public void setName(String Name) { - this.Name = Name; - } - - /** - * @return machine cores as an array - */ - public Core[] getCores() { - return Cores; - } - - public void setCores(Core[] Cores) { - this.Cores = Cores; - } - - - /** - * @return the machine state - */ - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - /** - * @return the status - */ - public HashMap<String, String> getStatus() { - return status; - } - - public void setStatus(HashMap<String, String> status) { - this.setStatus(status); - } - - - /** - * @return the number of cores in the machine - */ - public String getNp() { - return np; - } - - - public void setNp(String np) { - this.np = np; - } - - /** - * @return the ntype of the machine - */ - public String getNtype() { - return ntype; - } - - - public void setNtype(String ntype) { - this.ntype = ntype; - } - - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java deleted file mode 100644 index f78825b..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/SSHApiException.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api; - -/** - * An exception class to wrap SSH command execution related errors. - */ -public class SSHApiException extends Exception { - - public SSHApiException(String message) { - super(message); - } - - public SSHApiException(String message, Exception e) { - super(message, e); - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java deleted file mode 100644 index d3c2160..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/ServerInfo.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.airavata.gfac.ssh.api;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -/** - * Encapsulate server information. - */ -public class ServerInfo { - - private String host; - private String userName; - private int port = 22; - - public ServerInfo(String userName, String host) { - this.userName = userName; - this.host = host; - } - - public ServerInfo(String userName,String host, int port) { - this.host = host; - this.userName = userName; - this.port = port; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java deleted file mode 100644 index 6b4e913..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/AuthenticationInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.apache.airavata.gfac.ssh.api.authentication;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -/** - * User: AmilaJ ([email protected]) - * Date: 10/4/13 - * Time: 11:25 AM - */ - -/** - * An empty interface that represents authentication data to the API. - */ -public interface AuthenticationInfo { -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java deleted file mode 100644 index 1f327f0..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/GSIAuthenticationInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.airavata.gfac.ssh.api.authentication;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -import org.ietf.jgss.GSSCredential; - -import java.util.Properties; - -/** - * Authentication data. Could be MyProxy user name, password, could be GSSCredentials - * or could be SSH keys. - */ -public abstract class GSIAuthenticationInfo implements AuthenticationInfo { - - public Properties properties = new Properties(); - - public abstract GSSCredential getCredentials() throws SecurityException; - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java deleted file mode 100644 index ebd79f2..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHKeyAuthentication.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.airavata.gfac.ssh.api.authentication;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - -/** - * User: AmilaJ ([email protected]) - * Date: 10/4/13 - * Time: 2:39 PM - */ - -/** - * Abstracts out common methods for SSH key authentication. - */ -public interface SSHKeyAuthentication extends AuthenticationInfo { - - /** - * This is needed only if private key and public keys are encrypted. - * If they are not encrypted we can just return null. - * @return User should return pass phrase if keys are encrypted. If not null. - */ - String getPassPhrase(); - - /** - * Callback with the banner message. API user can get hold of banner message - * by implementing this method. - * @param message The banner message. - */ - void bannerMessage(String message); -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java deleted file mode 100644 index fd884f8..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPasswordAuthentication.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api.authentication; - -/** - * User: AmilaJ ([email protected]) - * Date: 10/4/13 - * Time: 11:22 AM - */ - -/** - * Password authentication for vanilla SSH. - */ -public interface SSHPasswordAuthentication extends AuthenticationInfo { - - /** - * Gets the password for given host name and given user name. - * @param userName The connecting user name name. - * @param hostName The connecting host. - * @return Password for the given user. - */ - String getPassword(String userName, String hostName); - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java deleted file mode 100644 index dcedfec..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyAuthentication.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 org.apache.airavata.gfac.ssh.api.authentication; - -/** - * User: AmilaJ ([email protected]) - * Date: 10/4/13 - * Time: 9:48 AM - */ - - -/** - * Public key authentication for vanilla SSH. - * The public key and private key are returned as byte arrays. Useful when we store private key/public key - * in a secure storage such as credential store. API user should implement this. - */ -public interface SSHPublicKeyAuthentication extends SSHKeyAuthentication { - - /** - * Gets the public key as byte array. - * @param userName The user who is trying to SSH - * @param hostName The host which user wants to connect to. - * @return The public key as a byte array. - */ - byte[] getPrivateKey(String userName, String hostName); - - /** - * Gets the private key as byte array. - * @param userName The user who is trying to SSH - * @param hostName The host which user wants to connect to. - * @return The private key as a byte array. - */ - byte[] getPublicKey(String userName, String hostName); - -} http://git-wip-us.apache.org/repos/asf/airavata/blob/13c2e79e/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java ---------------------------------------------------------------------- diff --git a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java b/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java deleted file mode 100644 index e22b9af..0000000 --- a/tools/gsissh/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/authentication/SSHPublicKeyFileAuthentication.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.airavata.gfac.ssh.api.authentication;/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * - */ - - -/** - * User: AmilaJ ([email protected]) - * Date: 10/4/13 - * Time: 9:52 AM - */ - -/** - * Public key authentication for vanilla SSH. - * The public key and private key stored files are returned. API user should implement this. - */ -public interface SSHPublicKeyFileAuthentication extends SSHKeyAuthentication { - - /** - * The file which contains the public key. - * @param userName The user who is trying to SSH - * @param hostName The host which user wants to connect to. - * @return The name of the file which contains the public key. - */ - String getPublicKeyFile(String userName, String hostName); - - /** - * The file which contains the public key. - * @param userName The user who is trying to SSH - * @param hostName The host which user wants to connect to. - * @return The name of the file which contains the private key. - */ - String getPrivateKeyFile(String userName, String hostName); - - -}
