コード例 #1
0
    def init(self, configurationAttributes):

        print "Casa. init called"
        self.authenticators = {}
        self.configFileLocation = "/etc/gluu/conf/casa.json"
        self.uid_attr = self.getLocalPrimaryKey()

        custScriptService = CdiUtil.bean(CustomScriptService)
        scriptsList = custScriptService.findCustomScripts(
            Collections.singletonList(CustomScriptType.PERSON_AUTHENTICATION),
            "oxConfigurationProperty", "displayName", "gluuStatus")
        dynamicMethods = self.computeMethods(scriptsList)

        if len(dynamicMethods) > 0:
            print "Casa. init. Loading scripts for dynamic modules: %s" % dynamicMethods

            for acr in dynamicMethods:
                moduleName = self.modulePrefix + acr
                try:
                    external = __import__(moduleName, globals(), locals(),
                                          ["PersonAuthentication"], -1)
                    module = external.PersonAuthentication(
                        self.currentTimeMillis)

                    print "Casa. init. Got dynamic module for acr %s" % acr
                    configAttrs = self.getConfigurationAttributes(
                        acr, scriptsList)

                    if acr == self.ACR_U2F:
                        u2f_application_id = configurationAttributes.get(
                            "u2f_app_id").getValue2()
                        configAttrs.put(
                            "u2f_application_id",
                            SimpleCustomProperty("u2f_application_id",
                                                 u2f_application_id))
                    elif acr == self.ACR_SG:
                        client_redirect_uri = configurationAttributes.get(
                            "supergluu_app_id").getValue2()
                        configAttrs.put(
                            "client_redirect_uri",
                            SimpleCustomProperty("client_redirect_uri",
                                                 client_redirect_uri))

                    if module.init(configAttrs):
                        module.configAttrs = configAttrs
                        self.authenticators[acr] = module
                    else:
                        print "Casa. init. Call to init in module '%s' returned False" % moduleName
                except:
                    print "Casa. init. Failed to load module %s" % moduleName
                    print "Exception: ", sys.exc_info()[1]

        print "Casa. init. Initialized successfully"
        return True
コード例 #2
0
ファイル: casa.py プロジェクト: sobhanpanda/oxAuth
    def getConfigurationAttributes(self, acr, scriptsList):

        configMap = HashMap()
        for customScript in scriptsList:
            if customScript.getName() == acr and customScript.isEnabled():
                for prop in customScript.getConfigurationProperties():
                    configMap.put(prop.getValue1(), SimpleCustomProperty(prop.getValue1(), prop.getValue2()))

        print "Casa. getConfigurationAttributes. %d configuration properties were found for %s" % (configMap.size(), acr)
        return configMap