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
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#ifndef __PINDIALOG_HXX__
|
#ifndef __PINDIALOG_HXX__
|
||||||
#define __PINDIALOG_HXX__
|
#define __PINDIALOG_HXX__
|
||||||
|
|
||||||
|
#include <cryptoki.hxx>
|
||||||
#include <qbrowserlib/log.hxx>
|
#include <qbrowserlib/log.hxx>
|
||||||
#include <ui_pinentry.h>
|
#include <ui_pinentry.h>
|
||||||
#include <QtGui/QDialog>
|
#include <QtGui/QDialog>
|
||||||
@@ -19,7 +20,9 @@
|
|||||||
class PinEntry: public QDialog, public Ui::PinEntry {
|
class PinEntry: public QDialog, public Ui::PinEntry {
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
public:
|
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);
|
setModal(true);
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
_cert->certificate(cert);
|
_cert->certificate(cert);
|
||||||
@@ -37,6 +40,12 @@ class PinEntry: public QDialog, public Ui::PinEntry {
|
|||||||
_certSerial->setText(cert.serialNumber());
|
_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) {
|
PinEntry& retries(int num) {
|
||||||
_pinstatus->setCurrentIndex(num==-1?1:(num==-2?2:0));
|
_pinstatus->setCurrentIndex(num==-1?1:(num==-2?2:0));
|
||||||
_retries->setText(tr("there are %1 PIN attempts left").arg(num));
|
_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);
|
_cert->setVisible(s);
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
void on__pin_textChanged(const QString &text) {
|
||||||
|
_buttonBox->button(QDialogButtonBox::Ok)
|
||||||
|
->setEnabled((unsigned long)text.size()>=_minPinLen &&
|
||||||
|
(unsigned long)text.size()<=_maxPinLen);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
QString utfConv(const QString& txt) {
|
QString utfConv(const QString& txt) {
|
||||||
QByteArray value(txt.toAscii());
|
QByteArray value(txt.toAscii());
|
||||||
@@ -85,6 +99,8 @@ class PinEntry: public QDialog, public Ui::PinEntry {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
QEventLoop _run;
|
QEventLoop _run;
|
||||||
|
unsigned long _maxPinLen;
|
||||||
|
unsigned long _minPinLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>668</width>
|
<width>688</width>
|
||||||
<height>602</height>
|
<height>594</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="_buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>_buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>PinEntry</receiver>
|
<receiver>PinEntry</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>_buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>PinEntry</receiver>
|
<receiver>PinEntry</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
|
@@ -208,7 +208,8 @@ class SmartCardAuth: public QObject {
|
|||||||
QSsl::Der), _parent);
|
QSsl::Der), _parent);
|
||||||
while (true) try {
|
while (true) try {
|
||||||
LOG<<"******************************************1*******";
|
LOG<<"******************************************1*******";
|
||||||
pinEntry.retries(retries(c.slot->slotinfo().slotDescription));
|
pinEntry.tokeninfo(c.slot->tokeninfo())
|
||||||
|
.retries(retries(c.slot->slotinfo().slotDescription));
|
||||||
LOG<<"******************************************2*******";
|
LOG<<"******************************************2*******";
|
||||||
int res(pinEntry.myexec());
|
int res(pinEntry.myexec());
|
||||||
LOG<<"******************************************3*******";
|
LOG<<"******************************************3*******";
|
||||||
|
Reference in New Issue
Block a user