def __init__(self, data, default_passphrase=""): super().__init__(data) self._passphrase_entry = self.builder.get_object("passphrase_entry") self._confirm_entry = self.builder.get_object("confirm_pw_entry") self._save_button = self.builder.get_object("passphrase_save_button") self._strength_bar = self.builder.get_object("strength_bar") self._strength_label = self.builder.get_object("strength_label") self._passphrase_warning_image = self.builder.get_object("passphrase_warning_image") self._passphrase_warning_label = self.builder.get_object("passphrase_warning_label") # Set the offset values for the strength bar colors self._strength_bar.add_offset_value("low", 2) self._strength_bar.add_offset_value("medium", 3) self._strength_bar.add_offset_value("high", 4) # Setup the password checker for passphrase checking self._checker = input_checking.PasswordChecker( initial_password_content=self._passphrase_entry.get_text(), initial_password_confirmation_content=self._confirm_entry.get_text(), policy_name=PASSWORD_POLICY_LUKS ) # configure the checker for passphrase checking self._checker.secret_type = constants.SecretType.PASSPHRASE # connect UI updates to check results self._checker.checks_done.connect(self._set_status) self.passphrase = default_passphrase self._passphrase_good_enough = False # check that the content of the passphrase field & the conformation field are the same self._confirm_check = input_checking.PasswordConfirmationCheck() # check passphrase validity, quality and strength self._validity_check = input_checking.PasswordValidityCheck() # connect UI updates to validity check results self._validity_check.result.password_score_changed.connect(self._set_password_strength) self._validity_check.result.status_text_changed.connect(self._set_password_status_text) # check if the passphrase contains non-ascii characters self._ascii_check = input_checking.PasswordASCIICheck() # check if the passphrase is empty self._empty_check = input_checking.PasswordEmptyCheck() # register the individual checks with the checker in proper order # 1) are both entered passphrases the same ? # 2) is the passphrase valid according to the current password checking policy ? # 3) is the passphrase free of non-ASCII characters ? self._checker.add_check(self._confirm_check) self._checker.add_check(self._validity_check) self._checker.add_check(self._ascii_check) self._checker.add_check(self._empty_check) # set the visibility of the password entries # - without this the password visibility toggle icon will # not be shown set_password_visibility(self._passphrase_entry, False) set_password_visibility(self._confirm_entry, False)
def initialize(self): NormalSpoke.initialize(self) # place holders for the text boxes self.pw = self.builder.get_object("pw") self.confirm = self.builder.get_object("confirmPW") self.lock = self.builder.get_object("lock") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # - Is there any data in the confirm box? self.add_check(self.pw, self._checkPasswordEmpty) # the password confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field so that errors focus on confirm, # and check changes to the password field in on_password_changed self._confirm_check = self.add_check(self.confirm, self._checkPasswordConfirm) # Keep a reference for these checks, since they have to be manually run for the # click Done twice check. self._pwStrengthCheck = self.add_check(self.pw, self._checkPasswordStrength) self._pwASCIICheck = self.add_check(self.pw, self._checkPasswordASCII) self.add_check(self.confirm, self._checkPasswordEmpty) # Counters for checks that ask the user to click Done to confirm self._waiveStrengthClicks = 0 self._waiveASCIIClicks = 0 # Password validation data self._pwq_error = None self._pwq_valid = True self._kickstarted = self.data.rootpw.seen if self._kickstarted: self.pw.set_placeholder_text(_("The password is set.")) self.confirm.set_placeholder_text(_("The password is set.")) self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("root") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False)
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # place holders for the text boxes self.pw = self.builder.get_object("pw") self.confirm = self.builder.get_object("confirmPW") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # - Is there any data in the confirm box? self._confirm_check = self.add_check(self.confirm, self.check_password_confirm) # Keep a reference for these checks, since they have to be manually run for the # click Done twice check. self._pwEmptyCheck = self.add_check(self.pw, self.check_password_empty) self._pwStrengthCheck = self.add_check( self.pw, self.check_user_password_strength) self._pwASCIICheck = self.add_check(self.pw, self.check_password_ASCII) self._kickstarted = self.data.rootpw.seen if self._kickstarted: self.pw.set_placeholder_text(_("The password is set.")) self.confirm.set_placeholder_text(_("The password is set.")) self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("root") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False) # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__, False) # report that we are done self.initialize_done()
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # place holders for the text boxes self.pw = self.builder.get_object("pw") self.confirm = self.builder.get_object("confirmPW") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # - Is there any data in the confirm box? self._confirm_check = self.add_check(self.confirm, self.check_password_confirm) # Keep a reference for these checks, since they have to be manually run for the # click Done twice check. self._pwEmptyCheck = self.add_check(self.pw, self.check_password_empty) self._pwStrengthCheck = self.add_check(self.pw, self.check_user_password_strength) self._pwASCIICheck = self.add_check(self.pw, self.check_password_ASCII) self._kickstarted = self.data.rootpw.seen if self._kickstarted: self.pw.set_placeholder_text(_("The password is set.")) self.confirm.set_placeholder_text(_("The password is set.")) self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("root") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False) # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__, False) # report that we are done self.initialize_done()
def __init__(self, data): GUIObject.__init__(self, data) GUIInputCheckHandler.__init__(self) self._confirm_entry = self.builder.get_object("confirm_pw_entry") self._passphrase_entry = self.builder.get_object("passphrase_entry") self._save_button = self.builder.get_object("passphrase_save_button") self._strength_bar = self.builder.get_object("strength_bar") self._strength_label = self.builder.get_object("strength_label") self._passphrase_warning_image = self.builder.get_object( "passphrase_warning_image") self._passphrase_warning_label = self.builder.get_object( "passphrase_warning_label") # Set the offset values for the strength bar colors self._strength_bar.add_offset_value("low", 2) self._strength_bar.add_offset_value("medium", 3) self._strength_bar.add_offset_value("high", 4) self._strength_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("luks") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # These will be set up later. self._pwq = None self._pwq_error = None self.passphrase = "" # the passphrase confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field and check changes to the # password field in on_passphrase_changed self._passphrase_match_check = self.add_check(self._confirm_entry, self._checkMatch) self._strength_check = self.add_check(self._passphrase_entry, self._checkStrength) self._ascii_check = self.add_check(self._passphrase_entry, self._checkASCII) # set the visibility of the password entries set_password_visibility(self._passphrase_entry, False) set_password_visibility(self._confirm_entry, False)
def __init__(self, data): GUIObject.__init__(self, data) GUIInputCheckHandler.__init__(self) self._confirm_entry = self.builder.get_object("confirm_pw_entry") self._passphrase_entry = self.builder.get_object("passphrase_entry") self._save_button = self.builder.get_object("passphrase_save_button") self._strength_bar = self.builder.get_object("strength_bar") self._strength_label = self.builder.get_object("strength_label") self._passphrase_warning_image = self.builder.get_object("passphrase_warning_image") self._passphrase_warning_label = self.builder.get_object("passphrase_warning_label") # Set the offset values for the strength bar colors self._strength_bar.add_offset_value("low", 2) self._strength_bar.add_offset_value("medium", 3) self._strength_bar.add_offset_value("high", 4) self._strength_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("luks") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # These will be set up later. self._pwq = None self._pwq_error = None self.passphrase = "" # the passphrase confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field and check changes to the # password field in on_passphrase_changed self._passphrase_match_check = self.add_check(self._confirm_entry, self._checkMatch) self._strength_check = self.add_check(self._passphrase_entry, self._checkStrength) self._ascii_check = self.add_check(self._passphrase_entry, self._checkASCII) # set the visibility of the password entries set_password_visibility(self._passphrase_entry, False) set_password_visibility(self._confirm_entry, False)
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # get object references from the builders self._password_entry = self.builder.get_object("password_entry") self._password_confirmation_entry = self.builder.get_object("password_confirmation_entry") self._password_bar = self.builder.get_object("password_bar") self._password_label = self.builder.get_object("password_label") self._enable_root_radio = self.builder.get_object("enable_root_radio") self._disable_root_radio = self.builder.get_object("disable_root_radio") self._root_password_ssh_login_override = self.builder.get_object("root_password_ssh_login_override") self._revealer = self.builder.get_object("password_revealer") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # Setup the password checker for password checking self._checker = input_checking.PasswordChecker( initial_password_content=self.password, initial_password_confirmation_content=self.password_confirmation, policy_name=PASSWORD_POLICY_ROOT ) # configure the checker for password checking self.checker.secret_type = constants.SecretType.PASSWORD # remove any placeholder texts if either password or confirmation field changes content from initial state self.checker.password.changed_from_initial_state.connect(self.remove_placeholder_texts) self.checker.password_confirmation.changed_from_initial_state.connect(self.remove_placeholder_texts) # connect UI updates to check results self.checker.checks_done.connect(self._checks_done) # check that the password is not empty self._empty_check = input_checking.PasswordEmptyCheck() # check that the content of the password field & the conformation field are the same self._confirm_check = input_checking.PasswordConfirmationCheck() # check password validity, quality and strength self._validity_check = input_checking.PasswordValidityCheck() # connect UI updates to validity check results self._validity_check.result.password_score_changed.connect(self.set_password_score) self._validity_check.result.status_text_changed.connect(self.set_password_status) # check if the password contains non-ascii characters self._ascii_check = input_checking.PasswordASCIICheck() # register the individual checks with the checker in proper order # 1) is the password non-empty ? # 2) are both entered passwords the same ? # 3) is the password valid according to the current password checking policy ? # 4) is the password free of non-ASCII characters ? self.checker.add_check(self._empty_check) self.checker.add_check(self._confirm_check) self.checker.add_check(self._validity_check) self.checker.add_check(self._ascii_check) # Set placeholders if the password has been set outside of the Anaconda # GUI we either don't really know anything about it if it's crypted # and still would not really want to expose it if its set in plaintext, # and thus can'treally show it in the UI in any meaningful way. if self._users_module.IsRootPasswordSet: password_set_message = _("Root password has been set.") self.password_entry.set_placeholder_text(password_set_message) self.password_confirmation_entry.set_placeholder_text(password_set_message) # Configure levels for the password bar self._password_bar.add_offset_value("low", 2) self._password_bar.add_offset_value("medium", 3) self._password_bar.add_offset_value("high", 4) # set visibility of the password entries # - without this the password visibility toggle icon will # not be shown set_password_visibility(self.password_entry, False) set_password_visibility(self.password_confirmation_entry, False) # Send ready signal to main event loop hubQ.send_ready(self.__class__.__name__) # report that we are done self.initialize_done()
def on_password_icon_clicked(self, entry, icon_pos, event): """Called by Gtk callback when the icon of a password entry is clicked.""" set_password_visibility(entry, not entry.get_visibility())
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # Create a new UserData object to store this spoke's state # as well as the state of the advanced user dialog. if self.data.user.userList: self._user = copy.copy(self.data.user.userList[0]) else: self._user = self.data.UserData() # gather references to relevant GUI objects # entry fields self._fullname_entry = self.builder.get_object("fullname_entry") self._username_entry = self.builder.get_object("username_entry") self._password_entry = self.builder.get_object("password_entry") self._password_confirmation_entry = self.builder.get_object( "password_confirmation_entry") # check boxes self._admin_checkbox = self.builder.get_object("admin_checkbox") self._password_required_checkbox = self.builder.get_object( "password_required_checkbox") # advanced user configration dialog button self._advanced_button = self.builder.get_object("advanced_button") # password checking status bar & label self._password_bar = self.builder.get_object("password_bar") self._password_label = self.builder.get_object("password_label") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # Setup the password checker for password checking self._checker = input_checking.PasswordChecker( initial_password_content=self.password, initial_password_confirmation_content=self.password_confirmation, policy=input_checking.get_policy(self.data, "user")) # configure the checker for password checking self.checker.username = self.username self.checker.secret_type = constants.SecretType.PASSWORD # remove any placeholder texts if either password or confirmation field changes content from initial state self.checker.password.changed_from_initial_state.connect( self.remove_placeholder_texts) self.checker.password_confirmation.changed_from_initial_state.connect( self.remove_placeholder_texts) # connect UI updates to check results self.checker.checks_done.connect(self._checks_done) # username and full name checks self._username_check = input_checking.UsernameCheck() self._fullname_check = input_checking.FullnameCheck() # empty username is considered a success so that the user can leave # the spoke without filling it in self._username_check.success_if_username_empty = True # check that the password is not empty self._empty_check = input_checking.PasswordEmptyCheck() # check that the content of the password field & the conformation field are the same self._confirm_check = input_checking.PasswordConfirmationCheck() # check password validity, quality and strength self._validity_check = input_checking.PasswordValidityCheck() # connect UI updates to validity check results self._validity_check.result.password_score_changed.connect( self.set_password_score) self._validity_check.result.status_text_changed.connect( self.set_password_status) # check if the password contains non-ascii characters self._ascii_check = input_checking.PasswordASCIICheck() # register the individual checks with the checker in proper order # 0) is the username and fullname valid ? # 1) is the password non-empty ? # 2) are both entered passwords the same ? # 3) is the password valid according to the current password checking policy ? # 4) is the password free of non-ASCII characters ? self.checker.add_check(self._username_check) self.checker.add_check(self._fullname_check) self.checker.add_check(self._empty_check) self.checker.add_check(self._confirm_check) self.checker.add_check(self._validity_check) self.checker.add_check(self._ascii_check) self.guesser = {self.username_entry: True} # Configure levels for the password bar self.password_bar.add_offset_value("low", 2) self.password_bar.add_offset_value("medium", 3) self.password_bar.add_offset_value("high", 4) # indicate when the password was set by kickstart self.password_kickstarted = self.data.user.seen # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. password_set_message = _("The password was set by kickstart.") if self.password_kickstarted: self.password_required = True self.password_entry.set_placeholder_text(password_set_message) self.password_confirmation_entry.set_placeholder_text( password_set_message) elif not self.checker.policy.emptyok: # Policy is that a non-empty password is required self.password_required = True if not self.checker.policy.emptyok: # User isn't allowed to change whether password is required or not self.password_required_checkbox.set_sensitive(False) self._advanced_user_dialog = AdvancedUserDialog(self._user, self.data) self._advanced_user_dialog.initialize() # set the visibility of the password entries set_password_visibility(self.password_entry, False) set_password_visibility(self.password_confirmation_entry, False) # report that we are done self.initialize_done()
def initialize(self): NormalSpoke.initialize(self) # Create a new UserData object to store this spoke's state # as well as the state of the advanced user dialog. if self.data.user.userList: self._user = copy.copy(self.data.user.userList[0]) else: self._user = self.data.UserData() # placeholders for the text boxes self.fullname = self.builder.get_object("t_fullname") self.username = self.builder.get_object("t_username") self.pw = self.builder.get_object("t_password") self.confirm = self.builder.get_object("t_verifypassword") self.admin = self.builder.get_object("c_admin") self.usepassword = self.builder.get_object("c_usepassword") self.b_advanced = self.builder.get_object("b_advanced") # Counters for checks that ask the user to click Done to confirm self._waiveStrengthClicks = 0 self._waiveASCIIClicks = 0 self.guesser = True self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("user") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # indicate when the password was set by kickstart self._password_kickstarted = self.data.user.seen # Password checks, in order of importance: # - if a password is required, is one specified? # - if a password is specified and there is data in the confirm box, do they match? # - if a password is specified and the confirm box is empty or match, how strong is it? # - if a strong password is specified, does it contain non-ASCII data? # - if a password is required, is there any data in the confirm box? self.add_check(self.pw, self._checkPasswordEmpty) # the password confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field so that errors focus on confirm, # and check changes to the password field in password_changed self._confirm_check = self.add_check(self.confirm, self._checkPasswordConfirm) # Keep a reference to these checks, since they have to be manually run for the # click Done twice check. self._pwStrengthCheck = self.add_check(self.pw, self._checkPasswordStrength) self._pwASCIICheck = self.add_check(self.pw, self._checkPasswordASCII) self.add_check(self.confirm, self._checkPasswordEmpty) self.add_check(self.username, self._checkUsername) self.add_re_check(self.fullname, GECOS_VALID, _("Full name cannot contain colon characters")) # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. if self._password_kickstarted: self.usepassword.set_active(True) self.pw.set_placeholder_text( _("The password was set by kickstart.")) self.confirm.set_placeholder_text( _("The password was set by kickstart.")) elif not self.policy.emptyok: # Policy is that a non-empty password is required self.usepassword.set_active(True) if not self.policy.emptyok: # User isn't allowed to change whether password is required or not self.usepassword.set_sensitive(False) self._advanced = AdvancedUserDialog(self._user, self.data) self._advanced.initialize() # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False)
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # Create a new UserData object to store this spoke's state # as well as the state of the advanced user dialog. if self.data.user.userList: self._user = copy.copy(self.data.user.userList[0]) else: self._user = self.data.UserData() # placeholders for the text boxes self.fullname = self.builder.get_object("t_fullname") self.username = self.builder.get_object("t_username") self.pw = self.builder.get_object("t_password") self.confirm = self.builder.get_object("t_verifypassword") self.admin = self.builder.get_object("c_admin") self.usepassword = self.builder.get_object("c_usepassword") self.b_advanced = self.builder.get_object("b_advanced") # set initial state of the input field self.input_enabled = self.usepassword.get_active() # Counters for checks that ask the user to click Done to confirm self.waive_clicks = 0 self.waive_ASCII_clicks = 0 self.guesser = { self.username: True } # Updated during the password changed event and used by the password # field validity checker self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("user") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # indicate when the password was set by kickstart self._password_kickstarted = self.data.user.seen # Password checks, in order of importance: # - if a password is required, is one specified? # - if a password is specified and there is data in the confirm box, do they match? # - if a password is specified and the confirm box is empty or match, how strong is it? # - if a strong password is specified, does it contain non-ASCII data? # - if a password is required, is there any data in the confirm box? # the password confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field so that errors focus on confirm, # and check changes to the password field in password_changed self._confirm_check = self.add_check(self.confirm, self.check_password_confirm) # Keep a reference to these checks, since they have to be manually run for the # click Done twice check. self._pwEmptyCheck = self.add_check(self.pw, self.check_password_empty) self._pwStrengthCheck = self.add_check(self.pw, self.check_user_password_strength) self._pwASCIICheck = self.add_check(self.pw, self.check_password_ASCII) self.add_check(self.username, self._checkUsername) self.add_re_check(self.fullname, GECOS_VALID, _("Full name cannot contain colon characters")) # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. if self._password_kickstarted: self.usepassword.set_active(True) self.pw.set_placeholder_text(_("The password was set by kickstart.")) self.confirm.set_placeholder_text(_("The password was set by kickstart.")) elif not self.policy.emptyok: # Policy is that a non-empty password is required self.usepassword.set_active(True) if not self.policy.emptyok: # User isn't allowed to change whether password is required or not self.usepassword.set_sensitive(False) self._advanced = AdvancedUserDialog(self._user, self.data) self._advanced.initialize() # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False) # report that we are done self.initialize_done()
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # We consider user creation requested if there was at least one user # in the DBus module user list at startup. # We also remember how the user was called so that we can clear it # in a reasonably safe way & if it was cleared. self._user_list = get_user_list(self._users_module, add_default=True) self._user_requested = False self._requested_user_cleared = False # if user has a name, it's an actual user that has been requested, # rather than a default user added by us if self.user.name: self._user_requested = True # gather references to relevant GUI objects # entry fields self._fullname_entry = self.builder.get_object("fullname_entry") self._username_entry = self.builder.get_object("username_entry") self._password_entry = self.builder.get_object("password_entry") self._password_confirmation_entry = self.builder.get_object("password_confirmation_entry") # check boxes self._admin_checkbox = self.builder.get_object("admin_checkbox") self._password_required_checkbox = self.builder.get_object("password_required_checkbox") # advanced user configration dialog button self._advanced_button = self.builder.get_object("advanced_button") # password checking status bar & label self._password_bar = self.builder.get_object("password_bar") self._password_label = self.builder.get_object("password_label") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # Setup the password checker for password checking self._checker = input_checking.PasswordChecker( initial_password_content=self.password, initial_password_confirmation_content=self.password_confirmation, policy_name=PASSWORD_POLICY_USER ) # configure the checker for password checking self.checker.username = self.username self.checker.secret_type = constants.SecretType.PASSWORD # remove any placeholder texts if either password or confirmation field changes content from initial state self.checker.password.changed_from_initial_state.connect(self.remove_placeholder_texts) self.checker.password_confirmation.changed_from_initial_state.connect(self.remove_placeholder_texts) # connect UI updates to check results self.checker.checks_done.connect(self._checks_done) # username and full name checks self._username_check = input_checking.UsernameCheck() self._fullname_check = input_checking.FullnameCheck() # empty username is considered a success so that the user can leave # the spoke without filling it in self._username_check.success_if_username_empty = True # check that the password is not empty self._empty_check = input_checking.PasswordEmptyCheck() # check that the content of the password field & the conformation field are the same self._confirm_check = input_checking.PasswordConfirmationCheck() # check password validity, quality and strength self._validity_check = input_checking.PasswordValidityCheck() # connect UI updates to validity check results self._validity_check.result.password_score_changed.connect(self.set_password_score) self._validity_check.result.status_text_changed.connect(self.set_password_status) # check if the password contains non-ascii characters self._ascii_check = input_checking.PasswordASCIICheck() # Skip the empty and validity password checks if no username is set self._empty_check.skip = True self._validity_check.skip = True # register the individual checks with the checker in proper order # 0) is the username and fullname valid ? # 1) is the password non-empty ? # 2) are both entered passwords the same ? # 3) is the password valid according to the current password checking policy ? # 4) is the password free of non-ASCII characters ? self.checker.add_check(self._username_check) self.checker.add_check(self._fullname_check) self.checker.add_check(self._empty_check) self.checker.add_check(self._confirm_check) self.checker.add_check(self._validity_check) self.checker.add_check(self._ascii_check) self.guesser = { self.username_entry: True } # Configure levels for the password bar self.password_bar.add_offset_value("low", 2) self.password_bar.add_offset_value("medium", 3) self.password_bar.add_offset_value("high", 4) # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. password_set_message = _("The password was set by kickstart.") if self.password_kickstarted: self.password_required = True self.password_entry.set_placeholder_text(password_set_message) self.password_confirmation_entry.set_placeholder_text(password_set_message) elif not self.checker.policy.allow_empty: # Policy is that a non-empty password is required self.password_required = True if not self.checker.policy.allow_empty: # User isn't allowed to change whether password is required or not self.password_required_checkbox.set_sensitive(False) self._advanced_user_dialog = AdvancedUserDialog(self) self._advanced_user_dialog.initialize() # set the visibility of the password entries # - without this the password visibility toggle icon will # not be shown set_password_visibility(self.password_entry, False) set_password_visibility(self.password_confirmation_entry, False) # report that we are done self.initialize_done()
def initialize(self): NormalSpoke.initialize(self) # Create a new UserData object to store this spoke's state # as well as the state of the advanced user dialog. if self.data.user.userList: self._user = copy.copy(self.data.user.userList[0]) else: self._user = self.data.UserData() self._wheel = self.data.GroupData(name="wheel") self._qubes = self.data.GroupData(name="qubes") self._groupDict = {"wheel": self._wheel, "qubes": self._qubes} # placeholders for the text boxes self.username = self.builder.get_object("t_username") self.pw = self.builder.get_object("t_password") self.confirm = self.builder.get_object("t_verifypassword") # Counters for checks that ask the user to click Done to confirm self._waiveStrengthClicks = 0 self._waiveASCIIClicks = 0 self.guesser = True self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label") # Configure levels for the password bar self.pw_bar.add_offset_value("low", 2) self.pw_bar.add_offset_value("medium", 3) self.pw_bar.add_offset_value("high", 4) self.pw_bar.add_offset_value("full", 4) # Configure the password policy, if available. Otherwise use defaults. self.policy = self.data.anaconda.pwpolicy.get_policy("user") if not self.policy: self.policy = self.data.anaconda.PwPolicyData() # indicate when the password was set by kickstart self._password_kickstarted = self.data.user.seen # Password checks, in order of importance: # - if a password is required, is one specified? # - if a password is specified and there is data in the confirm box, do they match? # - if a password is specified and the confirm box is empty or match, how strong is it? # - if a strong password is specified, does it contain non-ASCII data? # - if a password is required, is there any data in the confirm box? self.add_check(self.pw, self._checkPasswordEmpty) # the password confirmation needs to be checked whenever either of the password # fields change. attach to the confirm field so that errors focus on confirm, # and check changes to the password field in password_changed self._confirm_check = self.add_check(self.confirm, self._checkPasswordConfirm) # Keep a reference to these checks, since they have to be manually run for the # click Done twice check. self._pwStrengthCheck = self.add_check(self.pw, self._checkPasswordStrength) self._pwASCIICheck = self.add_check(self.pw, self._checkPasswordASCII) self.add_check(self.confirm, self._checkPasswordEmpty) self.add_check(self.username, self._checkUsername) # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. if self._password_kickstarted: self.pw.set_placeholder_text(_("The password was set by kickstart.")) self.confirm.set_placeholder_text(_("The password was set by kickstart.")) # set the visibility of the password entries set_password_visibility(self.pw, False) set_password_visibility(self.confirm, False)
def initialize(self): NormalSpoke.initialize(self) self.initialize_start() # Create a new UserData object to store this spoke's state # as well as the state of the advanced user dialog. if self.data.user.userList: self._user = copy.copy(self.data.user.userList[0]) else: self._user = self.data.UserData() # gather references to relevant GUI objects # entry fields self._fullname_entry = self.builder.get_object("fullname_entry") self._username_entry = self.builder.get_object("username_entry") self._password_entry = self.builder.get_object("password_entry") self._password_confirmation_entry = self.builder.get_object("password_confirmation_entry") # check boxes self._admin_checkbox = self.builder.get_object("admin_checkbox") self._password_required_checkbox = self.builder.get_object("password_required_checkbox") # advanced user configration dialog button self._advanced_button = self.builder.get_object("advanced_button") # password checking status bar & label self._password_bar = self.builder.get_object("password_bar") self._password_label = self.builder.get_object("password_label") # Install the password checks: # - Has a password been specified? # - If a password has been specified and there is data in the confirm box, do they match? # - How strong is the password? # - Does the password contain non-ASCII characters? # Setup the password checker for password checking self._checker = input_checking.PasswordChecker( initial_password_content = self.password, initial_password_confirmation_content = self.password_confirmation, policy = input_checking.get_policy(self.data, "user") ) # configure the checker for password checking self.checker.username = self.username self.checker.secret_type = constants.SecretType.PASSWORD # remove any placeholder texts if either password or confirmation field changes content from initial state self.checker.password.changed_from_initial_state.connect(self.remove_placeholder_texts) self.checker.password_confirmation.changed_from_initial_state.connect(self.remove_placeholder_texts) # connect UI updates to check results self.checker.checks_done.connect(self._checks_done) # username and full name checks self._username_check = input_checking.UsernameCheck() self._fullname_check = input_checking.FullnameCheck() # empty username is considered a success so that the user can leave # the spoke without filling it in self._username_check.success_if_username_empty = True # check that the password is not empty self._empty_check = input_checking.PasswordEmptyCheck() # check that the content of the password field & the conformation field are the same self._confirm_check = input_checking.PasswordConfirmationCheck() # regards both fields empty as success to let the user escape self._confirm_check.success_if_confirmation_empty = True # check password validity, quality and strength self._validity_check = input_checking.PasswordValidityCheck() # connect UI updates to validity check results self._validity_check.result.password_score_changed.connect(self.set_password_score) self._validity_check.result.status_text_changed.connect(self.set_password_status) # check if the password contains non-ascii characters self._ascii_check = input_checking.PasswordASCIICheck() # register the individual checks with the checker in proper order # 0) is the username and fullname valid ? # 1) is the password non-empty ? # 2) are both entered passwords the same ? # 3) is the password valid according to the current password checking policy ? # 4) is the password free of non-ASCII characters ? self.checker.add_check(self._username_check) self.checker.add_check(self._fullname_check) self.checker.add_check(self._empty_check) self.checker.add_check(self._confirm_check) self.checker.add_check(self._validity_check) self.checker.add_check(self._ascii_check) self.guesser = { self.username_entry: True } # Configure levels for the password bar self.password_bar.add_offset_value("low", 2) self.password_bar.add_offset_value("medium", 3) self.password_bar.add_offset_value("high", 4) # indicate when the password was set by kickstart self.password_kickstarted = self.data.user.seen # Modify the GUI based on the kickstart and policy information # This needs to happen after the input checks have been created, since # the Gtk signal handlers use the input check variables. password_set_message = _("The password was set by kickstart.") if self.password_kickstarted: self.password_required = True self.password_entry.set_placeholder_text(password_set_message) self.password_confirmation_entry.set_placeholder_text(password_set_message) elif not self.checker.policy.emptyok: # Policy is that a non-empty password is required self.password_required = True if not self.checker.policy.emptyok: # User isn't allowed to change whether password is required or not self.password_required_checkbox.set_sensitive(False) self._advanced_user_dialog = AdvancedUserDialog(self._user, self.data) self._advanced_user_dialog.initialize() # set the visibility of the password entries set_password_visibility(self.password_entry, False) set_password_visibility(self.password_confirmation_entry, False) # report that we are done self.initialize_done()