Skip to content

Commit c5f80cf

Browse files
committed
refactor(accessToken): 코드 추상화 수준 맞추기
- NPE 처리 추가.
1 parent 1aadb68 commit c5f80cf

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/com/somemore/auth/jwt/filter/JwtAuthFilter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private EncodedToken getAccessToken(HttpServletRequest request) {
6161
EncodedToken accessToken = findAccessTokenFromCookie(request);
6262

6363
if (accessToken.isUninitialized()) {
64-
accessToken = new EncodedToken(request.getHeader("Authorization"));
64+
accessToken = findAccessTokenFromHeader(request);
6565
}
6666

6767
if (accessToken.isUninitialized()) {
@@ -72,6 +72,15 @@ private EncodedToken getAccessToken(HttpServletRequest request) {
7272
return accessToken.removePrefix(prefix);
7373
}
7474

75+
private static EncodedToken findAccessTokenFromHeader(HttpServletRequest request) {
76+
String authorizationHeader = request.getHeader("Authorization");
77+
if (authorizationHeader == null || authorizationHeader.isEmpty()) {
78+
return new EncodedToken("UNINITIALIZED");
79+
}
80+
81+
return new EncodedToken(authorizationHeader);
82+
}
83+
7584
private EncodedToken findAccessTokenFromCookie(HttpServletRequest request) {
7685
Cookie[] cookies = request.getCookies();
7786
if (cookies == null) {

0 commit comments

Comments
 (0)