xref: /AOO41X/main/xmlsecurity/source/framework/securityengine.cxx (revision 06b3ce531745799678cf4bb887ef37436d81238b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmlsecurity.hxx"
26 
27 #include "securityengine.hxx"
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 
30 namespace cssu = com::sun::star::uno;
31 namespace cssl = com::sun::star::lang;
32 namespace cssxc = com::sun::star::xml::crypto;
33 namespace cssxw = com::sun::star::xml::wrapper;
34 
35 #define DECLARE_ASCII( SASCIIVALUE )                                                                            \
36     rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SASCIIVALUE ) )
37 
SecurityEngine(const cssu::Reference<cssl::XMultiServiceFactory> & rxMSF)38 SecurityEngine::SecurityEngine( const cssu::Reference< cssl::XMultiServiceFactory >& rxMSF )
39     :mxMSF( rxMSF ),
40      m_nIdOfTemplateEC(-1),
41      m_nNumOfResolvedReferences(0),
42      m_nIdOfKeyEC(-1),
43      m_bMissionDone(false),
44      m_nSecurityId(-1),
45      m_nStatus(::com::sun::star::xml::crypto::SecurityOperationStatus_UNKNOWN)
46 {
47 }
48 
49 /* XReferenceResolvedListener */
referenceResolved(sal_Int32)50 void SAL_CALL SecurityEngine::referenceResolved( sal_Int32 /*referenceId*/)
51     throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
52 {
53     m_nNumOfResolvedReferences++;
54     tryToPerform();
55 }
56 
57 /* XKeyCollector */
setKeyId(sal_Int32 id)58 void SAL_CALL SecurityEngine::setKeyId( sal_Int32 id )
59     throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
60 {
61     m_nIdOfKeyEC = id;
62     tryToPerform();
63 }
64 
65 /* XMissionTaker */
endMission()66 sal_Bool SAL_CALL SecurityEngine::endMission(  )
67     throw (com::sun::star::uno::RuntimeException)
68 {
69     sal_Bool rc = m_bMissionDone;
70 
71     if (!rc)
72     {
73         clearUp( );
74 
75         notifyResultListener();
76         m_bMissionDone = true;
77     }
78 
79     m_xResultListener = NULL;
80     m_xSAXEventKeeper = NULL;
81 
82     return rc;
83 }
84 
85