Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android IBM Mobilefirst 8.0基于LTPA的安全检查-获得令牌后不称为handleSuccess方法_Android_Cordova_Ibm Mobilefirst_Mobilefirst Server - Fatal编程技术网

Android IBM Mobilefirst 8.0基于LTPA的安全检查-获得令牌后不称为handleSuccess方法

Android IBM Mobilefirst 8.0基于LTPA的安全检查-获得令牌后不称为handleSuccess方法,android,cordova,ibm-mobilefirst,mobilefirst-server,Android,Cordova,Ibm Mobilefirst,Mobilefirst Server,我尝试根据本教程创建基于angularjs的Cordova移动应用程序: 以及基于以下示例的基于LTPA的安全检查登录流(在Mobilefirst 8.0中): 移动应用程序正在使用angular。授权实施: app.factory('Auth', function ($rootScope) { var securityCheckName = 'LTPA', _$scope = null, challengeHandler = null,

我尝试根据本教程创建基于angularjs的Cordova移动应用程序: 以及基于以下示例的基于LTPA的安全检查登录流(在Mobilefirst 8.0中):

移动应用程序正在使用angular。授权实施:

app.factory('Auth', function ($rootScope) {

    var securityCheckName = 'LTPA',
        _$scope = null,
        challengeHandler = null,
        URL = '',

    challengeHandler = WL.Client.createSecurityCheckChallengeHandler(securityCheckName);
    challengeHandler.securityCheckName = securityCheckName;
    WLAuthorizationManager.login(securityCheckName, {'username': '', 'password': ''});

    challengeHandler.handleChallenge = function (challenge) {
        if (challenge && challenge.loginURL) {
            URL = challenge.loginURL;
        }
    };

    challengeHandler.handleSuccess = function (data) {
        // code
    };

    challengeHandler.handleFailure = function (error) {
        // code
    };

    return {
        login: function ($scope, username, password) {
            _$scope = $scope;

            var request = new WLResourceRequest(URL, WLResourceRequest.POST);
            request.send("j_username=" + username + "&j_password=" + password + "&action=Login").then(
            function(response) {
                challengeHandler.submitChallengeAnswer({});
            },
            function(error) {
              // on error
            });
        }
    };
});
这似乎只适用于iOS。在Android上,不会调用handleSuccess函数

与过去一样,在Android设备上发送Cookie时存在问题(使用较旧的MF版本),因此我尝试了
登录
功能中的解决方法,即使用登录表单打开隐藏的InApp浏览器,然后进行用户登录过程,一旦收到令牌,它是通过
cordova cookie主插件设置的
,调用了
submitChallengeAnswer

login: function ($scope, username, password) {
    _$scope = $scope;

    var request = new WLResourceRequest(URL, WLResourceRequest.POST);
    request.send("j_username=" + username + "&j_password=" + password + "&action=Login").then(
    function(response) {
        if (device.platform == "iOS") {
            challengeHandler.submitChallengeAnswer({});
        } else {
            iab = cordova.InAppBrowser.open(URL, "_blank", "hidden=yes");
            iab.addEventListener('loadstop', function(event){

                iab.executeScript({code:
                    'var field1 = document.getElementsByTagName("input")[0];' +
                    'var field2 = document.getElementsByTagName("input")[1];' +
                    'field1.setAttribute("value", "' + username + '");' +
                    'field2.setAttribute("value", "' + password + '");' +
                    'document.forms[0].submit();'
                }, function(){
                    // on error
                });

                try {
                    cookieMaster.getCookieValue(URL, 'LtpaToken2', function(data) {
                        WL.Client.setCookie({
                          "name" : "LtpaToken2",
                          "value" : data.cookieValue,
                          "domain" : ".example.com",
                          "path" : "/",
                          "expires" : "Thu, 18 Dec 2999 12:00:00 UTC"
                        }).then(function() {
                            challengeHandler.submitChallengeAnswer({});
                        }).fail(function(err) {
                            // on error
                        });
                    }, function(error) {
                        // on error
                    });
                } catch(err) {
                    // on error
                }

            });

            iab.addEventListener('exit', function(){
                iab.removeEventListener('loadstop', function() { /* on success */ });
            });
        }
    },
    function(error) {
      // on error
    });
}

这个解决方案也不适用于我。我希望在激发
challengeHandler.submitChallengeAnswer()
之后,将调用
handleSuccess
,但它没有发生<改为调用code>handleChallenge。

为什么要发出resourcerequest,然后在其成功回调中执行submitchallengeanswer()?resourcerequest将导致流进入handlechallenge,并且在回答质询之前不会进入成功回调(submitchallengeanswer所在的位置)。单击时调用
登录
函数,因此流更像是:发送WLResourceRequest后,在成功回调submitchallengeanswer()中执行,并在结果handleChallenge()中调用handleSuccess()或handleFailure()。在iOS上(它在iOS上正常工作),在submitChallengeAnswer()之后,执行handleSuccess()并成功结束登录过程,但在Android上(问题所在)执行handleChallenge()。