Changeset 16563


Ignore:
Timestamp:
Aug 22, 2016, 7:15:01 PM (3 years ago)
Author:
dcorreia
Message:

Added remove specific configurations feature.
Updated login status toggle and checksystem page.

Location:
internals/2016/linuxloginsmartcardwizard/trunk/proto1
Files:
1 added
3 edited

Legend:

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

    r16544 r16563  
    11from PyQt5 import QtCore, QtGui, QtWidgets
    2 import main
     2import main, config
    33
    44
     
    8080    def initializePage(self):
    8181        print("Run system scripts...")
    82         self.timer.singleShot(2500, self.config)
     82        if not config.isPkcs11Installed():
     83            self.timer.singleShot(2500, self.config)
     84        else:
     85            self.systemErrorLabel.setText("Installed necessary packages.\n\n"
     86                                          "Created configuration directories.\n\n"
     87                                          "Obtained smartcard certificates.\n\n"
     88                                          "Finished setup of configuration files.\n\n")
     89            self.goodSystemLabel.show()
     90            self.completeChanged.emit()
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/config.py

    r16560 r16563  
    272272
    273273
    274 def isPcks11LoginActive():
     274def isPkcs11LoginActive():
    275275    authData = fileHelper.readFileToList(COMMONAUTH)
    276276    pkcs11Index = getIndexOfToken("pam_pkcs11.so", authData)
    277277    return pkcs11Index is not None
     278
     279
     280def isPkcs11Installed():
     281    return os.path.exists(PAMPKCS11_CONFIG)
    278282
    279283
     
    347351
    348352
     353def deleteSelectedCombos(indexList):
     354    combos = listLocalCombos()
     355    for index in indexList:
     356        number, username = combos[index][0], combos[index][2]
     357        deleteLocalCombo(number, username)
     358
     359
    349360def getCardAttribute(attribute, cardData):
    350361    index = getIndexOfToken(attribute, cardData)
  • internals/2016/linuxloginsmartcardwizard/trunk/proto1/mainwin.py

    r16561 r16563  
    113113        message = "\nBI Number".ljust(25) + " Full Name".ljust(25) + "  Username".ljust(25) + "\n"
    114114        localCombos = config.listLocalCombos()
    115         if localCombos is None:
    116             message = "\nYou have no local configurations yet.\n\n"\
     115        if localCombos is None or localCombos == []:
     116            message = "\nYou have no local configurations.\n\n"\
    117117                      "Please use the 'Add User Login' option to add \n"\
    118118                      "a new local configuration to your computer.\n"
     
    126126            self.messageBox.critical(self, "Title", "\nPlease close the current add user login wizard\n"
    127127                                                    "before trying to reset the login configurations.\n\n")
     128        if config.listLocalCombos() is None or config.listLocalCombos() == []:
     129            message = "\nYou have no local configurations yet.\n\n" \
     130                      "Please use the 'Add User Login' option to add \n" \
     131                      "a new local configuration to your computer.\n"
     132            self.messageBox.information(self, "Title", message)
    128133        else:
    129134            self.popup = resetPopup()
     
    150155
    151156    def checkLoginStatus(self):
    152         if config.isPcks11LoginActive():
    153             self.statusbarLabel.setText("Smartcard Login Enabled")
    154             self.statusbarSlider.setValue(self.statusbarSlider.maximum())
    155         else:
    156             self.statusbarLabel.setText("Smartcard Login Disabled")
    157             self.statusbarSlider.setValue(self.statusbarSlider.minimum())
     157        if config.isPkcs11Installed():
     158            self.statusbarSlider.show()
     159            if config.isPkcs11LoginActive():
     160                self.statusbarLabel.setText("Smartcard Login Enabled")
     161                self.statusbarSlider.setValue(self.statusbarSlider.maximum())
     162            else:
     163                self.statusbarLabel.setText("Smartcard Login Disabled")
     164                self.statusbarSlider.setValue(self.statusbarSlider.minimum())
     165        else:
     166            self.statusbarSlider.hide()
    158167
    159168    def changeLoginStatus(self):
    160         if config.isPcks11LoginActive():
     169        if config.isPkcs11LoginActive():
    161170            config.disablePkcs11Login()
    162171        else:
     
    182191            QCloseEvent.accept()
    183192
     193    def enterEvent(self, QEvent):
     194        self.checkLoginStatus()
     195
    184196
    185197class resetPopup(QtWidgets.QWidget):
     
    188200        self.resize(550, 400)
    189201        self.centerOnScreen()
     202
     203        self.firstRow = QtWidgets.QLabel(self)
     204        self.firstRow.setStyleSheet("font: bold;")
     205        self.firstRow.setGeometry(QtCore.QRect(40, 30, 400, 30))
     206        self.comboslist = QtWidgets.QListWidget(self)
     207        self.comboslist.setGeometry(QtCore.QRect(40, 60, 400, 250))
     208        self.buildLocalCombos()
     209
     210        self.selectAllButton = QtWidgets.QPushButton(self)
     211        self.selectAllButton.setGeometry(QtCore.QRect(210, 330, 100, 30))
     212
     213        self.removeSelectionButton = QtWidgets.QPushButton(self)
     214        self.removeSelectionButton.setGeometry(QtCore.QRect(320, 330, 120, 30))
     215
    190216        self.setWindowTitle("Remove Login Configurations")
     217        self.firstRow.setText("\n      BI Number".ljust(25)+"     Full Name".ljust(25)+"  Username".ljust(25) + "\n")
     218        self.selectAllButton.setText("Select All")
     219        self.removeSelectionButton.setText("Remove Selection")
     220
     221        self.selectAllButton.clicked.connect(self.selectAllEvent)
     222        self.removeSelectionButton.clicked.connect(self.removeSelectionEvent)
     223
     224        self.messageBox = QtWidgets.QMessageBox(self)
     225        self.selectedAll = False
    191226
    192227    def centerOnScreen(self):
     
    194229        self.move((resolution.width() / 2) - (self.frameSize().width() / 2),
    195230                  (resolution.height() / 2) - (self.frameSize().height() / 2))
     231
     232    def buildLocalCombos(self):
     233        self.comboslist.clear()
     234        localCombos = config.listLocalCombos()
     235        for combo in localCombos:
     236            number, name, user = combo[0], combo[1], combo[2]
     237            item = QtWidgets.QListWidgetItem("\n" + number.ljust(25) + name.ljust(25) + user.ljust(25) + "\n")
     238            item.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
     239            item.setData(QtCore.Qt.CheckStateRole, QtCore.QVariant(QtCore.Qt.Unchecked))
     240            self.comboslist.addItem(item)
     241
     242    def selectAllEvent(self):
     243        if self.selectedAll:
     244            self.unselectAllCombos()
     245            self.selectAllButton.setText("Select All")
     246            self.selectedAll = False
     247        else:
     248            self.selectAllCombos()
     249            self.selectAllButton.setText("Unselect All")
     250            self.selectedAll = True
     251
     252    def selectAllCombos(self):
     253        for i in range(self.comboslist.count()):
     254            item = self.comboslist.item(i)
     255            item.setCheckState(QtCore.Qt.Checked)
     256
     257    def unselectAllCombos(self):
     258        for i in range(self.comboslist.count()):
     259            item = self.comboslist.item(i)
     260            item.setCheckState(QtCore.Qt.Unchecked)
     261
     262    def removeSelectionEvent(self):
     263        ret = []
     264        message = "\n     BI Number".ljust(25) + "      Full Name".ljust(25) + "       Username".ljust(25) + "\n"
     265        for i in range(self.comboslist.count()):
     266            item = self.comboslist.item(i)
     267            if item.checkState() == QtCore.Qt.Checked:
     268                message += "     " + item.text().strip() + "\n"
     269                ret.append(i)
     270        if len(ret) == 0:
     271            self.messageBox.information(self, "Title", "\nNo login configurations selected.\n\n"
     272                                        "Please select the login configurations \n"
     273                                        "you would like to remove.\n\n")
     274        else:
     275            reply = self.messageBox.warning(self, "Title",
     276                                            "\nYou are about to remove the following login configurations:\n" +
     277                                            message + "\nAre you sure you want to remove them?\n",
     278                                            QMessageBox.No, QMessageBox.Yes)
     279            if reply == QMessageBox.Yes:
     280                config.deleteSelectedCombos(ret)
     281                self.buildLocalCombos()
     282
    196283
    197284if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.