Top JWT(JSON Web Token) frequently asked interview questions.
Q: What is need for JWT?
A :- JWT stands for JSON Web Token
- It is pronounced as JAWT
- It is Open Standard - RFC7519
- JWT makes it possible to communicate securely between two bodies
- JWT is used for Authorization
Understanding the need for JSON Web Token(JWT)
Q: What are the advantages of JWT?
A :Advantages of JWT Authorization
- JWT is self contained. It is a value token. So during each validation the Gmail server does not needs to fetch the information corresponding to it.
- It is digitally signed so if any one modifies it the server will know about it
- It is most suitable for Microservices Architecture
- It has other advantages like specifying the expiration time.
Q: What is the structure of JWT?
A : A JWT consists of 3 parts -- Header
- Payload
- Signature
Q: What is expiration date of JWT?
A : Expiration Time - This the time for which we want the generated JWT to be valid for. This will be in milliseconds. Suppose we want the JWT to be valid for 5 hours, then we will specify this value as 18000000Q: How do we specify expiration date of JWT?
A :
private String doGenerateToken(Map<String, Object> claims, String subject) {
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
.setExpiration(new Date(System.currentTimeMillis() + jwtExpirationInMs)).signWith(SignatureAlgorithm.HS512, secret).compact();
}
See Also
Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions
Popular Posts
1Z0-830 Java SE 21 Developer Certification
Azure AI Foundry Hello World
Azure AI Agent Hello World
Foundry vs Hub Projects
Build Agents with SDK
Bing Web Search Agent
Function Calling Agent
Spring Boot + Azure Key Vault Hello World Example
Spring Boot + Elasticsearch + Azure Key Vault Example
Spring Boot Azure AD (Entra ID) OAuth 2.0 Authentication
Deploy Spring Boot App to Azure App Service
Secure Azure App Service using Azure API Management
Deploy Spring Boot JAR to Azure App Service
Deploy Spring Boot + MySQL to Azure App Service
Spring Boot + Azure Managed Identity Example
Secure Spring Boot Azure Web App with Managed Identity + App Registration
Elasticsearch 8 Security - Integrate Azure AD OIDC