This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //this is example, not best practics to use | |
| public String generate(User user) throws TokenServiceException { | |
| try { | |
| PrivateKey privateKey = PemKeyUtils.privateKeyFromString(Files.readString(Paths.get("jwt_private_key.pem"))); | |
| Date date = Date.from(LocalDateTime.now().plusHours(12).atZone(ZoneId.systemDefault()).toInstant()); | |
| return Jwts.builder() | |
| .setSubject(user.getUsername()) // username is "login" | |
| .setExpiration(date) |