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 @@
*
* $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;
}
}
......@@ -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 );
}
......
......@@ -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
......
......@@ -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;
......
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