-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
235 additions
and
30 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
wabi/src/main/kotlin/com/wap/wabi/auth/admin/entity/AdminRefreshToken.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,53 @@ | ||
package com.wap.wabi.auth.admin.entity; | ||
|
||
import jakarta.persistence.*; | ||
import org.springframework.beans.factory.annotation.Value; | ||
|
||
@Entity | ||
public class AdminRefreshToken { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
private String adminName; | ||
private String refreshToken; | ||
private int reissueCount = 0; | ||
|
||
public AdminRefreshToken() { | ||
} | ||
|
||
public AdminRefreshToken(builder builder) { | ||
this.adminName = builder.adminName; | ||
this.refreshToken = builder.refreshToken; | ||
} | ||
|
||
public void updateRefreshToken(String refreshToken) { | ||
this.refreshToken = refreshToken; | ||
} | ||
|
||
public boolean validateRefreshToken(String refreshToken) { | ||
return this.refreshToken.equals(refreshToken); | ||
} | ||
|
||
public void increaseReissueCount() { | ||
reissueCount++; | ||
} | ||
|
||
public static class builder { | ||
private String adminName; | ||
private String refreshToken; | ||
|
||
public builder adminName(String adminName) { | ||
this.adminName = adminName; | ||
return this; | ||
} | ||
|
||
public builder refreshToken(String refreshToken) { | ||
this.refreshToken = refreshToken; | ||
return this; | ||
} | ||
|
||
public AdminRefreshToken build() { | ||
return new AdminRefreshToken(this); | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
wabi/src/main/kotlin/com/wap/wabi/auth/admin/repository/AdminRefreshTokenRepository.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,13 @@ | ||
package com.wap.wabi.auth.admin.repository; | ||
|
||
import com.wap.wabi.auth.admin.entity.AdminRefreshToken; | ||
import org.apache.poi.sl.draw.geom.GuideIf; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
@Repository | ||
public interface AdminRefreshTokenRepository extends JpaRepository<AdminRefreshToken, Long> { | ||
Optional<AdminRefreshToken> findAdminRefreshTokenByAdminNameAndReissueCountLessThan(String name, long count); | ||
Optional<AdminRefreshToken> findAdminRefreshTokenByAdminName(String name); | ||
} |
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
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
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
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
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