Changeset 16541


Ignore:
Timestamp:
Aug 18, 2016, 5:52:55 PM (3 years ago)
Author:
dcorreia
Message:

Added close event handler.

Location:
internals/2016/linuxloginsmartcardwizard/trunk/proto1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/eidlibPython_Wrapper/examples/simple_example.py

    r16521 r16541  
    55import pteid
    66
     7
    78def init():
    8   # First of all you always have to initialize the sdk.
    9   print("CC sdk example, starting...")
    10   pteid.PTEID_ReaderSet.initSDK()
     9    # First of all you always have to initialize the sdk.
     10    print("CC sdk example, starting...")
     11    pteid.PTEID_ReaderSet.initSDK()
     12
    1113
    1214def release():
    13   print("CC sdk example, releasing resources...")
    14   # At the end, always release the sdk
    15   pteid.PTEID_ReaderSet.releaseSDK()
     15    print("CC sdk example, releasing resources...")
     16    # At the end, always release the sdk
     17    pteid.PTEID_ReaderSet.releaseSDK()
     18
    1619
    1720def start():
    18   # Obtain the instance of readerSet
    19   readers = pteid.PTEID_ReaderSet.instance()
     21    # Obtain the instance of readerSet
     22    readers = pteid.PTEID_ReaderSet.instance()
    2023
    21   count = readers.readerCount()
    22   print("Number of connected card readers to the system:", count)
     24    count = readers.readerCount()
     25    print("Number of connected card readers to the system:", count)
    2326
    24   # Check if we have connected smart card readers
    25   if count:
    26     devices_names = []
     27    # Check if we have connected smart card readers
     28    if count:
     29        devices_names = []
    2730
    28     # Obtain the names of all connected readers
    29     for idx in range(count):
    30       print("Obtaining card name for index:", idx)
     31        # Obtain the names of all connected readers
     32        for idx in range(count):
     33            print("Obtaining card name for index:", idx)
    3134
    32       name = readers.getReaderName(idx)
    33       devices_names.append(name)
     35            name = readers.getReaderName(idx)
     36            devices_names.append(name)
    3437
    35       print("Connected device:", name)
     38            print("Connected device:", name)
    3639
    37     ctx_with_card = None
    38     # try to find a smart card in one of the detected readers
    39     for name in devices_names:
    40       reader_ctx = readers.getReaderByName(name)
    41      
    42       if reader_ctx.isCardPresent():
    43         print("The reader <", name, "> has a card in it.")
    44        
    45         ctx_with_card = reader_ctx
    46         # found a card connected, don't look around in other readers
    47         break
     40        ctx_with_card = None
     41        # try to find a smart card in one of the detected readers
     42        for name in devices_names:
     43            reader_ctx = readers.getReaderByName(name)
    4844
    49     # Now check if we have a card to access we can keep going
    50     if ctx_with_card:
    51       card = ctx_with_card.getEIDCard()
    52       for i in range(card.getCertificates().countFromCard()):
    53         import OpenSSL
    54         der = card.getCertificates().getCertFromCard(i).getCertData().GetBytes()
    55         x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, der)
    56         #print(x509.get_subject().get_components())
    57         comps = x509.get_subject().get_components()
    58         n_comps = []
    59         for t in comps:
    60             n_comps += [t[0]+t[1]]
    61         #print(n_comps)
    62         ret_subject = n_comps[0]
    63         for i in range(1,len(n_comps)):
    64             ret_subject += n_comps[i]
    65         print(ret_subject.decode())
    66     else:
    67       print("There's no card present in the reader, terminating...")
     45            if reader_ctx.isCardPresent():
     46                print("The reader <", name, "> has a card in it.")
     47
     48                ctx_with_card = reader_ctx
     49                # found a card connected, don't look around in other readers
     50                break
     51
     52        # Now check if we have a card to access we can keep going
     53        if ctx_with_card:
     54            card = ctx_with_card.getEIDCard()
     55            p = card.getPins()
     56            for i in range(card.pinCount()):
     57                if "Autenticação" in p.getPinByNumber(i).getLabel():
     58                    print(p.getPinByNumber(i).getTriesLeft())
     59                    p.getPinByNumber(i).verifyPin()
     60        else:
     61            print("There's no card present in the reader, terminating...")
    6862
    6963def dump_card_info(id):
    70   print("Card ID: ", id)
    71   print("-------------------------------------------------------")
    72   print("deliveryEntity             ", id.getIssuingEntity())
    73   print("country                    ", id.getCountry())
    74   print("documentType               ", id.getDocumentType())
    75   print("cardNumber                 ", id.getDocumentNumber())
    76   print("cardNumberPAN              ", id.getDocumentPAN())
    77   print("cardVersion                ", id.getDocumentVersion())
    78   print("deliveryDate               ", id.getValidityBeginDate())
    79   print("locale                     ", id.getLocalofRequest())
    80   print("validityDate               ", id.getValidityEndDate())
    81   print("name                       ", id.getSurname())
    82   print("firstname                  ", id.getGivenName())
    83   print("sex                        ", id.getGender())
    84   print("nationality                ", id.getNationality())
    85   print("birthDate                  ", id.getDateOfBirth())
    86   print("height                     ", id.getHeight())
    87   print("numBI                      ", id.getCivilianIdNumber())
    88   print("nameFather                 ", id.getSurnameFather())
    89   print("firstnameFather            ", id.getGivenNameFather())
    90   print("nameMother                 ", id.getSurnameMother())
    91   print("firstnameMother            ", id.getGivenNameMother())
    92   print("numNIF                     ", id.getTaxNo())
    93   print("numSS                      ", id.getSocialSecurityNumber())
    94   print("numSNS                     ", id.getHealthNumber())
    95   print("Accidental indications     ", id.getAccidentalIndications())
    96   print("mrz1                       ", id.getMRZ1())
    97   print("mrz2                       ", id.getMRZ2())
    98   print("mrz3                       ", id.getMRZ3())
    99   print("-------------------------------------------------------")
     64    print("Card ID: ", id)
     65    print("-------------------------------------------------------")
     66    print("deliveryEntity             ", id.getIssuingEntity())
     67    print("country                    ", id.getCountry())
     68    print("documentType               ", id.getDocumentType())
     69    print("cardNumber                 ", id.getDocumentNumber())
     70    print("cardNumberPAN              ", id.getDocumentPAN())
     71    print("cardVersion                ", id.getDocumentVersion())
     72    print("deliveryDate               ", id.getValidityBeginDate())
     73    print("locale                     ", id.getLocalofRequest())
     74    print("validityDate               ", id.getValidityEndDate())
     75    print("name                       ", id.getSurname())
     76    print("firstname                  ", id.getGivenName())
     77    print("sex                        ", id.getGender())
     78    print("nationality                ", id.getNationality())
     79    print("birthDate                  ", id.getDateOfBirth())
     80    print("height                     ", id.getHeight())
     81    print("numBI                      ", id.getCivilianIdNumber())
     82    print("nameFather                 ", id.getSurnameFather())
     83    print("firstnameFather            ", id.getGivenNameFather())
     84    print("nameMother                 ", id.getSurnameMother())
     85    print("firstnameMother            ", id.getGivenNameMother())
     86    print("numNIF                     ", id.getTaxNo())
     87    print("numSS                      ", id.getSocialSecurityNumber())
     88    print("numSNS                     ", id.getHealthNumber())
     89    print("Accidental indications     ", id.getAccidentalIndications())
     90    print("mrz1                       ", id.getMRZ1())
     91    print("mrz2                       ", id.getMRZ2())
     92    print("mrz3                       ", id.getMRZ3())
     93    print("-------------------------------------------------------")
    10094
    10195if __name__ == "__main__":
    102   init()
    103   start()
    104   release()
     96    init()
     97    start()
     98    release()
     99
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/w4pages.py

    r16521 r16541  
    11from PyQt5 import QtCore, QtGui, QtWidgets
     2from PyQt5.QtWidgets import QMessageBox
    23import welcome, checksystem, carduser, final
    34
     
    3738        self.addPage(self.wizardPage4)
    3839
    39         self.helpMessageBox = QtWidgets.QMessageBox()
     40        self.messageBox = QtWidgets.QMessageBox()
    4041        self.helpRequested.connect(self.showHelp)
    4142
    4243    def showHelp(self):
    4344        message = self.currentPage().helpMessage
    44         self.helpMessageBox.information(self, "Help Dialog", message)
     45        self.messageBox.information(self, "Help Dialog", message)
     46
     47    def closeEvent(self, QCloseEvent):
     48        if self.currentId() != 3:
     49            reply = self.messageBox.warning(self, "Title",  "\nAre you sure you want to close the wizard?\n\n"
     50                                                            "You will lose all progress you currently have on \n"
     51                                                            "the login configuration process.\n\n",
     52                                                            QMessageBox.No, QMessageBox.Yes)
     53            if reply == QMessageBox.Yes:
     54                QCloseEvent.accept()
     55            else:
     56                QCloseEvent.ignore()
     57        else:
     58            QCloseEvent.accept()
    4559
    4660if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.