当前位置: 首页>>代码示例>>Python>>正文


Python WebContainer.get_security方法代码示例

本文整理汇总了Python中pyasm.web.WebContainer.get_security方法的典型用法代码示例。如果您正苦于以下问题:Python WebContainer.get_security方法的具体用法?Python WebContainer.get_security怎么用?Python WebContainer.get_security使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.web.WebContainer的用法示例。


在下文中一共展示了WebContainer.get_security方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
    def execute(my):
        # Since this is not called with Command.execute_cmd
        my.check()

        web = WebContainer.get_web()

        reset_on = my.kwargs.get('reset') == True
        if reset_on:
            security = WebContainer.get_security()
            #Batch()
            login = Login.get_by_login(my.login)
            if not login:
                web.set_form_value(ResetPasswordWdg.MSG, 'This user [%s] does not exist or has been disabled. Please contact the Administrator.'%my.login)
                return
            email = login.get_value('email')
            if not email:
                web.set_form_value(ResetPasswordWdg.MSG, 'This user [%s] does not have an email entry for us to email you the new password. Please contact the Administrator.'%my.login)
                return

        
            # auto pass generation
            unique_code = ''.join([ random.choice('abcdefghijklmno12345') for i in xrange(0, 5)])
            auto_password = unique_code
            
            msg = ResetPasswordWdg.RESET_MSG
            
            # send the email
            try:
                from pyasm.command import EmailTriggerTestCmd

                admin = Login.get_by_login('admin')
                if admin:
                    sender_email = admin.get_value('email')
                else:
                    sender_email = '[email protected]'

                recipient_emails = [email]
                email_msg =  'Your TACTIC password has been reset. The new password is:\n%s\nYou can change your password once you log in by going to Edit My Account at the top right corner.'%auto_password
                email_cmd = EmailTriggerTestCmd(sender_email=sender_email, recipient_emails=recipient_emails, msg= email_msg, subject='TACTIC password change')
            
                email_cmd.execute()
            except TacticException, e:
                
                msg = "Failed to send an email for your new password. Reset aborted."
                web.set_form_value(ResetPasswordWdg.MSG, msg)
                raise 
            else:
                encrypted = hashlib.md5(auto_password).hexdigest()
                login.set_value('password', encrypted)
                login.commit()
                web.set_form_value(ResetPasswordWdg.MSG, 'A new password has been sent to your email address. Please check your email.')


                
            # handle windows domains
            #if my.domain:
            #    my.login = "%s\\%s" % (my.domain, my.login)

            web.set_form_value(ResetPasswordWdg.MSG, msg)
开发者ID:CeltonMcGrath,项目名称:TACTIC,代码行数:61,代码来源:reset_password_wdg.py

示例2: execute

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
    def execute(my):

        from pyasm.web import WebContainer
        web = WebContainer.get_web()

        # If the tag <force_lowercase_login> is set to "true"
        # in the TACTIC config file,
        # then force the login string argument to be lowercase.
        # This tag is false by default.
        my.login = web.get_form_value("login")
        if Config.get_value("security","force_lowercase_login") == "true":
            my.login = my.login.lower()
        my.password = web.get_form_value("password")
        my.domain = web.get_form_value("domain")

        if my.login == "" and my.password == "":
            return False

        
        if my.login == "" or  my.password == "":
            web.set_form_value(WebLoginWdg.LOGIN_MSG, \
                "Empty username or password") 
            return False
        
        security = WebContainer.get_security()

        # handle windows domains
        #if my.domain:
        #    my.login = "%s\\%s" % (my.domain, my.login)

        verify_password = web.get_form_value("verify_password")
        if verify_password:
            if verify_password != my.password:
                web.set_form_value(WebLoginWdg.LOGIN_MSG, \
                    "Passwords do not match.") 
                return False

            my.password = Login.get_default_password()

        try:
            security.login_user(my.login, my.password, domain=my.domain)
        except SecurityException, e:
            msg = str(e)
            if not msg:
                msg = "Incorrect username or password"

            from pyasm.widget import WebLoginWdg
            web.set_form_value(WebLoginWdg.LOGIN_MSG, msg)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:50,代码来源:web_login_cmd.py

示例3: add

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
    def add(my,widget,title=None,index=None):
        if title == None:
            title = widget.__class__.__name__

        # determine the url and check security
        # DEPRECATED!!!! use "tab" security
        url_selector = WebContainer.get_web().get_request_url().get_selector()
        check = "%s|%s" % (url_selector,title)

        # check tab security
        if my.mode != "check":
            security = WebContainer.get_security()
            if not security.check_access("url", check, "view"):
                return
            # new security mechanism
            if not security.check_access("tab_title", title, "view"):
                return
            # new, new security mechanism
            tab_path = my.get_tab_path(title)
            if not security.check_access("tab", tab_path, "view"):
                return

            # check if this tab is invisible
            if not my.check_visibility(tab_path):
                return

        if index == None:
            my.tab_names.append(title)
        else:
            my.tab_names.insert(index,title)

        my.wdg_dict[title] = widget
        # for tabs, the widget passed in can be None.  Only the
        # title is added
        if widget == None:
            return

        # only the selected one really gets added
        if not my.tab_value or title == my.tab_value:
            Container.put("tab_path", my.get_tab_path(title))

            widget = my.init_widget(widget, title)
            # the very first time user click on the main tab
            if not my.tab_value:
                my.tab_value = title

            super(TabWdg,my)._add_widget(widget, title)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:49,代码来源:tab_wdg.py

示例4: add

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
    def add(self,widget,title=None):
        if title == None:
            title = widget.__class__.__name__

        # determine the url and check security
        request_url = WebContainer.get_web().get_request_url()
        base = request_url.get_base()
        if base.endswith("/"):
            base = "%sIndex" % base 
        check = "%s|%s" % (base,title)

        security = WebContainer.get_security()
        if not security.check_access("url", check, "view"):
            return


        if not security.check_access("tab", title, "view"):
            return

        self.tab_names.append(title)

        # for tabs, the widget passed in can be None.  Only the
        # title is added
        assert widget != None

        # only the selected one really gets added
        try:
            # if a method was passed in, then execute it
            if type(widget) == types.MethodType:
                widget = MethodWdg(widget)
            elif isinstance(widget, basestring):
                widget = Common.create_from_class_path(widget)
            elif not isinstance(widget, Widget):
                widget = ClassWdg(widget)
                
        # catch all exceptions and log them
        except Exception as e:
            self.handle_exception(e)

        super(DynTabWdg,self)._add_widget(widget, title)
开发者ID:mincau,项目名称:TACTIC,代码行数:42,代码来源:tab_wdg.py

示例5: get_upload_dir

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
 def get_upload_dir(cls):
     from pyasm.web import WebContainer
     ticket = WebContainer.get_security().get_ticket().get_key()
     dir = "%s/upload/%s" % (Environment.get_tmp_dir(), ticket)
     return dir
开发者ID:funic,项目名称:TACTIC,代码行数:7,代码来源:file_checkin.py

示例6: execute

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
    def execute(my):

        from pyasm.web import WebContainer
        web = WebContainer.get_web()

        from pyasm.widget import WebLoginWdg
        # If the tag <force_lowercase_login> is set to "true"
        # in the TACTIC config file,
        # then force the login string argument to be lowercase.
        # This tag is false by default.
        my.login = web.get_form_value("login")
        if Config.get_value("security","force_lowercase_login") == "true":
            my.login = my.login.lower()
        my.password = web.get_form_value("password")
        my.domain = web.get_form_value("domain")

        if my.login == "" and my.password == "":
            return False

        
        if my.login == "" or  my.password == "":
            web.set_form_value(WebLoginWdg.LOGIN_MSG, \
                "Empty username or password") 
            return False
        
        security = WebContainer.get_security()

        # handle windows domains
        #if my.domain:
        #    my.login = "%s\\%s" % (my.domain, my.login)


        verify_password = web.get_form_value("verify_password")
        if verify_password:
            if verify_password != my.password:
                web.set_form_value(WebLoginWdg.LOGIN_MSG, \
                    "Passwords do not match.") 
                return False

            search = Search("sthpw/login")
         
            search.add_filter('upn',my.login)
            login_sobject = search.get_sobject()
            if not login_sobject:
                search2 = Search("sthpw/login")              
                search2.add_filter('login',my.login)
                login_sobject = search2.get_sobject()
            if login_sobject.get_value("login") == "admin":
                login_sobject.set_password(verify_password)

          

        try:
            security.login_user(my.login, my.password, domain=my.domain)
        except SecurityException, e:
            msg = str(e)
            if not msg:
                msg = "Incorrect username or password"
            web.set_form_value(WebLoginWdg.LOGIN_MSG, msg)


            max_attempts=-1
            try:
                max_attempts = int(Config.get_value("security", "max_login_attempt"))
            except:
                pass
            if max_attempts >0:
                login_attempt = login_sobject.get_value('login_attempt')

                login_attempt = login_attempt+1
                login_sobject.set_value('login_attempt', login_attempt)

                if login_attempt == max_attempts:
                    #set license_Type to disabled and set off the thread to re-enable it
                    login_sobject.set_value('license_type', 'disabled')
                    disabled_time = Config.get_value("security", "account_lockout_duration")
                    if not disabled_time:
                        disabled_time = "30 minutes"


                    delay,unit = disabled_time.split(" ",1)
                    if "minute" in unit:
                        delay = int(delay)*60
                    
                    elif "hour" in unit:
                        delay =int(delay)*3600
                    
                    elif "second" in unit:
                        delay = int(delay)
                    else:
                        #make delay default to 30 min
                        delay = 30*60

                    my.reenable_user(login_sobject, delay)

                
                login_sobject.commit(triggers=False)
开发者ID:pombredanne,项目名称:TACTIC,代码行数:99,代码来源:web_login_cmd.py

示例7: is_logged_in

# 需要导入模块: from pyasm.web import WebContainer [as 别名]
# 或者: from pyasm.web.WebContainer import get_security [as 别名]
 def is_logged_in(my):
     security = WebContainer.get_security()
     return security.is_logged_in()
开发者ID:0-T-0,项目名称:TACTIC,代码行数:5,代码来源:web_login_cmd.py


注:本文中的pyasm.web.WebContainer.get_security方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。