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
Damian Minkov 13 years ago
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>

@ -921,7 +921,8 @@
bundle-plugin-icqaccregwizz,bundle-plugin-jabberaccregwizz,
bundle-plugin-msnaccregwizz,bundle-plugin-sipaccregwizz,
bundle-plugin-yahooaccregwizz,bundle-plugin-aimaccregwizz,
bundle-commons-codec,bundle-httputil,bundle-plugin-spellcheck,
bundle-commons-codec,bundle-commons-logging,
bundle-httputil,bundle-plugin-spellcheck,
bundle-version-impl,bundle-shutdown-timeout,bundle-windows-clean-shutdown,
bundle-growlnotification,bundle-swingnotification,bundle-galagonotification,
bundle-sparkle, bundle-plugin-branding,
@ -1964,20 +1965,8 @@ javax.swing.event, javax.swing.border"/>
<!--BUNDLE-COMMONS-LOGGING -->
<target name="bundle-commons-logging">
<jar compress="true" destfile="lib/bundle/commons-logging.jar"
filesetmanifest="merge">
<zipfileset src="${lib.noinst}/commons-logging-1.1.1.jar"
prefix=""/>
<manifest>
<attribute name="Export-Package"
value="org.apache.commons.logging"/>
<attribute name="Bundle-Name"
value="Apache Commons Logging"/>
<attribute name="Bundle-Description"
value="An ultra-thin bridge between different logging implementations."/>
<attribute name="System-Bundle" value="yes"/>
</manifest>
</jar>
<copy file="${lib.noinst}/commons-logging-1.1.2.jar"
tofile="${bundles.dest}/commons-logging.jar"/>
</target>
<!--BUNDLE-COMMONS-CODEC -->
@ -1999,9 +1988,21 @@ javax.swing.event, javax.swing.border"/>
manifest="${src}/net/java/sip/communicator/service/httputil/httputil.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/service/httputil"
prefix="net/java/sip/communicator/service/httputil"/>
<zipfileset src="${lib.noinst}/httpclient-osgi-4.2.3.jar" prefix=""/>
<zipfileset src="${lib.noinst}/httpcore-osgi-4.2.3.jar" prefix=""/>
</jar>
<!--
Re-packaging into new bundle as original having wrong paths in osgi
bundle manifest and getting exceptions
'No paths specified in header' while loading
-->
<jar
compress="false" destfile="${bundles.dest}/httpclient.jar"
manifest="${lib.noinst}/httpclient.manifest.mf">
<zipfileset src="${lib.noinst}/httpclient-osgi-4.2.3.jar"
prefix=""/>
<zipfileset src="${lib.noinst}/httpcore-osgi-4.2.3.jar"
prefix=""/>
</jar>
</target>
<!-- BUNDLE-NOTIFICATION -->
@ -2369,7 +2370,7 @@ javax.swing.event, javax.swing.border"/>
<!--BUNDLE-BOUNCYCASTLE -->
<target name="bundle-bouncycastle">
<copy file="${lib.noinst}/bcprov-jdk15on-148.jar" tofile="${bundles.dest}/bouncycastle.jar"/>
<copy file="${lib.noinst}/bccontrib-1.0-SNAPSHOT.jar" tofile="${bundles.dest}/bccontrib.jar"/>
<copy file="${lib.noinst}/bccontrib-1.0-SNAPSHOT.jar" tofile="${bundles.dest}/bccontrib.jar"/>
</target>
<!--BUNDLE-PLUGIN-OTR -->

@ -60,6 +60,8 @@ felix.auto.start.32= \
felix.auto.start.35= \
reference:file:sc-bundles/commons-codec.jar \
reference:file:sc-bundles/commons-logging.jar \
reference:file:sc-bundles/httpclient.jar \
reference:file:sc-bundles/httputil.jar
felix.auto.start.40= \

@ -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

@ -19,9 +19,9 @@
import javax.net.ssl.*;
import javax.security.auth.callback.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.httputil.*;
import net.java.sip.communicator.util.Logger;
@ -430,14 +430,29 @@ public void handle(Callback[] callbacks)
}
else
{
AuthenticationWindow aw =
new AuthenticationWindow(
f.getName(),
null,
kt.getName(),
false,
null
);
AuthenticationWindowService
authenticationWindowService =
CertificateVerificationActivator
.getAuthenticationWindowService();
if(authenticationWindowService == null)
{
logger.error(
"No AuthenticationWindowService " +
"implementation");
throw new IOException("User cancel");
}
AuthenticationWindowService.AuthenticationWindow
aw = authenticationWindowService.create(
f.getName(),
null,
kt.getName(),
false,
false,
null, null, null, null,
null, null, null);
aw.setAllowSavePassword(false);
aw.setVisible(true);
if (!aw.isCanceled())

@ -8,6 +8,7 @@
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
@ -154,4 +155,14 @@ public static VerifyCertificateDialogService getCertificateDialogService()
}
return certificateDialogService;
}
/**
* Returns service to show authentication window.
* @return return service to show authentication window.
*/
public static AuthenticationWindowService getAuthenticationWindowService()
{
return ServiceUtils.getService(
bundleContext, AuthenticationWindowService.class);
}
}

@ -6,6 +6,7 @@ Bundle-Version: 0.0.1
System-Bundle: yes
Export-Package: net.java.sip.communicator.service.certificate
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.util,
net.java.sip.communicator.plugin.desktoputil,
org.jitsi.service.configuration,

@ -19,6 +19,7 @@ Import-Package: ch.imvs.sdes4j.srtp,
net.java.sip.communicator.service.certificate,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.hid,
net.java.sip.communicator.service.httputil,
net.java.sip.communicator.service.netaddr,
net.java.sip.communicator.service.netaddr.event,
net.java.sip.communicator.service.protocol,

@ -10,7 +10,6 @@
import java.net.*;
import java.net.URI;
import javax.net.ssl.*;
import javax.sip.address.*;
import net.java.sip.communicator.impl.protocol.sip.*;
@ -19,17 +18,15 @@
import net.java.sip.communicator.impl.protocol.sip.xcap.utils.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.httputil.*;
import net.java.sip.communicator.util.*;
import org.apache.http.*;
import org.apache.http.auth.*;
import org.apache.http.client.*;
import org.apache.http.client.methods.*;
import org.apache.http.conn.*;
import org.apache.http.conn.scheme.*;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.*;
import org.apache.http.impl.client.*;
import org.apache.http.params.*;
import org.osgi.framework.*;
/**
@ -68,11 +65,6 @@ public abstract class BaseHttpXCapClient implements HttpXCapClient
public static final String XCAP_ERROR_CONTENT_TYPE
= "application/xcap-error+xml";
/**
* The default timeout (10 seconds)
*/
private static int DEFAULT_TIMEOUT = 10 * 1000;
/**
* Current server uri.
*/
@ -98,11 +90,6 @@ public abstract class BaseHttpXCapClient implements HttpXCapClient
*/
private boolean connected;
/**
* How many seconds should the client wait for HTTP response.
*/
private int timeout;
/**
* The service we use to interact with user regarding certificates.
*/
@ -113,8 +100,6 @@ public abstract class BaseHttpXCapClient implements HttpXCapClient
*/
public BaseHttpXCapClient()
{
timeout = DEFAULT_TIMEOUT;
ServiceReference guiVerifyReference
= SipActivator.getBundleContext().getServiceReference(
CertificateService.class.getName());
@ -194,15 +179,13 @@ public XCapHttpResponse get(XCapResourceId resourceId)
protected XCapHttpResponse get(URI uri)
throws XCapException
{
DefaultHttpClient httpClient = createHttpClient();
DefaultHttpClient httpClient = null;
try
{
httpClient = createHttpClient();
HttpGet getMethod = new HttpGet(uri);
getMethod.setHeader("Connection", "close");
Credentials credentials =
new UsernamePasswordCredentials(getUserName(), password);
httpClient.getCredentialsProvider().
setCredentials(AuthScope.ANY, credentials);
HttpResponse response = httpClient.execute(getMethod);
XCapHttpResponse result = createResponse(response);
@ -246,7 +229,8 @@ protected XCapHttpResponse get(URI uri)
}
finally
{
httpClient.getConnectionManager().shutdown();
if(httpClient != null)
httpClient.getConnectionManager().shutdown();
}
}
@ -292,9 +276,11 @@ static void showError(Exception ex, String title, String message)
public XCapHttpResponse put(XCapResource resource)
throws XCapException
{
DefaultHttpClient httpClient = createHttpClient();
DefaultHttpClient httpClient = null;
try
{
httpClient = createHttpClient();
URI resourceUri = getResourceURI(resource.getId());
HttpPut putMethod = new HttpPut(resourceUri);
putMethod.setHeader("Connection", "close");
@ -302,10 +288,7 @@ public XCapHttpResponse put(XCapResource resource)
stringEntity.setContentType(resource.getContentType());
stringEntity.setContentEncoding("UTF-8");
putMethod.setEntity(stringEntity);
Credentials credentials =
new UsernamePasswordCredentials(getUserName(), password);
httpClient.getCredentialsProvider().
setCredentials(AuthScope.ANY, credentials);
if (logger.isDebugEnabled())
{
String logMessage = String.format(
@ -327,7 +310,8 @@ public XCapHttpResponse put(XCapResource resource)
}
finally
{
httpClient.getConnectionManager().shutdown();
if(httpClient != null)
httpClient.getConnectionManager().shutdown();
}
}
@ -343,16 +327,15 @@ public XCapHttpResponse delete(XCapResourceId resourceId)
throws XCapException
{
assertConnected();
DefaultHttpClient httpClient = createHttpClient();
DefaultHttpClient httpClient = null;
try
{
httpClient = createHttpClient();
URI resourceUri = getResourceURI(resourceId);
HttpDelete deleteMethod = new HttpDelete(resourceUri);
deleteMethod.setHeader("Connection", "close");
Credentials credentials =
new UsernamePasswordCredentials(getUserName(), password);
httpClient.getCredentialsProvider().
setCredentials(AuthScope.ANY, credentials);
if (logger.isDebugEnabled())
{
String logMessage = String.format(
@ -373,7 +356,8 @@ public XCapHttpResponse delete(XCapResourceId resourceId)
}
finally
{
httpClient.getConnectionManager().shutdown();
if(httpClient != null)
httpClient.getConnectionManager().shutdown();
}
}
@ -397,26 +381,6 @@ public URI getUri()
return uri;
}
/**
* Gets operation timeout.The deffault value is 10 seconds.
*
* @return operation timeout.
*/
public int getTimeout()
{
return timeout;
}
/**
* Sets operation timeout. The deffault value is 10 seconds.
*
* @param timeout operation timeout.
*/
public void setTimeout(int timeout)
{
this.timeout = timeout;
}
/**
* Utility method throwing an exception if the user is not connected.
*
@ -456,32 +420,16 @@ protected URI getResourceURI(XCapResourceId resourceId)
* @return the HTTP client.
*/
private DefaultHttpClient createHttpClient()
throws IOException
{
//TODO: move to HttpUtil
DefaultHttpClient httpClient = new DefaultHttpClient();
try
{
// make sure we use Certificate Verification Service if
// for some reason the certificate needs to be shown to user
// for approval
ClientConnectionManager ccm = httpClient.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
SSLContext ctx =
certificateVerification.getSSLContext(
certificateVerification.getTrustManager(uri.getHost()));
org.apache.http.conn.ssl.SSLSocketFactory ssf =
new org.apache.http.conn.ssl.SSLSocketFactory(ctx,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
sr.register(new Scheme("https", 443, ssf));
}
catch(Throwable e)
{
logger.error("Cannot add our trust manager to httpClient", e);
}
HttpParams httpParams = httpClient.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
HttpConnectionParams.setSoTimeout(httpParams, timeout);
return httpClient;
XCapCredentialsProvider credentialsProvider
= new XCapCredentialsProvider();
credentialsProvider.setCredentials(
AuthScope.ANY,
new UsernamePasswordCredentials(getUserName(), password));
return HttpUtils.getHttpClient(
null , null, uri.getHost(), credentialsProvider);
}
/**
@ -584,4 +532,45 @@ protected String getXCapErrorMessage(XCapHttpResponse response)
return null;
}
}
/**
* Our credentials provider simple impl.
*/
private class XCapCredentialsProvider
implements CredentialsProvider
{
/**
* The credentials to use.
*/
private Credentials credentials;
/**
* Sets credentials no matter of the scope.
* @param authscope the scope is not used.
* @param credentials the credentials to use
*/
public void setCredentials(AuthScope authscope,
Credentials credentials)
{
this.credentials = credentials;
}
/**
* Returns the credentials no matter of the scope.
* @param authscope not important
* @return the credentials.
*/
public Credentials getCredentials(AuthScope authscope)
{
return credentials;
}
/**
* Clears credentials.
*/
public void clear()
{
credentials = null;
}
}
}

@ -89,19 +89,4 @@ public XCapHttpResponse delete(XCapResourceId resourceId)
* @return server location.
*/
public URI getUri();
/**
* Gets operation timeout.
*
* @return operation timeout.
*/
public int getTimeout();
/**
* Sets operation timeout.
*
* @param timeout operation timeout.
*/
public void setTimeout(int timeout);
}

@ -11,6 +11,7 @@
import javax.swing.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.Logger;
import org.jitsi.util.*;
@ -23,7 +24,8 @@
*/
public class AuthenticationWindow
extends SIPCommDialog
implements ActionListener
implements ActionListener,
AuthenticationWindowService.AuthenticationWindow
{
private static final long serialVersionUID = 1L;
@ -172,7 +174,7 @@ public AuthenticationWindow(String server,
* the user that something went wrong
* @param signupLink an URL that allows the user to sign up
*/
private AuthenticationWindow(String userName,
AuthenticationWindow(String userName,
char[] password,
String server,
boolean isUserNameEditable,

@ -5,6 +5,7 @@
import java.security.cert.*;
import javax.imageio.*;
import javax.swing.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.certificate.*;
@ -71,6 +72,43 @@ public String showInputDialog(boolean prevSuccess)
}
},
null);
bundleContext.registerService(
AuthenticationWindowService.class.getName(),
new AuthenticationWindowService()
{
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)
{
ImageIcon imageIcon = null;
if(icon instanceof ImageIcon)
imageIcon = (ImageIcon)icon;
return new net.java.sip.communicator.plugin.desktoputil
.AuthenticationWindow(
userName, password,
server,
isUserNameEditable, isRememberPassword,
imageIcon,
windowTitle, windowText,
usernameLabelText, passwordLabelText,
errorMessage,
signupLink);
}
},
null);
}
/**

@ -19,6 +19,7 @@ Import-Package: org.osgi.framework,
org.jitsi.util,
net.java.sip.communicator.util,
net.java.sip.communicator.plugin.desktoputil,
org.apache.http.params,
javax.swing,
javax.swing.event,
javax.swing.table,

@ -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);
}
}

@ -2,6 +2,7 @@
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
@ -146,4 +147,14 @@ public static ConfigurationService getConfigurationService()
}
return configurationService;
}
/**
* Returns service to show authentication window.
* @return return service to show authentication window.
*/
public static AuthenticationWindowService getAuthenticationWindowService()
{
return ServiceUtils.getService(
bundleContext, AuthenticationWindowService.class);
}
}

@ -14,7 +14,7 @@
import javax.net.ssl.*;
import net.java.sip.communicator.util.Logger;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.gui.*;
import org.apache.http.*;
import org.apache.http.Header;
@ -24,7 +24,6 @@
import org.apache.http.client.params.*;
import org.apache.http.client.utils.*;
import org.apache.http.conn.scheme.*;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.*;
import org.apache.http.entity.mime.*;
import org.apache.http.entity.mime.content.*;
@ -524,11 +523,11 @@ else if(i == passwordParamIx && creds != null)
* in the new client
* @param address the address we will be connecting to
*/
private static DefaultHttpClient getHttpClient(
public static DefaultHttpClient getHttpClient(
String usernamePropertyName,
String passwordPropertyName,
final String address,
HTTPCredentialsProvider credentialsProvider)
CredentialsProvider credentialsProvider)
throws IOException
{
HttpParams params = new BasicHttpParams();
@ -559,12 +558,16 @@ private static DefaultHttpClient getHttpClient(
// note to any reviewer concerned about ALLOW_ALL_HOSTNAME_VERIFIER:
// the SSL context obtained from the certificate service takes care of
// certificate validation
Scheme sch =
new Scheme("https", 443, new SSLSocketFactory(sslCtx,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER));
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
//TODO: wrap the SSLSocketFactory to use our own DNS resolution
//TODO: register socketfactory for http to use our own DNS resolution
try
{
Scheme sch =
new Scheme("https", 443, new SSLSocketFactoryEx(sslCtx));
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
}
catch(Throwable t)
{
logger.error("Error creating ssl socket factory", t);
}
// set proxy from default jre settings
ProxySelectorRoutePlanner routePlanner = new ProxySelectorRoutePlanner(
@ -679,11 +682,24 @@ public Credentials getCredentials(AuthScope authscope)
// if password is not saved ask user for credentials
if(pass == null)
{
AuthenticationWindow authWindow =
new AuthenticationWindow(
AuthenticationWindowService authenticationWindowService =
HttpUtilActivator.getAuthenticationWindowService();
if(authenticationWindowService == null)
{
logger.error(
"No AuthenticationWindowService implementation");
return null;
}
AuthenticationWindowService.AuthenticationWindow authWindow =
authenticationWindowService.create(
authUsername, null,
authscope.getHost(), true, null, errorMessage,
authscope.getHost(),
true,
false,
null, null, null, null, null,
errorMessage,
HttpUtilActivator.getResources().getSettingsString(
"plugin.provisioning.SIGN_UP_LINK"));
authWindow.setVisible(true);

@ -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;
}
}

@ -32,6 +32,7 @@ Import-Package: org.xml.sax,
net.java.sip.communicator.service.resources,
net.java.sip.communicator.service.certificate,
net.java.sip.communicator.service.credentialsstorage,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.keybindings,
net.java.sip.communicator.service.netaddr,
net.java.sip.communicator.service.netaddr.event,
@ -47,14 +48,12 @@ Import-Package: org.xml.sax,
org.apache.commons.codec.digest,
org.apache.commons.codec.binary,
org.apache.commons.logging,
javax.net.ssl,
javax.security.auth.x500
Export-Package: net.java.sip.communicator.service.httputil,
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,
@ -77,4 +76,7 @@ Export-Package: net.java.sip.communicator.service.httputil,
org.apache.http.conn.scheme,
org.apache.http.conn.ssl,
org.apache.http.conn.util,
org.apache.http.impl.client
org.apache.http.impl.client,
javax.net.ssl,
javax.security.auth.x500
Export-Package: net.java.sip.communicator.service.httputil

Loading…
Cancel
Save