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 _X509CERTIFICATE_MSCRYPTIMPL_HXX_
25 #define _X509CERTIFICATE_MSCRYPTIMPL_HXX_
26 
27 #ifdef _MSC_VER
28 #pragma warning(push,1)
29 #endif
30 #include "Windows.h"
31 #include "WinCrypt.h"
32 #ifdef _MSC_VER
33 #pragma warning(pop)
34 #endif
35 #include <sal/config.h>
36 #include <rtl/ustring.hxx>
37 #include <cppuhelper/factory.hxx>
38 #include <cppuhelper/implbase2.hxx>
39 #include <com/sun/star/uno/Exception.hpp>
40 #include <com/sun/star/lang/XUnoTunnel.hpp>
41 #include <com/sun/star/uno/SecurityException.hpp>
42 #include <com/sun/star/security/XCertificate.hpp>
43 
44 class X509Certificate_MSCryptImpl : public ::cppu::WeakImplHelper2<
45 	::com::sun::star::security::XCertificate ,
46 	::com::sun::star::lang::XUnoTunnel >
47 {
48 	private :
49 		const CERT_CONTEXT* m_pCertContext ;
50 
51 	public :
52 		X509Certificate_MSCryptImpl() ;
53 		virtual ~X509Certificate_MSCryptImpl() ;
54 
55 		//Methods from XCertificate
56 		virtual sal_Int16 SAL_CALL getVersion() throw ( ::com::sun::star::uno::RuntimeException) ;
57 
58 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSerialNumber() throw ( ::com::sun::star::uno::RuntimeException) ;
59 
60 		virtual ::rtl::OUString SAL_CALL getIssuerName() throw ( ::com::sun::star::uno::RuntimeException) ;
61 
62 		virtual ::rtl::OUString SAL_CALL getSubjectName() throw ( ::com::sun::star::uno::RuntimeException) ;
63 
64 		virtual ::com::sun::star::util::DateTime SAL_CALL getNotValidBefore() throw ( ::com::sun::star::uno::RuntimeException) ;
65 
66 		virtual ::com::sun::star::util::DateTime SAL_CALL getNotValidAfter() throw ( ::com::sun::star::uno::RuntimeException) ;
67 
68 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getIssuerUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ;
69 
70 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectUniqueID() throw ( ::com::sun::star::uno::RuntimeException) ;
71 
72 		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) ;
73 
74 		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) ;
75 
76 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getEncoded() throw ( ::com::sun::star::uno::RuntimeException) ;
77 
78 		// MM : added by MM
79 		virtual ::rtl::OUString SAL_CALL getSubjectPublicKeyAlgorithm()
80 			throw ( ::com::sun::star::uno::RuntimeException) ;
81 
82 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSubjectPublicKeyValue()
83 			throw ( ::com::sun::star::uno::RuntimeException) ;
84 
85 		virtual ::rtl::OUString SAL_CALL getSignatureAlgorithm()
86 			throw ( ::com::sun::star::uno::RuntimeException) ;
87 
88 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getSHA1Thumbprint()
89 			throw ( ::com::sun::star::uno::RuntimeException) ;
90 
91 		virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getMD5Thumbprint()
92 			throw ( ::com::sun::star::uno::RuntimeException) ;
93 
94 		virtual sal_Int32 SAL_CALL getCertificateUsage( ) throw ( ::com::sun::star::uno::RuntimeException) ;
95 		// MM : end
96 
97 		//Methods from XUnoTunnel
98 		virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (com::sun::star::uno::RuntimeException);
99 
100 		static const ::com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId() ;
101 		static X509Certificate_MSCryptImpl* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xObj ) ;
102 
103 		//Helper methods
104 		void setMswcryCert( const CERT_CONTEXT* cert ) ;
105 		const CERT_CONTEXT* getMswcryCert() const ;
106 		void setRawCert( ::com::sun::star::uno::Sequence< sal_Int8 > rawCert ) throw ( ::com::sun::star::uno::RuntimeException) ;
107 } ;
108 
109 #endif	// _X509CERTIFICATE_MSCRYPTIMPL_HXX_
110 
111