summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMichael Mi <mmi@openoffice.org>2004-08-05 06:13:30 +0000
committerMichael Mi <mmi@openoffice.org>2004-08-05 06:13:30 +0000
commit30550266f14a737182b2ad8ebea226247e29cc61 (patch)
treea5de2d53b52d56e5be4e332f9a8f3a55763a6463 /xmlsecurity
parent9fbd13baf86c474420bc20863aff1a638bbf7625 (diff)
Issue number:
Submitted by: Andrew Fan Reviewed by: Fix the bug that NSS only can be initialized once if some resouces still in use.
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx66
1 files changed, 47 insertions, 19 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
index e199d07543b6..f9ed9b98acc4 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: seinitializer_nssimpl.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: mt $ $Date: 2004-07-23 09:58:22 $
+ * last change: $Author: mmi $ $Date: 2004-08-05 07:13:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -207,6 +207,27 @@ char* getCurrentProfilePath( )
#endif
+bool nsscrypto_initialize( const char* token ) {
+ static char initialized = 0 ;
+
+ //PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
+ if( !initialized ) {
+ PR_Init( PR_USER_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
+
+ if( NSS_Init( token ) != SECSuccess )
+ return false ;
+
+ initialized = 1 ;
+ }
+
+ return true ;
+}
+
+void nsscrypto_finalize() {
+ PK11_LogoutAll();
+ NSS_Shutdown();
+}
+
bool getMozillaCurrentProfile(rtl::OUString& profilePath);
SEInitializer_NssImpl::SEInitializer_NssImpl(
@@ -252,21 +273,28 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
/* Initialize NSPR and NSS */
- PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
+ /* Replaced with new methods by AF. ----
+ //PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
+ PR_Init( PR_USER_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
if (NSS_Init(sCertDir.getStr()) != SECSuccess )
{
PK11_LogoutAll();
return NULL;
}
+ ----*/
+ if( !nsscrypto_initialize( sCertDir.getStr() ) )
+ return NULL ;
+ else
+ atexit( nsscrypto_finalize ) ;
pCertHandle = CERT_GetDefaultCertDB() ;
pSlot = PK11_GetInternalKeySlot() ;
if (pSlot == NULL)
{
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -274,8 +302,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
if( pSymKey == NULL )
{
PK11_FreeSlot( pSlot ) ;
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -288,8 +316,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
{
PK11_FreeSymKey( pSymKey ) ;
PK11_FreeSlot( pSlot ) ;
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -299,8 +327,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
{
PK11_FreeSymKey( pSymKey ) ;
PK11_FreeSlot( pSlot ) ;
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -309,8 +337,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
{
PK11_FreeSymKey( pSymKey ) ;
PK11_FreeSlot( pSlot ) ;
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -329,8 +357,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
cssu::Reference< cssxc::XXMLSecurityContext > xSecCtx( mxMSF->createInstance ( sSecyrutyContext ), cssu::UNO_QUERY );
if( !xSecCtx.is() )
{
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
@@ -349,8 +377,8 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
PK11_FreeSlot( pSlot ) ;
}
- PK11_LogoutAll();
- NSS_Shutdown();
+ // PK11_LogoutAll();
+ // NSS_Shutdown();
return NULL;
}
}
@@ -363,8 +391,8 @@ void SAL_CALL SEInitializer_NssImpl::freeSecurityContext( const cssu::Reference<
* is destructed, so here no free process for the security context
* is needed.
*/
- PK11_LogoutAll();
- NSS_Shutdown();
+ //PK11_LogoutAll();
+ //NSS_Shutdown();
}
rtl::OUString SEInitializer_NssImpl_getImplementationName ()