-
Notifications
You must be signed in to change notification settings - Fork 6
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
2,447 changed files
with
1,278,076 additions
and
17,892 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/.gradle/ | ||
livedronemap-converter/logs |
Binary file not shown.
Empty file.
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,2 +1,8 @@ | ||
auto.sync=false | ||
build.scans.enabled=false | ||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(4.10)) | ||
connection.project.dir= | ||
eclipse.preferences.version=1 | ||
gradle.user.home=C\:/gradle/gradle-4.10.2 | ||
offline.mode=false | ||
override.workspace.settings=true |
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,3 @@ | ||
eclipse.preferences.version=1 | ||
encoding/<project>=UTF-8 | ||
encoding/README.md=UTF-8 |
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
117 changes: 117 additions & 0 deletions
117
livedronemap-admin/src/main/java/gaia3d/api/APIController.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,117 @@ | ||
package gaia3d.api; | ||
|
||
import org.slf4j.Logger; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.util.StringUtils; | ||
|
||
import gaia3d.domain.APIHeader; | ||
import gaia3d.domain.APILog; | ||
import gaia3d.domain.APIResult; | ||
import gaia3d.domain.APIValidationType; | ||
import gaia3d.domain.EncryptionStatus; | ||
import gaia3d.exception.CustomSecurityException; | ||
import gaia3d.security.AES128Cipher; | ||
import gaia3d.service.APILogService; | ||
|
||
public interface APIController { | ||
|
||
default void insertLog(APILogService aPILogService, String requestIp, String user_id, String url, Integer clientId, String clientName, APIResult aPIResult) { | ||
try { | ||
APILog aPILog = new APILog(); | ||
aPILog.setClient_id(clientId); | ||
aPILog.setClient_name(clientName); | ||
aPILog.setRequest_ip(requestIp); | ||
aPILog.setUser_id(user_id); | ||
aPILog.setUrl(url); | ||
aPILog.setStatus_code(aPIResult.getStatusCode()); | ||
aPILog.setMessage(aPIResult.getMessage()); | ||
|
||
aPILogService.insertAPILog(aPILog); | ||
} catch(Exception ex) { | ||
ex.printStackTrace(); | ||
//log.error("@@@@@@@@ API 이력 저장 중 오류가 발생했지만... 무시"); | ||
} | ||
} | ||
|
||
/** | ||
* 검증 | ||
* @param validationType | ||
* @param aPIHeader | ||
* @return | ||
*/ | ||
default APIResult validate(Logger log, APIValidationType validationType, APIHeader aPIHeader) { | ||
APIResult aPIResult = new APIResult(); | ||
try { | ||
if(aPIHeader == null) { | ||
aPIResult.setStatusCode(HttpStatus.UNAUTHORIZED.value()); | ||
aPIResult.setMessage("live drone map header is null or empty"); | ||
return aPIResult; | ||
} | ||
} catch(CustomSecurityException e) { | ||
aPIResult.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()); | ||
aPIResult.setException(e.getMessage()); | ||
aPIResult.setMessage("An error occurred during the encryption / decryption processing."); | ||
return aPIResult; | ||
} | ||
|
||
if(APIValidationType.AUTHETICATION.equals(validationType)) { | ||
if(StringUtils.isEmpty(aPIHeader.getApiKey())) { | ||
log.info("@@@@@@@@@@@@@@@@@@@ api key is null or empty"); | ||
aPIResult.setStatusCode(HttpStatus.UNAUTHORIZED.value()); | ||
aPIResult.setMessage("api key is null or empty"); | ||
return aPIResult; | ||
} | ||
} else if(APIValidationType.TOKEN.equals(validationType)) { | ||
if(StringUtils.isEmpty(aPIHeader.getToken())) { | ||
log.info("@@@@@@@@@@@@@@@@@@@ token is null or empty"); | ||
aPIResult.setStatusCode(HttpStatus.UNAUTHORIZED.value()); | ||
aPIResult.setMessage("token is null or empty"); | ||
return aPIResult; | ||
} | ||
} | ||
|
||
aPIResult.setStatusCode(HttpStatus.OK.value()); | ||
return aPIResult; | ||
} | ||
|
||
/** | ||
* header 복호화 | ||
* @param encryptionStatus | ||
* @param log | ||
* @param liveDroneMapHeader | ||
* @return | ||
*/ | ||
default APIHeader getHeader(String encryptionStatus, Logger log, String customHeader) { | ||
log.info("@@@@@@@@@@ encryptionStatus = {}", encryptionStatus); | ||
|
||
APIHeader apiHeader = null; | ||
if(StringUtils.isEmpty(customHeader)) { | ||
log.info("@@@@@@@@@@@@@@@@@@@ live_drone_map header is null or empty"); | ||
return apiHeader; | ||
} | ||
|
||
String decodeHeader = customHeader; | ||
// TODO Enum 나중에 고치자... 귀찮음 | ||
if(EncryptionStatus.Y.name().equals(encryptionStatus)) { | ||
try { | ||
decodeHeader = AES128Cipher.decode(customHeader); | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
throw new CustomSecurityException(e); | ||
} | ||
} | ||
log.info("@@@@@@@@@@@@@@@@@@@ customHeader = {}", decodeHeader); | ||
|
||
String[] headers = decodeHeader.split("&"); | ||
|
||
apiHeader = new APIHeader(); | ||
apiHeader.setUserId(headers[0].substring(8)); | ||
apiHeader.setApiKey(headers[1].substring(8)); | ||
apiHeader.setToken(headers[2].substring(6)); | ||
apiHeader.setRole(headers[3].substring(5)); | ||
apiHeader.setAlgorithm(headers[4].substring(10)); | ||
apiHeader.setType(headers[5].substring(5)); | ||
|
||
return apiHeader; | ||
} | ||
} |
Oops, something went wrong.