Worklight 6.0 Android Hybrid Application不会进入登录页面

时间:2014-07-11 10:12:59

标签: javascript android cordova ibm-mobilefirst

我们使用worklight 6.0为Android开发了一个混合应用程序。

应用程序调用需要基于表单的身份验证的查询 应用程序中也使用了设备身份验证和工作单身份验证。

在调用查询时,应用程序将使用Web服务调用worklight服务器,并将登录页面html作为响应传递 - 这在Android设备中无效,因为响应未到达应用程序并且应用程序在超时后挂起而无法重定向到登录页面。

我们正在使用服务器级别身份验证,其中WebSphere与LDAP集成。 使用LDAP成功进行用户身份验证,并对会话进行身份验证。通过针对XSRF,远程禁用等的预定义Worklight安全测试来保护资源。

此外,资源还通过设备自动配置和应用程序身份验证进行保护。用户通过LDAP进行身份验证后,设备身份验证将失败,应用程序将挂起

相同的应用程序在iOS中运行良好。

日志

 07-10 19:45:13.241: I/chromium(25549): [INFO:CONSOLE(978)] "processMessage failed: Stack: TypeError: undefined is not a function
    07-10 19:45:13.241: I/chromium(25549):     at invokeProcedure (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/wlclient.js:1686:23)
    07-10 19:45:13.241: I/chromium(25549):     at file:///data/data/com.MOIKuwait/files/www/default/js/common.js:2737:40
    07-10 19:45:13.241: I/chromium(25549):     at captureReturnValue (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js:852:20)
    07-10 19:45:13.241: I/chromium(25549):     at Object.cordova.callbackFromNative (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js:293:54)
    07-10 19:45:13.241: I/chromium(25549):     at processMessage (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js:971:21)
    07-10 19:45:13.241: I/chromium(25549):     at Function.androidExec.processMessages (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js:1009:17)
    07-10 19:45:13.241: I/chromium(25549):     at Object.androidExec [as exec] (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js:861:21)
    07-10 19:45:13.241: I/chromium(25549):     at WL.Device.getNetworkInfo (file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/wlgap.android.js:1251:13)
    07-10 19:45:13.241: I/chromium(25549):     at inquireVisaApplicationStatus (file:///data/data/com.MOIKuwait/files/www/default/js/common.js:2726:15)
    07-10 19:45:13.241: I/chromium(25549):     at validateAppNumber (file:///data/data/com.MOIKuwait/files/www/default/js/common.js:680:3)", source: file:///data/data/com.MOIKuwait/files/www/default/wlclient/js/cordova.js (978)

authenticationConfig.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<tns:loginConfiguration xmlns:tns="http://www.worklight.com/auth/config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <securityTests>

        <mobileSecurityTest name="WASTest-securityTest">
                    <testAppAuthenticity />
            <testDeviceId provisioningType="none" />
            <testUser realm="WASLTPARealm" />
        </mobileSecurityTest>

        <mobileSecurityTest name="PushNotificationSecurityTest">
            <testAppAuthenticity />
            <testDeviceId provisioningType="none" />
            <testUser realm="PushRealm" />
        </mobileSecurityTest>

    </securityTests>

    <realms>

        <realm loginModule="WASLTPAModule" name="WASLTPARealm">
            <className>com.worklight.core.auth.ext.WebSphereFormBasedAuthenticator</className>
            <parameter name="login-page" value="/login.html" />
            <parameter name="error-page" value="/loginError.html" />
        </realm>

        <realm name="PushRealm" loginModule="HeaderLoginModule">
            <className>com.worklight.core.auth.ext.HeaderAuthenticator</className>
        </realm>

    </realms>

    <loginModules>

        <loginModule name="WASLTPAModule">
            <className>com.worklight.core.auth.ext.WebSphereLoginModule</className>
        </loginModule>

        <loginModule name="HeaderLoginModule">
            <className>com.worklight.core.auth.ext.HeaderLoginModule</className>
            <parameter name="user-name-header" value="userid" />
        </loginModule>

    </loginModules>

</tns:loginConfiguration>

调用适配器

if(networkInfo.isNetworkConnected == "true"){
var invocationData = {
adapter : 'EnquiryServicesAdapter',
procedure : 'inquirePassportData',
parameters : [ UserUID ]
};
WL.Client.invokeProcedure(invocationData, {
onSuccess : successPassportResponse,
onFailure : failPassportResponse,
timeout : requestTimeout
});

EnquriyServiceAdapter.js

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed Materials - Property of IBM 5725-G92 (C) Copyright IBM Corp. 
    2011, 2013. All Rights Reserved. US Government Users Restricted Rights - 
    Use, duplication or disclosure restricted by GSA ADP Schedule Contract with 
    IBM Corp. -->
<wl:adapter name="EnquiryServicesAdapter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http">

    <displayName>EnquiryServicesAdapter</displayName>
    <description>EnquiryServicesAdapter</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>localhost</domain>
            <port>9080</port>
            <!-- Following properties used by adapter's key manager for choosing specific 
                certificate from key store <sslCertificateAlias></sslCertificateAlias> <sslCertificatePassword></sslCertificatePassword> -->
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="2" />
    </connectivity>

    <procedure name="inquirePassportData" securityTest="WASTest-securityTest" />


</wl:adapter>

EnquiryServicesAdapter-IMPL

function inquirePassportData(userId) {

    var instance = com.worklight.service.PassportEnquiryService.getInstance();

    var sessionInstance = WL.Server.getActiveUser('WASLTPARealm');

    WL.Logger.info(sessionInstance.userId);

    return {
        response : instance.getEnquiryDetails(sessionInstance.userId)
    };
}

1 个答案:

答案 0 :(得分:0)

根据你的日志,wlclient期望得到一个函数,但是收到一个未定义的。该调用来自common.js,第2737行。该文件是您的应用程序代码。我在那里放了一个断点并查看最新情况。很难说没有看到那部分代码。

您可以在此处阅读有关调试在Android上运行的JS代码的更多信息 - https://developer.chrome.com/devtools/docs/remote-debugging