In this post under JJWT I will show with example how to check whether a JWT is secured or not. JwtParser class has a “isSigned” method which will figure out whether the JWT is secured or not. All we need is to pass the test JWT string as an argument to this method. This method…… Continue reading Checking whether JWT is secured or not
Month: September 2022
Assumptions in JUnit5
In this post under Junit5, I will show with example, how to use Assumptions feature. Sometimes test case assertions depend on certain conditions. If a condition is met, then test case should be asserted otherwise we should skip the assertion. To test whether the condition is met or not, we take the help of “assumeTrue”…… Continue reading Assumptions in JUnit5
Parsing simple unsecured JWT containing claims
In this post under JJWT, I will show with example how to parse a simple unsecured JSON Web Token containing claims as payload. Below is the complete main code for your reference 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 class Example2 {10 public…… Continue reading Parsing simple unsecured JWT containing claims
Creating a simple unsecured JSON Web Token containing claims
In this post under JJWT, I will explain how to create a simple unsecured JSON Web Token whose payload is a set of claims. I will be using JJWT framework for this example and for 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 unsecured JSON Web Token containing claims