00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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
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 }