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

INTEGRATION: CWS xmlsec08 (1.3.10); FILE MERGED

2005/01/20 03:34:25 mmi 1.3.10.1: smartcard support
Issue number:  38448
Submitted by:
Reviewed by:
üst fff393cb
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: xmlencryption_mscryptimpl.cxx,v $ * $RCSfile: xmlencryption_mscryptimpl.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: rt $ $Date: 2004-11-26 14:58:07 $ * last change: $Author: vg $ $Date: 2005-03-10 18:11:00 $
* *
* 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,8 +79,8 @@ ...@@ -79,8 +79,8 @@
#include "xmlelementwrapper_xmlsecimpl.hxx" #include "xmlelementwrapper_xmlsecimpl.hxx"
#endif #endif
#ifndef _XMLSECURITYCONTEXT_MSCRYPTIMPL_HXX_ #ifndef _SECURITYENVIRONMENT_MSCRYPTIMPL_HXX_
#include "xmlsecuritycontext_mscryptimpl.hxx" #include "securityenvironment_mscryptimpl.hxx"
#endif #endif
#ifndef _ERRORCALLBACK_XMLSECIMPL_HXX_ #ifndef _ERRORCALLBACK_XMLSECIMPL_HXX_
...@@ -120,7 +120,7 @@ XMLEncryption_MSCryptImpl :: ~XMLEncryption_MSCryptImpl() { ...@@ -120,7 +120,7 @@ XMLEncryption_MSCryptImpl :: ~XMLEncryption_MSCryptImpl() {
Reference< XXMLEncryptionTemplate > Reference< XXMLEncryptionTemplate >
SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( SAL_CALL XMLEncryption_MSCryptImpl :: encrypt(
const Reference< XXMLEncryptionTemplate >& aTemplate , const Reference< XXMLEncryptionTemplate >& aTemplate ,
const Reference< XXMLSecurityContext >& aSecurityCtx const Reference< XSecurityEnvironment >& aEnvironment
) throw( com::sun::star::xml::crypto::XMLEncryptionException, ) throw( com::sun::star::xml::crypto::XMLEncryptionException,
com::sun::star::uno::SecurityException ) com::sun::star::uno::SecurityException )
{ {
...@@ -133,17 +133,17 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( ...@@ -133,17 +133,17 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt(
if( !aTemplate.is() ) if( !aTemplate.is() )
throw RuntimeException() ; throw RuntimeException() ;
if( !aSecurityCtx.is() ) if( !aEnvironment.is() )
throw RuntimeException() ; throw RuntimeException() ;
//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_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
if( pSecCtxt == NULL ) if( pSecEnv == NULL )
throw RuntimeException() ; throw RuntimeException() ;
//Get the encryption template //Get the encryption template
...@@ -210,23 +210,27 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( ...@@ -210,23 +210,27 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt(
isParentRef = sal_False; isParentRef = sal_False;
} }
pMngr = pSecCtxt->keysManager() ;
setErrorRecorder( aTemplate ); setErrorRecorder( aTemplate );
pMngr = pSecEnv->createKeysManager() ; //i39448
if( !pMngr ) {
throw RuntimeException() ;
}
//Create Encryption context //Create Encryption context
pEncCtx = xmlSecEncCtxCreate( pMngr ) ; pEncCtx = xmlSecEncCtxCreate( pMngr ) ;
if( pEncCtx == NULL ) if( pEncCtx == NULL )
{ {
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLEncryptionException() ; //throw XMLEncryptionException() ;
clearErrorRecorder(); clearErrorRecorder();
return aTemplate; return aTemplate;
} }
//Encrypt the template //Encrypt the template
if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) { if( xmlSecEncCtxXmlEncrypt( pEncCtx , pEncryptedData , pContent ) < 0 ) {
xmlSecEncCtxDestroy( pEncCtx ) ; xmlSecEncCtxDestroy( pEncCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLEncryptionException() ; //throw XMLEncryptionException() ;
clearErrorRecorder(); clearErrorRecorder();
...@@ -234,6 +238,7 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt( ...@@ -234,6 +238,7 @@ SAL_CALL XMLEncryption_MSCryptImpl :: encrypt(
} }
xmlSecEncCtxDestroy( pEncCtx ) ; xmlSecEncCtxDestroy( pEncCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//get the new EncryptedData element //get the new EncryptedData element
if (isParentRef) if (isParentRef)
...@@ -268,13 +273,16 @@ XMLEncryption_MSCryptImpl :: decrypt( ...@@ -268,13 +273,16 @@ XMLEncryption_MSCryptImpl :: decrypt(
throw RuntimeException() ; throw RuntimeException() ;
//Get Keys Manager //Get Keys Manager
Reference< XUnoTunnel > xSecTunnel( aSecurityCtx , UNO_QUERY ) ; Reference< XSecurityEnvironment > xSecEnv
= aSecurityCtx->getSecurityEnvironmentByIndex(
aSecurityCtx->getDefaultSecurityEnvironmentIndex());
Reference< XUnoTunnel > xSecTunnel( xSecEnv , UNO_QUERY ) ;
if( !xSecTunnel.is() ) { if( !xSecTunnel.is() ) {
throw RuntimeException() ; throw RuntimeException() ;
} }
XMLSecurityContext_MSCryptImpl* pSecCtxt = ( XMLSecurityContext_MSCryptImpl* )xSecTunnel->getSomething( XMLSecurityContext_MSCryptImpl::getUnoTunnelId() ) ; SecurityEnvironment_MSCryptImpl* pSecEnv = ( SecurityEnvironment_MSCryptImpl* )xSecTunnel->getSomething( SecurityEnvironment_MSCryptImpl::getUnoTunnelId() ) ;
if( pSecCtxt == NULL ) if( pSecEnv == NULL )
throw RuntimeException() ; throw RuntimeException() ;
//Get the encryption template //Get the encryption template
...@@ -310,14 +318,18 @@ XMLEncryption_MSCryptImpl :: decrypt( ...@@ -310,14 +318,18 @@ XMLEncryption_MSCryptImpl :: decrypt(
isParentRef = sal_False; isParentRef = sal_False;
} }
pMngr = pSecCtxt->keysManager() ;
setErrorRecorder( aTemplate ); setErrorRecorder( aTemplate );
pMngr = pSecEnv->createKeysManager() ; //i39448
if( !pMngr ) {
throw RuntimeException() ;
}
//Create Encryption context //Create Encryption context
pEncCtx = xmlSecEncCtxCreate( pMngr ) ; pEncCtx = xmlSecEncCtxCreate( pMngr ) ;
if( pEncCtx == NULL ) if( pEncCtx == NULL )
{ {
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLEncryptionException() ; //throw XMLEncryptionException() ;
clearErrorRecorder(); clearErrorRecorder();
return aTemplate; return aTemplate;
...@@ -326,6 +338,7 @@ XMLEncryption_MSCryptImpl :: decrypt( ...@@ -326,6 +338,7 @@ XMLEncryption_MSCryptImpl :: decrypt(
//Decrypt the template //Decrypt the template
if( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL ) { if( xmlSecEncCtxDecrypt( pEncCtx , pEncryptedData ) < 0 || pEncCtx->result == NULL ) {
xmlSecEncCtxDestroy( pEncCtx ) ; xmlSecEncCtxDestroy( pEncCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//throw XMLEncryptionException() ; //throw XMLEncryptionException() ;
clearErrorRecorder(); clearErrorRecorder();
...@@ -355,6 +368,7 @@ XMLEncryption_MSCryptImpl :: decrypt( ...@@ -355,6 +368,7 @@ XMLEncryption_MSCryptImpl :: decrypt(
//Destroy the encryption context //Destroy the encryption context
xmlSecEncCtxDestroy( pEncCtx ) ; xmlSecEncCtxDestroy( pEncCtx ) ;
pSecEnv->destroyKeysManager( pMngr ) ; //i39448
//get the decrypted element //get the decrypted element
XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef? XMLElementWrapper_XmlSecImpl * ret = new XMLElementWrapper_XmlSecImpl(isParentRef?
......
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