适用于移动设备上的Java的ADAL:不允许出现提示 [英] ADAL For Java on Mobile Devices: Prompt is Not Allowed

查看:168
本文介绍了适用于移动设备上的Java的ADAL:不允许出现提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ADAL4J的Java程序,该程序在非移动设备上很好用,但是当通过Oracle MAF(部署为Cordova,HTML5,CSS)部署到任何移动设备上时,它在AuthenticationContext方法上失败。

I've a Java program using ADAL4J that works great on a non-mobile device but when deployed to any mobile devices via Oracle MAF (which deploys as Cordova, HTML5, CSS), it fails on the AuthenticationContext method.

错误是:

 com.microsoft.aad.adal.AuthenticationException: Prompt is not allowed and failed to get token:

这是主要代码:

service = Executors.newFixedThreadPool(1);
String url = AUTHORIZATION_ENDPOINT + tenantId + "/oauth2/authorize";
//Next line is where it fails
authContext = new AuthenticationContext(url, false, service);
Future<AuthenticationResult> future =
         authContext.acquireToken(ARM_ENDPOINT, clientId, username, credential, null);
result = future.get();
System.out.println("Access Token - " + result.getAccessToken());
System.out.println("ID Token - " + result.getIdToken());

根据我所做的研究,看来我可能需要改用AcquireTokenSilent方法。此方法在Java的ADAL库中不存在(使用ADAL4J 1.1.3,本文中最新)。我确实看到有一个 ADAL for Cordova 库,其中包含此方法可能有效。但是使用NodeJS,如果可能的话,我更愿意使用Java解决方案。

Based on the research I've done it appears I may need to use the AcquireTokenSilent method instead, however this method does not exist in the ADAL for Java library (using ADAL4J 1.1.3, most recent as of this post). I did see that there is an ADAL for Cordova library that contains this method that may work. However that uses NodeJS and I'd prefer to stick with a Java solution if possible.

我们将非常感谢您的协助。谢谢。

Would appreciate any assistance. Thanks.

编辑:我认为主要问题是ADAL4J库不支持AuthenticationContext.tokenCache属性,也不包括对 PromptBehavior 选项。

I think the main issue if that the ADAL4J library does not support the AuthenticationContext.tokenCache property nor does it include support for the PromptBehavior option that is there in the device specific ADAL implementations.

如果为true,我将不得不尝试科尔多瓦的ADAL或每个设备的ADAL SDK。

If true, guess I'll either have to try the ADAL for Cordova or each device ADAL SDK.

推荐答案

根据您的描述,根据我的理解,我认为您想使用Java中的Oracle MAF创建跨iOS,Android / etc等移动应用程序的跨平台应用。

According to your description, based on my understanding, I think you want to create a mobile application cross platform like iOS/Android/etc using Oracle MAF in Java.

因此,根据我的经验,适合您Java需求的解决方案是使用OAuth2 REST API在Azure AD上通过Java HTTP客户端进行身份验证,请参考官方教程 OAuth 2.0授权代码流

So per my experience, the solution which be suitable for your needs in Java is using OAuth2 REST APIs for authentication via Java HTTP client on Azure AD, please refer to the offical tutorial OAuth 2.0 Authorization Code Flow.

如果仅用于Android,则可以直接使用 ADAL for Android 可以做到这一点。否则,似乎没有任何现有的库可以直接在Java的多平台内直接支持身份验证。希望对您有所帮助。

If just for Android, you can directly use ADAL for Android to do that. Otherwise, it seems that there is not any existing library to directly support for authentication within multi-platform in Java. Hope it helps.

这篇关于适用于移动设备上的Java的ADAL:不允许出现提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆