Creating and Parsing a secret key signed JWT containing claims

In this post under JWT, I will show with example how to create and parse a signed JWT containing claims. As mentioned in previous posts we will use an instance of JwtBuilder to construct a JSON Web Token. Below is the code snippet for your reference Snippet 1 1 JwtBuilder jwtBuilder = Jwts.builder(); 2 3…… Continue reading Creating and Parsing a secret key signed JWT containing claims

AssertDoesNotThrow Example

In this post under JUnit, I will explain with example what is the purpose and how to use “AssertDoesNotThrow” assertion method. AssertDoesNotThrow takes an executable code and assert that the method doesn’t throw any exception during execution. Below is the javadoc of “assertDoesNotThrow” exception public static void assertDoesNotThrow​(Executable executable) Where “Executable” is a functional interface…… Continue reading AssertDoesNotThrow Example

Parsing simple unsigned JWT containing claims

In this post under JJWT, I will show with example how to parse a simple unsigned JSON Web Token containing claims as payload. Below is the complete main code. Main class 1 package defaultPackage; 2 import io.jsonwebtoken.Claims; 3 import io.jsonwebtoken.Header; 4 import io.jsonwebtoken.Jwt; 5 import io.jsonwebtoken.JwtParser; 6 import io.jsonwebtoken.JwtParserBuilder; 7 import io.jsonwebtoken.Jwts; 8 9 public…… Continue reading Parsing simple unsigned JWT containing claims

Creating a simple unsigned JSON Web Token containing claims

In this post under JJWT, I will explain how to create a simple unsigned JSON Web Token whose payload is a set of claims. I will be using JJWT framework for this example and all the upcoming examples under JJWT. Below is the complete code for your reference Main Class 1 package defaultPackage; 2 3…… Continue reading Creating a simple unsigned JSON Web Token containing claims

assertTrue and assertFalse with Supplier Interface

In this post under JUnit 5, I will introduce you to a new overloaded version of “assertTrue” and “assertFalse” methods. In the earlier versions, we used to stored the result of a comparison in local variable of type boolean and when calling assertTrue or assertFalse, we used to pass that local variable as an argument…… Continue reading assertTrue and assertFalse with Supplier Interface