org/objectweb/proactive/core/ssh/SshParameters.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.ssh;
00032 
00033 import org.objectweb.proactive.core.util.HostsInfos;
00034 
00035 
00041 public class SshParameters {
00042     static private int _connectTimeout = -1;
00043     static private String _tryNormalFirst = null;
00044 
00045     static public boolean getTryNormalFirst() {
00046         if (_tryNormalFirst == null) {
00047             _tryNormalFirst = System.getProperty(
00048                     "proactive.tunneling.try_normal_first");
00049         }
00050         if ((_tryNormalFirst != null) && _tryNormalFirst.equals("yes")) {
00051             return true;
00052         } else {
00053             return false;
00054         }
00055     }
00056 
00057     static public int getConnectTimeout() {
00058         if (_connectTimeout == -1) {
00059             String timeout = System.getProperty(
00060                     "proactive.tunneling.connect_timeout");
00061             if (timeout != null) {
00062                 _connectTimeout = Integer.parseInt(timeout);
00063             } else {
00064                 _connectTimeout = 2000;
00065             }
00066         }
00067         return _connectTimeout;
00068     }
00069 
00070     static public boolean getUseTunnelGC() {
00071         String useTunnelGC = System.getProperty("proactive.tunneling.use_gc");
00072         if ((useTunnelGC != null) && useTunnelGC.equals("yes")) {
00073             return true;
00074         } else {
00075             return false;
00076         }
00077     }
00078 
00079     static public int getTunnelGCPeriod() {
00080         String gcPeriod = System.getProperty("proactive.tunneling.gc_period");
00081         if (gcPeriod != null) {
00082             return Integer.parseInt(gcPeriod);
00083         } else {
00084             // 10s
00085             return 10000;
00086         }
00087     }
00088 
00089     static public boolean getSshTunneling() {
00090         String tunneling = System.getProperty(
00091                 "proactive.communication.protocol");
00092         if ((tunneling != null) && tunneling.equals("rmissh")) {
00093             return true;
00094         } else {
00095             return false;
00096         }
00097     }
00098 
00099     static public String getSshUsername(String hostname) {
00100         return HostsInfos.getUserName(hostname);
00101     }
00102 
00103     static public String getSshPort() {
00104         String sshPort = System.getProperty("proactive.ssh.port");
00105         if (sshPort == null) {
00106             sshPort = "22";
00107         }
00108         return sshPort;
00109     }
00110 
00111     static public String getSshKnownHostsFile() {
00112         String hostfile = System.getProperty("proactive.ssh.known_hosts");
00113         if (hostfile == null) {
00114             hostfile = System.getProperty("user.home") + "/.ssh/known_hosts";
00115         }
00116         return hostfile;
00117     }
00118 
00119     static public String getSshKeyDirectory() {
00120         String keydir = System.getProperty("proactive.ssh.key_directory");
00121         if (keydir == null) {
00122             keydir = System.getProperty("user.home") + "/.ssh/";
00123         }
00124         return keydir;
00125     }
00126 }

Generated on Mon Jan 22 15:16:09 2007 for ProActive by  doxygen 1.5.1