Skip to content

Latest commit

 

History

History

java-tokenclient-usage

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Description

This sample showcases a Java back-end application leveraging the Token Client library to illustrate the token flow process of obtaining an Access Token issued by Xsuaa. Upon receiving incoming requests, the application retrieves credentials from the VCAP_SERVICES environment variable and requests a new access token through ClientCredentialsTokenFlow.

Deployment on Cloud Foundry

To deploy the application, the following steps are required:

  • Compile the Java application
  • Create a xsuaa service instance
  • Configure the manifest
  • Deploy the application
  • Access the application

Compile the Java application

Run maven to package the application

mvn clean package

Create the xsuaa service instance

Use the xs-security.json to define the authentication settings and create a service instance

cf create-service xsuaa application xsuaa-token-client -c xs-security.json

Configure the manifest

The vars contains hosts and paths that need to be adopted.

Deploy the application

Deploy the application using cf push. It will expect 1 GB of free memory quota.

cf push --vars-file ../vars.yml

Access the application

To access the application go to https://java-tokenclient-usage-<<ID>>.<<LANDSCAPE_APPS_DOMAIN>>/hello-token-client You should see something like this:

Access-Token: eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vYzUyOTU0MDB0cmlhbC5hdXRoZW50aWN...
Access-Token-Payload: {"jti":"a2ea5313e37345709985836b1400305f","ext_attr":{"enhancer":"XSUAA","zdn":"c5295400trial"},...
Expired-At: Wed Oct 16 13:37:00 UTC 2019

Clean-Up

Finally, delete your application and your service instances using the following commands:

cf delete -f java-tokenclient-usage
cf delete-service -f xsuaa-token-client