Authorization failure calling MobileFirst Adapter - ibm-mobilefirst

Not sure whether the same issue has been raised before (I tried to comment but was unable to do so - see link below)
Anyway, I've just upgraded my development environment to MobileFirst Studio 7.1 and I'm having an issue with the adapters we created in 7.0. The adapters deploy without error but when I try to call WL.Client.invokeProcedure from my browser (I'm just testing as a web app at the moment) I get an error 500 in the browser console.
I've tested the adapters using the "Run As ... > Call MobileFirst Adapter" menu option, and they work so this is only related to accessing the adapters from a client. The exception output in the MobileFirst Development Server console is:
[ERROR ] FWLSE0335E: Authorization failed: ClientId WbWBHC11bK was not found on the server. [project BusinessEnergy]
[ERROR ] FWLSE0048E: Unhandled exception caught: null
com.worklight.authorization.endpoint.OauthAuthorizationException
at com.worklight.core.auth.impl.AuthorizationFilterUtils.isAuthorizedClient(AuthorizationFilterUtils.java:63)
at com.worklight.core.auth.impl.AuthorizationFilterUtils.isSessionIndependentSupportedClient(AuthorizationFilterUtils.java:49)
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:197)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)
at com.worklight.analytics.AnalyticsFilter.doFilter(AnalyticsFilter.java:124)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:206)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:86)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:978)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1100)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4845)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:297)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:981)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[project BusinessEnergy]
com.worklight.authorization.endpoint.OauthAuthorizationException
I wondered whether something basic has changed with authentication in v7.1 but a colleague who created the new v7.1 project is running without this issue.
same question in a separate thread?

Found a resolution to my issue which was basically to clear the cookie cache in my browser. I don't have a requirement at the moment to view multiple apps in the same browser so I may not hit the other issue you mentioned Idan (thanks for your quick response though)

This is possibly the same issue as reported in the following APAR: PI48842 Previewing multiple applications in the same browser causing client authentication issues.
The APAR description is not similar to yours, but the error and exception in the stack trace are exactly the same.
[ERROR ] FWLSE0335E: Authorization failed: ClientId xjoWZVkUrR was
not found on the server. [project test]
[ERROR ] FWLSE0048E: Unhandled exception caught: null
com.worklight.authorization.endpoint.OauthAuthorizationException
If you are an IBM customer you can open a PMR (support ticket) and request a fix for this issue once it is available.

Related

Mobilefirst can not store userid into worklight database

We are using adapter-based authenticators. WL.Server.setActiveUser was called on the adapter.
I user WL.Logger.info to print out the parameters which I send to setActiveUser. They are correct.
In WL console, DeviceId got updated ,but we can not saw the userid in the device table.
enter image description here
we are using MFP 7.1 version.
We got below error in the log file. not sure it is related to the issue.
[9/5/16 23:09:48:567 EDT] 000000f4 GadgetAPIServ E com.worklight.gadgets.serving.GadgetAPIServlet createAjaxRequestExceptionJSON FWLSE0020E: Ajax request exception: Optimistic locking errors were detected when flushing to the data store. The following objects may have been concurrently modified in another transaction: [com.ibm.pushworks.server.entities.PushSubscription-com.ibm.pushworks.server.entities.PushSubscription-2] [project ]
[9/5/16 23:09:48:579 EDT] 000000f4 GadgetAPIServ E createAjaxRequestExceptionJSON FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request [project ]Optimistic locking errors were detected when flushing to the data store. The following objects may have been concurrently modified in another transaction: [com.ibm.pushworks.server.entities.PushSubscription-com.ibm.pushworks.server.entities.PushSubscription-2], User Identity {wl_directUpdateRealm=(name:null, loginModule:WLDirectUpdateNullLoginModule), SubscribeServlet=null, wl_authenticityRealm=null, ServicesRealm=(name:xxx#cn.ibm.com, loginModule:StrongDummy), wl_remoteDisableRealm=(name:null, loginModule:WLRemoteDisableNullLoginModule), SampleAppRealm=(name:xxx#cn.ibm.com, loginModule:StrongDummy), wl_antiXSRFRealm=(name:qmd8e821mcil59j4tedagchnvi, loginModule:WLAntiXSRFLoginModule), wl_deviceAutoProvisioningRealm=null, wl_deviceNoProvisioningRealm=(name:D07571B0-2685-4F6F-9C42-37B616F52190, loginModule:WLDeviceNoProvisioningLoginModule), myserver=(name:ea57e780-ce09-4bbd-aee5-5a1701388b72, loginModule:WeakDummy), wl_anonymousUserRealm=(name:ea57e780-ce09-4bbd-aee5-5a1701388b72, loginModule:WeakDummy)}. [project ]
It seems the security test defined in Authentication config file is not mentioned in Application Descriptor file . Please cross check security test in AuthenticatonConfig.xml and applicationDescription.xml
please follow below link.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/6.3/authentication-security/adapter-based-authentication/

Getting VersionConflictEngineException in IBM Mobile First 6.3

I'm receiving the following message on server log in IBM Mobile First 6.3 every time an Adapter is getting called:
Stacktrace
[ERROR ] Error sending bulk request: java.lang.RuntimeException:
failure in bulk execution: [2]: index [worklight], type [devices], id
[b2deefe7-0d15-4ed4-b199-7e42440fc372], message
[VersionConflictEngineException[[worklight][1]
[devices][b2deefe7-0d15-4ed4-b199-7e42440fc372]: version conflict,
current [58], provided [57]]] at
com.ibm.elasticsearch.servlet.DataReceiver.processData(DataReceiver.java:132)
at
com.ibm.elasticsearch.servlet.DataReceiver.processDataLegacy(DataReceiver.java:85)
at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source) ...
The adapter is executed correctly and the response is returned to the app.
Any idea why this error is happening?
Help will be appreciated.
Thanks.
This is an internal error in analytics. The error itself is actually harmless, however the analytics platform should be catching it... A defect will be logged for the message. In the meantime, if you're not using analytics, you can disable it by removing the WAR files from the Liberty server.
If you are using analytics, then I would recommend clearing out the analytics data folder and restarting the IMF platform (this would remove any data you have stored in analytics). This is assuming that you are running in development mode. The analytics data folder can be in the same directory as the server.xml file for your Liberty server.

IBM Worklight: AdapterAuthRealmChallengeHandler.submitSuccess() generates invalid http header

in previously correctly working dev. environment with WL 6.1.0.01.20140311-2356 after upgrade to Chrome 37.0.2062.120 there is now the following error when calling submitSuccess during authentication.
CHROME BROWSER LOG:
Uncaught SyntaxError: Failed to execute 'setRequestHeader' on
'XMLHttpRequest':
'{"wl_deviceNoProvisioningRealm":{"ID":{"token":"pg8cd4gnjh1kb0sjko6h1chqr4","app":{"id":"Moje
ČZU","version":"1.0"},"device":{"id":"previewDummyId","os":"previewDummyOS","model":"previewDummyModel","environment":"preview"},"custom":{}}}}'
is not a valid HTTP header field value.
WL SERVER LOG:
SRVE0777E: Exception thrown by application class
'com.worklight.core.auth.impl.AuthenticationContext.pushCurrentResource:398'
com.worklight.server.auth.api.WorkLightAuthenticationException at
com.worklight.core.auth.impl.AuthenticationContext.pushCurrentResource(AuthenticationContext.java:398)
at
com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:75)
at
com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedureInternal(DataAccessServiceImpl.java:389)
at
com.worklight.integration.services.impl.DataAccessServiceImpl.invokeProcedure(DataAccessServiceImpl.java:112)
at
com.worklight.gadgets.serving.handler.BackendQueryHandler.getContent(BackendQueryHandler.java:182)
at
com.worklight.gadgets.serving.handler.BackendQueryHandler.doPost(BackendQueryHandler.java:73)
at
com.worklight.gadgets.serving.GadgetAPIServlet.doGetOrPost(GadgetAPIServlet.java:141)
at
com.worklight.gadgets.serving.GadgetAPIServlet.doPost(GadgetAPIServlet.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at
com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240)
at [internal classes] at
com.worklight.core.auth.impl.AuthenticationFilter$1.execute(AuthenticationFilter.java:191)
at
com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
at
com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:195)
at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194)
at [internal classes]
not sure if "Moje ĆZU" latin2 character here not causing the issue?
Previous steps in authentication process looks working fine.
Firefox and Opera are also stuck but with different behavior.
However, when the app is deployed to Android device App still works fine.
This looks like an encoding issue.
When generating an application for the first time, the application id value in application-descriptor.xml is generated from the chosen app name; you can then alter it to anything else you'd like.
Note, though, that when adding a mobile environment the same value is used there as well, so if you are altering the value after already creating a mobile environment (which will have the "native" folder), you need to remove that native folder to have all artifacts re-generated correctly. Or, do a find all/replace and verify everything is working.
Worklight will not auto-replace this value after changing it in application-descriptor.xml.

Worklight LDAP Error

When trying the LDAP sample project provided by Worklight, I get the following error:
[ERROR ] FWLSE0020E: Ajax request exception: Adapter 'DummyAdapter'
does not exist [project module_23_2_LDAPLoginModule] [ERROR ]
FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error
message: FWLSE0069E: An internal error occurred during gadget request
[project module_23_2_LDAPLoginModule]Adapter 'DummyAdapter' does not
exist, User Identity {SubscribeServlet=null, LDAPRealm=null,
wl_authenticityRealm=null, wl_remoteDisableRealm=null,
wl_antiXSRFRealm=(name:rtm5uf72muh56gak3ms4gvvt42,
loginModule:WLAntiXSRFLoginModule),
wl_deviceAutoProvisioningRealm=null,
wl_deviceNoProvisioningRealm=null,
myserver=(name:776c1909-3ae4-45b5-a029-f0372b507a7d,
loginModule:WeakDummy),
wl_anonymousUserRealm=(name:776c1909-3ae4-45b5-a029-f0372b507a7d,
loginModule:WeakDummy)}. [project module_23_2_LDAPLoginModule]
com.worklight.common.log.filters.ErrorFilter
In order to make it work, what values do I need to change. I want to use my IBM LDAP server.
Thanks..Johnson
At least by reading the error message, it is pretty clear.
Did you make sure to also deploy the adapter and not just the application?
In your Worklight project, find the adapters folder. Open it. Then, right-click on the adapter folder within and select Run As > Deploy Worklight adapter.
Try the application again and see if it works, or if there are other errors displayed.
I suggest that instead of jumping right into what you want to do in your app, first learn the basics. Review the IBM Worklight Getting Started training modules, from the top.

IBM Worklight 6.1.0.1 - "file not found service/random" for Mobile Web environment

I have implement Encrypted Cache in my application. When testing is in the Mobile Web environment using the mobile browser in my device, I get the following exception:
[ERROR ] FWLSE0048E: Unhandled exception caught: SRVE0190E: File not
found: /apps/services/BMA_app/apps/services/random
java.io.FileNotFoundException: SRVE0190E: File not found:
/apps/services/BMA_app/apps/services/random at
com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:496)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:127)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:88)
at
com.worklight.core.auth.impl.AuthenticationFilter$1.execute(AuthenticationFilter.java:191)
at
com.worklight.core.auth.impl.AuthenticationServiceBean.accessResource(AuthenticationServiceBean.java:76)
at
com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:195)
at
com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194)
at
com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:85)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:949)
at
com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1029)
at
com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4499)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:282)
at
com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:954)
at
com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:252)
at
com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:584)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:421) at
java.lang.Thread.run(Thread.java:701) [project BMA_app] SRVE0190E:
File not found: /apps/services/BMA_app/apps/services/random
When testing in other environments, the error does not occur.
EDIT: I just saw that, this service allows to get a key for encrypted cache. It allows to open it. Given that, the service is 404, I got a failure for opening cache.
Moreover, the Worklight Console gives me this URL for mobile web app:
http:/my-server:port/BMA_app/apps/services/www/BMA_app/mobilewebapp/
the app tries to get a key for encrypted cache and send to http:/my-server:port/BMA_app/apps/services/BMA_app/apps/services/random
^ 404 error
If we cut this previous url to http://my-server:port/BMA_app/apps/services/random, it works.
It seems that in the URL "BMA_app/apps/services" is repeated twice instead of once.
Why and how to resolve it ?
Looks like you may have encountered a defect.
Testing in 6.1.0.1 with the Encrypted Cache sample project and adding to it the Mobile Web environment, if you use the link provided by the "Get App URL" button - then when you try to "open cache" from the app, it will fail with status code 10. This status code means that the app was unable to connect to the Worklight Server's Random generator service.
Indeed, when inspecting the console log, the app tries to connect to the following URL, where "EncryptedCache/apps/services" is repeated twice...:
http://192.168.1.101:10080/EncryptedCache/apps/services/EncryptedCache/apps/services/random?isAjaxRequest=true&x=0.18816258828155696
There is no workaround for this defect as it is the framework that generates the URL.
I have opened a defect.
If you are an IBM customer or business partner and require a fix, you can open a PMR and mention this Stackoverflow question.
Moving forward, the fix will be available in an iFix and any future fixpack released.