1*ec61c6edSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*ec61c6edSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*ec61c6edSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*ec61c6edSAndrew Rist  * distributed with this work for additional information
6*ec61c6edSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*ec61c6edSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*ec61c6edSAndrew Rist  * "License"); you may not use this file except in compliance
9*ec61c6edSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*ec61c6edSAndrew Rist  *
11*ec61c6edSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*ec61c6edSAndrew Rist  *
13*ec61c6edSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*ec61c6edSAndrew Rist  * software distributed under the License is distributed on an
15*ec61c6edSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*ec61c6edSAndrew Rist  * KIND, either express or implied.  See the License for the
17*ec61c6edSAndrew Rist  * specific language governing permissions and limitations
18*ec61c6edSAndrew Rist  * under the License.
19*ec61c6edSAndrew Rist  *
20*ec61c6edSAndrew Rist  *************************************************************/
21*ec61c6edSAndrew Rist 
22*ec61c6edSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX
25cdf0e10cSrcweir #define _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "com/sun/star/lang/XInitialization.hpp"
30cdf0e10cSrcweir #include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
31cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
32cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
33cdf0e10cSrcweir #include <xmlsecurity/documentsignaturehelper.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace com { namespace  sun { namespace star {
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 	namespace uno {
38cdf0e10cSrcweir 		class XComponentContext;
39cdf0e10cSrcweir 	}
40cdf0e10cSrcweir }}}
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class DocumentDigitalSignatures : public cppu::WeakImplHelper2
43cdf0e10cSrcweir <
44cdf0e10cSrcweir 	com::sun::star::security::XDocumentDigitalSignatures,
45cdf0e10cSrcweir 	com::sun::star::lang::XInitialization
46cdf0e10cSrcweir >
47cdf0e10cSrcweir {
48cdf0e10cSrcweir private:
49cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxCtx;
50cdf0e10cSrcweir     // will be set by XInitialization. If not we assume true. false means an earlier version.
51cdf0e10cSrcweir     ::rtl::OUString m_sODFVersion;
52cdf0e10cSrcweir     //The number of arguments which were passed in XInitialization::initialize
53cdf0e10cSrcweir     int m_nArgumentsCount;
54cdf0e10cSrcweir     //Indicates if the document already contains a document signature
55cdf0e10cSrcweir     bool m_bHasDocumentSignature;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     sal_Bool ImplViewSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ) throw (::com::sun::star::uno::RuntimeException);
58cdf0e10cSrcweir     sal_Bool ImplViewSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ) throw (::com::sun::star::uno::RuntimeException);
59cdf0e10cSrcweir     com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > ImplVerifySignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& rxStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignStream, DocumentSignatureMode eMode ) throw (::com::sun::star::uno::RuntimeException);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir public:
62cdf0e10cSrcweir     DocumentDigitalSignatures( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext>& rxCtx );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir     // for service registration...
65cdf0e10cSrcweir 	static ::rtl::OUString GetImplementationName() throw (com::sun::star::uno::RuntimeException);
66cdf0e10cSrcweir 	static ::com::sun::star::uno::Sequence < ::rtl::OUString > GetSupportedServiceNames() throw (com::sun::star::uno::RuntimeException);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	//XInitialization
69cdf0e10cSrcweir 	void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
70cdf0e10cSrcweir 		throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     // XDocumentDigitalSignatures
73cdf0e10cSrcweir     ::sal_Bool SAL_CALL signDocumentContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xSignStream ) throw (::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > SAL_CALL verifyDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir     void SAL_CALL showDocumentContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
76cdf0e10cSrcweir     ::rtl::OUString SAL_CALL getDocumentContentSignatureDefaultStreamName(  ) throw (::com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir     ::sal_Bool SAL_CALL signScriptingContent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xSignStream ) throw (::com::sun::star::uno::RuntimeException);
78cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > SAL_CALL verifyScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
79cdf0e10cSrcweir     void SAL_CALL showScriptingContentSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir     ::rtl::OUString SAL_CALL getScriptingContentSignatureDefaultStreamName(  ) throw (::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir     ::sal_Bool SAL_CALL signPackage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >& xSignStream ) throw (::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::security::DocumentSignatureInformation > SAL_CALL verifyPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
83cdf0e10cSrcweir     void SAL_CALL showPackageSignatures( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xSignInStream ) throw (::com::sun::star::uno::RuntimeException);
84cdf0e10cSrcweir     ::rtl::OUString SAL_CALL getPackageSignatureDefaultStreamName(  ) throw (::com::sun::star::uno::RuntimeException);
85cdf0e10cSrcweir     void SAL_CALL showCertificate( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Certificate ) throw (::com::sun::star::uno::RuntimeException);
86cdf0e10cSrcweir     void SAL_CALL manageTrustedSources(  ) throw (::com::sun::star::uno::RuntimeException);
87cdf0e10cSrcweir     ::sal_Bool SAL_CALL isAuthorTrusted( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Author ) throw (::com::sun::star::uno::RuntimeException);
88cdf0e10cSrcweir     ::sal_Bool SAL_CALL isLocationTrusted( const ::rtl::OUString& Location ) throw (::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir     void SAL_CALL addAuthorToTrustedSources( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Author ) throw (::com::sun::star::uno::RuntimeException);
90cdf0e10cSrcweir     void SAL_CALL addLocationToTrustedSources( const ::rtl::OUString& Location ) throw (::com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance(
95cdf0e10cSrcweir 	const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rCtx) throw ( com::sun::star::uno::Exception );
96cdf0e10cSrcweir 
97cdf0e10cSrcweir #endif // _XMLSECURITY_DOCUMENTDIGITALSIGNATURES_HXX
98