From f9f572270d72e33467272a8e7ef7ecc5e0648007 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Fri, 26 Nov 2010 12:47:54 +0000 Subject: [PATCH] Updatecheck activator, update authenticate window, exported window no more used. --- .../install/windows/installer-windows.wxs | 2 +- .../updatechecker/UpdateCheckActivator.java | 104 +++++++++--------- .../service/gui/ExportedWindow.java | 6 - 3 files changed, 55 insertions(+), 57 deletions(-) diff --git a/resources/install/windows/installer-windows.wxs b/resources/install/windows/installer-windows.wxs index b9b05fef0..c9eac8eed 100644 --- a/resources/install/windows/installer-windows.wxs +++ b/resources/install/windows/installer-windows.wxs @@ -170,7 +170,7 @@ - + diff --git a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java index ea2da7583..2a893ebeb 100644 --- a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java +++ b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java @@ -614,46 +614,6 @@ else if(u.getProtocol().equals("https")) vs.getSSLContext( u.getHost(), port).getSocketFactory()); } - - int responseCode = ((HttpURLConnection) uc).getResponseCode(); - - if(responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) - { - new Thread(new Runnable() - { - public void run() - { - ExportedWindow authWindow = - getUIService().getExportedWindow( - ExportedWindow.AUTHENTICATION_WINDOW); - - UserCredentials cred = new UserCredentials(); - authWindow.setParams(new Object[]{cred}); - authWindow.setVisible(true); - - userCredentials = cred; - - if(cred.getUserName() == null) - { - userCredentials = null; - } - else - windowsUpdate(); - } - }).start(); - } - else if(responseCode == HttpURLConnection.HTTP_OK - && userCredentials != null - && userCredentials.getUserName() != null - && userCredentials.isPasswordPersistent()) - { - // if save password is checked save the pass - getConfigurationService().setProperty( - UPDATE_USERNAME_CONFIG, userCredentials.getUserName()); - getConfigurationService().setProperty( - UPDATE_PASSWORD_CONFIG, new String(Base64.encode( - userCredentials.getPasswordAsString().getBytes()))); - } } InputStream in = uc.getInputStream(); @@ -785,18 +745,25 @@ public boolean verify(String urlHostName, SSLSession session) { protected PasswordAuthentication getPasswordAuthentication() { - // if there is something save return it - ConfigurationService config = getConfigurationService(); - String uName - = (String) config.getProperty(UPDATE_USERNAME_CONFIG); - if(uName != null) + if(userCredentials == null) { - String pass - = (String) config.getProperty(UPDATE_PASSWORD_CONFIG); + // if there is something save return it + ConfigurationService config = getConfigurationService(); + String uName + = (String) config.getProperty(UPDATE_USERNAME_CONFIG); + if(uName != null) + { + String pass + = (String) config.getProperty(UPDATE_PASSWORD_CONFIG); - if(pass != null) - return new PasswordAuthentication(uName, - new String(Base64.decode(pass)).toCharArray()); + if(pass != null) + { + userCredentials = new UserCredentials(); + userCredentials.setUserName(uName); + userCredentials.setPassword(pass.toCharArray()); + userCredentials.setPasswordPersistent(true); + } + } } if(userCredentials != null) @@ -807,6 +774,43 @@ protected PasswordAuthentication getPasswordAuthentication() } else { + AuthenticationWindow authWindow = + new AuthenticationWindow("host", true, null); + + userCredentials = new UserCredentials(); + + authWindow.setVisible(true); + + if (!authWindow.isCanceled()) + { + userCredentials.setUserName(authWindow.getUserName()); + userCredentials.setPassword(authWindow.getPassword()); + userCredentials.setPasswordPersistent( + authWindow.isRememberPassword()); + + if(authWindow.isRememberPassword()) + { + // if save password is checked save the pass + getConfigurationService().setProperty( + UPDATE_USERNAME_CONFIG, + userCredentials.getUserName()); + getConfigurationService().setProperty( + UPDATE_PASSWORD_CONFIG, + new String(Base64.encode( + userCredentials.getPasswordAsString() + .getBytes()))); + } + + return new PasswordAuthentication( + userCredentials.getUserName(), + userCredentials.getPassword()); + } + else + { + userCredentials.setUserName(null); + userCredentials = null; + } + return null; } } diff --git a/src/net/java/sip/communicator/service/gui/ExportedWindow.java b/src/net/java/sip/communicator/service/gui/ExportedWindow.java index b610fbad1..dd5eeeccf 100644 --- a/src/net/java/sip/communicator/service/gui/ExportedWindow.java +++ b/src/net/java/sip/communicator/service/gui/ExportedWindow.java @@ -33,12 +33,6 @@ public interface ExportedWindow public static final WindowID CHAT_WINDOW = new WindowID("ChatWindow"); - /** - * The authentication window identifier. - */ - public static final WindowID AUTHENTICATION_WINDOW - = new WindowID("AuthenticationWindow"); - /** * The main (contact list) window identifier. */