70 |
71 |
71 // ---------------------------------------------------------------------------- |
72 // ---------------------------------------------------------------------------- |
72 // convertDateTime() |
73 // convertDateTime() |
73 // ---------------------------------------------------------------------------- |
74 // ---------------------------------------------------------------------------- |
74 // |
75 // |
75 QDateTime convertDateTime(const TTime& aTime) |
76 void convertDateTime(const TTime& aFromTime, QDateTime& aToDateTime) |
76 { |
77 { |
77 const TDateTime &symbianDateTime = aTime.DateTime(); |
78 const TDateTime &symbianDateTime = aFromTime.DateTime(); |
78 |
79 |
79 QDateTime dateTime; |
|
80 QDate date(symbianDateTime.Year(), symbianDateTime.Month()+1, symbianDateTime.Day()+1); |
80 QDate date(symbianDateTime.Year(), symbianDateTime.Month()+1, symbianDateTime.Day()+1); |
81 QTime time(symbianDateTime.Hour(), symbianDateTime.Minute(), symbianDateTime.Second()); |
81 QTime time(symbianDateTime.Hour(), symbianDateTime.Minute(), symbianDateTime.Second()); |
82 dateTime.setDate(date); |
82 aToDateTime.setDate(date); |
83 dateTime.setTime(time); |
83 aToDateTime.setTime(time); |
84 |
|
85 return dateTime; |
|
86 } |
84 } |
87 |
85 |
88 |
86 |
89 // ======== MEMBER FUNCTIONS ======== |
87 // ======== MEMBER FUNCTIONS ======== |
90 |
88 |
91 // ---------------------------------------------------------------------------- |
89 // ---------------------------------------------------------------------------- |
92 // UntrustedCertificateInfoSymbian::UntrustedCertificateInfoSymbian() |
90 // UntrustedCertificateInfoSymbian::UntrustedCertificateInfoSymbian() |
93 // ---------------------------------------------------------------------------- |
91 // ---------------------------------------------------------------------------- |
94 // |
92 // |
95 UntrustedCertificateInfoSymbian::UntrustedCertificateInfoSymbian( |
93 UntrustedCertificateInfoSymbian::UntrustedCertificateInfoSymbian( |
96 const CX509Certificate& aCert) : UntrustedCertificateInfoBase(), iCert(0) |
94 const QByteArray &aEncodedCert) : UntrustedCertificateInfoBase(), |
97 { |
95 mCert(0), mMd5Fingerprint() |
98 QT_TRAP_THROWING(ConstructL(aCert)); |
96 { |
|
97 QT_TRAP_THROWING(ConstructL(aEncodedCert)); |
99 } |
98 } |
100 |
99 |
101 // ---------------------------------------------------------------------------- |
100 // ---------------------------------------------------------------------------- |
102 // UntrustedCertificateInfoSymbian::~UntrustedCertificateInfoSymbian() |
101 // UntrustedCertificateInfoSymbian::~UntrustedCertificateInfoSymbian() |
103 // ---------------------------------------------------------------------------- |
102 // ---------------------------------------------------------------------------- |
104 // |
103 // |
105 UntrustedCertificateInfoSymbian::~UntrustedCertificateInfoSymbian() |
104 UntrustedCertificateInfoSymbian::~UntrustedCertificateInfoSymbian() |
106 { |
105 { |
107 delete iCert; |
106 delete mCert; |
108 } |
107 } |
109 |
108 |
110 // ---------------------------------------------------------------------------- |
109 // ---------------------------------------------------------------------------- |
111 // UntrustedCertificateInfoSymbian::commonNameMatches() |
110 // UntrustedCertificateInfoSymbian::commonNameMatches() |
112 // ---------------------------------------------------------------------------- |
111 // ---------------------------------------------------------------------------- |
117 QT_TRAP_THROWING(matches = CommonNameMatchesL(siteName)); |
116 QT_TRAP_THROWING(matches = CommonNameMatchesL(siteName)); |
118 return matches; |
117 return matches; |
119 } |
118 } |
120 |
119 |
121 // ---------------------------------------------------------------------------- |
120 // ---------------------------------------------------------------------------- |
122 // UntrustedCertificateInfoSymbian::isPermanentAcceptAllowed() |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 bool UntrustedCertificateInfoSymbian::isPermanentAcceptAllowed() const |
|
126 { |
|
127 return isDateValid(); |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // UntrustedCertificateInfoSymbian::certificateDetails() |
121 // UntrustedCertificateInfoSymbian::certificateDetails() |
132 // ---------------------------------------------------------------------------- |
122 // ---------------------------------------------------------------------------- |
133 // |
123 // |
134 QString UntrustedCertificateInfoSymbian::certificateDetails() const |
124 QString UntrustedCertificateInfoSymbian::certificateDetails(const QString &siteName) const |
135 { |
125 { |
136 QString details; |
126 // TODO: localized UI string needed |
137 QTextStream stream(&details); |
127 QString details = tr("Service:\n%1\n\nIssuer:\n%2\n\nSubject:\n%3\n\n" |
138 // TODO: localised UI strings needed |
128 "Valid from:\n%4\n\nValid until:\n%5\n\nCertificate format:\n%6\n\n" |
139 stream << tr("Issuer:\n%1\n").arg(issuerName()); |
129 "Algorithm:\n%7\n\nSerial number:\n%8\n\n" |
140 stream << endl; |
130 "Fingerprint (SHA1):\n%9\n\nFingerprint (MD5):\n%10") |
141 stream << tr("Subject:\n%1\n").arg(subjectName()); |
131 .arg(siteName) // %1 |
142 stream << endl; |
132 .arg(issuerName()) // %2 |
143 stream << tr("Valid from:\n%1\n").arg(validFrom().toString()); |
133 .arg(subjectName()) // %3 |
144 stream << endl; |
134 .arg(validFrom().toString()) // %4 |
145 stream << tr("Valid until:\n%1\n").arg(validTo().toString()); |
135 .arg(validTo().toString()) // %5 |
146 stream << endl; |
136 .arg(format()) // %6 |
147 stream << tr("Certificate format:\n%1\n").arg(format()); |
137 .arg(combinedAlgorithmName()) // %7 |
148 stream << endl; |
138 .arg(formattedSerialNumber(serialNumber())) // %8 |
149 stream << tr("Algorithm:\n%1\n").arg(combinedAlgorithmName()); |
139 .arg(formattedFingerprint(fingerprint())) // %9 |
150 stream << endl; |
140 .arg(formattedFingerprint(mMd5Fingerprint)); // %10 |
151 stream << tr("Serial number:\n%1\n").arg(formattedSerialNumber()); |
|
152 stream << endl; |
|
153 stream << tr("Fingerprint (SHA1):\n%1\n").arg(formattedFingerprint()); |
|
154 // TODO: MD5 fingerprint missing |
|
155 return details; |
141 return details; |
156 } |
142 } |
157 |
143 |
158 // ---------------------------------------------------------------------------- |
144 // ---------------------------------------------------------------------------- |
159 // UntrustedCertificateInfoSymbian::ConstructL() |
145 // UntrustedCertificateInfoSymbian::ConstructL() |
160 // ---------------------------------------------------------------------------- |
146 // ---------------------------------------------------------------------------- |
161 // |
147 // |
162 void UntrustedCertificateInfoSymbian::ConstructL(const CX509Certificate& aCert) |
148 void UntrustedCertificateInfoSymbian::ConstructL(const QByteArray &aEncodedCert) |
163 { |
149 { |
164 ASSERT( iCert == 0 ); |
150 TPtrC8 encodedCert( reinterpret_cast<const TText8*>( aEncodedCert.constData() ), |
165 iCert = CX509Certificate::NewL( aCert ); |
151 aEncodedCert.length() ); |
166 |
152 |
167 HBufC16* subjectBuf = iCert->SubjectL(); |
153 ASSERT( mCert == 0 ); |
168 mSubjectName = QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length()); |
154 mCert = CX509Certificate::NewL( encodedCert ); |
169 delete subjectBuf; |
155 |
170 |
156 HBufC16* subjectBuf = NULL; |
171 HBufC16* issuerBuf = iCert->IssuerL(); |
157 X509CertNameParser::SubjectFullNameL( *mCert, subjectBuf ); |
172 mIssuerName = QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length()); |
158 CleanupStack::PushL( subjectBuf ); |
173 delete issuerBuf; |
159 QT_TRYCATCH_LEAVING( mSubjectName = |
174 |
160 QString::fromUtf16(subjectBuf->Ptr(), subjectBuf->Length()) ); |
175 TPtrC8 fingerprint = iCert->Fingerprint(); |
161 CleanupStack::PopAndDestroy( subjectBuf ); |
176 mFingerprint = QByteArray::fromRawData( |
162 |
177 reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length()); |
163 HBufC16* issuerBuf = NULL; |
178 |
164 X509CertNameParser::IssuerFullNameL( *mCert, issuerBuf ); |
179 TPtrC8 serialNumber = iCert->SerialNumber(); |
165 CleanupStack::PushL( issuerBuf ); |
180 mSerialNumber = QByteArray::fromRawData( |
166 QT_TRYCATCH_LEAVING( mIssuerName = |
181 reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length()); |
167 QString::fromUtf16(issuerBuf->Ptr(), issuerBuf->Length())); |
182 |
168 CleanupStack::PopAndDestroy( issuerBuf ); |
183 const CValidityPeriod& validityPeriod = iCert->ValidityPeriod(); |
169 |
184 mValidFrom = convertDateTime(validityPeriod.Start()); |
170 TPtrC8 fingerprint = mCert->Fingerprint(); |
185 mValidTo = convertDateTime(validityPeriod.Finish()); |
171 QT_TRYCATCH_LEAVING( mFingerprint = QByteArray::fromRawData( |
|
172 reinterpret_cast<const char*>(fingerprint.Ptr()), fingerprint.Length()) ); |
|
173 |
|
174 mMd5Fingerprint = Md5FingerprintL( mCert->Encoding() ); |
|
175 |
|
176 TPtrC8 serialNumber = mCert->SerialNumber(); |
|
177 QT_TRYCATCH_LEAVING( mSerialNumber = QByteArray::fromRawData( |
|
178 reinterpret_cast<const char*>(serialNumber.Ptr()), serialNumber.Length()) ); |
|
179 |
|
180 const CValidityPeriod& validityPeriod = mCert->ValidityPeriod(); |
|
181 convertDateTime(validityPeriod.Start(), mValidFrom); |
|
182 convertDateTime(validityPeriod.Finish(), mValidTo); |
186 |
183 |
187 mFormat = X509Certificate; |
184 mFormat = X509Certificate; |
188 |
185 |
189 const CSigningAlgorithmIdentifier& alg = iCert->SigningAlgorithm(); |
186 const CSigningAlgorithmIdentifier& alg = mCert->SigningAlgorithm(); |
190 mDigestAlgorithm = mapAlgorithm(alg.DigestAlgorithm().Algorithm()); |
187 mDigestAlgorithm = mapAlgorithm(alg.DigestAlgorithm().Algorithm()); |
191 mAsymmetricAlgorithm = mapAlgorithm(alg.AsymmetricAlgorithm().Algorithm()); |
188 mAsymmetricAlgorithm = mapAlgorithm(alg.AsymmetricAlgorithm().Algorithm()); |
192 } |
189 } |
193 |
190 |
194 // ---------------------------------------------------------------------------- |
191 // ---------------------------------------------------------------------------- |