GithubHelp home page GithubHelp logo

azuread / azure-activedirectory-library-for-android Goto Github PK

View Code? Open in Web Editor NEW
178.0 178.0 107.0 16.58 MB

The ADAL SDK for Android gives you the ability to add support for Work Accounts to your application with just a few lines of additional code. This SDK gives your application the full functionality of Microsoft Azure AD, including industry standard protocol support for OAuth2, Web API integration with user level consent, and two factor authentication support.

Home Page: http://www.windowsazure.com/en-us/services/active-directory/

License: MIT License

PowerShell 0.17% Shell 0.31% Java 99.52%

azure-activedirectory-library-for-android's People

Contributors

adambjohnsonx avatar aherciya avatar amishra-dev avatar brandwe avatar danieldobalian avatar fadidurah avatar heidijinxujia avatar hsar avatar iambmelt avatar iamgusain avatar jaredsburrows avatar kreedula avatar melissaahn avatar mohitc1 avatar msft-cofitz avatar nazukj avatar omercs avatar p3dr0rv avatar paivybhav avatar paulkagiri avatar piqiums avatar randallilama avatar rpdome avatar sangonzal avatar shahzaibj avatar shoatman avatar talk2arpit avatar tanmaymanolkar1 avatar wainaina avatar weijjia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-activedirectory-library-for-android's Issues

samples- testapp needs to be updated

Users are trying testapp as an initial sample. It was used for instrumentation app for testing. Update that so that it does not launch activity if user did not enter anything.

Azure Jenkins build for SDK 19 not launching emulator

Commencing build of Revision ed41726 (origin/master)
Checking out Revision ed41726 (origin/master)
[android] Using Android SDK: C:\android-sdk
[android] Setting hardware properties:
hw.keyboard: yes
hw.touchScreen: yes
hw.dPad: yes
[android] Waiting 60 seconds before starting emulator...
$ C:\android-sdk/platform-tools/adb.exe start-server
[android] Starting Android emulator
$ C:\android-sdk/tools/emulator.exe -no-boot-anim -ports 59511,59512 -prop persist.sys.language=en -prop persist.sys.country=US -avd hudson_en-US_320_768x1280_android-19_x86 -no-snapshot-load -no-snapshot-save

  • daemon not running. starting it now on port 59513 *
  • daemon started successfully *
    WARNING: Data partition already in use. Changes will not persist!
    ko:Snapshot storage already in use: d:\workspace\ADAL-Android.android\avd\hudson_en-US_320_768x1280_android-19_x86.avd/snapshots.img
    [android] Emulator did not appear to start; giving up
    $ C:\android-sdk/platform-tools/adb.exe disconnect localhost:59512
    [android] Stopping Android emulator
    $ C:\android-sdk/platform-tools/adb.exe kill-server
    Recording test results
    No test report files were found. Configuration error?
    Emma: looking for coverage reports in the provided path: tests/Functional/coverage/coverage.xml
    Finished: NOT_BUILT

ADAL is crashing when ADAL.Jar is used in Application

When ADAL.Jar filed is used as external jar file in Android app than ADAL library crashes looking for class android.security.KeyPairGeneratorSpec$Builder.

Following is the stack for crash.

03-05 22:14:27.908: D/ScenarioHealthApp(875): MainActivity onCreate(), creating AuthenticationContext
03-05 22:14:29.247: V/DefaultTokenCacheStore(875): : Started to initialize storage helper. null
**************>>>>>>>>>>
03-05 22:14:29.318: E/dalvikvm(875): Could not find class 'android.security.KeyPairGeneratorSpec$Builder', referenced from method com.microsoft.adal.StorageHelper.getKeyPairFromAndroidKeyStore
03-05 22:14:29.327: W/dalvikvm(875): VFY: unable to resolve new-instance 101 (Landroid/security/KeyPairGeneratorSpec$Builder;) in Lcom/microsoft/adal/StorageHelper;
03-05 22:14:29.327: D/dalvikvm(875): VFY: replacing opcode 0x22 at 0x003f
03-05 22:14:29.357: D/dalvikvm(875): DexOpt: unable to opt direct call 0x01bf at 0x43 in Lcom/microsoft/adal/StorageHelper;.getKeyPairFromAndroidKeyStore
03-05 22:14:29.378: V/DefaultTokenCacheStore(875): : Finished to initialize storage helper. null
03-05 22:14:29.407: V/AuthenticationContext(875): : CorrelationId generated f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.427: V/AuthenticationContext(875): : Token request started CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.447: V/AuthenticationContext(875): : Checking refresh tokens CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.457: V/AuthenticationContext(875): : Looking for regular refresh token CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.477: V/AuthenticationContext(875): : Looking for Multi Resource Refresh token CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.507: V/AuthenticationContext(875): : Refresh token is not available CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.507: V/AuthenticationContext(875): : Starting Authentication Activity with callback:1087267864 CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.518: V/AuthenticationContext(875): : Put waiting request: 1087267864 CorrelationId: f6362f9d-d783-40bf-91f9-7e0c89352a54. null
03-05 22:14:29.767: D/ScenarioHealthApp(875): MainActivity onStart(), ScenarioCount : 0
03-05 22:14:29.777: D/ScenarioHealthApp(875): MainActivity onResume(), ScenarioCount : 0
03-05 22:14:29.837: W/dalvikvm(875): VFY: unable to resolve static field 2294 (title_confirmation_activity_authentication) in Lcom/microsoft/adal/R$string;
03-05 22:14:29.837: D/dalvikvm(875): VFY: replacing opcode 0x60 at 0x0005
03-05 22:14:29.860: W/dalvikvm(875): VFY: unable to resolve static field 2290 (activity_authentication) in Lcom/microsoft/adal/R$layout;
03-05 22:14:29.875: D/dalvikvm(875): VFY: replacing opcode 0x60 at 0x0007
03-05 22:14:29.877: W/dalvikvm(875): VFY: unable to resolve static field 2291 (login) in Lcom/microsoft/adal/R$menu;
03-05 22:14:29.877: D/dalvikvm(875): VFY: replacing opcode 0x60 at 0x0004
03-05 22:14:29.907: D/AndroidRuntime(875): Shutting down VM
03-05 22:14:29.907: W/dalvikvm(875): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
03-05 22:14:29.967: E/AndroidRuntime(875): FATAL EXCEPTION: main
03-05 22:14:29.967: E/AndroidRuntime(875): java.lang.NoClassDefFoundError: com.microsoft.adal.R$layout
03-05 22:14:29.967: E/AndroidRuntime(875): at com.microsoft.adal.AuthenticationActivity.onCreate(AuthenticationActivity.java:102)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.Activity.performCreate(Activity.java:5104)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.ActivityThread.access$600(ActivityThread.java:141)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.os.Looper.loop(Looper.java:137)
03-05 22:14:29.967: E/AndroidRuntime(875): at android.app.ActivityThread.main(ActivityThread.java:5041)
03-05 22:14:29.967: E/AndroidRuntime(875): at java.lang.reflect.Method.invokeNative(Native Method)
03-05 22:14:29.967: E/AndroidRuntime(875): at java.lang.reflect.Method.invoke(Method.java:511)
03-05 22:14:29.967: E/AndroidRuntime(875): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-05 22:14:29.967: E/AndroidRuntime(875): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-05 22:14:29.967: E/AndroidRuntime(875): at dalvik.system.NativeStart.main(Native Method)

Handling of server error in ADAL lib

01-22 18:05:18.115: D/HttpWebRequest(1058): Setting header: x-client-DM
01-22 18:05:18.255: D/HttpWebRequest(1058): Setting header: x-client-SKU
01-22 18:05:18.255: D/HttpWebRequest(1058): Setting header: Accept
01-22 18:05:18.285: D/HttpWebRequest(1058): Setting header: Host
01-22 18:05:18.285: D/HttpWebRequest(1058): Setting header: x-client-Ver
01-22 18:05:18.475: I/Choreographer(1058): Skipped 93 frames! The application may be doing too much work on its main thread.
01-22 18:05:18.925: I/Choreographer(1058): Skipped 37 frames! The application may be doing too much work on its main thread.
01-22 18:05:19.325: D/AuthenticationActivity(1058): AuthenticationActivity onStop
01-22 18:05:19.385: D/HttpWebRequest(1058): Exception:null
01-22 18:05:19.395: D/HttpWebRequest(1058): HttpWebRequest OnPostExecute thread:1058
01-22 18:05:19.445: E/Oauth(1058): SERVER_ERROR: null.
01-22 18:05:19.445: E/Oauth(1058): java.io.EOFException
01-22 18:05:19.445: E/Oauth(1058): at libcore.io.Streams.readAsciiLine(Streams.java:203)
01-22 18:05:19.445: E/Oauth(1058): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:573)
01-22 18:05:19.445: E/Oauth(1058): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:821)
01-22 18:05:19.445: E/Oauth(1058): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283)
01-22 18:05:19.445: E/Oauth(1058): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:495)
01-22 18:05:19.445: E/Oauth(1058): at libcore.net.http.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:134)
01-22 18:05:19.445: E/Oauth(1058): at com.microsoft.adal.HttpWebRequest.doInBackground(HttpWebRequest.java:169)
01-22 18:05:19.445: E/Oauth(1058): at com.microsoft.adal.HttpWebRequest.doInBackground(HttpWebRequest.java:1)
01-22 18:05:19.445: E/Oauth(1058): at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-22 18:05:19.445: E/Oauth(1058): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
01-22 18:05:19.445: E/Oauth(1058): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
01-22 18:05:19.445: E/Oauth(1058): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
01-22 18:05:19.445: E/Oauth(1058): at java.lang.Thread.run(Thread.java:856)

Webview is empty for login screen in sample app 'ADAL.testapp" as well as Office 365 sdk's 'Office365Demo'

Nexus 7 - running Android 4.4.2 (Build# KOT49H).
On loading (based on logs), the webview in AuthenticationActivity (from ADAL) redirects to login.microsoftonline.com

WebView fails on this page with
[INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
03-07 23:27:11.078: E/qdutils(32175): FBIOGET_FSCREENINFO failed

The error messages seem similar to the issue described here - https://code.google.com/p/chromium/issues/detail?id=315111

Error log -

03-07 23:27:10.838: V/AuthenticationActivity(32175): : Page finished:about:blank. null
03-07 23:27:10.848: V/AuthenticationActivity(32175): : Page started:https://login.windows.net/5f41a0a1-b8fe-4c14-a161-fe0ef5ff363b/oauth2/authorize?response_type=code&client_id=31e60246-b658-4b72-9ff1-35079c731272&resource=https%3A%2F%2Foutlook.office365.com%2F&redirect_uri=http%3A%2F%2Fbushel.in&state=YT1odHRwczovL2xvZ2luLndpbmRvd3MubmV0LzVmNDFhMGExLWI4ZmUtNGMxNC1hMTYxLWZlMGVmNWZmMzYzYiZyPWh0dHBzOi8vb3V0bG9vay5vZmZpY2UzNjUuY29tLw&login_hint=admin%40clientdevel.onmicrosoft.com&x-client-SKU=Android&x-client-Ver=0.5&x-client-OS=19&x-client-DM=Nexus+7. null
03-07 23:27:11.038: I/chromium(32175): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
03-07 23:27:11.068: I/chromium(32175): [INFO:async_pixel_transfer_manager_android.cc(56)] Async pixel transfers not supported
03-07 23:27:11.078: E/qdutils(32175): FBIOGET_FSCREENINFO failed
03-07 23:27:13.791: V/AuthenticationActivity(32175): : Page started:https://login.microsoftonline.com/login.srf?wa=wsignin1.0&wtrealm=https%3a%2f%2flogin.windows.net%2f&wreply=https%3a%2f%2flogin.windows.net%2f5f41a0a1-b8fe-4c14-a161-fe0ef5ff363b%2fwsfederation&wctx=3wEBD09BdXRoMkF1dGhvcml6ZQEPT0F1dGgyQXV0aG9yaXplASQ1ZjQxYTBhMS1iOGZlLTRjMTQtYTE2MS1mZTBlZjVmZjM2M2IBAQEPb2F1dGgyLmF1dGhjb2RlAAEeaHR0cHM6Ly9vdXRsb29rLm9mZmljZTM2NS5jb20vAQEkMzFlNjAyNDYtYjY1OC00YjcyLTlmZjEtMzUwNzljNzMxMjcyARBodHRwOi8vYnVzaGVsLmluAAEBARFjbGllbnRyZWRpcmVjdHVyaQEQaHR0cDovL2J1c2hlbC5pbgEFAQN1dGIBBUZhbHNlAQVzdGF0ZQGCAVlUMW9kSFJ3Y3pvdkwyeHZaMmx1TG5kcGJtUnZkM011Ym1WMEx6Vm1OREZoTUdFeExXSTRabVV0TkdNeE5DMWhNVFl4TFdabE1HVm1OV1ptTXpZellpWnlQV2gwZEhCek9pOHZiM1YwYkc5dmF5NXZabVpwWTJVek5qVXVZMjl0THcBC2ludGVyYWN0aXZlAQRUcnVlAQlMb2dpbkhpbnQBIWFkbWluQGNsaWVudGRldmVsLm9ubWljcm9zb2Z0LmNvbQEPRm9yY2VGcmVzaExvZ2luAQVGYWxzZe01&wp=MBI_FED_SSL&username=admin%40clientdevel.onmicrosoft.com. null

Question about refresh token

When I am using refresh token to update expired access token, the new refresh token value I am getting is null. So when new access token is getting expired authentication activity opens and authentication flow starts again. Is this behavior expected or there is bug in a library/server?

Android 4.4 compatibility

Library is not working on devices with Android version 4.4. Tested on emulator with Android 4.4 and on Nexus 4 device.

Test runs on devices for different SDK levels

Real device test runs.
API Device
15 Nexus 4
16 Nexus 4
17 Nexus 4
18 Nexus 4 / Nexus 7 / Nexus 10
18 Samsung S4 with KNOX
19 Samsung

Setup emulator to test agains API 15 - 19(Latest) for daily builds.

AADAL pure Java port

Would be great if we can have Azure authentication functionality for pure Java without dependency on Android.

Maven: expose ADAL as Maven artifact

Using Maven is quite common for Java development. Gradle - Android new build system - is in turn extensively using Maven repositories and artifacts. Official Android IDE (IntelliJ IDEA based) is using Gradle by default.

It would come very handy if ADAL library can be used not only as a project dependency but also as a Maven/Gradle dependency. Providing *.aar deliverable would make ADAL one step closer to developer, expose SDK in a simple well known “*.jar as a dependency” format and fit into Android ecosystem.

Caching in API < 18

Looks like token caching in API < 18 does not work. Here is storage helper loadSecretKeyForAPI method:

if (Build.VERSION.SDK_INT >= 18) {
    try {
        // androidKeyStore can store app specific self signed cert.
        // Asymmetric cryptography is used to protect the session
        // key
        // used for Encryption and HMac
        sKey = getSecretKeyFromAndroidKeyStore();
        sMacKey = getMacKey(sKey);
        sBlobVersion = VERSION_ANDROID_KEY_STORE;
        return;
    } catch (Exception e) {
        Logger.e(TAG, "Failed to get private key from AndroidKeyStore", "",
        ADALError.ANDROIDKEYSTORE_FAILED, e);
    }
}

sKey = getSecretKey(AuthenticationSettings.INSTANCE.getSecretKeyData());
sMacKey = getMacKey(sKey);
sBlobVersion = VERSION_USER_DEFINED;

As we can see, in API < 18 sKey obtained using AuthenticationSettings.INSTANCE.getSecretKeyData(). In current implementation it has null value by default, so getSecretKey() throws an exception and encrypt() method (that calls this code) returns null. Returned value is then checked and put in the cache (preferences storage) only if it has non-null value. Therefore items caching seems to be non-working in API < 18 (I am using emulator with API 17). And my question is: what should I do to make caching work?

Remove Clock skew

ADAL.NET does not have clock skew. After discussing with the team, we decided to remove the clock skew.

Maven Central Release

It would be very convenient to have ADAL artifact on Maven Central. This way Maven applications will be able to simply reference it as dependency.

Now the options are:

  • Set up maven configuration to automatically download source code, build it and deploy it to local repository. This brings unwanted complexity to configuration and a new module to the application that could have had a single pom.
  • Make developer do it all manually.

Thanks

coverage report issue

coverage plugin needs coverege.ec file to generate json post for coveralls. It is missing or not working.
remote object '/data/data/com.microsoft.adal.test/files/coverage.ec' does not exist

License headers scrub

Many files do not have a license header, and the ones that do do not appear to be correct.

When including ADAL.Jar file in project there is no documentation

When com.microsoft.adal.jar file is included in project as external lib, there is no documentation available in eclipse studio which developer can use it for his programming.

This is must have thing for developer for best experience.

Also add steps in readme file how to set source folder in eclipse for debugging purpose.

Authorization URL format

What should be the format for authority URL?
For example https://login.windows.net``/common/oauth2/token
I've took some time to look into AADAL and not sure if I have a clear picture of how the second part of the URL is being handled. I've found it in 2 places:

private String getAuthorizationCommonEndpoint(final URL authorizationEndpointUrl) throws MalformedURLException {
    return String.format("https://%s%s", authorizationEndpointUrl.getHost(), AUTHORIZATION_COMMON_ENDPOINT);
}

So it looks like we could even omit /common/ postfix and everything after it from authority URL since the only part used is the host.

private final static String DEFAULT_AUTHORIZE_ENDPOINT = "/oauth2/authorize";
private final static String DEFAULT_TOKEN_ENDPOINT = "/oauth2/token";

As it comes from the names they are used for different purposes.

Q: So what is the format one should follow for authority URL to ensure maximum stability i.e. to guarantee that it'll be valid?

Thanks

Provide Developer a guidance or sample for refreshing token in Andorid App

There should be a some doc or sample code or clear guidance for application developer how authentication context works and how it can be used to refresh token.

Currently there is no sample which shows how to use authentication context to find where previously acquired token is expired before sending to the resource. If token is expired then show the developer a way how to refresh access token. Show some example code.

Currently my application is acquiring a token in main activity (as there needs to be callback function needed by ADAL lib in activity) and later it starts new activity A2, which uses acquired token. Now app is active overnight on A2 page and token has expired. so in morning user gets an error when trying to use same token. Show some sample code how developer can refresh token on activity A2.

Above scenario is going to be very common for all the developers.

Hotfix to master (#82)

Could you please merge issue #82 to master as a hotfix. Currently it's state is invalid since aar is generated w/o java classes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.