Skip to content
Snippets Groups Projects

fix token issue

Merged GIMENEZ TANGUY requested to merge tanguy/jwt-authentication into main
Compare and
2 files
+ 4
3
Preferences
Compare changes
Files
2
@@ -12,7 +12,7 @@ import java.util.Date;
public class JWTTokenController {
private static byte[] SECRET_KEY = DatatypeConverter.parseBase64Binary(System.getenv("TOKEN_SECRET_KEY"));
private static byte[] SECRET_KEY = DatatypeConverter.parseBase64Binary(JWTTokenController.class.getClassLoader().getResourceAsStream("token").toString());
public static String createToken(String id, String issuer, String subject, long ttl) {
@@ -20,14 +20,14 @@ public class JWTTokenController {
long nowMilliseconds = System.currentTimeMillis();
Key signingkey = new SecretKeySpec(SECRET_KEY, algo.getJcaName());
Key signinkey = new SecretKeySpec(SECRET_KEY, algo.getJcaName());
JwtBuilder builder = Jwts.builder()
.setId(id)
.setIssuedAt(new Date(nowMilliseconds))
.setIssuer(issuer)
.setSubject(subject)
.signWith(algo, signingkey);
.signWith(algo, signinkey);
if(ttl >= 0) {
builder.setExpiration(new Date(nowMilliseconds + ttl));