WebSphere software logo IBM Logo

OAuth Sample

The OAuth samples demonstrate OAuth 2.0 client, client registration, and client revocation. The samples show the basic implementation of JavaServer Pages (JSP) to write an OAuth client, an OAuth client registering servlet, and an OAuth client revocation servlet.

Here is what you should know about this sample before proceeding.

Time required to set up and configure this sample

Approximately 15 minutes

Prerequisites for use

This sample was tested most recently with WebSphere Application Server Version 8.5.0.1.

  1. WebSphere Application Server 8.5.0.1
  2. WebSphere Application Server 8.0.0.5
  3. WebSphere Application Server 7.0.0.25

Copyright license

COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, modify, and distribute these sample programs in any form without payment to IBM for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample code is written. Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS TO THE SAMPLE SOURCE CODE.

About this task

Key phrases associated with this sample: "OAuth", "authorization"

The sample code shows how to write a provider side application to register an OAuth client, remove client authorization, how to customize OAuth service provider, and how to write an OAuth client to work with OAuth service provider.
Clienttable.jsp

Use clienttable.jsp as a sample management page to interface with the client provider object that is supplied to the OAuth provider component. The management page is tailored to interact with the default in-memory client provider sample, com.ibm.ws.security.oauth20.plugins.BaseClientProvider. Use custom management tools for other client repositories, like a database, or modify this page, as needed.

This JSP sample adds a registered client to an XML based client store. The Oauth service provider uses the client store XML file as a gatekeeper to decide if a client can make OAuth request to the service.

Dbclienttable.jsp

This JSP sample saves a registered oauth client to oauth database table.

Use this as a sample management page to interface with the Client Provider object supplied to the OAuth provider component. This page is tailored to interact with the default database client provider sample, <%=targetClientProvider%>. Use custom management tools for other client repositories, like a database, or modify this page to meet your needs.

Getting Started
You can use this sample as is, or you can build your own application by using this sample.

To learn more about OAuth see the OAuth documentation in the WebSphere Application Server Information Center

Locating the source code

You can find the source code for the OAuth Sample in the OAuth/src/ directory. The was.oauth.samples.war/WebContent sub-directory contains the source code for the sample.

Procedure