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 #ifndef OOX_CORE_ENCRYPTION_HXX 25 #define OOX_CORE_ENCRYPTION_HXX 26 27 #include <sal/types.h> 28 #include <com/sun/star/beans/NamedValue.hpp> 29 #include <com/sun/star/io/XInputStream.hpp> 30 #include "com/sun/star/uno/Reference.hxx" 31 #include <com/sun/star/uno/XComponentContext.hpp> 32 #include <comphelper/sequenceashashmap.hxx> 33 #include "oox/helper/binaryinputstream.hxx" 34 #include "oox/helper/binaryoutputstream.hxx" 35 36 37 namespace oox { 38 namespace core { 39 40 // ============================================================================ 41 42 class EncryptionInfo 43 { 44 public: 45 // Parses the given stream, and returns a subclass which implements the virtual methods below. 46 static EncryptionInfo* readEncryptionInfo( 47 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& context, 48 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& inputStream ) throw ( ::com::sun::star::uno::Exception ); 49 ~EncryptionInfo()50 virtual ~EncryptionInfo() {} 51 // Checks whether decryption can work, ie. we support all the algorithms, key sizes, etc. 52 virtual bool isImplemented() = 0; 53 // On success, returns a non-empty sequence, and internally stores whatever is needed for a subsequent call to decryptStream() to work. 54 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > verifyPassword( const ::rtl::OUString& rPassword ) throw ( ::com::sun::star::uno::Exception ) = 0; 55 // On success, returns true, and internally stores whatever is needed for a subsequent call to decryptStream() to work. 56 virtual bool verifyEncryptionData( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rEncryptionData ) throw ( ::com::sun::star::uno::Exception ) = 0; 57 // Decrypts the stream using keys derived from previous calls to verifyPassword() or verifyEncryptionData(). 58 virtual void decryptStream( BinaryXInputStream &aEncryptedPackage, BinaryXOutputStream &aDecryptedPackage ) throw ( ::com::sun::star::uno::Exception ) = 0; 59 }; 60 61 // ============================================================================ 62 63 } // namespace core 64 } // namespace oox 65 66 #endif 67