WL.Client.connect发送请求

时间:2015-09-03 09:03:42

标签: android ibm-mobilefirst

我有两个问题 第一个问题:
请求之间有什么区别

D/wl.request (16655): WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://mywebseal:80/worklight/authorization/v1/clients/instance

并请求

D/HttpPostRequestSender (3235): WLHybridRequestSender.run in WLHybridRequestSender.java:42 :: Sending request http://mywebseal:80/worklight/apps/services/api/<appname>/Android/init

我实现了通过反向代理IBM WebSEAL使用登录表单的混合应用程序。我在Android Lollipop设备上进行测试 在测试期间,WL.Client.connect只能正常工作一次,并已通过课程WLHybridRequestSender执行了请求。
在其他尝试中,WL.Client.connect继续使用类WLRequestSender发出请求,而不对源代码进行任何修改。
WLRequestSender无法识别从Webseal Http Response返回的登录页面 应用程序没有改变,我不明白发生了什么以及为什么 第二个问题:
WL框架如何使用WLHybridRequestSender或WLRequestSender决定是否发出请求?

对于那些希望深化我用Mobilefirst 7.0.0.00-20150729-1801和IBM Security Access Manager for Web 8.0.1.0实现http://www-01.ibm.com/support/docview.wss?uid=swg24034222的人。

logcat错误如下:

D/NONE(16655): Request [/apps/services/api/ISAMforMobileFirst/android/init]
W/PluginManager(16655): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.getClientInstanceIdHeader blocked the main thread for 153ms. Plugin should use CordovaInterface.getThreadPool().
D/wl.request(16655): WLRequestSender.run in WLRequestSender.java:40 :: Sending request http://mywebseal:80/worklight/authorization/v1/clients/instance
E/wl.response(16655): WLResponse.responseTextToJSON in WLResponse.java:116 :: Response from MobileFirst Platform server failed because could not read JSON from response with text {
E/wl.response(16655): document.write(warningString);
E/wl.response(16655): }
E/wl.response(16655): else{
E/wl.response(16655): document.cookie = 'acceptsCookies=yes; expires=Fri, 13-Apr-1970 00:00:00 GMT';
E/wl.response(16655): }
E/wl.response(16655): org.json.JSONException: Expected ':' after document.write(warningString) at character 32 of {
E/wl.response(16655): document.write(warningString);
E/wl.response(16655): }
E/wl.response(16655): else{
E/wl.response(16655): document.cookie = 'acceptsCookies=yes; expires=Fri, 13-Apr-1970 00:00:00 GMT';
E/wl.response(16655): }
E/wl.response(16655):   at org.json.JSONTokener.syntaxError(JSONTokener.java:450)
E/wl.response(16655):   at org.json.JSONTokener.readObject(JSONTokener.java:379)
E/wl.response(16655):   at org.json.JSONTokener.nextValue(JSONTokener.java:100)
E/wl.response(16655):   at org.json.JSONObject.<init>(JSONObject.java:155)
E/wl.response(16655):   at org.json.JSONObject.<init>(JSONObject.java:172)
E/wl.response(16655):   at com.worklight.wlclient.api.WLResponse.responseTextToJSON(WLResponse.java:114)
E/wl.response(16655):   at com.worklight.wlclient.api.WLResponse.getResponseJSON(WLResponse.java:269)
E/wl.response(16655):   at com.worklight.wlclient.WLRequest.checkResponseForSuccesses(WLRequest.java:559)
E/wl.response(16655):   at com.worklight.wlclient.WLRequest.requestFinished(WLRequest.java:280)
E/wl.response(16655):   at com.worklight.wlclient.WLRequestSender.run(WLRequestSender.java:52)
E/wl.response(16655):   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/wl.response(16655):   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/wl.response(16655):   at java.lang.Thread.run(Thread.java:841)

虽然成功的logcat是以下

D/NONE(3235): Request [/apps/services/api/ISAMforMobileFirst/android/init]
W/PluginManager(16655): THREAD WARNING: exec() call to WLAuthorizationManagerPlugin.getClientInstanceIdHeader blocked the main thread for 149ms. Plugin should use CordovaInterface.getThreadPool().
D/HttpPostRequestSender(3235): WLHybridRequestSender.run in WLHybridRequestSender.java:42 :: Sending request http://mywebseal:80/worklight/apps/services/api/ISAMforMobileFirst/android/init
I/chromium(3235): [INFO:CONSOLE(27)] "Entry: ISAMOAuthChallengeHandler.isCustomResponse()", source: file:///android_asset/www/default/js/ISAMOAuthChallengeHandler/ISAMOAuthChallengeHandler.js (27)
I/chromium(3235): [INFO:CONSOLE(30)] "{"request":{"options":{"method":"post","asynchronous":true,"contentType":"application/x-www-form-urlencoded","encoding":"UTF-8","parameters":{"isAjaxRequest":"true","x":0.858127806102857},"evalJSON":true,"evalJS":true,"timeout":45000,"onAuthentication":null,"isAuthResponse":null,"requestHeaders":{"x-wl-app-version":"3.4","x-wl-app-details":"{\"applicationDetails\":{\"platformVersion\":\"7.0.0.0\",\"nativeVersion\":\"1119668270\",\"skinName\":\"default\",\"skinChecksum\":1215343974}}","x-wl-clientlog-deviceId":"be86efe08752ad62","x-wl-clientlog-appname":"ISAMforMobileFirst","x-wl-clientlog-appversion":"3.4","x-wl-clientlog-osversion":"5.0.2","x-wl-clientlog-env":"android","x-wl-clientlog-model":"Android SDK built for x86","X-WL-ClientId":"29ea85036b812a83f9922245119483e32537ce54","X-WL-Session":"e63ad99f-2453-4bcb-8a7c-f989f8211485"},"optionalHeaders":{"x-wl-clientlog-deviceId":"be86efe08752ad62","x-wl-clientlog-appname":"ISAMforMobileFirst","x-wl-clientlog-appversion":"3.4","x-wl-clientlog-osversion":"5.0.2","x-wl-clientlog-env":"android","x-wl-clientlog-model":"Android SDK built for x86"}},"transport":{"timeout":45000,"status":200,"statusText":"OK","response":"<entire html login page webseal>"              
I/chromium(3235): [INFO:CONSOLE(34)] "Exit: ISAMOAuthChallengeHandler.isCustomResponse(), Response found but not CustomResponse for ISAMOAuthChallengeHandler -  returning false", source: file:///android_asset/www/default/js/ISAMOAuthChallengeHandler/ISAMOAuthChallengeHandler.js (34)
I/chromium(3235): [INFO:CONSOLE(25)] "Entry: ISAMLoginFormChallengeHandler.isCustomResponse()", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (25)
I/chromium(3235): [INFO:CONSOLE(29)] "{"request":{"options":{"method":"post","asynchronous":true,"contentType":"application/x-www-form-urlencoded","encoding":"UTF-8","parameters":{"isAjaxRequest":"true","x":0.858127806102857},"evalJSON":true,"evalJS":true,"timeout":45000,"onAuthentication":null,"isAuthResponse":null,"requestHeaders":{"x-wl-app-version":"3.4","x-wl-app-details":"{\"applicationDetails\":{\"platformVersion\":\"7.0.0.0\",\"nativeVersion\":\"1119668270\",\"skinName\":\"default\",\"skinChecksum\":1215343974}}","x-wl-clientlog-deviceId":"be86efe08752ad62","x-wl-clientlog-appname":"ISAMforMobileFirst","x-wl-clientlog-appversion":"3.4","x-wl-clientlog-osversion":"5.0.2","x-wl-clientlog-env":"android","x-wl-clientlog-model":"Android SDK built for x86","X-WL-ClientId":"29ea85036b812a83f9922245119483e32537ce54","X-WL-Session":"e63ad99f-2453-4bcb-8a7c-f989f8211485"},"optionalHeaders":{"x-wl-clientlog-deviceId":"be86efe08752ad62","x-wl-clientlog-appname":"ISAMforMobileFirst","x-wl-clientlog-appversion":"3.4","x-wl-clientlog-osversion":"5.0.2","x-wl-clientlog-env":"android","x-wl-clientlog-model":"Android SDK built for x86"}},"transport":{"timeout":45000,"status":200,"statusText":"OK","response":"<entire html login page webseal>"
I/chromium(3235): [INFO:CONSOLE(209)] "Entry: ISAMLoginFormChallengeHandler.isPasswordChangeResponse()", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (209)
I/chromium(3235): [INFO:CONSOLE(259)] "ISAMLoginFormChallengeHandler.isPasswordChangeResponse returning false - not a password change response", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (259)
I/chromium(3235): [INFO:CONSOLE(275)] "Entry: ISAMLoginFormChallengeHandler.isLoginFormResponse()", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (275)
I/chromium(3235): [INFO:CONSOLE(280)] "ISAMLoginFormChallengeHandler.isLoginFormResponse - pkmslogin.form found in response.", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (280)
I/chromium(3235): [INFO:CONSOLE(312)] "ISAMLoginFormChallengeHandler.isLoginFormResponse - Returning true.", source: file:///android_asset/www/default/js/ISAMLoginFormChallengeHandler/ISAMLoginFormChallengeHandler.js (312)

由于

在解释Idan之后如果我通过直接指向MFS构建应用程序,应用程序将获取令牌。 然后我通过指向WebSEAL再次构建并且没有问题,因为它之前已经进行了自我注册。 如果我在Android设备上删除应用程序的数据,则问题会再次出现,因为该令牌已被删除。

因此,我们可以通过说WebSEAL联接受到保护来解决问题,它需要正确的表单身份验证。

但是在这个交叉点内有两个端点,都注册了连接。

也许应该为初始授权流程制作一个特定的ISAM配置?

我提到了WebSEAL,但实际上反向代理是由IBM Security Access Manager for Web(ISAM)完成的,它也拥有WebSEAL的功能。

在request.log中出现错误

unauthenticated 07 / Sep / 2015: 17: 25: 01 +0200 "POST / worklight / authorization / v1 / clients / instance HTTP / 1.1" 200 3552

有用的日志WireShark?也许不吧。无论如何你想发送它,现在我必须生产它。

2 个答案:

答案 0 :(得分:0)

启动IBM MobileFirst Platform 7.0后,应用程序需要先执行客户端实例注册,然后才能向MobileFirst Server发送其他请求。问题中提到的Registrationconnect是其中的一部分。 WLHybridRequestSenderWLRequestSender是用于实现此目的的类。混合应用程序使用WLHybridRequestSender发送请求,WLRequestSender是负责发送注册请求的类。其余的功能是框架内部的。

根据提供的失败流的堆栈跟踪,发生的事情是WLRequestSender无法处理注册请求的响应。它取代了正确的JSON响应,而不是:

{
 document.write(warningString);
 }
else{
document.cookie = 'acceptsCookies=yes; expires=Fri, 13-Apr-1970 00:00:00 GMT';
 }

根据来自愉快流程的日志,可以看出客户端已经存在注册数据(有一个调用来获取客户端实例头,然后立即执行连接请求),以及因此,不发送注册请求。而是按预期执行连接请求。

您提到使用了WebSEAL,并且提供的信息不足以理解它失败的原因(可能是因为WebSEAL正在改变发送的请求) - 请提供以下内容:

  • WireShark从失败时开始记录
  • 完整服务器日志

答案 1 :(得分:0)

我解决了问题,这个问题就像这样:

pdadmin sec_master> acl create endpoint_auth
pdadmin sec_master> acl modify endpoint_auth set unauthenticated Tr
pdadmin sec_master> acl modify endpoint_auth set any-other Tr
pdadmin sec_master> acl attach /WebSEAL/<myObjectSpace>/worklight/authorization/v1/clients/instance endpoint_auth

现在一切正常;只有注册请求端点可供未经身份验证的用户使用 您对此解决方案有何看法? 此致