Questions tagged [jjwt]

Use when referencing the JJWT library for the JVM and Android

The JJWT library for the JVM and Android: https://github.com/jwtk/jjwt

138 questions
22
votes
1 answer

Static secret as byte[], Key or String?

I have started to work with JJWT to handle JWT on my server application. My JWT secret will be stored at resources folder and I will load the secret with Properties class. The JJWT provides three methods to sign the JWT, one uses byte[], other uses…
Paulo
  • 2,956
  • 3
  • 20
  • 30
18
votes
1 answer

Verifying JWT Signature using public key endpoint

I'm wanting to verify the signature of some JWTs from Microsoft. I'm using Spring-Boot, the JJWT library and following endpoint: https://login.microsoftonline.com/common/discovery/v2.0/keys The endpoint returns an array of JSON public keys. Here is…
Ryan D
  • 1,023
  • 11
  • 16
16
votes
3 answers

DefaultJwtParser: how to merely decode the JWT? (no secret key, no validation)

I don't want to verify the JWT using the secret key (which I don't have), I only want to decode the JWT and read the payload. Can this be achieved using jsonwebtoken.io:jjwt? It seems like there is a method missing in the API. Of course, I could…
Jaroslav Záruba
  • 4,694
  • 5
  • 39
  • 58
13
votes
4 answers

Key bytes can only be specified for HMAC signatures. Please specify a PublicKey or PrivateKey instance

I am trying to read a Json Web Token(JWT) generated from Google OpenID Connect's Id Token in order to get the claims and to verify using jjwt library. I have tried several ways to fix it with the code below. String publicKeyFromJsonFile =…
John Erbynn
  • 355
  • 1
  • 4
  • 14
12
votes
1 answer

JWT Token Invalid Signature

I am using JWT in my application for login authentication process. To generate the token I am using: Jwts.builder().setSubject(username).signWith(SignatureAlgorithm.HS512, MacProvider.generateKey()).compact(); Generated…
Mohit224
  • 443
  • 1
  • 10
  • 24
12
votes
3 answers

java.lang.IllegalArgumentException: A signing key must be specified if the specified JWT is digitally signed

I'm looking to implement JWT in my application for that I'm doing some R&D on it by taking a reference from : https://stormpath.com/blog/jwt-java-create-verify. I was successfully able to implement the generateToken() method, when I am trying to…
user5778069
9
votes
2 answers

How to create a Spring Security Key for signing a JWT token?

I use implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.10.6' as dependency. I would like to create a JWT token as follows: @Value("${jwt.token.secret}") private Key secret; JwtToken.builder().value(Jwts.builder() …
codeme
  • 861
  • 2
  • 12
  • 29
9
votes
1 answer

JWT: jwtk/jjwt with public/private keys

Auth0 provides two JWT libraries, one for Node: node-jsonwebtoken, and one for Java: java-jwt. It turns out that java-jwt does not support public/private key pairs. However, another java library, the jjwt library, claims to support that feature.…
Predrag Stojadinović
  • 3,439
  • 6
  • 34
  • 52
7
votes
1 answer

JJWT dependency confusion

I inherited a java project that has this in the POM.xml: 0.11.1 // from https://github.com/jwtk/jjwt#maven io.jsonwebtoken
Jason
  • 2,451
  • 2
  • 23
  • 31
7
votes
1 answer

Expiration of JWT not working when using expiration date in UTC

I am using jjwt for jwt token creation. Everything works fine when setting expiration date with local system time, i.e. Date expDate = new Date(new Date().getTime() + 180000); //java.util.Date But I tried using UTC format date time and signed…
Ujjwal Jung Thapa
  • 604
  • 2
  • 8
  • 31
7
votes
1 answer

JJWT Tokens. How do I set timeout?

Using the jjwt library, String compactJws = Jwts.builder().setSubject("Joe").signWith(SignatureAlgorithm.HS512, key).compact(); But this token is permanent, how do I set some kind of timeout on this?
robm
  • 77
  • 1
  • 6
6
votes
2 answers

JJWT library and handle expiration ExpiredJWTException

The problem is that my application throws an exception when the token expires and I can't catch that exception. I want to catch that exception and do another thing. Tried commenting exception statement on catch block but no progress. Exception: …
user8920693
  • 85
  • 1
  • 1
  • 9
5
votes
5 answers

How do I get a custom field out of the payload using JJWT

OK, I am adding a couple of custom claims to the payload when I generate the JWT, and I can pull those out just fine in my front-end (javascript). I then have my javascript send an ajax call to a micro-service and it passes the JWT along with it. I…
Jacob Miles
  • 196
  • 1
  • 2
  • 13
4
votes
3 answers

Can't find io.jsonwebtoken.impl.DefaultJwtBuilder when starting project in a docker container

When starting my Quarkus project locally with mvn quarkus:dev I have no errors when executing a function which utilizes JJWT. However when I export my project into a docker container it gives me an error stating that it can't find…
Xander Vos
  • 73
  • 1
  • 1
  • 7
4
votes
0 answers

JWT refresh token with jjwt

recently I've started my project in SpringBoot and Kotlin and I wanted to create user management system. After a few searches, I've looked at this video regarding the implementation of JWT tokens for the authentication process. Everything seems to…
Yonatan Karp-Rudin
  • 1,056
  • 8
  • 24
1
2 3
9 10