1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _X509CERTIFICATE_MSCRYPTIMPL_HXX_
29 #define _X509CERTIFICATE_MSCRYPTIMPL_HXX_
30 
31 #ifdef _MSC_VER
32 #pragma warning(push,1)
33 #endif
34 #include "Windows.h"
35 #include "WinCrypt.h"
36 #ifdef _MSC_VER
37 #pragma warning(pop)
38 #endif
39 #include <sal/config.h>
40 #include <rtl/ustring.hxx>
41 #include <cppuhelper/factory.hxx>
42 #include <cppuhelper/implbase2.hxx>
43 #include <com/sun/star/uno/Exception.hpp>
44 #include <com/sun/star/lang/XUnoTunnel.hpp>
45 #include <com/sun/star/uno/SecurityException.hpp>
46 #include <com/sun/star/security/XCertificate.hpp>
47 
48 class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper2<
49 	::com::sun::star::security::XCertificate ,
50 	::com::sun::star::lang::XUnoTunnel >
51 {
52 	private :
53 		const CERT_CONTEXT* m_pCertContext ;
54 
55 	public :
56 		X509Certificate_MSCryptImpl() ;
57 		virtual ~X509Certificate_MSCryptImpl() ;
58 
59 		//Methods from XCertificate
60 		virtual sal_Int16 SAL_CALL getVersion() throw ( ::com::sun::star::uno::RuntimeException) ;
61 
62 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSerialNumber() throw ( ::com::sun::star::uno::RuntimeException) ;
63 
64 		virtual ::rtl::OUString SAL_CALL getIssuerName() throw ( ::com::sun::star::uno::RuntimeException) ;
65 
66 		virtual ::rtl::OUString SAL_CALL getSubjectName() throw ( ::com::sun::star::uno::RuntimeException) ;
67 
68 		virtual ::com::sun::star::util::DateTime SAL_CALL getNotValidBefore() throw ( ::com::sun::star::uno::RuntimeException) ;
69 
70 		virtual ::com::sun::star::util::DateTime SAL_CALL getNotValidAfter() throw ( ::com::sun::star::uno::RuntimeException) ;
71 
72 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getIssuerUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ;
73 
74 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ;
75 
76 		virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > > SAL_CALL getExtensions() throw ( ::com::sun::star::uno::RuntimeException) ;
77 
78 		virtual ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificateExtension > SAL_CALL findCertificateExtension( const ::com::sun::star::uno::Sequence< sal_Int8 >& oid ) throw (::com::sun::star::uno::RuntimeException) ;
79 
80 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getEncoded() throw ( ::com::sun::star::uno::RuntimeException) ;
81 
82 		// MM : added by MM
83 		virtual ::rtl::OUString SAL_CALL getSubjectPublicKeyAlgorithm()
84 			throw ( ::com::sun::star::uno::RuntimeException) ;
85 
86 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectPublicKeyValue()
87 			throw ( ::com::sun::star::uno::RuntimeException) ;
88 
89 		virtual ::rtl::OUString SAL_CALL getSignatureAlgorithm()
90 			throw ( ::com::sun::star::uno::RuntimeException) ;
91 
92 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSHA1Thumbprint()
93 			throw ( ::com::sun::star::uno::RuntimeException) ;
94 
95 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getMD5Thumbprint()
96 			throw ( ::com::sun::star::uno::RuntimeException) ;
97 
98 		virtual sal_Int32 SAL_CALL getCertificateUsage( ) throw ( ::com::sun::star::uno::RuntimeException) ;
99 		// MM : end
100 
101 		//Methods from XUnoTunnel
102 		virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (com::sun::star::uno::RuntimeException);
103 
104 		static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
105 		static X509Certificate_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ;
106 
107 		//Helper methods
108 		void setMswcryCert( const CERT_CONTEXT* cert ) ;
109 		const CERT_CONTEXT* getMswcryCert() const ;
110 		void setRawCert( ::com::sun::star::uno::Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) ;
111 } ;
112 
113 #endif	// _X509CERTIFICATE_MSCRYPTIMPL_HXX_
114 
115