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


Python Contexts.getApplicationContext方法代码示例

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


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

示例1: authenticate

# 需要导入模块: from org.jboss.seam.contexts import Contexts [as 别名]
# 或者: from org.jboss.seam.contexts.Contexts import getApplicationContext [as 别名]
    def authenticate(self, configurationAttributes, requestParameters, step):
        context = Contexts.getApplicationContext()

        print "Wikid. Authentication. Cheking client"
        wc = context.get("wClient")
        if ((wc is None) or (not wc.isConnected())):
            print "Wikid. Authenticate for step 1. Creating new client."
            wikid_server_host = configurationAttributes.get("wikid_server_host").getValue2()
            wikid_server_port = int(configurationAttributes.get("wikid_server_port").getValue2())
    
            wikid_cert_path = configurationAttributes.get("wikid_cert_path").getValue2()
            wikid_cert_pass = configurationAttributes.get("wikid_cert_pass").getValue2()
            wikid_ca_store_path = configurationAttributes.get("wikid_ca_store_path").getValue2()
            wikid_ca_store_pass = configurationAttributes.get("wikid_ca_store_pass").getValue2()

            wc = wClient(wikid_server_host, wikid_server_port, wikid_cert_path, wikid_cert_pass, wikid_ca_store_path, wikid_ca_store_pass)
            context.set("wClient", wc)

        if (step == 1):
            print "Wikid. Authenticate for step 1"

            credentials = Identity.instance().getCredentials()
            user_name = credentials.getUsername()
            user_password = credentials.getPassword()

            logged_in = False
            if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
                userService = UserService.instance()
                logged_in = userService.authenticate(user_name, user_password)

            if (not logged_in):
                return False

            return wc.isConnected()
        elif (step == 2):
            print "Wikid. Authenticate for step 2"
            wc = context.get("wClient")
            if (wc is None):
                print "Wikid. Authenticate. Client is invalid"
                return False

            wikid_user_array = requestParameters.get("username")
            wikid_passcode_array = requestParameters.get("passcode")
            if ArrayHelper.isEmpty(wikid_user_array) or  ArrayHelper.isEmpty(wikid_passcode_array):
                print "Wikid. Authenticate. Username or passcode is empty"
                return False

            wikid_user = wikid_user_array[0]
            wikid_passcode = wikid_passcode_array[0]
            wikid_server_code = configurationAttributes.get("wikid_server_code").getValue2()

            print "Wikid. Authenticate for step 2 wikid_user: " + wikid_user

            is_valid = wc.CheckCredentials(wikid_user, wikid_passcode, wikid_server_code);

            if is_valid:
                print "Wikid. Authenticate for step 2. wikid_user: " + wikid_user + " authenticated successfully"
            else:
                print "Wikid. Authenticate for step 2. Failed to authenticate. wikid_user: " + wikid_user

            return is_valid
        else:
            return False
开发者ID:CIVICS,项目名称:oxAuth,代码行数:65,代码来源:WikidExternalAuthenticator.py


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