Kaydet (Commit) ee641112 authored tarafından Mikhail Voitenko's avatar Mikhail Voitenko

allow to do some special site-related settings in configuration

üst c87fcd67
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: Helper.java,v $ * $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 Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -696,18 +696,9 @@ public class Helper ...@@ -696,18 +696,9 @@ public class Helper
} }
boolean bNoUnknownCertNotification = false; boolean bNoUnknownCertNotification = false;
if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && m_aAcceptedUnknownCerts != null ) if ( aHostConfig.getProtocol().getScheme().equals( "https" ) && AllowUnknownCert( xContext, aURI.toString() ) )
{
Boolean bAccepted = (Boolean)m_aAcceptedUnknownCerts.get( aHostConfig.getHost() );
bNoUnknownCertNotification = ( bAccepted != null && bAccepted.booleanValue() );
}
if ( !bNoUnknownCertNotification )
{
Helper.GetHttpClient().executeMethod( aHostConfig, aMethod );
}
else
{ {
// let unknown certificates be accepted
{ {
{ {
aHostConfig.setHost( aHostConfig.getHost(), ( aURI.getPort() < 0 ? 443 : aURI.getPort() ), Helper.GetOwnHttps( aURI.getPort() ) ); aHostConfig.setHost( aHostConfig.getHost(), ( aURI.getPort() < 0 ? 443 : aURI.getPort() ), Helper.GetOwnHttps( aURI.getPort() ) );
...@@ -715,6 +706,10 @@ public class Helper ...@@ -715,6 +706,10 @@ public class Helper
} }
} }
} }
else
{
Helper.GetHttpClient().executeMethod( aHostConfig, aMethod );
}
} }
} }
...@@ -755,12 +750,12 @@ public class Helper ...@@ -755,12 +750,12 @@ public class Helper
return bResult; 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 throws com.sun.star.uno.Exception, java.io.IOException, WikiCancelException
{ {
HostConfiguration aHostConfig = null; 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(); HostConfiguration aNewHostConfig = new HostConfiguration();
...@@ -781,7 +776,11 @@ public class Helper ...@@ -781,7 +776,11 @@ public class Helper
aPost.addParameter( "wpName", sWikiUser ); aPost.addParameter( "wpName", sWikiUser );
aPost.addParameter( "wpRemember", "1" ); aPost.addParameter( "wpRemember", "1" );
aPost.addParameter( "wpPassword", sWikiPass ); 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 ); ExecuteMethod( aPost, aNewHostConfig, aPostURI, xContext, false );
...@@ -971,5 +970,62 @@ public class Helper ...@@ -971,5 +970,62 @@ public class Helper
return bResult; 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;
}
} }
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: WikiArticle.java,v $ * $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 Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -57,7 +57,6 @@ public class WikiArticle ...@@ -57,7 +57,6 @@ public class WikiArticle
protected String m_sWikiUser; protected String m_sWikiUser;
protected String m_sWikiPass; protected String m_sWikiPass;
protected String m_sWikiDomain = "sun";
protected String m_sTitle = ""; protected String m_sTitle = "";
...@@ -268,7 +267,7 @@ public class WikiArticle ...@@ -268,7 +267,7 @@ public class WikiArticle
protected boolean Login() protected boolean Login()
throws com.sun.star.uno.Exception, java.io.IOException, WikiCancelException 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 ); return ( m_aHostConfig != null );
} }
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: WikiEditSettingDialog.java,v $ * $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 Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -196,7 +196,7 @@ public class WikiEditSettingDialog extends WikiDialog ...@@ -196,7 +196,7 @@ public class WikiEditSettingDialog extends WikiDialog
else else
{ {
if ( ( sUserName.length() > 0 || sPassword.length() > 0 ) 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 // a wrong login information is provided
// show error // show error
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: WikiPropDialog.java,v $ * $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 Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -344,8 +344,10 @@ public class WikiPropDialog extends WikiDialog{ ...@@ -344,8 +344,10 @@ public class WikiPropDialog extends WikiDialog{
{ {
Helper.ShowError( m_xContext, Helper.ShowError( m_xContext,
m_xDialog, m_xDialog,
Helper.DLG_SENDTITLE,
Helper.CANCELSENDING_ERROR, Helper.CANCELSENDING_ERROR,
null ); null,
false );
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment