New version of pace-gui indicates wether or not a suitable card was found.
This works by polling the card every second via opensc-tool --atr The radio buttons have been removed to have enough space for the new label git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@148 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -60,10 +60,20 @@
|
|||||||
<property name="position">3</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="lbl_cardStatus">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes"><span fgcolor="red" font_weight="bold" font="11">Keine Karte gefunden</span></property>
|
||||||
|
<property name="use_markup">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTable" id="table1">
|
<object class="GtkTable" id="table1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">5</property>
|
<property name="n_rows">4</property>
|
||||||
<property name="n_columns">3</property>
|
<property name="n_columns">3</property>
|
||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
@@ -74,11 +84,46 @@
|
|||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
<signal name="clicked" handler="on_btnOne_clicked"/>
|
<signal name="clicked" handler="on_btnOne_clicked"/>
|
||||||
</object>
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnFour">
|
||||||
|
<property name="label" translatable="yes">4</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnFour_clicked"/>
|
||||||
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">1</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnSeven">
|
||||||
|
<property name="label" translatable="yes">7</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnSeven_clicked"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnDel">
|
||||||
|
<property name="label">Entf</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnDel_clicked"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
<property name="bottom_attach">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="btnTwo">
|
<object class="GtkButton" id="btnTwo">
|
||||||
<property name="label" translatable="yes">2</property>
|
<property name="label" translatable="yes">2</property>
|
||||||
@@ -90,36 +135,6 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnThree">
|
|
||||||
<property name="label" translatable="yes">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnThree_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnFour">
|
|
||||||
<property name="label" translatable="yes">4</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnFour_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -133,36 +148,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">2</property>
|
<property name="top_attach">1</property>
|
||||||
<property name="bottom_attach">3</property>
|
<property name="bottom_attach">2</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnSix">
|
|
||||||
<property name="label" translatable="yes">6</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnSix_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">2</property>
|
|
||||||
<property name="bottom_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnSeven">
|
|
||||||
<property name="label" translatable="yes">7</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnSeven_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -176,23 +163,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="bottom_attach">4</property>
|
<property name="bottom_attach">3</property>
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnNine">
|
|
||||||
<property name="label" translatable="yes">9</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnNine_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
<property name="top_attach">3</property>
|
|
||||||
<property name="bottom_attach">4</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -206,8 +178,51 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="bottom_attach">5</property>
|
<property name="bottom_attach">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnThree">
|
||||||
|
<property name="label" translatable="yes">3</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnThree_clicked"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnSix">
|
||||||
|
<property name="label" translatable="yes">6</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnSix_clicked"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="btnNine">
|
||||||
|
<property name="label" translatable="yes">9</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="on_btnNine_clicked"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">2</property>
|
||||||
|
<property name="right_attach">3</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -221,64 +236,13 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">2</property>
|
<property name="left_attach">2</property>
|
||||||
<property name="right_attach">3</property>
|
<property name="right_attach">3</property>
|
||||||
<property name="top_attach">4</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="bottom_attach">5</property>
|
<property name="bottom_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="btnDel">
|
|
||||||
<property name="label">Entf</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<signal name="clicked" handler="on_btnDel_clicked"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">4</property>
|
|
||||||
<property name="bottom_attach">5</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkRadioButton" id="rdioPUK">
|
|
||||||
<property name="label" translatable="yes">PUK</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">rdioCAN</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">2</property>
|
|
||||||
<property name="right_attach">3</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkRadioButton" id="rdioPIN">
|
|
||||||
<property name="label" translatable="yes">PIN</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">rdioCAN</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkRadioButton" id="rdioCAN">
|
|
||||||
<property name="label" translatable="yes">CAN</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">False</property>
|
|
||||||
<property name="active">True</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">4</property>
|
<property name="position">5</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from threading import Thread, Event
|
||||||
try:
|
try:
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require("2.0")
|
pygtk.require("2.0")
|
||||||
@@ -14,7 +15,7 @@ except:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#glade_dir is set by the build system
|
#glade_dir is set by the build system
|
||||||
from pinpad_globals import glade_dir
|
from pinpad_globals import *
|
||||||
|
|
||||||
class PinpadGTK:
|
class PinpadGTK:
|
||||||
"""This a simple GTK based GUI to enter a PIN"""
|
"""This a simple GTK based GUI to enter a PIN"""
|
||||||
@@ -63,6 +64,11 @@ class PinpadGTK:
|
|||||||
font = pango.FontDescription("Monospace")
|
font = pango.FontDescription("Monospace")
|
||||||
txtOutput.modify_font(pango.FontDescription("sans 24"))
|
txtOutput.modify_font(pango.FontDescription("sans 24"))
|
||||||
|
|
||||||
|
#Look for card and set the label accordingly
|
||||||
|
lbl_cardStatus = self.builder.get_object("lbl_cardStatus")
|
||||||
|
self.cardChecker = cardChecker(lbl_cardStatus, ePA_ATR)
|
||||||
|
gobject.idle_add(self.cardChecker.start)
|
||||||
|
|
||||||
#Change the font for the buttons
|
#Change the font for the buttons
|
||||||
#For this you have to retrieve the label of each button and change
|
#For this you have to retrieve the label of each button and change
|
||||||
#its font
|
#its font
|
||||||
@@ -88,7 +94,12 @@ class PinpadGTK:
|
|||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
if (self.window):
|
if (self.window):
|
||||||
self.window.connect("destroy", gtk.main_quit)
|
self.window.connect("destroy", self.shutdown)
|
||||||
|
|
||||||
|
def shutdown(self, widget):
|
||||||
|
self.cardChecker.stop()
|
||||||
|
self.cardChecker.join()
|
||||||
|
gtk.main_quit()
|
||||||
|
|
||||||
def digit_clicked(self, widget):
|
def digit_clicked(self, widget):
|
||||||
c = widget.get_label()
|
c = widget.get_label()
|
||||||
@@ -102,14 +113,11 @@ class PinpadGTK:
|
|||||||
|
|
||||||
#Check which radio button is checked, so we know what kind of secret to
|
#Check which radio button is checked, so we know what kind of secret to
|
||||||
#use for PACE
|
#use for PACE
|
||||||
rdio = self.builder.get_object("rdioCAN")
|
|
||||||
rdioGrp = rdio.get_group()
|
|
||||||
rdioActive = [r for r in rdioGrp if r.get_active()]
|
|
||||||
env_arg = os.environ
|
env_arg = os.environ
|
||||||
env_arg[rdioActive[0].get_label()] = self.pin
|
env_arg["PIN"] = self.pin #We alway use the eID-PIN
|
||||||
|
|
||||||
#We have to provide the type of secret to use via a command line parameter
|
#We have to provide the type of secret to use via a command line parameter
|
||||||
param = "--" + rdioActive[0].get_label().lower()
|
param = "--pin"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(["pace-tool", param, "-v"],
|
p = subprocess.Popen(["pace-tool", param, "-v"],
|
||||||
@@ -144,7 +152,8 @@ class PinpadGTK:
|
|||||||
else:
|
else:
|
||||||
lbl = self.builder.get_object("txtOutput")
|
lbl = self.builder.get_object("txtOutput")
|
||||||
popup = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL |
|
popup = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL |
|
||||||
gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
|
gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING,
|
||||||
|
gtk.BUTTONS_OK,
|
||||||
"PIN wurde falsch eingegeben. Bitte erneut versuchen")
|
"PIN wurde falsch eingegeben. Bitte erneut versuchen")
|
||||||
res = popup.run()
|
res = popup.run()
|
||||||
popup.destroy()
|
popup.destroy()
|
||||||
@@ -180,6 +189,46 @@ class Popup(object):
|
|||||||
fraction = 0.0
|
fraction = 0.0
|
||||||
self.progbar.set_fraction(fraction)
|
self.progbar.set_fraction(fraction)
|
||||||
|
|
||||||
|
class cardChecker(Thread):
|
||||||
|
""" This class searches for a card with a given ATR and displays
|
||||||
|
wether or not it was found on the label of a widget """
|
||||||
|
|
||||||
|
def __init__(self, widget, atr, intervall=1):
|
||||||
|
Thread.__init__(self)
|
||||||
|
self._finished = Event()
|
||||||
|
self.widget = widget
|
||||||
|
self.targetATR = atr
|
||||||
|
self.intervall = intervall
|
||||||
|
|
||||||
|
def __cardCheck(self):
|
||||||
|
"""
|
||||||
|
Actually this method should make use of pyscard, but I couldn't make
|
||||||
|
it run on the OpenMoko yet. Therefor we call opensc-tool instead, which
|
||||||
|
leads to higher delays """
|
||||||
|
|
||||||
|
try:
|
||||||
|
p = subprocess.Popen(["opensc-tool", "--atr"], stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE, close_fds=True)
|
||||||
|
|
||||||
|
line = p.stdout.readline().rstrip()
|
||||||
|
if line == self.targetATR:
|
||||||
|
gobject.idle_add(self.widget.set_label, STR_CARD_FOUND)
|
||||||
|
else:
|
||||||
|
gobject.idle_add(self.widget.set_label, STR_NO_CARD)
|
||||||
|
|
||||||
|
except OSError, e:
|
||||||
|
pass #FIXME
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while (True):
|
||||||
|
if self._finished.isSet(): return
|
||||||
|
self.__cardCheck()
|
||||||
|
self._finished.wait(self.intervall)
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self._finished.set()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
gobject.threads_init()
|
||||||
pinpad = PinpadGTK()
|
pinpad = PinpadGTK()
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|||||||
@@ -2,3 +2,7 @@ name = "pinpad"
|
|||||||
version = "@VERSION@"
|
version = "@VERSION@"
|
||||||
image_dir = "@prefix@/share/pixmaps"
|
image_dir = "@prefix@/share/pixmaps"
|
||||||
glade_dir = "@prefix@/share/" + name
|
glade_dir = "@prefix@/share/" + name
|
||||||
|
|
||||||
|
STR_NO_CARD = "<span fgcolor=\"red\" font_weight=\"bold\" font=\"11\">Keine Karte gefunden</span>"
|
||||||
|
STR_CARD_FOUND = "<span fgcolor=\"green\" font_weight=\"bold\" font=\"11\">Karte gefunden</span>"
|
||||||
|
ePA_ATR = "3b:84:80:01:00:00:90:00:95"
|
||||||
|
|||||||
Reference in New Issue
Block a user