Skip to content

Commit

Permalink
fix: Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
devmizz committed Jun 3, 2024
1 parent f54b5be commit 421813f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.example.error;

import org.example.exception.BusinessException;
import org.example.exception.ErrorResponse;
import org.example.exception.GlobalError;
import jakarta.validation.ConstraintViolationException;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.example.exception.BusinessException;
import org.example.exception.ErrorResponse;
import org.example.exception.GlobalError;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package org.example.filter;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.example.exception.BusinessException;
import org.example.exception.ErrorResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;
import lombok.extern.slf4j.Slf4j;
import org.example.exception.BusinessException;
import org.example.exception.ErrorResponse;
import org.example.exception.GlobalError;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public record TokenProperty(
Long refreshTokenExpirationSeconds
) {

public SecretKey getBASE64URLSecretKey() {
public SecretKey getBase64URLSecretKey() {
return Keys.hmacShaKeyFor(
Decoders.BASE64URL.decode(secretKey)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private String createAccessToken(UserParam userParam, Date from) {
.expiration(
new Date(from.getTime() + tokenProperty.accessTokenExpirationSeconds())
)
.signWith(tokenProperty.getBASE64URLSecretKey())
.signWith(tokenProperty.getBase64URLSecretKey())
.compact();
}

Expand All @@ -39,7 +39,7 @@ private String createRefreshToken(UserParam userParam, Date from) {
.expiration(
new Date(from.getTime() + tokenProperty.refreshTokenExpirationSeconds())
)
.signWith(tokenProperty.getBASE64URLSecretKey())
.signWith(tokenProperty.getBase64URLSecretKey())
.compact();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.example.security.token;

import org.example.exception.BusinessException;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwt;
import io.jsonwebtoken.Jwts;
import jakarta.servlet.http.HttpServletRequest;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.example.exception.BusinessException;
import org.example.property.TokenProperty;
import org.example.security.dto.UserParam;
import org.example.security.vo.TokenError;
Expand Down Expand Up @@ -66,7 +66,7 @@ private Object parsePayload(String token) {

private Jwt<?, ?> parseToken(String token) {
return Jwts.parser()
.verifyWith(tokenProperty.getBASE64URLSecretKey())
.verifyWith(tokenProperty.getBase64URLSecretKey())
.build()
.parse(token);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void accessTokenInvalidBeforeHourAgo() {
Assertions.assertThrowsExactly(
ExpiredJwtException.class,
() -> Jwts.parser()
.verifyWith(tokenProperty.getBASE64URLSecretKey())
.verifyWith(tokenProperty.getBase64URLSecretKey())
.build()
.parse(token.accessToken())
);
Expand All @@ -54,7 +54,7 @@ void accessTokenValidAfterHourAgo() {

Assertions.assertDoesNotThrow(
() -> Jwts.parser()
.verifyWith(tokenProperty.getBASE64URLSecretKey())
.verifyWith(tokenProperty.getBase64URLSecretKey())
.build()
.parse(token.accessToken())
);
Expand All @@ -69,7 +69,7 @@ void refreshTokenInvalidBeforeHourAgo() {
Assertions.assertThrowsExactly(
ExpiredJwtException.class,
() -> Jwts.parser()
.verifyWith(tokenProperty.getBASE64URLSecretKey())
.verifyWith(tokenProperty.getBase64URLSecretKey())
.build()
.parse(token.refreshToken())
);
Expand All @@ -84,7 +84,7 @@ void refreshTokenValidAfterHourAgo() {

Assertions.assertDoesNotThrow(
() -> Jwts.parser()
.verifyWith(tokenProperty.getBASE64URLSecretKey())
.verifyWith(tokenProperty.getBase64URLSecretKey())
.build()
.parse(token.refreshToken())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import org.example.exception.BusinessException;
import java.util.Date;
import java.util.UUID;
import org.example.exception.BusinessException;
import org.example.property.TokenProperty;
import org.example.security.dto.TokenParam;
import org.example.security.dto.UserParam;
Expand Down Expand Up @@ -69,7 +69,8 @@ void extractUserIdFromExpiredToken() {
new Date(new Date().getTime() - tokenProperty.accessTokenExpirationSeconds())
).accessToken();

UUID extractedUserIdFromExpiredToken = jwtHandler.getUserIdFromExpiredToken(expiredAccessToken);
UUID extractedUserIdFromExpiredToken = jwtHandler.getUserIdFromExpiredToken(
expiredAccessToken);
assertThat(extractedUserIdFromExpiredToken).isEqualTo(userParam.userId());
}
}
4 changes: 2 additions & 2 deletions config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@
<module name="AbbreviationAsWordInName">
<property name="ignoreFinal" value="false"/>
<property name="allowedAbbreviationLength" value="0"/>
<property name="allowedAbbreviations" value="JWT, AWS, API"/>
<property name="allowedAbbreviations" value="JWT, AWS, API, URL"/>
<property name="tokens"
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, ANNOTATION_DEF, ANNOTATION_FIELD_DEF,
PARAMETER_DEF, VARIABLE_DEF, METHOD_DEF, PATTERN_VARIABLE_DEF, RECORD_DEF,
RECORD_COMPONENT_DEF"/>
</module>
<module name="NoWhitespaceBeforeCaseDefaultColon"/>
<module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<!-- <module name="VariableDeclarationUsageDistance"/> -->
<module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/>
Expand Down

0 comments on commit 421813f

Please sign in to comment.