Adapter procedure call, reporting an authentication failure

旧巷老猫 提交于 2019-12-25 07:23:54

问题


Client code attempts to invoke adapter. This triggers authentication to the appropriate realm. It is possible that the user does not have suitable credentials and eventually wants to stop trying. I can provide a "Give Up" button, and we can use the challegeHandler to tell Worklight to stop the authentication effort like this:

this.challengeHandler.submitFailure();

This works to the extent that the login attempt terminates, but it seems that code calling the adapter gets no callback and hence any Deferred objects that might be waiting for resolution are left in limbo.

The question is whether we can arrange to get the authentication failure back to the caller of the adapter procedure?


回答1:


I have been informed of a workaround to this issue whereby you call:

challengeHandler.activeRequest.onUnresponsiveHost() 

Before actually calling:

challengeHandler.submitFailure()

This will trigger the failure and reject the deferred as intended.

This is a workaround though so it might not work in future versions. I am going to raise a request for enhancement (link pending) and I would appreciate it if you could vote it up as well to ensure this functionality is available in the future.




回答2:


First of all, submitFailure() will not call adapter. It will notify client side framework that authentication has failed completely so the framework will dispose of any stored requests that are waiting for authentication to finish.

If you want to wipe user identity on a server side you have two options

  1. create an adapter procedure which doesn't require authentication and call WL.Server.setActiveUser("realm-name",null). This will terminate any userIdentity.
  2. call WL.Client.logout("realm-name") in your app


来源:https://stackoverflow.com/questions/16717325/adapter-procedure-call-reporting-an-authentication-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!