1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Device dialog plugin that shows untrusted certificate |
|
15 * dialog for TLS server authentication failure errors. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "untrustedcertificatewidget.h" |
|
20 #include "untrustedcertificatedefinitions.h" |
|
21 #include "untrustedcertificateinfobase.h" |
|
22 #include "untrustedcertificateinfo_symbian.h" |
|
23 #include <securitydefs.h> // TValidationError |
|
24 |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // UntrustedCertificateWidget::isInvalidCertificate() |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 bool UntrustedCertificateWidget::isCertificateValid() |
|
33 { |
|
34 return (mValidationError != ESignatureInvalid && mValidationError != ECertificateRevoked); |
|
35 } |
|
36 |
|
37 // ---------------------------------------------------------------------------- |
|
38 // UntrustedCertificateWidget::processEncodedCertificate() |
|
39 // ---------------------------------------------------------------------------- |
|
40 // |
|
41 void UntrustedCertificateWidget::processEncodedCertificate(const QByteArray &encodedCert) |
|
42 { |
|
43 UntrustedCertificateInfoBase *info = new UntrustedCertificateInfoSymbian(encodedCert); |
|
44 if (mCertificateInfo) { |
|
45 delete mCertificateInfo; |
|
46 mCertificateInfo = 0; |
|
47 } |
|
48 mCertificateInfo = info; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // UntrustedCertificateWidget::descriptionText() |
|
53 // ---------------------------------------------------------------------------- |
|
54 // |
|
55 QString UntrustedCertificateWidget::descriptionText() |
|
56 { |
|
57 QString text; |
|
58 if (!isCertificateValid()) { |
|
59 //: Information note text shown if the server certificate has an invalid signature |
|
60 // TODO: localised UI string |
|
61 text = tr("'%1' has sent an invalid certificate. Connection cannot be created."); |
|
62 } else if (mValidationError == EValidatedOK || mValidationError == EDateOutOfRange) { |
|
63 bool isDateValid = mCertificateInfo->isDateValid(); |
|
64 bool isSiteValid = mCertificateInfo->commonNameMatches(mServerName); |
|
65 if (!isDateValid && !isSiteValid) { |
|
66 // TODO: hbTrId("txt_untrustedcert_dialog _accept_site_ood") |
|
67 text = tr("'%1' has sent a certificate with different site name and which is out of date. Accept anyway?"); |
|
68 } else if (!isSiteValid) { |
|
69 // TODO: hbTrId("txt_untrustedcert_dialog _accept_site" |
|
70 text = tr("'%1' has sent a certificate with different site name. Accept anyway?"); |
|
71 } else { |
|
72 // TODO: hbTrId("txt_untrustedcert_dialog_accept_ood") |
|
73 text = tr("'%1' has sent a certificate which is out of date. Accept anyway?"); |
|
74 } |
|
75 } else { |
|
76 bool isDateValid = mCertificateInfo->isDateValid(); |
|
77 bool isSiteValid = mCertificateInfo->commonNameMatches(mServerName); |
|
78 if (!isDateValid && !isSiteValid) { |
|
79 // TODO: hbTrId("txt_untrustedcert_dialog _accept_untrusted_site_ood" |
|
80 text = tr("'%1' has sent an untrusted certificate with different site name and which is out of date. Accept anyway?"); |
|
81 } else if (!isSiteValid) { |
|
82 // TODO: hbTrId("txt_untrustedcert_dialog _accept_untrusted_site" |
|
83 text = tr("'%1' has sent an untrusted certificate with different site name. Accept anyway?"); |
|
84 } else if (!isDateValid) { |
|
85 // TODO: hbTrId("txt_untrustedcert_dialog _accept_untrusted_ood") |
|
86 text = tr("'%1' has sent an untrusted certificate which is out of date. Accept anyway?"); |
|
87 } else { |
|
88 // TODO: hbTrId("txt_untrustedcert_dialog _accept_untrusted" |
|
89 text = tr("'%1' has sent an untrusted certificate. Accept anyway?"); |
|
90 } |
|
91 } |
|
92 return text; |
|
93 } |
|
94 |
|