-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from KUIT-Space/develop
- Loading branch information
Showing
39 changed files
with
804 additions
and
73 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...ument_resolver/jwtLogin/JwtLoginAuth.java โ ...gumentResolver/jwtLogin/JwtLoginAuth.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
2 changes: 1 addition & 1 deletion
2
.../JwtLoginAuthHandlerArgumentResolver.java โ .../JwtLoginAuthHandlerArgumentResolver.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
12 changes: 12 additions & 0 deletions
12
src/main/java/space/space_spring/argumentResolver/userSpace/CheckUserSpace.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,12 @@ | ||
package space.space_spring.argumentResolver.userSpace; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface CheckUserSpace { | ||
boolean required() default true; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/space/space_spring/argumentResolver/userSpace/UserSpaceAuth.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,11 @@ | ||
package space.space_spring.argumentResolver.userSpace; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface UserSpaceAuth { | ||
} |
32 changes: 32 additions & 0 deletions
32
...a/space/space_spring/argumentResolver/userSpace/UserSpaceAuthHandlerArgumentResolver.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,32 @@ | ||
package space.space_spring.argumentResolver.userSpace; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
import space.space_spring.argumentResolver.jwtLogin.JwtLoginAuth; | ||
import space.space_spring.dao.UserSpaceDao; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class UserSpaceAuthHandlerArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
private final UserSpaceDao userSpaceDao; | ||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
// ์ผ๋จ parameter์ return value type ์ ๊ฒ์ฌํ์ง๋ X | ||
return parameter.hasParameterAnnotation(UserSpaceAuth.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); | ||
return | ||
userSpaceDao.findUserSpaceAuthById((Long)request.getAttribute("userSpaceId")); | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/space/space_spring/argumentResolver/userSpace/UserSpaceId.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,11 @@ | ||
package space.space_spring.argumentResolver.userSpace; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface UserSpaceId { | ||
} |
26 changes: 26 additions & 0 deletions
26
...ava/space/space_spring/argumentResolver/userSpace/UserSpaceIdHandlerArgumentResolver.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,26 @@ | ||
package space.space_spring.argumentResolver.userSpace; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
import space.space_spring.argumentResolver.jwtLogin.JwtLoginAuth; | ||
|
||
@Component | ||
public class UserSpaceIdHandlerArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
// ์ผ๋จ parameter์ return value type ์ ๊ฒ์ฌํ์ง๋ X | ||
return parameter.hasParameterAnnotation(UserSpaceId.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest(); | ||
return request.getAttribute("userSpaceId"); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
src/main/java/space/space_spring/config/UserSpaceValidationInterceptorURL.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,16 @@ | ||
package space.space_spring.config; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum UserSpaceValidationInterceptorURL { | ||
//SPACE("/space/**"), | ||
TEST("/space/{spaceId}/test/**"), | ||
; | ||
|
||
private final String urlPattern; | ||
|
||
UserSpaceValidationInterceptorURL(String urlPattern) { | ||
this.urlPattern = urlPattern; | ||
} | ||
} |
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
Oops, something went wrong.