1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <vcl/weld.hxx>
25 namespace com::sun::star
{
26 namespace security
{ class XCertificate
; }
27 namespace xml::crypto
{ class XSecurityEnvironment
; }
30 class CertificateViewerGeneralTP
;
31 class CertificateViewerDetailsTP
;
32 class CertificateViewerCertPathTP
;
33 class CertificateChooser
;
35 class CertificateViewer final
: public weld::GenericDialogController
38 friend class CertificateViewerGeneralTP
;
39 friend class CertificateViewerDetailsTP
;
40 friend class CertificateViewerCertPathTP
;
42 bool const mbCheckForPrivateKey
;
44 css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
> mxSecurityEnvironment
;
45 css::uno::Reference
< css::security::XCertificate
> mxCert
;
47 CertificateChooser
* mpParentChooser
;
49 std::unique_ptr
<weld::Notebook
> mxTabCtrl
;
51 std::unique_ptr
<CertificateViewerGeneralTP
> mxGeneralPage
;
52 std::unique_ptr
<CertificateViewerDetailsTP
> mxDetailsPage
;
53 std::unique_ptr
<CertificateViewerCertPathTP
> mxPathId
;
55 DECL_LINK(ActivatePageHdl
, const OString
&, void);
58 CertificateViewer(weld::Window
* pParent
, const css::uno::Reference
< css::xml::crypto::XSecurityEnvironment
>& rxSecurityEnvironment
, const css::uno::Reference
< css::security::XCertificate
>& rXCert
, bool bCheckForPrivateKey
, CertificateChooser
* pParentChooser
);
59 CertificateChooser
* GetParentChooser() { return mpParentChooser
; }
62 class CertificateViewerTP
65 std::unique_ptr
<weld::Builder
> mxBuilder
;
66 std::unique_ptr
<weld::Container
> mxContainer
;
67 CertificateViewer
* mpDlg
;
70 CertificateViewerTP(weld::Container
* pParent
, const OUString
& rUIXMLDescription
,
71 const OString
& rID
, CertificateViewer
* pDlg
);
74 class CertificateViewerGeneralTP
: public CertificateViewerTP
77 std::unique_ptr
<weld::Image
> m_xCertImg
;
78 std::unique_ptr
<weld::Label
> m_xHintNotTrustedFT
;
79 std::unique_ptr
<weld::Label
> m_xIssuedToLabelFT
;
80 std::unique_ptr
<weld::Label
> m_xIssuedToFT
;
81 std::unique_ptr
<weld::Label
> m_xIssuedByLabelFT
;
82 std::unique_ptr
<weld::Label
> m_xIssuedByFT
;
83 std::unique_ptr
<weld::Label
> m_xValidFromDateFT
;
84 std::unique_ptr
<weld::Label
> m_xValidToDateFT
;
85 std::unique_ptr
<weld::Image
> m_xKeyImg
;
86 std::unique_ptr
<weld::Label
> m_xHintCorrespPrivKeyFT
;
89 CertificateViewerGeneralTP(weld::Container
* pParent
, CertificateViewer
* pDlg
);
92 struct Details_UserDatat
95 bool const mbFixedWidthFont
;
97 Details_UserDatat(OUString aTxt
, bool bFixedWidthFont
)
98 : maTxt(std::move(aTxt
))
99 , mbFixedWidthFont(bFixedWidthFont
)
104 class CertificateViewerDetailsTP
: public CertificateViewerTP
107 std::vector
<std::unique_ptr
<Details_UserDatat
>> m_aUserData
;
109 std::unique_ptr
<weld::TreeView
> m_xElementsLB
;
110 std::unique_ptr
<weld::TextView
> m_xValueDetails
;
112 DECL_LINK(ElementSelectHdl
, weld::TreeView
&, void);
113 void InsertElement(const OUString
& rField
, const OUString
& rValue
,
114 const OUString
& rDetails
, bool bFixedWidthFont
= false);
116 CertificateViewerDetailsTP(weld::Container
* pParent
, CertificateViewer
* pDlg
);
119 struct CertPath_UserData
121 css::uno::Reference
< css::security::XCertificate
> mxCert
;
124 CertPath_UserData(css::uno::Reference
<css::security::XCertificate
> xCert
, bool bValid
)
125 : mxCert(std::move(xCert
))
131 class CertificateViewerCertPathTP
: public CertificateViewerTP
134 CertificateViewer
* mpParent
;
135 bool mbFirstActivateDone
;
137 std::vector
<std::unique_ptr
<CertPath_UserData
>> maUserData
;
138 std::shared_ptr
<CertificateViewer
> mxCertificateViewer
;
140 std::unique_ptr
<weld::TreeView
> mxCertPathLB
;
141 std::unique_ptr
<weld::TreeIter
> mxScratchIter
;
142 std::unique_ptr
<weld::Button
> mxViewCertPB
;
143 std::unique_ptr
<weld::TextView
> mxCertStatusML
;
144 std::unique_ptr
<weld::Label
> mxCertOK
;
145 std::unique_ptr
<weld::Label
> mxCertNotValidated
;
147 DECL_LINK(ViewCertHdl
, weld::Button
&, void);
148 DECL_LINK(CertSelectHdl
, weld::TreeView
&, void);
149 void InsertCert(const weld::TreeIter
* pParent
, const OUString
& _rName
,
150 const css::uno::Reference
< css::security::XCertificate
>& rxCert
,
154 CertificateViewerCertPathTP(weld::Container
* pParent
, CertificateViewer
* pDlg
);
155 ~CertificateViewerCertPathTP();
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */