        OAuth 2.0 Authorization Code Flow - Client Example


This sample demonstrates how to use OAuth 2.0 Authorization Code flow
to communicate with Idenity Provider (Authorization Server).

This is implemented as a web application.  This uses
google-oauth-java-client to invoke OAuth2.0 requests.


Pre-Requisites
==============
This sample assumes the expertise with the following technologies

* Java 1.8
* Maven for building and dependency management

Compile
=======
Maven has to be installed to compile and run the example.  Download
maven from http://maven.apache.org/download.cgi and invoke the
following steps

set the JAVA_HOME to Java SDK version 1.8 path

1. edit the file under src/main/resources/oauth.properties. Change the
endpoints to point to an actual implementation of NetIQ Access Manager
Identity Provider.

2. runt the following command
   mvn install

This will compile the sample, package & install in local repository

Run
===

1. Edit system host file entries to point your current system with a
sample dns name.  localhost cannot be used as that will be forbidden
in Identity provider.
   On Linux, edit /etc/hosts and add the following line
      <your_non_localhost_ip_address>  authztest.com

  On Windows, edit %WINDOWS%\drivers\etc\hosts
      <your_non_localhost_ip_address>  authztest.com

   authztest.com should have been registered as "redirect_uri" in
   OAuth 2 Client configuration of Identity Provider of Access Manager.

2. issue the following command

mvn jetty:run

This will start the jetty server hosting the application.  You can
connect to the url by opening a browser and launch

https://authztest.com:20443/

Then you can click Login.  This redirect browser to OAuth 2.0
Authorization server, gets user authenticated and mints an
"Authorization Code".  This code is being passed back to this web
application. This web application exchanges the code with an "OAuth
2.0 Access Token".

This application uses the token to further consume the RESTful service of
managing a list of "task" items.

In addition to that, you can validate the token and get user's claims using
UserInfo endpoint.

