2014-07-11 86 views
2

我們使用worklight 6.0爲Android開發了混合應用程序。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) 
    }; 
} 
+0

工作的呢? –

+0

此外,只是爲了檢查,你有功能successPassportResponse和failPassportResponse實際執行? –

回答

0

根據你的日誌wlclient期待得到一個功能,而是接受一個未定義的來代替。該調用來自common.js,第2737行。此文件是您的應用程序代碼。我會在那裏放置一個斷點並檢查發生了什麼。很難說沒有看到那部分代碼。

你可以閱讀更多有關調試Android上跑這裏你的JS代碼 - https://developer.chrome.com/devtools/docs/remote-debugging如果刪除了安全測試的程序inquirePassportData