File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
services/identity/src/main/java/com/crapi/config Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 2828import java .io .ByteArrayInputStream ;
2929import java .io .IOException ;
3030import java .io .InputStream ;
31+ import java .math .BigDecimal ;
3132import java .net .URI ;
3233import java .net .URLConnection ;
3334import java .nio .charset .StandardCharsets ;
@@ -45,7 +46,7 @@ public class JwtProvider {
4546 private static final Logger logger = LoggerFactory .getLogger (JwtProvider .class );
4647
4748 @ Value ("${app.jwtExpiration}" )
48- private int jwtExpiration ;
49+ private String jwtExpiration ;
4950
5051 private KeyPair keyPair ;
5152
@@ -82,11 +83,14 @@ public String getPublicJwkSet() {
8283 * @return generated token with expire date
8384 */
8485 public String generateJwtToken (User user ) {
86+ int jwtExpirationInt ;
87+ if (jwtExpiration .contains ("e+" )) jwtExpirationInt = new BigDecimal (jwtExpiration ).intValue ();
88+ else jwtExpirationInt = Integer .parseInt (jwtExpiration );
8589 return Jwts .builder ()
8690 .setSubject ((user .getEmail ()))
8791 .claim ("role" , user .getRole ().getName ())
8892 .setIssuedAt (new Date ())
89- .setExpiration (new Date ((new Date ()).getTime () + jwtExpiration ))
93+ .setExpiration (new Date ((new Date ()).getTime () + jwtExpirationInt ))
9094 .signWith (SignatureAlgorithm .RS256 , this .keyPair .getPrivate ())
9195 .compact ();
9296 }
You can’t perform that action at this time.
0 commit comments