LCOV - code coverage report
Current view: top level - xmlsecurity/source/framework - securityengine.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 7 14.3 %
Date: 2015-06-13 12:38:46 Functions: 1 6 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_SECURITYENGINE_HXX
      21             : #define INCLUDED_XMLSECURITY_SOURCE_FRAMEWORK_SECURITYENGINE_HXX
      22             : 
      23             : #include <com/sun/star/xml/crypto/sax/XReferenceResolvedListener.hpp>
      24             : #include <com/sun/star/xml/crypto/sax/XReferenceResolvedBroadcaster.hpp>
      25             : #include <com/sun/star/xml/crypto/sax/XKeyCollector.hpp>
      26             : #include <com/sun/star/xml/crypto/sax/XMissionTaker.hpp>
      27             : #include <com/sun/star/xml/crypto/sax/XSAXEventKeeper.hpp>
      28             : #include <com/sun/star/xml/crypto/XXMLSignature.hpp>
      29             : 
      30             : #include <cppuhelper/implbase3.hxx>
      31             : 
      32             : class SecurityEngine : public cppu::WeakImplHelper3
      33             : <
      34             :     com::sun::star::xml::crypto::sax::XReferenceResolvedListener,
      35             :     com::sun::star::xml::crypto::sax::XKeyCollector,
      36             :     com::sun::star::xml::crypto::sax::XMissionTaker
      37             : >
      38             : /****** securityengine.hxx/CLASS SecurityEngine *******************************
      39             :  *
      40             :  *   NAME
      41             :  *  SecurityEngine -- Base class of SignatureEngine and EncryptionEngine
      42             :  *
      43             :  *   FUNCTION
      44             :  *  Maintains common members and methods related with security engine
      45             :  *  operation.
      46             :  *
      47             :  *   AUTHOR
      48             :  *  Michael Mi
      49             :  *  Email: michael.mi@sun.com
      50             :  ******************************************************************************/
      51             : {
      52             : protected:
      53             : 
      54             :     /*
      55             :      * A SAXEventKeeper internally maintians all resources that a security
      56             :      * operation needs. The m_xSAXEventKeeper member is used to release
      57             :      * those resources when the security operation finishes.
      58             :      */
      59             :     com::sun::star::uno::Reference<
      60             :         com::sun::star::xml::crypto::sax::XSAXEventKeeper > m_xSAXEventKeeper;
      61             : 
      62             :     /*
      63             :      * the id of ElementCollector of the template element.
      64             :      * For a signature, the template element is the Signature element,
      65             :      * for a encryption, the EncryptedData/EncryptedKey element is.
      66             :      */
      67             :     sal_Int32 m_nIdOfTemplateEC;
      68             : 
      69             :     /*
      70             :      * remembers how many referenced elements have been bufferred completely,
      71             :      * including the key element, template element, and referenced element of
      72             :      * signature.
      73             :      */
      74             :     sal_Int32 m_nNumOfResolvedReferences;
      75             : 
      76             :     /*
      77             :      * the id of ElementCollector of the key element.
      78             :      * If a Signature element or EncryptedData/EncryptedKey element has
      79             :      * an internal key sub-element, then this member should be -1
      80             :      */
      81             :     sal_Int32 m_nIdOfKeyEC;
      82             : 
      83             :     /*
      84             :      * remembers whether the current opertion has finished.
      85             :      */
      86             :     bool      m_bMissionDone;
      87             : 
      88             :     /*
      89             :      * the Id of the security entity, a signature or encryption, which is used for
      90             :      * the result listener to identify the entity.
      91             :      */
      92             :     sal_Int32 m_nSecurityId;
      93             : 
      94             :     /*
      95             :      * the status of the operation
      96             :      */
      97             :     com::sun::star::xml::crypto::SecurityOperationStatus m_nStatus;
      98             : 
      99             :     /*
     100             :      * the result listener, which will receives the security operation result.
     101             :      */
     102             :     com::sun::star::uno::Reference<
     103             :         com::sun::star::uno::XInterface >
     104             :         m_xResultListener;
     105             : 
     106             : protected:
     107             :     explicit SecurityEngine();
     108           4 :     virtual ~SecurityEngine() {};
     109             : 
     110             :     /*
     111             :      * perform the security operation.
     112             :      * Any derived class will implement this method respectively.
     113             :      */
     114           0 :     virtual void tryToPerform( )
     115           0 :         throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException){};
     116             : 
     117             :     /*
     118             :      * clear up all resources used by this operation.
     119             :      * This method is called after the operation finishes, or a End-Your-Mission
     120             :      * message is received.
     121             :      * Any derived class will implement this method respectively.
     122             :      */
     123           0 :     virtual void clearUp( ) const {};
     124             : 
     125             :         /*
     126             :          * notifies any possible result listener.
     127             :          * When verify a signature or conduct a decryption, the operation result will
     128             :          * be transferred to a listener by this method.
     129             :      * Any derived class will implement this method respectively.
     130             :          */
     131           0 :     virtual void notifyResultListener() const
     132             :         throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
     133           0 :         {};
     134             : 
     135             :     /*
     136             :      * checks whether everything is ready.
     137             :      * Any derived class will implement this method respectively.
     138             :      */
     139           0 :     virtual bool checkReady() const { return true; };
     140             : 
     141             : public:
     142             :     /* XReferenceResolvedListener */
     143             :     virtual void SAL_CALL referenceResolved( sal_Int32 referenceId )
     144             :             throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             : 
     146             :     /* XKeyCollector */
     147             :     virtual void SAL_CALL setKeyId( sal_Int32 id )
     148             :             throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     149             : 
     150             :         /* XMissionTaker */
     151             :         virtual sal_Bool SAL_CALL endMission(  )
     152             :             throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     153             : };
     154             : 
     155             : #endif
     156             : 
     157             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11