Compare commits
2 commits
b222a89a2b
...
93b606ba99
| Author | SHA1 | Date | |
|---|---|---|---|
| 93b606ba99 | |||
| 809ec6989e |
4 changed files with 64 additions and 4 deletions
2
build.sh
2
build.sh
|
|
@ -3,7 +3,7 @@
|
||||||
# Let's go to the folder containing the build.sh file
|
# Let's go to the folder containing the build.sh file
|
||||||
# We don't want to remove all .class files on the system should
|
# We don't want to remove all .class files on the system should
|
||||||
# the script run on /
|
# the script run on /
|
||||||
VERSION="0.2.1"
|
VERSION="0.2.2"
|
||||||
BASEDIR=$(dirname $0)
|
BASEDIR=$(dirname $0)
|
||||||
echo $BASEDIR
|
echo $BASEDIR
|
||||||
cd $BASEDIR
|
cd $BASEDIR
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class Main {
|
||||||
private static void usageError(String msg) {
|
private static void usageError(String msg) {
|
||||||
System.err.println(msg);
|
System.err.println(msg);
|
||||||
System.err.println("Usage: [-3dFX] /*[-PSHBTNCHC]*/ [-STRPCCMD] [-altFKeyRemap]" +
|
System.err.println("Usage: [-3dFX] /*[-PSHBTNCHC]*/ [-STRPCCMD] [-altFKeyRemap]" +
|
||||||
" [-maximized] [-cp codepage] [-devName name]" +
|
" [-maximized] [-cp codepage] [-devName name] [-useSSL|noSSL]" +
|
||||||
" [-autoLogon <fieldsCount>;<usrFieldLabel>;<pwdFieldLabel>;<user>;<passwd>]" +
|
" [-autoLogon <fieldsCount>;<usrFieldLabel>;<pwdFieldLabel>;<user>;<passwd>]" +
|
||||||
" host-name");
|
" host-name");
|
||||||
System.err.println("Supported code pages:");
|
System.err.println("Supported code pages:");
|
||||||
|
|
@ -86,6 +86,7 @@ public class Main {
|
||||||
|
|
||||||
boolean pUse3dFX = false;
|
boolean pUse3dFX = false;
|
||||||
boolean pAltFKeyRemap = false;
|
boolean pAltFKeyRemap = false;
|
||||||
|
int pUseSSL = -1;
|
||||||
//boolean pPSHBTNCHC = false;
|
//boolean pPSHBTNCHC = false;
|
||||||
boolean pSTRPCCMD = false;
|
boolean pSTRPCCMD = false;
|
||||||
boolean pMaximized = false;
|
boolean pMaximized = false;
|
||||||
|
|
@ -111,6 +112,10 @@ public class Main {
|
||||||
pMaximized = true;
|
pMaximized = true;
|
||||||
else if ("-altFKeyRemap".equalsIgnoreCase(arg))
|
else if ("-altFKeyRemap".equalsIgnoreCase(arg))
|
||||||
pAltFKeyRemap = true;
|
pAltFKeyRemap = true;
|
||||||
|
else if ("-noSSL".equalsIgnoreCase(arg))
|
||||||
|
pUseSSL = 0;
|
||||||
|
else if ("-useSSL".equalsIgnoreCase(arg))
|
||||||
|
pUseSSL = 1;
|
||||||
else if ("-cp".equalsIgnoreCase(arg))
|
else if ("-cp".equalsIgnoreCase(arg))
|
||||||
expectCP = true;
|
expectCP = true;
|
||||||
else if ("-devName".equalsIgnoreCase(arg))
|
else if ("-devName".equalsIgnoreCase(arg))
|
||||||
|
|
@ -150,6 +155,7 @@ public class Main {
|
||||||
usageError("A code page is expected");
|
usageError("A code page is expected");
|
||||||
|
|
||||||
final boolean altFKeyRemap = pAltFKeyRemap;
|
final boolean altFKeyRemap = pAltFKeyRemap;
|
||||||
|
final int useSSL = pUseSSL;
|
||||||
final boolean use3dFX = pUse3dFX;
|
final boolean use3dFX = pUse3dFX;
|
||||||
// final boolean enablePSHBTNCHC = pPSHBTNCHC;
|
// final boolean enablePSHBTNCHC = pPSHBTNCHC;
|
||||||
final boolean enableSTRPCCMD = pSTRPCCMD;
|
final boolean enableSTRPCCMD = pSTRPCCMD;
|
||||||
|
|
@ -187,6 +193,7 @@ public class Main {
|
||||||
|
|
||||||
em.setStrPcCmdEnabled(enableSTRPCCMD);
|
em.setStrPcCmdEnabled(enableSTRPCCMD);
|
||||||
em.setAltFKeyRemap(altFKeyRemap);
|
em.setAltFKeyRemap(altFKeyRemap);
|
||||||
|
em.setUseSSL(useSSL);
|
||||||
em.setCodePage(codePage);
|
em.setCodePage(codePage);
|
||||||
|
|
||||||
if (deviceName != null)
|
if (deviceName != null)
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ public class XI5250Emulator extends XI5250Crt implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final String VERSION = "0.1 (1.19i)";
|
public static final String VERSION = "0.2.2 (1.19i)";
|
||||||
|
|
||||||
public static final int MAX_ROWS = 27;
|
public static final int MAX_ROWS = 27;
|
||||||
public static final int MAX_COLS = 132;
|
public static final int MAX_COLS = 132;
|
||||||
|
|
@ -345,6 +345,7 @@ public class XI5250Emulator extends XI5250Crt implements Serializable {
|
||||||
private String ivHost;
|
private String ivHost;
|
||||||
|
|
||||||
private boolean ivAltFKeyRemap;
|
private boolean ivAltFKeyRemap;
|
||||||
|
private int ivUseSSL;
|
||||||
|
|
||||||
private boolean ivStrPcCmdEnabled;
|
private boolean ivStrPcCmdEnabled;
|
||||||
private boolean ivReceivedStrPcCmd;
|
private boolean ivReceivedStrPcCmd;
|
||||||
|
|
@ -590,11 +591,19 @@ public class XI5250Emulator extends XI5250Crt implements Serializable {
|
||||||
ivAltFKeyRemap = value;
|
ivAltFKeyRemap = value;
|
||||||
firePropertyChange(ALTFKEY_REMAP, old, ivAltFKeyRemap);
|
firePropertyChange(ALTFKEY_REMAP, old, ivAltFKeyRemap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseSSL(int value) {
|
||||||
|
ivUseSSL = value;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getAltFKeyRemap() {
|
public boolean getAltFKeyRemap() {
|
||||||
return ivAltFKeyRemap;
|
return ivAltFKeyRemap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getUseSSL() {
|
||||||
|
return ivUseSSL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param value - if true the STRPCCMD order is enabled.
|
* @param value - if true the STRPCCMD order is enabled.
|
||||||
*/
|
*/
|
||||||
|
|
@ -770,6 +779,8 @@ public class XI5250Emulator extends XI5250Crt implements Serializable {
|
||||||
if (ivTelnetEnv != null)
|
if (ivTelnetEnv != null)
|
||||||
ivTelnet.setEnvironment(ivTelnetEnv);
|
ivTelnet.setEnvironment(ivTelnetEnv);
|
||||||
|
|
||||||
|
ivTelnet.setUseSSL(ivUseSSL);
|
||||||
|
|
||||||
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_BINARY, true);
|
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_BINARY, true);
|
||||||
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_TTYPE, true);
|
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_TTYPE, true);
|
||||||
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_EOR, true);
|
ivTelnet.setLocalReqFlag(XITelnet.TELOPT_EOR, true);
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,12 @@ import java.io.InputStream;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import javax.net.ssl.SSLSocket;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -163,6 +169,7 @@ public class XITelnet {
|
||||||
|
|
||||||
private String ivTermType;
|
private String ivTermType;
|
||||||
private String ivEnvironment;
|
private String ivEnvironment;
|
||||||
|
private int ivUseSSL;
|
||||||
|
|
||||||
transient private int ivIACParserStatus = SIAC_START;
|
transient private int ivIACParserStatus = SIAC_START;
|
||||||
|
|
||||||
|
|
@ -301,7 +308,15 @@ public class XITelnet {
|
||||||
ivEnvironment = aEnv;
|
ivEnvironment = aEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUseSSL(int aUseSSL) {
|
||||||
|
ivUseSSL = aUseSSL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUseSSL() {
|
||||||
|
if ((ivUseSSL == -1) && (ivPort == 992))
|
||||||
|
return 1;
|
||||||
|
return ivUseSSL;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public String getEnvironment() {
|
public String getEnvironment() {
|
||||||
|
|
@ -354,6 +369,22 @@ public class XITelnet {
|
||||||
return ivRemoteFlags[flag];
|
return ivRemoteFlags[flag];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SSLSocketFactory getTrustAllFactory() throws Exception {
|
||||||
|
// 1. Créer un TrustManager qui ne vérifie rien
|
||||||
|
TrustManager[] trustAllCerts = new TrustManager[] {
|
||||||
|
new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() { return null; }
|
||||||
|
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
|
||||||
|
public void checkServerTrusted(X509Certificate[] certs, String authType) {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 2. Initialiser le contexte SSL avec ce TrustManager
|
||||||
|
SSLContext sc = SSLContext.getInstance("TLS");
|
||||||
|
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||||
|
|
||||||
|
return sc.getSocketFactory();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tryes to establish a telnet connection.
|
* Tryes to establish a telnet connection.
|
||||||
|
|
@ -368,7 +399,13 @@ public class XITelnet {
|
||||||
connecting();
|
connecting();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ivSocket = new Socket(ivFirstHost, ivPort);
|
if (getUseSSL() == 1) {
|
||||||
|
SSLSocketFactory factory = getTrustAllFactory(); //(SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||||
|
ivSocket = factory.createSocket(ivFirstHost, ivPort);
|
||||||
|
((SSLSocket)ivSocket).startHandshake(); // Déclenche le chiffrement
|
||||||
|
} else {
|
||||||
|
ivSocket = new Socket(ivFirstHost, ivPort);
|
||||||
|
}
|
||||||
ivSocket.setKeepAlive(true);
|
ivSocket.setKeepAlive(true);
|
||||||
|
|
||||||
ivIn = ivSocket.getInputStream();
|
ivIn = ivSocket.getInputStream();
|
||||||
|
|
@ -396,6 +433,11 @@ public class XITelnet {
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
catchedIOException(ex);
|
catchedIOException(ex);
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
System.err.println("Erreur connexion l429 " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue