Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
app Add logout when back per @jcesarmobile proposal Nov 10, 2016
gradle/wrapper Update Android Gradle Tools version Nov 7, 2016
.gitignore Adding AuthExamples Jan 5, 2015
README.md Update gradle instruction Nov 10, 2016
build.gradle Update Android Gradle Tools version Nov 7, 2016
gradlew
gradlew.bat Adding AuthExamples Jan 5, 2015
settings.gradle Adding AuthExamples Jan 5, 2015

README.md

Mobile app showing the AeroGear Auth feature on Android

Author: Summers Pittman (secondsun)
Level: Beginner
Technologies: Java, Android
Summary: A basic example of HTTP Authentication
Source: https://github.com/aerogear/aerogear-android-cookbook/tree/master/AuthExamples

What is it?

Auth project demonstrates how to integrate HTTP Basic or HTTP Digest authentication into applications.

This simple project consists of a simple authenticated REST GET call.

This application is run on an Android device or emulator. It also requires the Authentication Server be running.

How do I run it?

System Requirements

Configure

Edit org.jboss.aerogear.android.cookbook.authexamples.Constants#URL_BASE to be the path of the application.

This application has an backend implementation in our Backend Cookbook and also an only version

In the case of a emulator and server are running on the same machine the URL will be http://10.0.2.2:8080/authentication/rest.

Build Application

$ cd /path/to/authExamples/
$ ./gradlew clean build

Running the app

To deploy, run and debug the application on an Android device attached to your system, on the command line enter the following:

$ cd /path/to/authExamples
$ ./gradlew installDebug

How does it work?

HowToUseHttpBasicAuthentication and HowToUseDigestAuthentication are two activities which create appropriate AuthenticationModules and associate them with Pipe objects. The UI provides buttons to log in, log out, and fetch data from the Authentication Server.

// Create a Authentication Module
HttpBasicAuthenticationConfiguration authenticationConfig = null;
try {
    authenticationConfig = AuthenticationManager
        .config("login", HttpBasicAuthenticationConfiguration.class)
        .baseURL(new URL(Constants.URL_BASE));
} catch (MalformedURLException e) {
    e.printStackTrace();
}

AuthenticationModule module = authenticationConfig.asModule();

// Create the pipe
RestfulPipeConfiguration pipeConfig = PipeManager
    .config("beer", RestfulPipeConfiguration.class)
    .module(authModule)
    .withUrl(new URL(Constants.URL_BASE + "/grocery/beers"));

Pipe<String> pipe = pipeConfig.forClass(String.class);

//use the pipe as normal
pipe.read(new YourCallback());

Notes

There are two regressions problems to be fixed:

  • AGDROID-349 - HttpDigest Module needs to be able to disable making a server call on logout
  • AGDROID-350 - HTTPBasic and HTTPDigest callbacks aren't triggered on the UI thread