QString Common::tokenInfo( CertType type, const TokenData &data ) { QString content; QTextStream s( &content ); SslCertificate c( data.cert() ); s << "<table width=\"100%\"><tr><td>"; if( c.isTempel() ) { s << tr("Company") << ": <font color=\"black\">" << c.toString( "CN" ) << "</font><br />"; s << tr("Register code") << ": <font color=\"black\">" << c.subjectInfo( "serialNumber" ) << "</font><br />"; } else { s << tr("Name") << ": <font color=\"black\">" << c.toString( "GN SN" ) << "</font><br />"; s << tr("Personal code") << ": <font color=\"black\">" << c.subjectInfo( "serialNumber" ) << "</font><br />"; } s << tr("Card in reader") << ": <font color=\"black\">" << data.card() << "</font><br />"; bool willExpire = c.expiryDate().toLocalTime() <= QDateTime::currentDateTime().addDays( 105 ); s << (type == AuthCert ? tr("Auth certificate is") : tr("Sign certificate is") ) << " "; if( c.isValid() ) { s << "<font color=\"green\">" << tr("valid") << "</font>"; if( willExpire ) s << "<br /><font color=\"red\">" << tr("Your certificates will expire soon") << "</font>"; } else s << "<font color=\"red\">" << tr("expired") << "</font>"; if( data.flags() & TokenData::PinLocked ) s << "<br /><font color=\"red\">" << tr("PIN is locked") << "</font>"; s << "</td><td align=\"center\" width=\"75\">"; if( !c.isValid() || willExpire || data.flags() & TokenData::PinLocked ) { s << "<a href=\"openUtility\"><img src=\":/images/warning.png\"><br />" "<font color=\"red\">" << tr("Open utility") << "</font></a>"; } else if( c.isTempel() ) s << "<img src=\":/images/ico_stamp_blue_75.png\">"; else s << "<img src=\":/images/ico_person_blue_75.png\">"; s << "</td></tr></table>"; return content; }
bool AccessCert::download( bool noCard ) { if( noCard ) { QDesktopServices::openUrl( QUrl( tr("http://www.sk.ee/toend/") ) ); return false; } SslCertificate tempel( qApp->signer()->tokensign().cert() ); if( tempel.type() & SslCertificate::TempelType ) { setIcon( Information ); setText( tr("For getting server access certificate to Tempel contact <a href=\"mailto:[email protected]\">[email protected]</a>") ); return false; } setIcon( Information ); setText( tr("Hereby I agree to terms and conditions of validity confirmation service and " "will use the service in extent of 10 signatures per month. If you going to " "exceed the limit of 10 signatures per month or/and will use the service for " "commercial purposes, please refer to IT support of your company. Additional " "information is available from <a href=\"%1\">%1</a> or phone 1777") .arg( tr("http://www.id.ee/kehtivuskinnitus") ) ); setStandardButtons( Help ); QPushButton *agree = addButton( tr("Agree"), AcceptRole ); if( exec() == Help ) { QDesktopServices::openUrl( QUrl( tr("http://www.id.ee/kehtivuskinnitus") ) ); return false; } removeButton( agree ); QSigner *s = qApp->signer(); QPKCS11 *p = qobject_cast<QPKCS11*>(reinterpret_cast<QObject*>(s->handle())); #ifdef Q_OS_WIN QCNG *c = qobject_cast<QCNG*>(reinterpret_cast<QObject*>(s->handle())); if( !p && !c ) return false; #endif s->lock(); Qt::HANDLE key = 0; TokenData token; if( p ) { bool retry = false; do { retry = false; token.setCard( s->tokensign().card() ); Q_FOREACH( const TokenData &t, p->tokens() ) if( token.card() == t.card() && SslCertificate( t.cert() ).enhancedKeyUsage().contains( SslCertificate::ClientAuth ) ) token.setCert( t.cert() ); QPKCS11::PinStatus status = p->login( token ); switch( status ) { case QPKCS11::PinOK: break; case QPKCS11::PinCanceled: s->unlock(); return false; case QPKCS11::PinIncorrect: showWarning( QPKCS11::errorString( status ) ); retry = true; break; default: showWarning( tr("Error downloading server access certificate!") + "\n" + QPKCS11::errorString( status ) ); s->unlock(); return false; } } while( retry ); key = p->key(); } else {