-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- JWT 생성 구현 - Claims(Payload), 검증, 조회 미구현 resolve : #27
- Loading branch information
1 parent
5e9695e
commit 650223c
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/univ/goormthon/kongju/global/jwt/provider/JwtProvider.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package univ.goormthon.kongju.global.jwt.provider; | ||
|
||
import io.jsonwebtoken.Claims; | ||
import io.jsonwebtoken.Jwts; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.crypto.SecretKey; | ||
import java.util.Date; | ||
|
||
@Component | ||
public class JwtProvider { | ||
|
||
private final SecretKey key = Jwts.SIG.HS256.key().build(); | ||
private final long validityInMilliseconds = 1000 * 60 * 60; // 1시간 | ||
|
||
public String generateToken(Authentication authentication) { | ||
String email = authentication.getName(); | ||
|
||
return Jwts.builder() | ||
.subject(email) | ||
.signWith(key) | ||
.issuedAt(new Date()) | ||
.expiration(new Date(new Date().getTime() + validityInMilliseconds)) | ||
.compact(); | ||
} | ||
|
||
public Claims getClaims(String token) { | ||
} | ||
|
||
public boolean validateToken(String token) { | ||
} | ||
|
||
public Authentication getAuthentication(String token) { | ||
} | ||
|
||
|
||
} |