works principially, but also accepts 5, because that's the length of the transport pin - card is wrongly initialized, but at least behaviour is standard conform and implementation is generic; refs #126

master
Marc Wäckerlin 12 years ago
parent bcc95090db
commit 3a53b1e09e
  1. 18
      src/pinentry.hxx
  2. 10
      src/pinentry.ui
  3. 3
      src/smartcardauth.hxx

@ -8,6 +8,7 @@
#ifndef __PINDIALOG_HXX__
#define __PINDIALOG_HXX__
#include <cryptoki.hxx>
#include <qbrowserlib/log.hxx>
#include <ui_pinentry.h>
#include <QtGui/QDialog>
@ -19,7 +20,9 @@
class PinEntry: public QDialog, public Ui::PinEntry {
Q_OBJECT;
public:
PinEntry(const QSslCertificate& cert, QWidget *parent=0): QDialog(parent) {
PinEntry(const QSslCertificate& cert, QWidget *parent=0):
QDialog(parent),
_maxPinLen(-1), _minPinLen(0) {
setModal(true);
setupUi(this);
_cert->certificate(cert);
@ -37,6 +40,12 @@ class PinEntry: public QDialog, public Ui::PinEntry {
_certSerial->setText(cert.serialNumber());
}
}
PinEntry& tokeninfo(const cryptoki::TokenInfo& ti) {
_maxPinLen = ti.maxPinLen;
_minPinLen = ti.minPinLen;
on__pin_textChanged(_pin->text());
return *this;
}
PinEntry& retries(int num) {
_pinstatus->setCurrentIndex(num==-1?1:(num==-2?2:0));
_retries->setText(tr("there are %1 PIN attempts left").arg(num));
@ -76,6 +85,11 @@ class PinEntry: public QDialog, public Ui::PinEntry {
_cert->setVisible(s);
adjustSize();
}
void on__pin_textChanged(const QString &text) {
_buttonBox->button(QDialogButtonBox::Ok)
->setEnabled((unsigned long)text.size()>=_minPinLen &&
(unsigned long)text.size()<=_maxPinLen);
}
protected:
QString utfConv(const QString& txt) {
QByteArray value(txt.toAscii());
@ -85,6 +99,8 @@ class PinEntry: public QDialog, public Ui::PinEntry {
}
private:
QEventLoop _run;
unsigned long _maxPinLen;
unsigned long _minPinLen;
};
#endif

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>668</width>
<height>602</height>
<width>688</width>
<height>594</height>
</rect>
</property>
<property name="windowTitle">
@ -179,7 +179,7 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<widget class="QDialogButtonBox" name="_buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -203,7 +203,7 @@
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<sender>_buttonBox</sender>
<signal>accepted()</signal>
<receiver>PinEntry</receiver>
<slot>accept()</slot>
@ -219,7 +219,7 @@
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<sender>_buttonBox</sender>
<signal>rejected()</signal>
<receiver>PinEntry</receiver>
<slot>reject()</slot>

@ -208,7 +208,8 @@ class SmartCardAuth: public QObject {
QSsl::Der), _parent);
while (true) try {
LOG<<"******************************************1*******";
pinEntry.retries(retries(c.slot->slotinfo().slotDescription));
pinEntry.tokeninfo(c.slot->tokeninfo())
.retries(retries(c.slot->slotinfo().slotDescription));
LOG<<"******************************************2*******";
int res(pinEntry.myexec());
LOG<<"******************************************3*******";

Loading…
Cancel
Save