本文整理汇总了C++中SslCertificate::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ SslCertificate::toString方法的具体用法?C++ SslCertificate::toString怎么用?C++ SslCertificate::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SslCertificate
的用法示例。
在下文中一共展示了SslCertificate::toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: link
void SignatureWidget::link( const QString &url )
{
if( url == "details" )
(new SignatureDialog( s, qApp->activeWindow() ))->show();
else if( url == "remove" )
{
SslCertificate c = s.cert();
QString msg = tr("Remove signature %1")
.arg( c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ) );
QMessageBox::StandardButton b = QMessageBox::warning( qApp->activeWindow(), msg, msg,
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel );
if( b == QMessageBox::Ok )
Q_EMIT removeSignature( num );
}
}
示例2:
PinDialog::PinDialog( PinFlags flags, const QSslCertificate &cert, TokenData::TokenFlags token, QWidget *parent )
: QDialog( parent )
{
SslCertificate c = cert;
init( flags, c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ), token );
}
示例3: st
SignatureWidget::SignatureWidget( const DigiDocSignature &signature, unsigned int signnum, QWidget *parent )
: QLabel( parent )
, num( signnum )
, s( signature )
{
setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
setWordWrap( true );
const SslCertificate cert = s.cert();
QString content;
QTextStream st( &content );
if( cert.isTempel() )
st << "<img src=\":/images/ico_stamp_blue_16.png\">";
else
st << "<img src=\":/images/ico_person_blue_16.png\">";
st << "<b>" << Qt::escape( cert.toString( cert.showCN() ? "CN" : "GN SN" ) ) << "</b>";
QString tooltip;
QTextStream t( &tooltip );
QDateTime date = s.dateTime();
if( !s.location().isEmpty() )
{
st << "<br />" << Qt::escape( s.location() );
t << Qt::escape( s.location() ) << "<br />";
}
if( !s.role().isEmpty() )
{
st << "<br />" << Qt::escape( s.role() );
t << Qt::escape( s.role() ) << "<br />";
}
if( !date.isNull() )
{
st << "<br />" << tr("Signed on") << " "
<< SslCertificate::formatDate( date, "dd. MMMM yyyy" ) << " "
<< tr("time") << " "
<< date.toString( "hh:mm" );
t << tr("Signed on") << " "
<< SslCertificate::formatDate( date, "dd. MMMM yyyy" ) << " "
<< tr("time") << " "
<< date.toString( "hh:mm" );
}
setToolTip( tooltip );
st << "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
st << "<td>" << tr("Signature is") << " ";
switch( s.validate() )
{
case DigiDocSignature::Valid: st << "<font color=\"green\">" << tr("valid"); break;
case DigiDocSignature::Invalid: st << "<font color=\"red\">" << tr("not valid"); break;
case DigiDocSignature::Unknown: st << "<font color=\"red\">" << tr("unknown"); break;
}
if( signature.isTest() )
st << " (" << tr("Test signature") << ")";
st << "</font>";
st << "</td><td align=\"right\">";
st << "<a href=\"details\">" << tr("Show details") << "</a>";
st << "</td></tr><tr><td></td>";
st << "<td align=\"right\">";
st << "<a href=\"remove\">" << tr("Remove") << "</a>";
st << "</td></tr></table>";
setText( content );
connect( this, SIGNAL(linkActivated(QString)), SLOT(link(QString)) );
}
示例4: sa
SignatureWidget::SignatureWidget( const DigiDocSignature &signature, unsigned int signnum, QWidget *parent )
: QLabel( parent )
, num( signnum )
, s( signature )
{
setObjectName( QString("signatureWidget%1").arg(signnum) );
setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
setWordWrap( true );
setTextInteractionFlags( Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse );
connect( this, SIGNAL(linkActivated(QString)), SLOT(link(QString)) );
const SslCertificate cert = s.cert();
QString accessibility, content, tooltip;
QTextStream sa( &accessibility );
QTextStream sc( &content );
QTextStream st( &tooltip );
if( cert.type() & SslCertificate::TempelType )
sc << "<img src=\":/images/ico_stamp_blue_16.png\">";
else
sc << "<img src=\":/images/ico_person_blue_16.png\">";
sc << "<b>" << Qt::escape( cert.toString( cert.showCN() ? "CN" : "GN SN" ) ) << "</b>";
if( !s.location().isEmpty() )
{
sa << " " << tr("Location") << " " << s.location();
sc << "<br />" << Qt::escape( s.location() );
st << Qt::escape( s.location() ) << "<br />";
}
if( !s.role().isEmpty() )
{
sa << " " << tr("Role") << " " << s.role();
sc << "<br />" << Qt::escape( s.role() );
st << Qt::escape( s.role() ) << "<br />";
}
DateTime date( s.dateTime().toLocalTime() );
if( !date.isNull() )
{
sa << " " << tr("Signed on") << " "
<< date.formatDate( "dd. MMMM yyyy" ) << " "
<< tr("time") << " "
<< date.toString( "hh:mm" );
sc << "<br />" << tr("Signed on") << " "
<< date.formatDate( "dd. MMMM yyyy" ) << " "
<< tr("time") << " "
<< date.toString( "hh:mm" );
st << tr("Signed on") << " "
<< date.formatDate( "dd. MMMM yyyy" ) << " "
<< tr("time") << " "
<< date.toString( "hh:mm" );
}
setToolTip( tooltip );
sa << " " << tr("Signature is") << " ";
sc << "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr>";
sc << "<td>" << tr("Signature is") << " ";
switch( s.validate() )
{
case DigiDocSignature::Valid:
sa << tr("valid");
sc << "<font color=\"green\">" << tr("valid");
break;
case DigiDocSignature::Warning:
sa << tr("valid") << " (" << tr("Warnings") << ")";
sc << "<font color=\"green\">" << tr("valid") << "</font> <font>(" << tr("Warnings") << ")";
break;
case DigiDocSignature::Test:
sa << tr("valid") << " (" << tr("Test signature") << ")";
sc << "<font color=\"green\">" << tr("valid") << "</font> <font>(" << tr("Test signature") << ")";
break;
case DigiDocSignature::Invalid:
sa << tr("not valid");
sc << "<font color=\"red\">" << tr("not valid");
break;
case DigiDocSignature::Unknown:
sa << tr("unknown");
sc << "<font color=\"red\">" << tr("unknown");
break;
}
sc << "</font>";
sc << "</td><td align=\"right\">";
sc << "<a href=\"details\" style=\"color: #509B00\" title=\"" << tr("Show details") << "\">" << tr("Show details") << "</a>";
sc << "</td></tr><tr><td></td>";
sc << "<td align=\"right\">";
if( s.parent()->isSupported() )
sc << "<a href=\"remove\" style=\"color: #509B00\" title=\"" << tr("Remove") << "\">" << tr("Remove") << "</a>";
sc << "</td></tr></table>";
setText( content );
setAccessibleName( tr("Signature") + " " + cert.toString( cert.showCN() ? "CN" : "GN SN" ) );
setAccessibleDescription( accessibility );
}
示例5: addCertButton
SignatureDialog::SignatureDialog( const DigiDocSignature &signature, QWidget *parent )
: QDialog( parent )
, s( signature )
, d( new SignatureDialogPrivate )
{
d->setupUi( this );
d->error->hide();
setAttribute( Qt::WA_DeleteOnClose );
const SslCertificate c = s.cert();
#define addCertButton(cert, button) if(!cert.isNull()) \
d->buttonBox->addButton(button, QDialogButtonBox::ActionRole)->setProperty("cert", QVariant::fromValue(cert));
addCertButton(s.cert(), tr("Show signer's certificate"));
addCertButton(s.ocspCert(), tr("Show OCSP certificate"));
addCertButton(s.tsaCert(), tr("Show TSA certificate"));
addCertButton(qApp->confValue( Application::TSLCert ).value<QSslCertificate>(), tr("Show TSL certificate"));
QString status;
switch( s.validate() )
{
case DigiDocSignature::Valid:
status = tr("Signature is valid");
break;
case DigiDocSignature::Warning:
status = QString("%1 (%2)").arg( tr("Signature is valid"), tr("Warnings") );
if( !s.lastError().isEmpty() )
d->error->setPlainText( s.lastError() );
if( s.warning() & DigiDocSignature::WrongNameSpace )
{
d->info->setText( tr(
"This Digidoc document has not been created according to specification, "
"but the digital signature is legally valid. Please inform the document creator "
"of this issue. <a href='http://www.id.ee/?id=36511'>Additional information</a>.") );
}
if( s.warning() & DigiDocSignature::DigestWeak )
{
d->info->setText( tr(
"The current BDOC container uses weaker encryption method than officialy accepted in Estonia.") );
}
break;
case DigiDocSignature::Test:
status = QString("%1 (%2)").arg( tr("Signature is valid"), tr("Test signature") );
if( !s.lastError().isEmpty() )
d->error->setPlainText( s.lastError() );
d->info->setText( tr(
"Test signature is signed with test certificates that are similar to the "
"certificates of real tokens, but digital signatures with legal force cannot "
"be given with them as there is no actual owner of the card. "
"<a href='http://www.id.ee/index.php?id=30494'>Additional information</a>.") );
break;
case DigiDocSignature::Invalid:
status = tr("Signature is not valid");
d->error->setPlainText( s.lastError().isEmpty() ? tr("Unknown error") : s.lastError() );
d->info->setText( tr(
"This is an invalid signature or malformed digitally signed file. The signature is not valid.") );
break;
case DigiDocSignature::Unknown:
status = tr("Signature status unknown");
d->error->setPlainText( s.lastError().isEmpty() ? tr("Unknown error") : s.lastError() );
d->info->setText( tr(
"Signature status is displayed unknown if you don't have all validity confirmation service "
"certificates and/or certificate authority certificates installed into your computer. "
"<a href='http://www.id.ee/index.php?id=35941'>Additional information</a>.") );
break;
}
if( d->error->toPlainText().isEmpty() && d->info->text().isEmpty() )
d->tabWidget->removeTab( 0 );
else
d->buttonBox->addButton( QDialogButtonBox::Help );
d->title->setText( c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ) + "\n" + status );
setWindowTitle( c.toString( c.showCN() ? "CN serialNumber" : "GN SN serialNumber" ) + " - " + status );
const QStringList l = s.locations();
d->signerCity->setText( l.value( 0 ) );
d->signerState->setText( l.value( 1 ) );
d->signerZip->setText( l.value( 2 ) );
d->signerCountry->setText( l.value( 3 ) );
Q_FOREACH( const QString &role, s.roles() )
{
QLineEdit *line = new QLineEdit( role, d->signerRoleGroup );
line->setReadOnly( true );
d->signerRoleGroupLayout->addRow( line );
}
// Certificate info
QTreeWidget *t = d->signatureView;
t->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
addItem( t, tr("TSL URL"), qApp->confValue( Application::TSLUrl ).toString() );
addItem( t, tr("Signer's computer time (UTC)"), DateTime( s.signTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
addItem( t, tr("Signature method"), s.signatureMethod() );
addItem( t, tr("Container format"), s.parent()->mediaType() );
if( s.type() != DigiDocSignature::DDocType )
addItem( t, tr("Signature format"), s.profile() );
if( !s.policy().isEmpty() )
{
#define toVer(X) (X)->toUInt() - 1
QStringList ver = s.policy().split( "." );
if( ver.size() >= 3 )
addItem( t, tr("Signature policy"), QString("%1.%2.%3").arg( toVer(ver.end()-3) ).arg( toVer(ver.end()-2) ).arg( toVer(ver.end()-1) ) );
//.........这里部分代码省略.........
示例6: rect
PrintSheet::PrintSheet( DigiDoc *doc, QPrinter *printer )
: QPainter( printer )
, p( printer )
{
printer->setOrientation( QPrinter::Portrait );
left = p->pageRect().left();
margin = left;
right = p->pageRect().right() - 2*margin;
top = p->pageRect().top();
bottom = p->pageRect().y() + p->pageRect().height() - 2*margin;
#ifdef Q_OS_MAC
scale( 0.8, 0.8 );
right /= 0.8;
bottom /= 0.8;
#endif
QFont text = font();
text.setFamily( "Arial, Liberation Sans, Helvetica, sans-serif" );
text.setPixelSize( 12 );
QFont head = text;
QFont sHead = text;
head.setPixelSize( 28 );
sHead.setPixelSize( 18 );
QPen oPen = pen();
QPen sPen = pen();
QPen hPen = pen();
hPen.setWidth( 2 );
sPen.setWidth( 1 );
sPen.setStyle( Qt::DotLine );
setFont( head );
QRect rect( left, top, right, 60 );
drawText( rect, Qt::TextWordWrap, tr("VALIDITY CONFIRMATION SHEET"), &rect );
setPen( hPen );
drawLine( left, rect.bottom(), right, rect.bottom() );
top += rect.height() + 30;
setFont( sHead );
drawText( left, top, tr("SIGNED FILES") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
drawText( left, top, tr("FILE NAME") );
drawText( right-150, top, tr("FILE SIZE") );
for( int i = 0; i < doc->documentModel()->rowCount(); ++i )
{
int fileHeight = drawTextRect( QRect( left, top+5, right - left - 150, 20 ),
doc->documentModel()->index( i, 0 ).data().toString() );
drawTextRect( QRect( right-150, top+5, 150, fileHeight ),
doc->documentModel()->index( i, 2 ).data().toString() );
top += fileHeight;
newPage( 50 );
}
top += 35;
newPage( 50 );
setFont( sHead );
drawText( left, top, tr("SIGNERS") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
int i = 1;
Q_FOREACH( const DigiDocSignature &sig, doc->signatures() )
{
const SslCertificate cert = sig.cert();
bool tempel = cert.isTempel();
newPage( 50 );
drawText( left, top, tr("NO.") );
drawText( left+40, top, tempel ? tr( "COMPANY" ) : tr( "NAME" ) );
drawText( right-300, top, tempel ? tr("REGISTER CODE") : tr("PERSONAL CODE") );
drawText( right-170, top, tr("TIME") );
top += 5;
int nameHeight = drawTextRect( QRect( left+40, top, right - left - 340, 20 ),
cert.toString( cert.showCN() ? "CN" : "GN SN" ) );
drawTextRect( QRect( left, top, 40, nameHeight ),
QString::number( i++ ) );
drawTextRect( QRect( right-300, top, 130, nameHeight ),
cert.subjectInfo( "serialNumber" ) );
drawTextRect( QRect( right-170, top, 170, nameHeight ),
DateTime( sig.dateTime() ).toStringZ( "dd.MM.yyyy hh:mm:ss" ) );
top += 20 + nameHeight;
QString valid;
switch( sig.validate() )
{
case DigiDocSignature::Valid: valid.append( tr("SIGNATURE IS VALID") ); break;
case DigiDocSignature::Invalid: valid.append( tr("SIGNATURE IS NOT VALID") ); break;
//.........这里部分代码省略.........
示例7: init
PinDialog::PinDialog( PinType type, const QSslCertificate &cert, TokenData::TokenFlags flags, QWidget *parent )
: QDialog( parent )
{
SslCertificate c = cert;
init( type, c.toString( c.isTempel() ? "CN serialNumber" : "GN SN serialNumber" ), flags );
}
示例8: QTime
PrintSheet::PrintSheet( DigiDoc *doc, QPrinter *printer )
: QPainter( printer )
, p( printer )
{
printer->setOrientation( QPrinter::Portrait );
QDateTime utc = QDateTime::currentDateTime().toUTC();
utc.setTimeSpec( Qt::LocalTime );
int diffsec = utc.secsTo( QDateTime::currentDateTime() );
QString timediff = diffsec >= 0 ? "+" : "-";
timediff += QTime().addSecs( diffsec >= 0 ? diffsec : -diffsec ).toString( "hh:mm" );
left = p->pageRect().x();
margin = left;
right = p->pageRect().topRight().x() - 2*margin;
top = p->pageRect().topLeft().y() + 30;
#ifdef Q_OS_MAC
scale( 0.8, 0.8 );
right /= 0.8;
#endif
QFont text = font();
text.setFamily( "Arial, Liberation Sans, Helvetica, sans-serif" );
text.setPixelSize( 12 );
QFont head = text;
QFont sHead = text;
head.setPixelSize( 28 );
sHead.setPixelSize( 18 );
QPen oPen = pen();
QPen sPen = pen();
QPen hPen = pen();
hPen.setWidth( 2 );
sPen.setWidth( 1 );
sPen.setStyle( Qt::DotLine );
setFont( head );
drawText( left, top, tr("VALIDITY CONFIRMATION SHEET") );
setPen( hPen );
drawLine( left, top+3, right, top+3 );
top += 45;
setFont( sHead );
drawText( left, top, tr("SIGNED FILES") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
drawText( left, top, tr("FILE NAME") );
drawText( left+400, top, tr("FILE SIZE") );
for( int i = 0; i < doc->documentModel()->rowCount(); ++i )
{
drawLine( left, top+5, right, top+5 );
drawLine( left, top+5, left, top+25 );
drawLine( left+395, top+5, left+395, top+25 );
drawLine( right, top+5, right, top+25 );
top += 20;
drawText( left+5, top, doc->documentModel()->index( i, 0 ).data().toString() );
drawText( left+400, top, doc->documentModel()->index( i, 2 ).data().toString() );
drawLine( left, top+5, right, top+5 );
newPage( 50 );
}
top += 35;
newPage( 50 );
setFont( sHead );
drawText( left, top, tr("SIGNERS") );
setPen( sPen );
drawLine( left, top+3, right, top+3 );
top += 30;
setFont( text );
setPen( oPen );
int i = 1;
Q_FOREACH( const DigiDocSignature &sig, doc->signatures() )
{
newPage( 50 );
const SslCertificate cert = sig.cert();
bool tempel = cert.isTempel();
drawText( left, top, tr("NO.") );
drawLine( left+35, top+5, left+35, top+25 );
drawText( left+40, top, tempel ? tr( "COMPANY" ) : tr( "NAME" ) );
drawLine( right-305, top+5, right-305, top+25 );
drawText( right-300, top, tempel ? tr("REGISTER CODE") : tr("PERSONAL CODE") );
drawLine( right-165, top+5, right-165, top+25 );
drawText( right-160, top, tr("TIME") );
drawRect( left, top+5, right - margin, 20 );
top += 20;
drawText( left+5, top, QString::number( i ) );
drawText( left+40, top, cert.toString( cert.showCN() ? "CN" : "GN SN" ) );
drawText( right-300, top, cert.subjectInfo( "serialNumber" ) );
drawText( right-160, top, sig.dateTime().toString( "dd.MM.yyyy hh:mm:ss" ) + " " + timediff );
top += 25;
//.........这里部分代码省略.........