Kaydet (Commit) 4a4df3f9 authored tarafından Vladimir Glazounov's avatar Vladimir Glazounov

INTEGRATION: CWS xmlsec08 (1.3.10); FILE MERGED

2005/01/20 03:34:29 mmi 1.3.10.1: smartcard support
Issue number:  38448
Submitted by:
Reviewed by:
üst 84db4cc7
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlsignature_nssimpl.cxx,v $ * $RCSfile: xmlsignature_nssimpl.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: rt $ $Date: 2004-11-26 14:59:34 $ * last change: $Author: vg $ $Date: 2005-03-10 18:14:35 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -79,6 +79,10 @@ ...@@ -79,6 +79,10 @@
#include "xmlelementwrapper_xmlsecimpl.hxx" #include "xmlelementwrapper_xmlsecimpl.hxx"
#endif #endif
#ifndef _SECURITYENVIRONMENT_NSSIMPL_HXX_
#include "securityenvironment_nssimpl.hxx"
#endif
#ifndef _XMLSECURITYCONTEXT_NSSIMPL_HXX_ #ifndef _XMLSECURITYCONTEXT_NSSIMPL_HXX_
#include "xmlsecuritycontext_nssimpl.hxx" #include "xmlsecuritycontext_nssimpl.hxx"
#endif #endif
...@@ -106,6 +110,7 @@ using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ; ...@@ -106,6 +110,7 @@ using ::com::sun::star::xml::wrapper::XXMLDocumentWrapper ;
using ::com::sun::star::xml::crypto::XSecurityEnvironment ; using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
using ::com::sun::star::xml::crypto::XXMLSignature ; using ::com::sun::star::xml::crypto::XXMLSignature ;
using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ; using ::com::sun::star::xml::crypto::XXMLSignatureTemplate ;
using ::com::sun::star::xml::crypto::XSecurityEnvironment ;
using ::com::sun::star::xml::crypto::XXMLSecurityContext ; using ::com::sun::star::xml::crypto::XXMLSecurityContext ;
using ::com::sun::star::xml::crypto::XUriBinding ; using ::com::sun::star::xml::crypto::XUriBinding ;
using ::com::sun::star::xml::crypto::XMLSignatureException ; using ::com::sun::star::xml::crypto::XMLSignatureException ;
...@@ -120,7 +125,7 @@ XMLSignature_NssImpl :: ~XMLSignature_NssImpl() { ...@@ -120,7 +125,7 @@ XMLSignature_NssImpl :: ~XMLSignature_NssImpl() {
Reference< XXMLSignatureTemplate > Reference< XXMLSignatureTemplate >
SAL_CALL XMLSignature_NssImpl :: generate( SAL_CALL XMLSignature_NssImpl :: generate(
const Reference< XXMLSignatureTemplate >& aTemplate , const Reference< XXMLSignatureTemplate >& aTemplate ,
const Reference< XXMLSecurityContext >& aSecurityCtx const Reference< XSecurityEnvironment >& aEnvironment
) throw( com::sun::star::xml::crypto::XMLSignatureException, ) throw( com::sun::star::xml::crypto::XMLSignatureException,
com::sun::star::uno::SecurityException ) com::sun::star::uno::SecurityException )
{ {
...@@ -131,7 +136,7 @@ SAL_CALL XMLSignature_NssImpl :: generate( ...@@ -131,7 +136,7 @@ SAL_CALL XMLSignature_NssImpl :: generate(
if( !aTemplate.is() ) if( !aTemplate.is() )
throw RuntimeException() ; throw RuntimeException() ;
if( !aSecurityCtx.is() ) if( !aEnvironment.is() )
throw RuntimeException() ; throw RuntimeException() ;
//Get the xml node //Get the xml node
...@@ -161,23 +166,33 @@ SAL_CALL XMLSignature_NssImpl :: generate( ...@@ -161,23 +166,33 @@ SAL_CALL XMLSignature_NssImpl :: generate(
} }
//Get Keys Manager //Get Keys Manager
Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
if( !xSecTunnel.is() ) { if( !xSecTunnel.is() ) {
throw RuntimeException() ; throw RuntimeException() ;
} }
#if 0 //i39448 : the key manager should be retrieved from SecurityEnvironment, instead of SecurityContext
XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ;
if( pSecCtxt == NULL ) if( pSecCtxt == NULL )
throw RuntimeException() ; throw RuntimeException() ;
#endif
pMngr = pSecCtxt->keysManager() ; SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xSecTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
if( pSecEnv == NULL )
throw RuntimeException() ;
setErrorRecorder( aTemplate ); setErrorRecorder( aTemplate );
pMngr = pSecEnv->createKeysManager() ; //i39448
if( !pMngr ) {
throw RuntimeException() ;
}
//Create Signature context //Create Signature context
pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ;
if( pDsigCtx == NULL ) if( pDsigCtx == NULL )
{ {
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLSignatureException() ; //throw XMLSignatureException() ;
clearErrorRecorder(); clearErrorRecorder();
return aTemplate; return aTemplate;
...@@ -186,6 +201,7 @@ SAL_CALL XMLSignature_NssImpl :: generate( ...@@ -186,6 +201,7 @@ SAL_CALL XMLSignature_NssImpl :: generate(
//Sign the template //Sign the template
if( xmlSecDSigCtxSign( pDsigCtx , pNode ) < 0 ) { if( xmlSecDSigCtxSign( pDsigCtx , pNode ) < 0 ) {
xmlSecDSigCtxDestroy( pDsigCtx ) ; xmlSecDSigCtxDestroy( pDsigCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//Unregistered the stream/URI binding //Unregistered the stream/URI binding
if( xUriBinding.is() ) if( xUriBinding.is() )
...@@ -197,6 +213,7 @@ SAL_CALL XMLSignature_NssImpl :: generate( ...@@ -197,6 +213,7 @@ SAL_CALL XMLSignature_NssImpl :: generate(
} }
xmlSecDSigCtxDestroy( pDsigCtx ) ; xmlSecDSigCtxDestroy( pDsigCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//Unregistered the stream/URI binding //Unregistered the stream/URI binding
if( xUriBinding.is() ) if( xUriBinding.is() )
...@@ -249,55 +266,52 @@ SAL_CALL XMLSignature_NssImpl :: validate( ...@@ -249,55 +266,52 @@ SAL_CALL XMLSignature_NssImpl :: validate(
throw RuntimeException() ; throw RuntimeException() ;
} }
//added for test: save the result setErrorRecorder( aTemplate );
/*
sal_Int32 nSecurityEnvironment = aSecurityCtx->getSecurityEnvironmentNumber();
sal_Int32 i;
for (i=0; i<nSecurityEnvironment; ++i)
{ {
FILE *dstFile = fopen( "c:\\1.txt", "w" ) ; Reference< XSecurityEnvironment > aEnvironment = aSecurityCtx->getSecurityEnvironmentByIndex(i);
xmlDocDump( dstFile, pNode->doc) ;
fclose( dstFile ) ;
}
*/
//Get Keys Manager //Get Keys Manager
Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; Reference< XUnoTunnel > xSecTunnel( aEnvironment , UNO_QUERY ) ;
if( !xSecTunnel.is() ) { if( !xSecTunnel.is() ) {
throw RuntimeException() ; throw RuntimeException() ;
} }
XMLSecurityContext_NssImpl* pSecCtxt = ( XMLSecurityContext_NssImpl* )xSecTunnel->getSomething( XMLSecurityContext_NssImpl::getUnoTunnelId() ) ; SecurityEnvironment_NssImpl* pSecEnv = ( SecurityEnvironment_NssImpl* )xSecTunnel->getSomething( SecurityEnvironment_NssImpl::getUnoTunnelId() ) ;
if( pSecCtxt == NULL ) if( pSecEnv == NULL )
throw RuntimeException() ; throw RuntimeException() ;
pMngr = pSecCtxt->keysManager() ; pMngr = pSecEnv->createKeysManager() ; //i39448
if( !pMngr ) {
throw RuntimeException() ;
}
setErrorRecorder( aTemplate ); //Create Signature context
pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ;
if( pDsigCtx == NULL )
{
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLSignatureException() ;
clearErrorRecorder();
return aTemplate;
}
//Create Signature context //Verify signature
pDsigCtx = xmlSecDSigCtxCreate( pMngr ) ; int rs = xmlSecDSigCtxVerify( pDsigCtx , pNode );
if( pDsigCtx == NULL )
{
//throw XMLSignatureException() ;
clearErrorRecorder();
return aTemplate;
}
//Verify signature
if( xmlSecDSigCtxVerify( pDsigCtx , pNode ) < 0 ) {
xmlSecDSigCtxDestroy( pDsigCtx ) ; xmlSecDSigCtxDestroy( pDsigCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//Unregistered the stream/URI binding if (rs >= 0)
if( xUriBinding.is() ) {
xmlUnregisterStreamInputCallbacks() ; break;
}
//throw XMLSignatureException() ;
clearErrorRecorder();
return aTemplate;
} }
//valid = ( pDsigCtx->status == xmlSecDSigStatusSucceeded ) ;
xmlSecDSigCtxDestroy( pDsigCtx ) ;
//Unregistered the stream/URI binding //Unregistered the stream/URI binding
if( xUriBinding.is() ) if( xUriBinding.is() )
xmlUnregisterStreamInputCallbacks() ; xmlUnregisterStreamInputCallbacks() ;
......
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