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. Authenticate for step 2. wikid_user: "******" authenticated successfully" else: print "Wikid. Authenticate for step 2. Failed to authenticate. wikid_user: " + wikid_user return is_valid else: return False