Changeset 16523


Ignore:
Timestamp:
Aug 11, 2016, 1:03:58 PM (3 years ago)
Author:
dcorreia
Message:

Added list local configurations feature.

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

Legend:

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

    r16519 r16523  
    7878        if ctx_with_card:
    7979            card = ctx_with_card.getEIDCard()
     80            card_id = card.getID()
     81            print(card_id.getDocumentNumber())
     82            print(card_id.getGivenName()+card_id.getSurname())
    8083            baseFileName = "certDerFile"
    8184            cardCertTotal = card.getCertificates().countFromCard()
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16519 r16523  
    185185        certSubject = fileHelper.readFileToString(TEMP_CERTDATA)
    186186        if "Autentica" in certSubject and "serialNumber=" in certSubject:
     187            fileHelper.appendStringToFile("/tmp/temp_sub", certSubject)
    187188            # we only want the value so we remove the starting "subject= " -> 9 characters
    188189            cardSubject = certSubject[9::]
     
    208209    :param username: name of the user
    209210    :param certificate: card subject certificate
    210     :return: True on success and False otherwise
     211    :return: True on success and False if user mapping already exists
    211212    """
    212213    if certificate is None:
     
    214215    try:
    215216        combo = certificate.strip() + " -> " + username + "\n"
    216         if not hasUserCardCombo(combo):
     217        if hasUserCardCombo(combo):
     218            fileHelper.printDebugInfo("Mapping for user '%s' with this smartcard already exists" % username)
     219        else:
    217220            fileHelper.appendStringToFile(PAMPKCS11_MAPPING, combo)
    218221            fileHelper.printDebugInfo("Added mapping for user '%s'" % username)
     
    295298    fileHelper.executeCommand(awkCmd, open(TEMP_LOCALUSERS, mode="w"))
    296299    return [s.strip() for s in fileHelper.readFileToList(TEMP_LOCALUSERS)]
     300
     301
     302def listLocalCombos():
     303    try:
     304        combosList = [line for line in fileHelper.readFileToList(PAMPKCS11_MAPPING) if "#" not in line]
     305        localCombos = []
     306        for combo in combosList:
     307            localCombos.append(getComboInfo(combo))
     308        return localCombos
     309    except FileNotFoundError as error:
     310        fileHelper.printDebugInfo(error)
     311
     312
     313def getCardAttribute(attribute, cardData):
     314    index = getIndexOfToken(attribute, cardData)
     315    return cardData[index].split("=")[1]
     316
     317
     318def getComboInfo(combo):
     319    cardData, username = combo.split("->")
     320    number = getCardAttribute("serialNumber", cardData.split("/"))  # 'BI+number+extra digit'
     321    name = getCardAttribute("CN", cardData.split("/"))
     322    return [number[2:-1], name.strip().title(), username.strip()]
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/fileHelper.py

    r16519 r16523  
    1818    """
    1919    try:
    20         print(os.getcwd())
    2120        process = subprocess.Popen(command, shell=True, stdout=outputPath, stderr=subprocess.PIPE)
    2221        process.wait()
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/mainwin.py

    r16520 r16523  
    44
    55import fileHelper
    6 
     6import config
    77
    88class MyMainWindow(QtWidgets.QMainWindow):
     
    6464        self.title.setText("SmartCard Login Configuration")
    6565        self.addUserButton.setText("Add User Login")
    66         self.listConfigButton.setText("List Current Card Configurations")
     66        self.listConfigButton.setText("List Local Configurations")
    6767        self.resetConfigButton.setText("Reset Login Configurations")
    6868
     
    8585        # TODO Update back-end scripts to support this feature
    8686        # TODO Launch a popup with this information
    87         self.messageBox.information(self, "Title", "Work in progress...")
     87        message = "\n" + "BI Number".ljust(20) + "Full Name".ljust(20) + " " + "Username".ljust(20) + "\n"
     88        for combo in config.listLocalCombos():
     89            message += combo[0].ljust(20) + combo[1].ljust(20) + combo[2].ljust(20) + "\n"
     90        self.messageBox.information(self, "Title", message)
    8891        print("List current login configurations")
    8992
     
    98101                  "configurations in this computer.\n\n" \
    99102                  "You will lose all current login configurations \n" \
    100                   "and disable smartcard login on your computer.\n\n" \
     103                  "and disable smartcard login in your computer.\n\n" \
    101104                  "Do you still want to reset your current \n" \
    102105                  "smartcard login configurations?\n"
Note: See TracChangeset for help on using the changeset viewer.