diff options
author | Mikhail Voitenko <mav@openoffice.org> | 2008-01-29 10:01:28 +0000 |
---|---|---|
committer | Mikhail Voitenko <mav@openoffice.org> | 2008-01-29 10:01:28 +0000 |
commit | ee64111244de6bab796972fe130f1a1e19f94bd5 (patch) | |
tree | bcf9925cc543c4c36c5ed718cc45b83d223894ba | |
parent | c87fcd67b26f2a67755bb69eb5fafb99dcbe47d8 (diff) |
allow to do some special site-related settings in configuration
4 files changed, 83 insertions, 26 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index 06c41f5c4833..e3cd1c0c7bda 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.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mav $ $Date: 2008-01-28 13:47:59 $ + * last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -696,18 +696,9 @@ public class Helper } boolean bNoUnknownCertNotification = false; - if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && m_aAcceptedUnknownCerts != null ) - { - Boolean bAccepted = (Boolean)m_aAcceptedUnknownCerts.get( aHostConfig.getHost() ); - bNoUnknownCertNotification = ( bAccepted != null && bAccepted.booleanValue() ); - } - - if ( !bNoUnknownCertNotification ) - { - Helper.GetHttpClient().executeMethod( aHostConfig, aMethod ); - } - else + if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && AllowUnknownCert( xContext, aURI.toString() ) ) { + // let unknown certificates be accepted { { aHostConfig.setHost( aHostConfig.getHost(), ( aURI.getPort() < 0 ? 443 : aURI.getPort() ), Helper.GetOwnHttps( aURI.getPort() ) ); @@ -715,6 +706,10 @@ public class Helper } } } + else + { + Helper.GetHttpClient().executeMethod( aHostConfig, aMethod ); + } } } @@ -755,12 +750,12 @@ public class Helper return bResult; } - static protected HostConfiguration Login( URI aMainURL, String sWikiUser, String sWikiPass, String sWikiDomain, XComponentContext xContext ) + static protected HostConfiguration Login( URI aMainURL, String sWikiUser, String sWikiPass, XComponentContext xContext ) throws com.sun.star.uno.Exception, java.io.IOException, WikiCancelException { HostConfiguration aHostConfig = null; - if ( sWikiUser != null && sWikiUser.length() > 0 && sWikiPass != null && sWikiDomain != null && xContext != null ) + if ( sWikiUser != null && sWikiUser.length() > 0 && sWikiPass != null && xContext != null ) { HostConfiguration aNewHostConfig = new HostConfiguration(); @@ -781,7 +776,11 @@ public class Helper aPost.addParameter( "wpName", sWikiUser ); aPost.addParameter( "wpRemember", "1" ); aPost.addParameter( "wpPassword", sWikiPass ); - aPost.addParameter( "wpDomain", sWikiDomain ); + String[][] pArgs = GetSpecialArgs( xContext, aMainURL.toString() ); + if ( pArgs != null ) + for ( int nArgInd = 0; nArgInd < pArgs.length; nArgInd++ ) + if ( pArgs[nArgInd].length == 2 && pArgs[nArgInd][0] != null && pArgs[nArgInd][1] != null ) + aPost.addParameter( pArgs[nArgInd][0], pArgs[nArgInd][1] ); ExecuteMethod( aPost, aNewHostConfig, aPostURI, xContext, false ); @@ -971,5 +970,62 @@ public class Helper return bResult; } + + private static boolean AllowUnknownCert( XComponentContext xContext, String aURL ) + { + try + { + XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); + if ( xNameAccess.hasByName( aURL ) ) + { + XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + if ( xEntry != null && xEntry.hasByName( "AllowUnknownCertificate" ) ) + return AnyConverter.toBoolean( xEntry.getByName( "AllowUnknownCertificate" ) ); + } + } + catch( Exception e ) + { + e.printStackTrace(); + } + + return false; + } + + private static String[][] GetSpecialArgs( XComponentContext xContext, String aURL ) + { + try + { + XNameAccess xNameAccess = GetConfigNameAccess( xContext, "org.openoffice.Office.Custom.WikiExtension/SpecialData" ); + if ( xNameAccess.hasByName( aURL ) ) + { + XNameAccess xEntry = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xNameAccess.getByName( aURL ) ); + if ( xEntry != null ) + { + XNameAccess xArgs = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class, xEntry.getByName( "AdditionalLoginArguments" ) ); + if ( xArgs != null ) + { + String[] pNames = xArgs.getElementNames(); + if ( pNames != null && pNames.length > 0 ) + { + String[][] pResult = new String[pNames.length][2]; + for ( int nInd = 0; nInd < pNames.length; nInd++ ) + { + pResult[nInd][0] = pNames[nInd]; + pResult[nInd][1] = AnyConverter.toString( xArgs.getByName( pNames[nInd] ) ); + } + + return pResult; + } + } + } + } + } + catch( Exception e ) + { + e.printStackTrace(); + } + + return null; + } } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java index f1cfc1a94313..6273f931ff72 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java @@ -4,9 +4,9 @@ * * $RCSfile: WikiArticle.java,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mav $ $Date: 2007-12-13 15:11:05 $ + * last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -57,7 +57,6 @@ public class WikiArticle protected String m_sWikiUser; protected String m_sWikiPass; - protected String m_sWikiDomain = "sun"; protected String m_sTitle = ""; @@ -268,7 +267,7 @@ public class WikiArticle protected boolean Login() throws com.sun.star.uno.Exception, java.io.IOException, WikiCancelException { - m_aHostConfig = Helper.Login( m_aMainURI, m_sWikiUser, m_sWikiPass, m_sWikiDomain, m_xContext ); + m_aHostConfig = Helper.Login( m_aMainURI, m_sWikiUser, m_sWikiPass, m_xContext ); return ( m_aHostConfig != null ); } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java index 08550631def4..a45f292816e5 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiEditSettingDialog.java @@ -4,9 +4,9 @@ * * $RCSfile: WikiEditSettingDialog.java,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mav $ $Date: 2008-01-28 13:48:00 $ + * last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -196,7 +196,7 @@ public class WikiEditSettingDialog extends WikiDialog else { if ( ( sUserName.length() > 0 || sPassword.length() > 0 ) - && Helper.Login( new URI( sMainURL ), sUserName, sPassword, "sun", m_xContext ) == null ) + && Helper.Login( new URI( sMainURL ), sUserName, sPassword, m_xContext ) == null ) { // a wrong login information is provided // show error diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java index 3c1b4756586c..9cd9d8456e6b 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiPropDialog.java @@ -4,9 +4,9 @@ * * $RCSfile: WikiPropDialog.java,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: mav $ $Date: 2008-01-28 13:48:00 $ + * last change: $Author: mav $ $Date: 2008-01-29 11:01:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -344,8 +344,10 @@ public class WikiPropDialog extends WikiDialog{ { Helper.ShowError( m_xContext, m_xDialog, + Helper.DLG_SENDTITLE, Helper.CANCELSENDING_ERROR, - null ); + null, + false ); } return true; |