In this lesson, we will use a JWT (this time a signature with asymmetric RSA keys) to authenticate ourselves when calling the application. We will create a JWT that is verified on the server-side, where the subject can be used to identify who called the endpoint. This does not make use of the standards demonstrated in the following example.

This example can be used in machine-to-machine communication where data exchange is performed using REST endpoints. A program will generate a public and private RSA key, which will be used to create a JWT token. The JAX-RS filter will use this token to authenticate.

Create the project

We start once again from the project template that we defined earlier and add the required dependencies and classes to it.

  • If you want to work within the Educative platform, simply use the project we’ve created at the end of this lesson. If you choose to work locally, you will need to create a Maven project jwtauth as described in "Introduction to Window Shopping."

Add dependency

Add the following dependency to the pom.xml file:

Get hands-on with 1200+ tech skills courses.