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.rmissh;
00032
00033 import java.io.IOException;
00034 import java.net.InetAddress;
00035 import java.net.Socket;
00036 import java.net.UnknownHostException;
00037 import java.rmi.server.RMIClientSocketFactory;
00038
00039 import org.objectweb.proactive.core.util.HostsInfos;
00040
00041
00045 public class SshRMIClientSocketFactory implements RMIClientSocketFactory,
00046 java.io.Serializable {
00047 String username;
00048 String hostname;
00049
00050 public SshRMIClientSocketFactory() {
00051 this.username = System.getProperty("user.name");
00052 try {
00053 this.hostname = InetAddress.getLocalHost().getCanonicalHostName();
00054 } catch (UnknownHostException e) {
00055 this.hostname = "locahost";
00056 }
00057 }
00058
00059 public Socket createSocket(String host, int port) throws IOException {
00060 String realName = HostsInfos.getSecondaryName(host);
00061 Socket socket = new SshSocket(realName, port);
00062 return socket;
00063 }
00064
00065 public boolean equals(Object obj) {
00066
00067
00068
00069 return this.getClass().equals(obj.getClass());
00070 }
00071
00072 public int hashCode() {
00073 return this.getClass().hashCode();
00074 }
00075
00076 private void readObject(java.io.ObjectInputStream in)
00077 throws java.io.IOException, ClassNotFoundException {
00078 in.defaultReadObject();
00079 HostsInfos.setUserName(hostname, username);
00080 }
00081 }