Spring Boot — JWT Token based resource authentication & JavaMailSender

The idea behind that sending JWT token to the developer email while working in the development phase.

TechShareZone — Spring-boot-jwt and email

In the current trend of running with the crowd, I have experienced that when any secure microservices module is in the development phase the developer’s pain is hitting a controller that gets generate the JWT token, Why don’t set the MAX_EXPIRE 24hrs or 8hrs and send it to the developer’s email address.

Here is explanation of the implementation. See the gradle.build for required dependencies from below link.



We need to create an utility class or service that will be responsible to following functionalities-
1- generateToken
2- validateToken
3- extractClaim
4- extractExpiration
5- extractUserName
6- extractAllClaims

Please refer following link for looking of the implementation of these methods.

Request Filter — that validate every request

Filter that is used for inspecting every request of the user and extract the userName from the JWT token and validate that JWT token

“jwt”: “eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJmb28iLCJleHAiOjE2MDYzOTU0ODMsImlhdCI6MTYwNjM1OTQ4M30.bmWzebUtCos1a-eTQK7c28XIMos46_qjqvL5YwUSLCk”


This controller is used to generateToken and send that token to the developer’s email address. (as of now hard coded but we can pick it from IDE configurations)



Technology Enthusiast and Open Source Technology advocate

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store