Exemple #1
0
    def new_user(self, username, password, email = None,
                 org_id = None, org_password = None):
        """
        Finish off creating the user.

        The user has to exist (must be already reserved), the password must
        match and we set the e-mail address if one is given

        Return true if success
        """

        log_debug(1, username, email)
        # email has to be a string or nothing
        if not checkValue(email, None, "", type("")):
            raise rhnFault(30, _faultValueString(email, "email"))
        # be somewhat drastic about the org values
        if org_id and org_password:
            org_password = str(org_password)
            try:
                org_id = int(str(org_id))
            except ValueError:
                raise rhnFault(30, _faultValueString(org_id, "org_id")), None, sys.exc_info()[2]
        else:
            org_id = org_password = None
        username, password  = rhnUser.check_user_password(username, password)
        email = rhnUser.check_email(email)
        # now create this user
        ret = rhnUser.new_user(username, password, email, org_id, org_password)
        # rhnUser.new_user will raise it's own faults.
        return ret
Exemple #2
0
    def new_user(self, username, password, email = None,
                 org_id = None, org_password = None):
        """
        Finish off creating the user.

        The user has to exist (must be already reserved), the password must
        match and we set the e-mail address if one is given

        Return true if success
        """

        log_debug(1, username, email)
        # email has to be a string or nothing
        if not checkValue(email, None, "", type("")):
            raise rhnFault(30, _faultValueString(email, "email"))
        # be somewhat drastic about the org values
        if org_id and org_password:
            org_password = str(org_password)
            try:
                org_id = int(str(org_id))
            except ValueError:
                raise rhnFault(30, _faultValueString(org_id, "org_id")), None, sys.exc_info()[2]
        else:
            org_id = org_password = None
        username, password  = rhnUser.check_user_password(username, password)
        email = rhnUser.check_email(email)
        # now create this user
        ret = rhnUser.new_user(username, password, email, org_id, org_password)
        # rhnUser.new_user will raise it's own faults.
        return ret
Exemple #3
0
    def validate_system_user(self, username, password):
        username, password = rhnUser.check_user_password(username,
                                                         password)
        user = rhnUser.search(username)

        if user is None:
            log_error("Can't register server to non-existent user")
            raise rhnFault(2, _("Attempt to register a system to an invalid username"))

        # This check validates username and password
        if not user.check_password(password):
            log_error("User password check failed", username)
            raise rhnFault(2)

        if rhnUser.is_user_disabled(username):
            msg = _("""
                   %s Account has been deactivated on this server.
                   Please contact your Org administrator for more help.""")
            raise rhnFault(1, msg % username, explain=0)

        return user
Exemple #4
0
    def validate_system_user(self, username, password):
        username, password = rhnUser.check_user_password(username,
                                                         password)
        user = rhnUser.search(username)

        if user is None:
            log_error("Can't register server to non-existent user")
            raise rhnFault(2, _("Attempt to register a system to an invalid username"))

        # This check validates username and password
        if not user.check_password(password):
            log_error("User password check failed", username)
            raise rhnFault(2)

        if rhnUser.is_user_disabled(username):
            msg = _("""
                   %s Account has been deactivated on this server.
                   Please contact your Org administrator for more help.""")
            raise rhnFault(1, msg % username, explain=0)

        return user