-
Notifications
You must be signed in to change notification settings - Fork 111
Exception when using ADAL cordova on a encrypted android phone #14
Comments
@fw224 Was the Company Portal app installed on the device where this repros? |
Same issue here. On iOS it is working, on android the type cast exception occurs |
+1 |
FYI @weijjia I think issue here is that if the Company Portal is installed then the Android version of ADAL uses that to get tokens. The cordova version of ADAL depends on the Android version of ADAL. When Android ADAL talks the Company Portal a different object type that the Cordova version of ADAL isn't prepared to deal with causes a crash. We've seen this issue in at least one other context as well and are working on a fix, but it may require an update to both Cordova ADAL and the Company Portal. |
@RandalliLama Sorry I just saw the issue. For the crash stack trace, I don't think it even starts to talk to company portal. It looks like the crash happens inside the readTokenCacheItems, which contains the authContext.getCache. In android version of ADAL, the getCache method will check if we can switch to broker, it seems in this particular case, the existence of Company Portal makes adal-android switch to broker, and we're retuning a new anonymous inner class implementing the interface ITokenCacheStore. When authContext.getCache returns, the cordova plugin is trying to cast it to the DefaultTokenCacheStore...oops, exception is thrown here. The returned anonymous inner class implementing the interface ITokenCacheStore cannot be casted to DefaultTokenCacheStore. |
Also seeing this issue on a WP8.1 device, but not the emulator. Packaging is Windows Universal app.
The relevant line, as @RandalliLama and @weijjia suggest, is reading the token cache: win(context.tokenCache.readItems().map(function(item) { |
Fixes #14. Perform tokenCache operations with caution.
I am developing a cordova app that uses ADAL cordova and requires a service from a corp network (MSFT corp network). ADAL cordova works using an emulator, but on a real device (which requires encryption to access the corp network) ADAL cordova is giving me an exception. The following is the exact error:
E/PluginManager(18227): Uncaught exception from plugin
E/PluginManager(18227): java.lang.ClassCastException: com.microsoft.aad.adal.AuthenticationContext$1 cannot be cast to com.microsoft.aad.adal.DefaultTokenCacheStore
E/PluginManager(18227): at com.microsoft.aad.adal.CordovaAdalPlugin.readTokenCacheItems(CordovaAdalPlugin.java:165)
E/PluginManager(18227): at com.microsoft.aad.adal.CordovaAdalPlugin.execute(CordovaAdalPlugin.java:83)
E/PluginManager(18227): at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:84)
E/PluginManager(18227): at org.apache.cordova.PluginManager.exec(PluginManager.java:147)
E/PluginManager(18227): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
E/PluginManager(18227): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
E/PluginManager(18227): at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
E/PluginManager(18227): at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
E/PluginManager(18227): at android.os.Handler.dispatchMessage(Handler.java:102)
E/PluginManager(18227): at android.os.Looper.loop(Looper.java:145)
E/PluginManager(18227): at android.os.HandlerThread.run(HandlerThread.java:61)
And the following is my code:
$scope.context = new Microsoft.ADAL.AuthenticationContext(authority);
Any help would be appreciated!
The text was updated successfully, but these errors were encountered: