mirror of https://github.com/sipwise/jitsi.git
Creates authenticate windows service that will create the dialog and will show it to user used with different impl on android and desktop.
Expose some common functionality in httputil and reuse it in xcap implementation in sip provider. Wraps sslSocketFactory to use the constructor that is common for android and desktop httpclient lib. Creates separate bundle for httpclient libs in order to separate it from httputil bundle which will be used in android.cusax-fix
parent
76631ca877
commit
e35e4a7974
@ -1,92 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/felix.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://www.osgi.org/javadoc/r4v42/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jdic-all.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bundle/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/aclibico-2.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/apache-ant-1.7.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/cglib-nodep.osgi-2.1_3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/commons-logging-1.1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dhcp4java-1.00.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dict4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dnsjava.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://www.dnsjava.org/dnsjava-current/doc/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/easymock-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/forms-1.2.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-meta-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-3.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-meta-3.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-core-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/google-collect-1.0-rc1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/hexdump-0.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/httpclient-osgi-4.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/httpcore-osgi-4.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/ice4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sdp.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="https://hudson.jboss.org/jenkins/job/jain-sip/lastStableBuild/artifact/javadoc/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jdom.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jfontchooser-1.0.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmdns.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jml-1.0b5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmyspell-core.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jna.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jnsapi.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-client.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-common.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-protocol.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jsch-0.1.36.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jsocks-klea.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/json-simple-1.1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/laf-widget.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/libdbus-java-2.7.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://dbus.freedesktop.org/doc/dbus-java/api/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/libjitsi.jar" sourcepath="/libjitsi"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/log4j-1.2.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/mac_widgets-0.9.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/objenesis-1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/otr4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/pircbot.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/profiler4j-1.0-beta3-SC.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/rome-0.9.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/sdes4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/smack.jar" sourcepath="lib/installer-exclude/smack-src.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/smackx.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/swing-worker-1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jna-platform.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/unix-0.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/ymsg_network_v0_67.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/linux/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/growl4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/OrangeExtensions.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/solaris/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/windows/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmork-1.0.5-SNAPSHOT.jar" sourcepath="/jmork"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/bcprov-jdk15on-148.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/bccontrib-1.0-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/zrtp4j-light.jar"/>
|
||||
<classpathentry kind="output" path="classes"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/felix.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://www.osgi.org/javadoc/r4v42/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/jdic-all.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bundle/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/aclibico-2.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/apache-ant-1.7.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/cglib-nodep.osgi-2.1_3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/commons-logging-1.1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dhcp4java-1.00.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dict4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/dnsjava.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://www.dnsjava.org/dnsjava-current/doc/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/easymock-3.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/fmj.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/forms-1.2.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-client-meta-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-3.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-contacts-meta-3.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/gdata-core-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/google-collect-1.0-rc1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/hexdump-0.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/httpclient-osgi-4.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/httpcore-osgi-4.2.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/ice4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sdp.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="https://hudson.jboss.org/jenkins/job/jain-sip/lastStableBuild/artifact/javadoc/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-api.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jain-sip-ri.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jdic_misc.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jdom.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jfontchooser-1.0.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmdns.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jml-1.0b5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmyspell-core.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jna.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jnsapi.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-client.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-common.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/joscar-protocol.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jsch-0.1.36.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jsocks-klea.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/json-simple-1.1.1.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/laf-widget.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/libdbus-java-2.7.jar">
|
||||
<attributes>
|
||||
<attribute name="javadoc_location" value="http://dbus.freedesktop.org/doc/dbus-java/api/"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/libjitsi.jar" sourcepath="/libjitsi"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/log4j-1.2.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/mac_widgets-0.9.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/objenesis-1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/otr4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/pircbot.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/profiler4j-1.0-beta3-SC.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/rome-0.9.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/sdes4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/smack.jar" sourcepath="lib/installer-exclude/smack-src.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/smackx.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/swing-worker-1.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jna-platform.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/unix-0.5.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/ymsg_network_v0_67.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/linux/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/growl4j.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/mac/OrangeExtensions.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/solaris/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/os-specific/windows/jdic_stub.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/jmork-1.0.5-SNAPSHOT.jar" sourcepath="/jmork"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/bcprov-jdk15on-148.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/bccontrib-1.0-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/installer-exclude/zrtp4j-light.jar"/>
|
||||
<classpathentry kind="output" path="classes"/>
|
||||
</classpath>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,38 @@
|
||||
Bundle-Name: Apache Http Client
|
||||
Bundle-Description: Apache Http Client
|
||||
Bundle-Vendor: jitsi.org
|
||||
Bundle-Version: 4.2.3
|
||||
System-Bundle: yes
|
||||
Import-Package: org.apache.commons.logging,
|
||||
javax.net.ssl
|
||||
Export-Package: org.apache.http,
|
||||
org.apache.http.entity,
|
||||
org.apache.http.entity.mime,
|
||||
org.apache.http.entity.mime.content,
|
||||
org.apache.http.impl,
|
||||
org.apache.http.impl.conn,
|
||||
org.apache.http.impl.entity,
|
||||
org.apache.http.impl.io,
|
||||
org.apache.http.io,
|
||||
org.apache.http.message,
|
||||
org.apache.http.params,
|
||||
org.apache.http.protocol,
|
||||
org.apache.http.util,
|
||||
org.apache.http.annotation,
|
||||
org.apache.http.auth,
|
||||
org.apache.http.auth.params,
|
||||
org.apache.http.client,
|
||||
org.apache.http.client.entity,
|
||||
org.apache.http.client.methods,
|
||||
org.apache.http.client.params,
|
||||
org.apache.http.client.protocol,
|
||||
org.apache.http.client.utils,
|
||||
org.apache.http.conn,
|
||||
org.apache.http.conn.params,
|
||||
org.apache.http.conn.routing,
|
||||
org.apache.http.conn.scheme,
|
||||
org.apache.http.conn.ssl,
|
||||
org.apache.http.conn.util,
|
||||
org.apache.http.impl.client
|
||||
|
||||
|
||||
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Creates and show authentication window, normally to fill in username and
|
||||
* password.
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public interface AuthenticationWindowService
|
||||
{
|
||||
/**
|
||||
* Creates an instance of the <tt>AuthenticationWindow</tt> implementation.
|
||||
*
|
||||
* @param server the server name
|
||||
* @param isUserNameEditable indicates if the user name is editable
|
||||
* @param icon the icon to display on the left of the authentication window
|
||||
* @param windowTitle customized window title
|
||||
* @param windowText customized window text
|
||||
* @param usernameLabelText customized username field label text
|
||||
* @param passwordLabelText customized password field label text
|
||||
* @param errorMessage an error message if this dialog is shown to indicate
|
||||
* the user that something went wrong
|
||||
* @param signupLink an URL that allows the user to sign up
|
||||
*/
|
||||
public AuthenticationWindow create(String userName,
|
||||
char[] password,
|
||||
String server,
|
||||
boolean isUserNameEditable,
|
||||
boolean isRememberPassword,
|
||||
Object icon,
|
||||
String windowTitle,
|
||||
String windowText,
|
||||
String usernameLabelText,
|
||||
String passwordLabelText,
|
||||
String errorMessage,
|
||||
String signupLink);
|
||||
|
||||
/**
|
||||
* The window interface used by implementers.
|
||||
*/
|
||||
public interface AuthenticationWindow
|
||||
{
|
||||
/**
|
||||
* Shows window implementation.
|
||||
*
|
||||
* @param isVisible specifies whether we should be showing or hiding the
|
||||
* window.
|
||||
*/
|
||||
public void setVisible(final boolean isVisible);
|
||||
|
||||
/**
|
||||
* Indicates if this window has been canceled.
|
||||
*
|
||||
* @return <tt>true</tt> if this window has been canceled,
|
||||
* <tt>false</tt> - otherwise.
|
||||
*/
|
||||
public boolean isCanceled();
|
||||
|
||||
/**
|
||||
* Returns the user name entered by the user or previously set if the
|
||||
* user name is not editable.
|
||||
*
|
||||
* @return the user name.
|
||||
*/
|
||||
public String getUserName();
|
||||
|
||||
/**
|
||||
* Returns the password entered by the user.
|
||||
*
|
||||
* @return the password.
|
||||
*/
|
||||
public char[] getPassword();
|
||||
|
||||
/**
|
||||
* Indicates if the password should be remembered.
|
||||
*
|
||||
* @return <tt>true</tt> if the password should be remembered,
|
||||
* <tt>false</tt> - otherwise.
|
||||
*/
|
||||
public boolean isRememberPassword();
|
||||
|
||||
/**
|
||||
* Shows or hides the "save password" checkbox.
|
||||
* @param allow the checkbox is shown when allow is <tt>true</tt>
|
||||
*/
|
||||
public void setAllowSavePassword(boolean allow);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.httputil;
|
||||
|
||||
import org.apache.http.conn.*;
|
||||
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||
import org.apache.http.params.*;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
|
||||
/**
|
||||
* Wrapper for SSLSocketFactory to use the constructor which is available
|
||||
* in android. The certificate validation is handled by the SSLContext
|
||||
* which we use to create sockets for this factory.
|
||||
*
|
||||
* TODO: wrap the SSLSocketFactory to use our own DNS resolution
|
||||
* TODO: register socketfactory for http to use our own DNS resolution
|
||||
*
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class SSLSocketFactoryEx
|
||||
extends SSLSocketFactory
|
||||
{
|
||||
/**
|
||||
* The context that will be used to create sockets.
|
||||
*/
|
||||
private SSLContext context;
|
||||
|
||||
/**
|
||||
* Constructor using the super constructor available for android.
|
||||
*
|
||||
* @param context the context to use
|
||||
* @throws UnrecoverableKeyException
|
||||
* @throws KeyStoreException
|
||||
* @throws KeyManagementException
|
||||
* @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public SSLSocketFactoryEx(SSLContext context)
|
||||
throws
|
||||
UnrecoverableKeyException,
|
||||
KeyStoreException,
|
||||
KeyManagementException,
|
||||
NoSuchAlgorithmException
|
||||
{
|
||||
super((KeyStore) null);
|
||||
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates socket.
|
||||
* @param params
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public Socket createSocket(final HttpParams params)
|
||||
throws
|
||||
IOException
|
||||
{
|
||||
return this.context.getSocketFactory().createSocket();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public Socket createLayeredSocket(
|
||||
final Socket socket,
|
||||
final String host,
|
||||
final int port,
|
||||
final HttpParams params)
|
||||
throws IOException,
|
||||
UnknownHostException
|
||||
{
|
||||
return this.context.getSocketFactory()
|
||||
.createSocket(
|
||||
socket,
|
||||
host,
|
||||
port,
|
||||
true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.1
|
||||
*/
|
||||
public Socket connectSocket(
|
||||
final Socket socket,
|
||||
final InetSocketAddress remoteAddress,
|
||||
final InetSocketAddress localAddress,
|
||||
final HttpParams params)
|
||||
throws IOException,
|
||||
UnknownHostException,
|
||||
ConnectTimeoutException
|
||||
{
|
||||
if(remoteAddress == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Remote address may not be null");
|
||||
}
|
||||
if(params == null)
|
||||
{
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
Socket sock = socket != null ?
|
||||
socket : this.context.getSocketFactory().createSocket();
|
||||
if(localAddress != null)
|
||||
{
|
||||
sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
|
||||
sock.bind(localAddress);
|
||||
}
|
||||
|
||||
int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
|
||||
int soTimeout = HttpConnectionParams.getSoTimeout(params);
|
||||
|
||||
try
|
||||
{
|
||||
sock.setSoTimeout(soTimeout);
|
||||
sock.connect(remoteAddress, connTimeout);
|
||||
}
|
||||
catch(SocketTimeoutException ex)
|
||||
{
|
||||
throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
|
||||
}
|
||||
|
||||
String hostname;
|
||||
if(remoteAddress instanceof HttpInetSocketAddress)
|
||||
{
|
||||
hostname = ((HttpInetSocketAddress) remoteAddress)
|
||||
.getHttpHost().getHostName();
|
||||
}
|
||||
else
|
||||
{
|
||||
hostname = remoteAddress.getHostName();
|
||||
}
|
||||
|
||||
SSLSocket sslsock;
|
||||
// Setup SSL layering if necessary
|
||||
if(sock instanceof SSLSocket)
|
||||
{
|
||||
sslsock = (SSLSocket) sock;
|
||||
}
|
||||
else
|
||||
{
|
||||
int port = remoteAddress.getPort();
|
||||
sslsock = (SSLSocket) this.context.getSocketFactory()
|
||||
.createSocket(sock, hostname, port, true);
|
||||
}
|
||||
|
||||
return sslsock;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue