-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev/refactor/media-file'
- Loading branch information
Showing
59 changed files
with
1,031 additions
and
838 deletions.
There are no files selected for viewing
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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/prgrms2/java/bitta/global/exception/AuthenticationException.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,15 @@ | ||
package com.prgrms2.java.bitta.global.exception; | ||
|
||
public enum AuthenticationException { | ||
CANNOT_ACCESS(403, "해당 API에 대한 액세스 권한이 없습니다."); | ||
|
||
private AuthenticationTaskException authenticationTaskException; | ||
|
||
AuthenticationException(int code, String message) { | ||
authenticationTaskException = new AuthenticationTaskException(code, message); | ||
} | ||
|
||
public AuthenticationTaskException get() { | ||
return authenticationTaskException; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/prgrms2/java/bitta/global/exception/AuthenticationTaskException.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 com.prgrms2.java.bitta.global.exception; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class AuthenticationTaskException extends RuntimeException { | ||
private int code; | ||
private String message; | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/prgrms2/java/bitta/global/util/AuthenticationProvider.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,31 @@ | ||
package com.prgrms2.java.bitta.global.util; | ||
|
||
import com.prgrms2.java.bitta.member.entity.Role; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.util.StringUtils; | ||
|
||
|
||
public class AuthenticationProvider { | ||
public static String getUsername() { | ||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
if (authentication == null || authentication.getName() == null) { | ||
throw new RuntimeException("No authentication information."); | ||
} | ||
|
||
return authentication.getName(); | ||
} | ||
|
||
public static Role getRoles() { | ||
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
|
||
if (authentication == null || authentication.getAuthorities().isEmpty()) { | ||
throw new RuntimeException(""); | ||
} | ||
|
||
String role = authentication.getAuthorities().iterator().next().getAuthority(); | ||
|
||
return Role.valueOf(role); | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/main/java/com/prgrms2/java/bitta/media/entity/MediaCategory.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.prgrms2.java.bitta.media.entity; | ||
|
||
public enum MediaCategory { | ||
IMAGE, VIDEO, PROFILE | ||
IMAGE, VIDEO | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/prgrms2/java/bitta/media/exception/MediaException.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,18 @@ | ||
package com.prgrms2.java.bitta.media.exception; | ||
|
||
public enum MediaException { | ||
BAD_REQUEST(400, "올바르지 않은 접근 경로입니다."), | ||
NOT_FOUND(404, "해당 파일은 존재하지 않습니다."), | ||
INTERNAL_ERROR(500, "파일 처리에 실패했습니다."), | ||
INVALID_FORMAT(500, "올바르지 않은 파일 포맷입니다."); | ||
|
||
private MediaTaskException mediaTaskException; | ||
|
||
MediaException(int code, String message) { | ||
mediaTaskException = new MediaTaskException(code, message); | ||
} | ||
|
||
public MediaTaskException get() { | ||
return mediaTaskException; | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/com/prgrms2/java/bitta/media/exception/MediaFileException.java
This file was deleted.
Oops, something went wrong.
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.