Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java keeps only new httpclient implementation, the old one is not mo… #488

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,29 @@
<name>GeneXus Standard Classes for Android</name>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxcryptocommon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxcommon</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gxcryptocommon</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>0.7</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@
import java.util.Hashtable;
import java.util.Enumeration;

import java.awt.Frame;
import java.awt.Panel;
import java.awt.Label;
import java.awt.Color;
import java.awt.Button;
import java.awt.Graphics;
import java.awt.Dimension;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;


/**
* This module handles Netscape cookies (also called Version 0 cookies)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
import java.util.Vector;
import java.util.StringTokenizer;

import java.awt.Frame;
import java.awt.Panel;
import java.awt.Label;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.TextField;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;

/**
* This class is the default authorization handler. It currently handles the
* authentication schemes "Basic", "Digest", and "SOCKS5" (used for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
import java.net.NoRouteToHostException;
import java.util.Vector;

import com.genexus.common.interfaces.SpecificImplementation;

import java.util.StringTokenizer;
import java.applet.Applet;


/**
Expand Down Expand Up @@ -664,11 +661,11 @@ public static String descramble(String scrambled)
*
* @param applet the current applet
*/
public HTTPConnection(Object applet) throws ProtocolNotSuppException
{
if (SpecificImplementation.HTTPConnection != null)
SpecificImplementation.HTTPConnection.createHttpConnectionFromApplet(applet, this);
}
// public HTTPConnection(Object applet) throws ProtocolNotSuppException
// {
// if (SpecificImplementation.HTTPConnection != null)
// SpecificImplementation.HTTPConnection.createHttpConnectionFromApplet(applet, this);
// }


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import java.io.IOException;

import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSocketFactory;
import javax.security.cert.X509Certificate;

/** Esta clase provee un Binding SSL para la libreria JSSE de Sun
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

package HTTPClient;

import java.io.FileInputStream;


/**
* This class implements the MD4 hash as specified in RFC-1320.
Expand Down
6 changes: 6 additions & 0 deletions androidreports/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>gxcommon</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
8 changes: 7 additions & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.69</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<finalName>gxcommon</finalName>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class SpecificImplementation {
public static IExtensionMessages Messages;
public static IExtensionPictureFormatter PictureFormatter;
public static IExtensionSdtMessages_Message SdtMessages_Message;
public static IExtensionHTTPConnection HTTPConnection;
public static ICryptoAlhorithms Algorithms;
public static IExtensionModelContext ModelContext;
public static boolean KeepDecimals;
Expand Down
11 changes: 5 additions & 6 deletions common/src/main/java/com/genexus/internet/GXHttpClient.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.genexus.internet;

import HTTPClient.ParseException;
import HTTPClient.URI;
import com.genexus.CommonUtil;
import com.genexus.common.interfaces.SpecificImplementation;
import java.io.*;
import java.net.URISyntaxException;
import java.util.Hashtable;
import java.util.Vector;

Expand Down Expand Up @@ -130,17 +129,17 @@ public boolean getIncludeCookies()
return this.includeCookies;
}

public void setURL(String stringURL)
{
@Override
public void setURL(String stringURL) {
try
{
URI url = new URI(stringURL);
java.net.URI url = new java.net.URI(stringURL);
setHost(url.getHost());
setPort(url.getPort());
setBaseURL(url.getPath());
setSecure(url.getScheme().equalsIgnoreCase("https") ? 1 : 0);
}
catch (ParseException e)
catch (URISyntaxException e)
{
System.err.println("E " + e + " " + stringURL);
e.printStackTrace();
Expand Down
35 changes: 35 additions & 0 deletions common/src/main/java/com/genexus/internet/SSLConnConstructor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.genexus.internet;

import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;

import javax.net.ssl.SSLContext;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;

public class SSLConnConstructor {

public static SSLConnectionSocketFactory getSSLSecureInstance(String[] supportedProtocols) {
try {
SSLContext sslContext = SSLContextBuilder
.create()
.loadTrustMaterial(new TrustSelfSignedStrategy())
.build();
return new SSLConnectionSocketFactory(
sslContext,
supportedProtocols,
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
} catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
e.printStackTrace();
}
return new SSLConnectionSocketFactory(
SSLContexts.createDefault(),
supportedProtocols,
null,
SSLConnectionSocketFactory.getDefaultHostnameVerifier());
}
}
36 changes: 19 additions & 17 deletions gxmail/src/main/java/com/genexus/internet/POP3Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.genexus.CommonUtil;
import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.platform.INativeFunctions;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.protocol.BasicHttpContext;

public class POP3Session implements GXInternetConstants,IPOP3Session
{
Expand Down Expand Up @@ -136,23 +138,23 @@ private void connectNormal() throws GXMailException
login();
}

private Socket getConnectionSocket(int type) throws UnknownHostException, IOException
{
System.setProperty("HTTPClient.sslUseTLS", "false");
InetAddress ipAddr = InetAddress.getByName(pop3Host.trim());
switch(type)
{
case CONN_NORMAL:
return new Socket(pop3Host.trim(), pop3Port);
case CONN_TLS:
System.setProperty("HTTPClient.sslUseTLS", "true");
return HTTPClient.SSLManager.getSSLConnection(false).getSSLSocket(ipAddr, pop3Port);
case CONN_SSL:
HTTPClient.ISSLConnection connection = HTTPClient.SSLManager.getSSLConnection(false);
return connection.processSSLSocket(connection.getSSLSocket(ipAddr, pop3Port), ipAddr.getHostName(), pop3Port);
}
return new Socket(pop3Host.trim(), pop3Port);
}
private Socket getConnectionSocket(int type) throws UnknownHostException, IOException
{
InetAddress ipAddr = InetAddress.getByName(pop3Host.trim());
SSLConnectionSocketFactory sslConn;
switch(type)
{
case CONN_NORMAL:
return new Socket(pop3Host.trim(), pop3Port);
case CONN_TLS:
sslConn = SSLConnConstructor.getSSLSecureInstance(new String[] { "TLSv1.1", "TLSv1.2" });
return sslConn.createLayeredSocket(new Socket(pop3Host.trim(), pop3Port),ipAddr.getHostName(),pop3Port,new BasicHttpContext());
case CONN_SSL:
sslConn = SSLConnConstructor.getSSLSecureInstance(new String[] { "TLSv1" });
return sslConn.createLayeredSocket(new Socket(pop3Host.trim(), pop3Port),ipAddr.getHostName(),pop3Port,new BasicHttpContext());
}
return new Socket(pop3Host.trim(), pop3Port);
}

public void logout(GXPOP3Session sessionInfo)
{
Expand Down
36 changes: 19 additions & 17 deletions gxmail/src/main/java/com/genexus/internet/SMTPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.genexus.CommonUtil;
import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.platform.INativeFunctions;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.protocol.BasicHttpContext;

final class SMTPSession implements GXInternetConstants,ISMTPSession
{
Expand Down Expand Up @@ -452,23 +454,23 @@ public void run()
}
}

private Socket getConnectionSocket(int type) throws UnknownHostException, IOException
{
System.setProperty("HTTPClient.sslUseTLS", "false");
InetAddress ipAddr = InetAddress.getByName(host.trim());
switch(type)
{
case CONN_NORMAL:
return new Socket(host.trim(), port);
case CONN_TLS:
System.setProperty("HTTPClient.sslUseTLS", "true");
return HTTPClient.SSLManager.getSSLConnection(false).getSSLSocket(ipAddr, port);
case CONN_SSL:
HTTPClient.ISSLConnection connection = HTTPClient.SSLManager.getSSLConnection(false);
return connection.processSSLSocket(connection.getSSLSocket(ipAddr, port), ipAddr.getHostName(), port);
}
return new Socket(host.trim(), port);
}
private Socket getConnectionSocket(int type) throws UnknownHostException, IOException
{
InetAddress ipAddr = InetAddress.getByName(host.trim());
SSLConnectionSocketFactory sslConn;
switch(type)
{
case CONN_NORMAL:
return new Socket(host.trim(), port);
case CONN_TLS:
sslConn = SSLConnConstructor.getSSLSecureInstance(new String[] { "TLSv1.1", "TLSv1.2" });
return sslConn.createLayeredSocket(new Socket(host.trim(), port),ipAddr.getHostName(),port,new BasicHttpContext());
case CONN_SSL:
sslConn = SSLConnConstructor.getSSLSecureInstance(new String[] { "TLSv1" });
return sslConn.createLayeredSocket(new Socket(host.trim(), port),ipAddr.getHostName(),port,new BasicHttpContext());
}
return new Socket(host.trim(), port);
}

private void doLogin(boolean startTLS) throws GXMailException
{
Expand Down
Loading