        OAuth 2.0 Resource Server Example


This sample demonstrates how to use OAuth 2.0 for Resource Servers.

This is implemented as a Jersey Restful application.  This uses
google-oauth-java-client to validate OAuth2.0 tokens.

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

* Java 1.8
* Restful development with Jersey
* 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


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

You can then compile and run sample-authz-flow sample given in the sdk.
That application will consume this rest service.

If you want to test with curl, try the following commands

# to get list of tasks
export access_token=<token_received>
curl --ciphers AES128-SHA256  -v -k -H "Authorization: Bearer $access_token" https://localhost:10443/rest/todos

# to add a new task
curl --ciphers AES128-SHA256  -v -k -H "Authorization: Bearer $access_token" -X POST -d "[{\"id\": \"test2\", \"description\":\"test my script\"}]" -H 'Content-Type:application/json' https://localhost:10443/rest/todos