Changeset 16535


Ignore:
Timestamp:
Aug 12, 2016, 5:04:34 PM (3 years ago)
Author:
dcorreia
Message:

Updated back-end to support new interface features.

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

Legend:

Unmodified
Added
Removed
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/cardHelper.py

    r16523 r16535  
    8686                card.getCertificates().getCertFromCard(i).getCertData().writeToFile(baseFileName+str(i))
    8787            return [baseFileName, cardCertTotal]
     88        else:
     89            release()
     90            print("There's no card present in the reader, terminating...")
     91
     92
     93def getCardNumber():
     94    init()
     95    # Obtain the instance of readerSet
     96    readers = pteid.PTEID_ReaderSet.instance()
     97    count = readers.readerCount()
     98
     99    # Check if we have connected smart card readers
     100    if count:
     101        devices_names = []
     102
     103        # Obtain the names of all connected readers
     104        for idx in range(count):
     105            name = readers.getReaderName(idx)
     106            devices_names.append(name)
     107            print("Connected device:", name)
     108
     109        ctx_with_card = None
     110        # try to find a smart card in one of the detected readers
     111        for name in devices_names:
     112            reader_ctx = readers.getReaderByName(name)
     113
     114            if reader_ctx.isCardPresent():
     115                ctx_with_card = reader_ctx
     116                # found a card connected, don't look around in other readers
     117                break
     118
     119        # Now check if we have a card to access we can keep going
     120        if ctx_with_card:
     121            card = ctx_with_card.getEIDCard()
     122            card_id = card.getID()
     123            ret = card_id.getDocumentNumber()
     124            release()
     125            return ret[:-6]
     126
     127        else:
     128            release()
     129            print("There's no card present in the reader, terminating...")
     130
     131
     132def getCardFullName():
     133    init()
     134    # Obtain the instance of readerSet
     135    readers = pteid.PTEID_ReaderSet.instance()
     136    count = readers.readerCount()
     137
     138    # Check if we have connected smart card readers
     139    if count:
     140        devices_names = []
     141
     142        # Obtain the names of all connected readers
     143        for idx in range(count):
     144            name = readers.getReaderName(idx)
     145            devices_names.append(name)
     146            print("Connected device:", name)
     147
     148        ctx_with_card = None
     149        # try to find a smart card in one of the detected readers
     150        for name in devices_names:
     151            reader_ctx = readers.getReaderByName(name)
     152
     153            if reader_ctx.isCardPresent():
     154                ctx_with_card = reader_ctx
     155                # found a card connected, don't look around in other readers
     156                break
     157
     158        # Now check if we have a card to access we can keep going
     159        if ctx_with_card:
     160            card = ctx_with_card.getEIDCard()
     161            card_id = card.getID()
     162            ret = card_id.getGivenName()+" "+card_id.getSurname()
     163            release()
     164            return ret
     165
    88166        else:
    89167            print("There's no card present in the reader, terminating...")
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16523 r16535  
    217217        if hasUserCardCombo(combo):
    218218            fileHelper.printDebugInfo("Mapping for user '%s' with this smartcard already exists" % username)
     219            return False
    219220        else:
    220221            fileHelper.appendStringToFile(PAMPKCS11_MAPPING, combo)
    221222            fileHelper.printDebugInfo("Added mapping for user '%s'" % username)
    222         return True
     223            return True
    223224    except AttributeError as error:
    224225        fileHelper.printDebugInfo(error)
    225226        fileHelper.printDebugInfo("Failed to add mapping for user '%s'" % username)
    226         return False
    227227
    228228
Note: See TracChangeset for help on using the changeset viewer.