kjbank.com 도메인 처리
This commit is contained in:
@@ -29,6 +29,30 @@ public class FileService {
|
||||
private final BinaryStorageService binaryStorageService;
|
||||
private final FileTypeDetector fileTypeDetector;
|
||||
|
||||
private static final ThreadLocal<Boolean> internalUserContext = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 현재 스레드에 내부 사용자 컨텍스트 설정
|
||||
*/
|
||||
public static void setInternalUserContext(boolean isInternal) {
|
||||
internalUserContext.set(isInternal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부 사용자 컨텍스트 조회
|
||||
*/
|
||||
public static boolean isInternalUserContext() {
|
||||
Boolean isInternal = internalUserContext.get();
|
||||
return isInternal != null && isInternal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부 사용자 컨텍스트 정리
|
||||
*/
|
||||
public static void clearInternalUserContext() {
|
||||
internalUserContext.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 파일 ID를 기반으로 파일 정보를 검색합니다.
|
||||
*
|
||||
@@ -71,8 +95,15 @@ public class FileService {
|
||||
String type = fileTypeDetector.detectFileType(file.getBytes());
|
||||
log.debug("upload file type:{}", type);
|
||||
|
||||
if(type.equalsIgnoreCase("unknown")) {
|
||||
throw new InvalidFileException("허용된 파일 형식이 아닙니다. <br>문서파일과 이미지 파일만 등록 가능합니다. <br>(pdf, doc, docx, xls, xlsx, ppt, pptx, hwp, gif, jpg, png)");
|
||||
boolean isValidType = !type.equalsIgnoreCase("unknown");
|
||||
|
||||
if (!isValidType) {
|
||||
if (isInternalUserContext()) {
|
||||
log.warn("Internal user bypassed file validation - File: {}, Type: {}",
|
||||
file.getOriginalFilename(), type);
|
||||
} else {
|
||||
throw new InvalidFileException("허용된 파일 형식이 아닙니다. <br>문서파일과 이미지 파일만 등록 가능합니다. <br>(pdf, doc, docx, xls, xlsx, ppt, pptx, hwp, gif, jpg, png)");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(file.getOriginalFilename()) && file.getSize() > 0) {
|
||||
@@ -82,7 +113,13 @@ public class FileService {
|
||||
fileDetail.setFileSn(fileSn);
|
||||
fileDetail.setFileSize((int) file.getSize());
|
||||
fileDetail.setOriginalFileName(FilenameUtils.getBaseName(file.getOriginalFilename()));
|
||||
fileDetail.setFileExtension(type);
|
||||
|
||||
if (isValidType) {
|
||||
fileDetail.setFileExtension(type);
|
||||
} else {
|
||||
fileDetail.setFileExtension(FilenameUtils.getExtension(file.getOriginalFilename()));
|
||||
}
|
||||
|
||||
String contentReference = binaryStorageService.store(file.getBytes());
|
||||
fileDetail.setFileContents(contentReference);
|
||||
fileInfo.getFileDetails().add(fileDetail);
|
||||
@@ -232,12 +269,17 @@ public class FileService {
|
||||
String type = fileTypeDetector.detectFileType(file.getBytes());
|
||||
log.debug("upload file type:{}", type);
|
||||
|
||||
if (isCheckMime) {
|
||||
if(type.equalsIgnoreCase("unknown")) {
|
||||
throw new InvalidFileException("허용된 파일 형식이 아닙니다. <br>문서파일과 이미지 파일만 등록 가능합니다. <br>(pdf, doc, docx, xls, xlsx, ppt, pptx, hwp, gif, jpg, png)");
|
||||
}
|
||||
} else {
|
||||
log.debug("파일 체크 옵션 해제 - FileType : {}", type);
|
||||
boolean isValidType = !type.equalsIgnoreCase("unknown");
|
||||
|
||||
if (isCheckMime && !isValidType) {
|
||||
if (isInternalUserContext()) {
|
||||
log.warn("Internal user bypassed file validation - File: {}, Type: {}",
|
||||
fileName, type);
|
||||
} else {
|
||||
throw new InvalidFileException("허용된 파일 형식이 아닙니다. <br>문서파일과 이미지 파일만 등록 가능합니다. <br>(pdf, doc, docx, xls, xlsx, ppt, pptx, hwp, gif, jpg, png)");
|
||||
}
|
||||
} else if (!isCheckMime) {
|
||||
log.debug("파일 체크 옵션 해제 - FileType : {}", type);
|
||||
}
|
||||
|
||||
FileDetail fileDetail = new FileDetail();
|
||||
|
||||
Reference in New Issue
Block a user