Skip to content

Commit

Permalink
Merge branch 'release/v1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jwpark-gaia3d committed Jan 6, 2019
2 parents 810a1db + 1cb8edc commit 2c18989
Show file tree
Hide file tree
Showing 2,447 changed files with 1,278,076 additions and 17,892 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/.gradle/
livedronemap-converter/logs
Binary file removed .gradle/4.9/fileChanges/last-build.bin
Binary file not shown.
Empty file.
6 changes: 6 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
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
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
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
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
live drone map

TODO
1 REST 방식
2 RestTemplate 사용
3 template(thymeleaf) 사용
4 또 뭐가 있을까?

1. postgresql 11 적용
2. tomcat 추가 계정으로 start
3. template(thymeleaf)
4. 외부 API, 내부 API, ajax, 일반 페이지 어떻게 url 구분 및 보안 적용 할지
5. chart ... jqplot 에서 echarts
6. 디자인
1) 목록 페이지
- table 로 만들고
46 changes: 36 additions & 10 deletions livedronemap-admin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ final String DEFAULT_PROFILE = 'local'

buildscript {
ext {
springBootVersion = '2.0.4.RELEASE'
lombokVersion = '1.18.2'
springBootVersion = '2.1.0.RELEASE'
lombokVersion = '1.18.4'
}
repositories {
mavenCentral()
Expand Down Expand Up @@ -41,6 +41,10 @@ configurations {
providedRuntime
}

test {
ignoreFailures = true
}

sourceSets {
main {
resources {
Expand All @@ -51,11 +55,26 @@ sourceSets {

if (profile == 'real') {
println " ===========> profile file is ${profile}"
srcDir "src/main/resources/${profile}"
println " ===========> copy from src/main/resources/real to src/main/resources"

copy {
from("src/main/resources/real") {
//exclude 'logback.xml'
include 'application.properties'
include 'livedronemap.properties'
include 'logback-spring.xml'
}
into "src/main/resources"
}

//copy {
// from "src/main/resources/${profile}"
// into "src/main/resources"
//}
// from("src/main/resources/properties-$targetServer") {
// include 'logback.xml'
// }
// into("src/main/resources/")
//}

//delete file("src/main/resources/properties-dev")
} else {
println " ===========> profile file is ${profile}"
//srcDir "src/main/resources"
Expand All @@ -66,17 +85,24 @@ sourceSets {
}

dependencies {
//compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-actuator')
//compile('org.springframework.boot:spring-boot-starter-mail')
//compile('org.springframework.boot:spring-boot-starter-quartz')
//compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile('javax.servlet:jstl')
compile('org.springframework.security:spring-security-core')

compile ('org.apache.commons:commons-io:1.3.2')
compile 'com.zaxxer:HikariCP:3.2.0'
//compile ('org.apache.commons:commons-io:1.3.2')
compile 'commons-codec:commons-codec:1.11'
compile 'com.zaxxer:HikariCP'
compile 'org.apache.taglibs:taglibs-standard-jstlel:1.2.5'
compile 'org.apache.commons:commons-exec:1.3'
compile 'org.apache.httpcomponents:httpclient'

compile 'io.springfox:springfox-swagger2:2.9.2'
compile 'io.springfox:springfox-swagger-ui:2.9.2'
compile 'org.mockito:mockito-core:2.22.0'

runtime('org.springframework.boot:spring-boot-devtools')
runtime('org.postgresql:postgresql')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.filter.HiddenHttpMethodFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

Expand Down Expand Up @@ -33,4 +35,11 @@ public void addCorsMappings(CorsRegistry registry) {
}
};
}

@Bean
public FilterRegistrationBean<HiddenHttpMethodFilter> hiddenHttpMethodFilter() {
FilterRegistrationBean<HiddenHttpMethodFilter> registrationBean = new FilterRegistrationBean<>(new HiddenHttpMethodFilter());
registrationBean.addUrlPatterns("/*");
return registrationBean;
}
}
117 changes: 117 additions & 0 deletions livedronemap-admin/src/main/java/gaia3d/api/APIController.java
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;
}
}
Loading

0 comments on commit 2c18989

Please sign in to comment.