diff --git a/.classpath b/.classpath
index cdfb90ba6..3ada0efd0 100644
--- a/.classpath
+++ b/.classpath
@@ -1,92 +1,92 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.xml b/build.xml
index dfdee9395..fec3a1b27 100644
--- a/build.xml
+++ b/build.xml
@@ -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"/>
-
-
-
-
-
-
-
-
-
+
@@ -1999,9 +1988,21 @@ javax.swing.event, javax.swing.border"/>
manifest="${src}/net/java/sip/communicator/service/httputil/httputil.manifest.mf">
-
-
+
+
+
+
+
+
@@ -2369,7 +2370,7 @@ javax.swing.event, javax.swing.border"/>
-
+
diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties
index 42d6d9e0a..42cd65434 100644
--- a/lib/felix.client.run.properties
+++ b/lib/felix.client.run.properties
@@ -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= \
diff --git a/lib/installer-exclude/commons-logging-1.1.1.jar b/lib/installer-exclude/commons-logging-1.1.1.jar
deleted file mode 100644
index 8758a96b7..000000000
Binary files a/lib/installer-exclude/commons-logging-1.1.1.jar and /dev/null differ
diff --git a/lib/installer-exclude/commons-logging-1.1.2.jar b/lib/installer-exclude/commons-logging-1.1.2.jar
new file mode 100644
index 000000000..d6a543c4e
Binary files /dev/null and b/lib/installer-exclude/commons-logging-1.1.2.jar differ
diff --git a/lib/installer-exclude/httpclient.manifest.mf b/lib/installer-exclude/httpclient.manifest.mf
new file mode 100644
index 000000000..31b24ee1a
--- /dev/null
+++ b/lib/installer-exclude/httpclient.manifest.mf
@@ -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
+
+
diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java
index 1a1557c3b..751d7f4a5 100644
--- a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java
@@ -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())
diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java
index eeee7e3b0..528ec4774 100644
--- a/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java
+++ b/src/net/java/sip/communicator/impl/certificate/CertificateVerificationActivator.java
@@ -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);
+ }
}
diff --git a/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf
index 2c5516828..981e58a4a 100644
--- a/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf
+++ b/src/net/java/sip/communicator/impl/certificate/certificate.manifest.mf
@@ -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,
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf
index 5e5e90650..7430ef0b3 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf
+++ b/src/net/java/sip/communicator/impl/protocol/sip/sip.provider.manifest.mf
@@ -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,
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java
index 96e9f1a08..326cf9347 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/BaseHttpXCapClient.java
@@ -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;
+ }
+ }
}
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/xcap/HttpXCapClient.java b/src/net/java/sip/communicator/impl/protocol/sip/xcap/HttpXCapClient.java
index 1c4d4ce55..73ec40e5e 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/xcap/HttpXCapClient.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/xcap/HttpXCapClient.java
@@ -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);
-
}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java
index c5199d83c..dc53b138b 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java
@@ -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,
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java
index b2dcf5188..de92b2814 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java
@@ -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);
}
/**
diff --git a/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf b/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf
index afa6e8594..8b95d2c55 100644
--- a/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/provisioning/provisioning.manifest.mf
@@ -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,
diff --git a/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java b/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java
new file mode 100644
index 000000000..f134444e3
--- /dev/null
+++ b/src/net/java/sip/communicator/service/gui/AuthenticationWindowService.java
@@ -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 AuthenticationWindow 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 true if this window has been canceled,
+ * false - 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 true if the password should be remembered,
+ * false - otherwise.
+ */
+ public boolean isRememberPassword();
+
+ /**
+ * Shows or hides the "save password" checkbox.
+ * @param allow the checkbox is shown when allow is true
+ */
+ public void setAllowSavePassword(boolean allow);
+ }
+}
diff --git a/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java b/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java
index 325aab5de..225a3432c 100644
--- a/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java
+++ b/src/net/java/sip/communicator/service/httputil/HttpUtilActivator.java
@@ -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);
+ }
}
diff --git a/src/net/java/sip/communicator/service/httputil/HttpUtils.java b/src/net/java/sip/communicator/service/httputil/HttpUtils.java
index 2bf7abb33..c3226265d 100644
--- a/src/net/java/sip/communicator/service/httputil/HttpUtils.java
+++ b/src/net/java/sip/communicator/service/httputil/HttpUtils.java
@@ -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);
diff --git a/src/net/java/sip/communicator/service/httputil/SSLSocketFactoryEx.java b/src/net/java/sip/communicator/service/httputil/SSLSocketFactoryEx.java
new file mode 100644
index 000000000..fee8e9842
--- /dev/null
+++ b/src/net/java/sip/communicator/service/httputil/SSLSocketFactoryEx.java
@@ -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;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf b/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf
index 3aae98642..435c0f90e 100644
--- a/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf
+++ b/src/net/java/sip/communicator/service/httputil/httputil.manifest.mf
@@ -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