diff options
author | Mikhail Voitenko <mav@openoffice.org> | 2007-12-13 14:11:05 +0000 |
---|---|---|
committer | Mikhail Voitenko <mav@openoffice.org> | 2007-12-13 14:11:05 +0000 |
commit | 0abb975d91fad4ff55930f22c382bc6cb1bffb67 (patch) | |
tree | e1395620b10ca2f3597d9f4c7089efa763994780 /swext/mediawiki/src/com/sun/star/wiki/Helper.java | |
parent | 7f1c15e5149bbe53918d99f47cbbe15643ded35c (diff) |
use password container to store passwords
Diffstat (limited to 'swext/mediawiki/src/com/sun/star/wiki/Helper.java')
-rw-r--r-- | swext/mediawiki/src/com/sun/star/wiki/Helper.java | 83 |
1 files changed, 80 insertions, 3 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index f3101987a86d..2dfac486d25b 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -4,9 +4,9 @@ * * $RCSfile: Helper.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mav $ $Date: 2007-12-13 10:34:07 $ + * last change: $Author: mav $ $Date: 2007-12-13 15:11:05 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -35,6 +35,8 @@ package com.sun.star.wiki; +import com.sun.star.awt.XControl; +import com.sun.star.awt.XControlContainer; import com.sun.star.awt.XDialog; import com.sun.star.beans.NamedValue; import com.sun.star.beans.PropertyValue; @@ -53,6 +55,10 @@ import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.system.SystemShellExecuteFlags; import com.sun.star.system.XSystemShellExecute; +import com.sun.star.task.UrlRecord; +import com.sun.star.task.XInteractionHandler; +import com.sun.star.task.XMasterPasswordHandling; +import com.sun.star.task.XPasswordContainer; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; @@ -85,6 +91,9 @@ public class Helper private static boolean m_bAllowConnection = true; private static Hashtable m_aAcceptedUnknownCerts; + private static XPasswordContainer m_xPasswordContainer; + private static XInteractionHandler m_xInteractionHandler; + synchronized protected static HttpClient GetHttpClient() throws WikiCancelException { @@ -121,6 +130,42 @@ public class Helper return m_bAllowConnection; } + synchronized protected static XPasswordContainer GetPasswordContainer( XComponentContext xContext ) + throws com.sun.star.uno.Exception + { + if ( m_xPasswordContainer == null && xContext != null ) + { + XMultiComponentFactory xFactory = xContext.getServiceManager(); + if ( xFactory != null ) + m_xPasswordContainer = (XPasswordContainer)UnoRuntime.queryInterface( + XPasswordContainer.class, + xFactory.createInstanceWithContext( "com.sun.star.task.PasswordContainer", xContext ) ); + } + + if ( m_xPasswordContainer == null ) + throw new com.sun.star.uno.RuntimeException(); + + return m_xPasswordContainer; + } + + synchronized protected static XInteractionHandler GetInteractionHandler( XComponentContext xContext ) + throws com.sun.star.uno.Exception + { + if ( m_xInteractionHandler == null && xContext != null ) + { + XMultiComponentFactory xFactory = xContext.getServiceManager(); + if ( xFactory != null ) + m_xInteractionHandler = ( XInteractionHandler )UnoRuntime.queryInterface( + XInteractionHandler.class, + xFactory.createInstanceWithContext( "com.sun.star.task.InteractionHandler", xContext ) ); + } + + if ( m_xInteractionHandler == null ) + throw new com.sun.star.uno.RuntimeException(); + + return m_xInteractionHandler; + } + protected static Protocol GetOwnHttps( int nPort ) { return new Protocol( "https", new WikiProtocolSocketFactory(), ( ( nPort < 0 ) ? 443 : nPort ) ); @@ -630,7 +675,7 @@ public class Helper return null; } - private static void SetControlPropInDialog( XDialog xDialog, String aControlName, String aPropName, Object aPropValue ) + protected static void SetControlPropInDialog( XDialog xDialog, String aControlName, String aPropName, Object aPropValue ) { if ( xDialog != null && aControlName != null && aPropName != null && aPropValue != null ) { @@ -646,5 +691,37 @@ public class Helper } } } + + protected static UrlRecord GetUsersForURL( XComponentContext xContext, String sURL ) + { + UrlRecord aResult = null; + try + { + aResult = GetPasswordContainer( xContext ).find( sURL, GetInteractionHandler( xContext ) ); + } + catch( Exception e ) + { + e.printStackTrace(); + } + + return aResult; + } + + protected static boolean PasswordStoringIsAllowed( XComponentContext xContext ) + { + boolean bResult = false; + try + { + XMasterPasswordHandling xMasterHdl = (XMasterPasswordHandling)UnoRuntime.queryInterface( XMasterPasswordHandling.class, GetPasswordContainer( xContext ) ); + if ( xMasterHdl != null ) + bResult = xMasterHdl.isPersistentStoringAllowed(); + } + catch( Exception e ) + { + e.printStackTrace(); + } + + return bResult; + } } |