ing
This commit is contained in:
commit
278a3cc0e2
88
.gitignore
vendored
Normal file
88
.gitignore
vendored
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Created by .ignore support plugin (hsz.mobi)
|
||||
### JetBrains template
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff:
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/dictionaries
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.xml
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
### Maven template
|
||||
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
|
||||
# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
|
||||
!/.mvn/wrapper/maven-wrapper.jar
|
||||
### Java template
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
14
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
.idea/
|
||||
*.iml
|
||||
/target/
|
||||
.settings/
|
||||
.classpath
|
||||
.project
|
27
.vscode/launch.json
vendored
Normal file
27
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Debug",
|
||||
"request": "launch",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"console": "internalConsole",
|
||||
"stopOnEntry": false,
|
||||
"mainClass": "com.loafle.overflow.central.Central",
|
||||
"projectName": "central",
|
||||
"args": "50006"
|
||||
},
|
||||
{
|
||||
"type": "java",
|
||||
"name": "Debug (Attach)",
|
||||
"request": "attach",
|
||||
"hostName": "localhost",
|
||||
"port": 0
|
||||
}
|
||||
]
|
||||
}
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"java.configuration.updateBuildConfiguration": "automatic"
|
||||
}
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
@ -0,0 +1,28 @@
|
|||
FROM openjdk:8-jdk-alpine
|
||||
MAINTAINER Loafle <rnd@loafle.com>
|
||||
|
||||
ENV APP_FILENAME="com.loafle.overflow.central-1.0.0-SNAPSHOT.jar" \
|
||||
APP_HOME_PATH="/service" \
|
||||
APP_MAIN_CLASS="com.loafle.overflow.central.Central" \
|
||||
APP_CONF_PATH="/opt/conf" \
|
||||
PATH="$PATH:/opt/bin"
|
||||
|
||||
ADD build/docker/bin/*.sh /opt/bin/
|
||||
ADD target/lib ${APP_HOME_PATH}/lib
|
||||
ADD target/${APP_FILENAME} ${APP_HOME_PATH}/
|
||||
|
||||
RUN apk add --no-cache curl \
|
||||
&& chmod +x /opt/bin/*.sh
|
||||
|
||||
ENV TINI_VERSION='0.17.0' \
|
||||
TINI_SHA='4007655082f573603c02bc1d2137443c8e153af047ffd088d02ccc01e6f06170'
|
||||
|
||||
# Use tini as subreaper in Docker container to adopt zombie processes
|
||||
RUN curl -fsSL https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini-static-amd64 -o /bin/tini \
|
||||
&& chmod +x /bin/tini
|
||||
|
||||
VOLUME ${APP_CONF_PATH}
|
||||
EXPOSE 50006
|
||||
|
||||
ENTRYPOINT ["/bin/tini", "--"]
|
||||
CMD ["docker-entrypoint.sh"]
|
30
build/docker-compose.yml
Normal file
30
build/docker-compose.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
overFlow-server:
|
||||
restart: always
|
||||
image: docker.loafle.net/overflow/central:1.0.0-SNAPSHOT
|
||||
container_name: overFlow-server
|
||||
volumes:
|
||||
- /service/central/data/opt/conf:/opt/conf
|
||||
# - /home/crusader/Temp/docker/conf:/opt/conf
|
||||
ports:
|
||||
- "50006:50006"
|
||||
|
||||
# postgresql:
|
||||
# restart: always
|
||||
# image: postgres:9.6-alpine
|
||||
# container_name: overFlow-dao-postgres
|
||||
# environment:
|
||||
# - POSTGRES_DB=overflow
|
||||
# - POSTGRES_USER=overflow
|
||||
# - POSTGRES_PASSWORD=qwer5795
|
||||
# # - POSTGRES_INITDB_ARGS="--data-checksums"
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
|
||||
# docker-compose up -d
|
||||
# docker-compose stop
|
||||
# docker-compose rm
|
||||
# or
|
||||
# docker-compose -f ./docker-compose.yml up -d
|
9
build/docker/bin/docker-entrypoint.sh
Normal file
9
build/docker/bin/docker-entrypoint.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd /service
|
||||
|
||||
/usr/bin/java -classpath ${APP_CONF_PATH}/:${APP_FILENAME}:lib/* ${APP_MAIN_CLASS} 50006
|
||||
|
||||
exec "$@"
|
3
build/docker/conf/cache.properties
Normal file
3
build/docker/conf/cache.properties
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Caffeine
|
||||
cache.cache-names:memberListByDomain,memberListByProbeKey
|
||||
cache.caffeine.spec: initialCapacity=100,maximumSize=500,expireAfterAccess=5m,recordStats
|
11
build/docker/conf/database.properties
Normal file
11
build/docker/conf/database.properties
Normal file
|
@ -0,0 +1,11 @@
|
|||
datasource.url=jdbc:postgresql://192.168.1.50:5432/overflow
|
||||
datasource.username=overflow
|
||||
datasource.password=qwer5795
|
||||
datasource.driver-class-name=org.postgresql.Driver
|
||||
|
||||
jpa.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
|
||||
jpa.database=postgresql
|
||||
jpa.hibernate.ddl-auto=create
|
||||
#jpa.hibernate.ddl-auto=update
|
||||
jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
|
||||
jpa.show-sql=true
|
34
build/docker/conf/logback.xml
Normal file
34
build/docker/conf/logback.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="3 seconds">
|
||||
<contextName>central</contextName>
|
||||
|
||||
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- rollover daily -->
|
||||
<fileNamePattern>central-%d{yyyy-MM-dd'T'HH:mm}.%i.log.zip</fileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>1024kb</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<Pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- TRACE > DEBUG > INFO > WARN > ERROR -->
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="ROLLING" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<logger name="com.loafle.overflow" level="ALL" />
|
||||
</configuration>
|
14
build/docker/conf/mail.properties
Normal file
14
build/docker/conf/mail.properties
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Naver SMTP
|
||||
mail.host=smtp.worksmobile.com
|
||||
mail.port=465
|
||||
mail.username=geek@loafle.com
|
||||
mail.password=@loafle@5795
|
||||
mail.protocol=smtps
|
||||
|
||||
mail.properties.mail.smtp.auth=true
|
||||
mail.transport.protocol=smtp
|
||||
mail.properties.mail.smtp.starttls.enable=true
|
||||
mail.smtps.ssl.checkserveridentity=true
|
||||
mail.smtps.ssl.trust=*
|
||||
|
||||
|
4
build/docker/conf/redis.properties
Normal file
4
build/docker/conf/redis.properties
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Redis
|
||||
redis.host=192.168.1.50
|
||||
redis.port=6379
|
||||
redis.channels=/webapp,/probe,/auth
|
6
build/docker/conf/velocity.properties
Normal file
6
build/docker/conf/velocity.properties
Normal file
|
@ -0,0 +1,6 @@
|
|||
resource.loader=jar
|
||||
jar.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
|
||||
jar.runtime.log.logsystem.class=org.apache.velocity.runtime.log.SimpleLog4JLogSystem
|
||||
jar.runtime.log.logsystem.log4j.category=velocity
|
||||
jar.resource.loader.cache=true
|
||||
input.encoding=UTF-8
|
361
pom.xml
Normal file
361
pom.xml
Normal file
|
@ -0,0 +1,361 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.loafle</groupId>
|
||||
<artifactId>maven_parent_jar</artifactId>
|
||||
<version>1.0.0-RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>central</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>com.loafle.overflow.central</name>
|
||||
|
||||
<properties>
|
||||
<grpc.version>1.2.0</grpc.version>
|
||||
<jedis.version>2.9.0</jedis.version>
|
||||
<caffeine.version>2.5.6</caffeine.version>
|
||||
<protoc.version>3.2.0</protoc.version>
|
||||
<spring.version>4.3.9.RELEASE</spring.version>
|
||||
<spring.data.jpa.version>1.11.4.RELEASE</spring.data.jpa.version>
|
||||
<spring.data.redis.version>1.8.7.RELEASE</spring.data.redis.version>
|
||||
<spring.crypto.version>4.2.3.RELEASE</spring.crypto.version>
|
||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
||||
<javax.mail.version>1.4.7</javax.mail.version>
|
||||
<javax.mail-api.version>1.6.0</javax.mail-api.version>
|
||||
<jackson.mapper.version>1.9.13</jackson.mapper.version>
|
||||
<apache.velocity.version>1.7</apache.velocity.version>
|
||||
<docker.registry.name>docker.loafle.net/overflow</docker.registry.name>
|
||||
<googleauth.version>1.1.2</googleauth.version>
|
||||
<fasterxml.uuid.verion>3.1.5</fasterxml.uuid.verion>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-protobuf</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-stub</artifactId>
|
||||
<version>${grpc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Dependency-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-jpa</artifactId>
|
||||
<version>${spring.data.jpa.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
<version>${spring.data.redis.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.4-1200-jdbc41</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>${jackson.mapper.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-entitymanager</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-crypto -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
<version>${spring.crypto.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mail -->
|
||||
<!-- https://mvnrepository.com/artifact/javax.mail/mail -->
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>${javax.mail.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>${javax.mail-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity</artifactId>
|
||||
<version>${apache.velocity.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
<version>${caffeine.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.loafle</groupId>
|
||||
<artifactId>overflow_api_server</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>crawler</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.warrenstrange</groupId>
|
||||
<artifactId>googleauth</artifactId>
|
||||
<version>${googleauth.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.uuid</groupId>
|
||||
<artifactId>java-uuid-generator</artifactId>
|
||||
<version>${fasterxml.uuid.verion}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/${environment}</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</testResource>
|
||||
</testResources>
|
||||
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.5.0.Final</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
|
||||
<plugins>
|
||||
<!-- Copy Maven dependencies into target/lib/ -->
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<includeScope>runtime</includeScope>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.xolstice.maven.plugins</groupId>
|
||||
<artifactId>protobuf-maven-plugin</artifactId>
|
||||
<version>0.5.0</version>
|
||||
<configuration>
|
||||
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
<goal>compile-custom</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>${protoc.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>1.25.322</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jsonLibrary>jackson2</jsonLibrary>
|
||||
<classPatterns>
|
||||
<classPattern>com.loafle.overflow.central.module.**.model.*</classPattern>
|
||||
</classPatterns>
|
||||
<outputKind>module</outputKind>
|
||||
<outputFileType>implementationFile</outputFileType>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.loafle.overflow.central.Central</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
||||
<version>1.3.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>build</id>
|
||||
<goals>
|
||||
<goal>build</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>com.loafle.overflow.central.Central</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<repository>${docker.registry.name}/${project.artifactId}</repository>
|
||||
<tag>${project.version}</tag>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!--<artifactId>maven-assembly-plugin</artifactId>-->
|
||||
<!--<version>2.2.1</version>-->
|
||||
<!--<configuration>-->
|
||||
<!--<descriptorRefs>-->
|
||||
<!--<descriptorRef>jar-with-dependencies</descriptorRef>-->
|
||||
<!--</descriptorRefs>-->
|
||||
<!--</configuration>-->
|
||||
<!--</plugin>-->
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<environment>local</environment>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>development</id>
|
||||
<properties>
|
||||
<environment>development</environment>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>staging</id>
|
||||
<properties>
|
||||
<environment>staging</environment>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>production</id>
|
||||
<properties>
|
||||
<environment>production</environment>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
21
src/main/java/com/loafle/overflow/central/Central.java
Normal file
21
src/main/java/com/loafle/overflow/central/Central.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package com.loafle.overflow.central;
|
||||
|
||||
import com.loafle.overflow.central.proxy.ServiceProxy;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Central {
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
if(args.length <= 0) {
|
||||
System.out.println("Port args");
|
||||
System.out.println("first parameter is Port Number");
|
||||
return;
|
||||
}
|
||||
|
||||
int port = Integer.valueOf(args[0]);
|
||||
|
||||
final ServiceProxy server = new ServiceProxy();
|
||||
server.start(port);
|
||||
server.blockUntilShutdown();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.loafle.overflow.central.commons.exception;
|
||||
|
||||
import io.grpc.Status;
|
||||
|
||||
public class OverflowException extends Exception {
|
||||
protected Status.Code code;
|
||||
|
||||
public OverflowException(Status.Code code) {
|
||||
super();
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public OverflowException(Status.Code code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Status.Code getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.central.commons.exception;
|
||||
|
||||
public class OverflowRuntimeException extends RuntimeException {
|
||||
public OverflowRuntimeException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public OverflowRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.loafle.overflow.central.commons.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 1. 3.
|
||||
*/
|
||||
public class Mail {
|
||||
private String mailFrom;
|
||||
|
||||
private String mailTo;
|
||||
|
||||
private String mailCc;
|
||||
|
||||
private String mailBcc;
|
||||
|
||||
private String mailSubject;
|
||||
|
||||
private String mailContent;
|
||||
|
||||
private String contentType;
|
||||
|
||||
private List< Object > attachments;
|
||||
|
||||
private Map< String, Object > model;
|
||||
|
||||
public Mail() {
|
||||
contentType = "text/plain";
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public void setContentType(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
public String getMailBcc() {
|
||||
return mailBcc;
|
||||
}
|
||||
|
||||
public void setMailBcc(String mailBcc) {
|
||||
this.mailBcc = mailBcc;
|
||||
}
|
||||
|
||||
public String getMailCc() {
|
||||
return mailCc;
|
||||
}
|
||||
|
||||
public void setMailCc(String mailCc) {
|
||||
this.mailCc = mailCc;
|
||||
}
|
||||
|
||||
public String getMailFrom() {
|
||||
return mailFrom;
|
||||
}
|
||||
|
||||
public void setMailFrom(String mailFrom) {
|
||||
this.mailFrom = mailFrom;
|
||||
}
|
||||
|
||||
public String getMailSubject() {
|
||||
return mailSubject;
|
||||
}
|
||||
|
||||
public void setMailSubject(String mailSubject) {
|
||||
this.mailSubject = mailSubject;
|
||||
}
|
||||
|
||||
public String getMailTo() {
|
||||
return mailTo;
|
||||
}
|
||||
|
||||
public void setMailTo(String mailTo) {
|
||||
this.mailTo = mailTo;
|
||||
}
|
||||
|
||||
public Date getMailSendDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
public String getMailContent() {
|
||||
return mailContent;
|
||||
}
|
||||
|
||||
public void setMailContent(String mailContent) {
|
||||
this.mailContent = mailContent;
|
||||
}
|
||||
|
||||
public List< Object > getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void setAttachments(List < Object > attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public Map< String, Object > getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(Map < String, Object > model) {
|
||||
this.model = model;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.loafle.overflow.central.commons.model;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 8. 25.
|
||||
*/
|
||||
public class PageParams {
|
||||
|
||||
private int pageNo;
|
||||
private int countPerPage;
|
||||
private String sortCol;
|
||||
private String sortDirection;
|
||||
|
||||
public int getPageNo() {
|
||||
return pageNo;
|
||||
}
|
||||
|
||||
public void setPageNo(int pageNo) {
|
||||
this.pageNo = pageNo;
|
||||
}
|
||||
|
||||
public int getCountPerPage() {
|
||||
return countPerPage;
|
||||
}
|
||||
|
||||
public void setCountPerPage(int countPerPage) {
|
||||
this.countPerPage = countPerPage;
|
||||
}
|
||||
|
||||
public String getSortCol() {
|
||||
return sortCol;
|
||||
}
|
||||
|
||||
public void setSortCol(String sortCol) {
|
||||
this.sortCol = sortCol;
|
||||
}
|
||||
|
||||
public String getSortDirection() {
|
||||
return sortDirection;
|
||||
}
|
||||
|
||||
public void setSortDirection(String sortDirection) {
|
||||
this.sortDirection = sortDirection;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package com.loafle.overflow.central.commons.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PublishMessage {
|
||||
private TargetType targetType;
|
||||
private List<String> targets;
|
||||
private PublishMessageBody message;
|
||||
|
||||
public void setTargetType(TargetType targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
public TargetType getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
public void setTargets(List<String> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public void addTarget(String target) {
|
||||
if (null == targets) {
|
||||
targets = new ArrayList<>();
|
||||
}
|
||||
targets.add(target);
|
||||
}
|
||||
|
||||
public List<String> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setMessage(PublishMessageBody message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public PublishMessageBody getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static enum TargetType {
|
||||
MEMBER_SESSION("MEMBER_SESSION"),
|
||||
MEMBER("MEMBER"),
|
||||
PROBE("PROBE");
|
||||
|
||||
final private String name;
|
||||
|
||||
private TargetType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PublishMessageBody {
|
||||
private String jsonrpc = "2.0";
|
||||
private PublishMessageBodyNotification result;
|
||||
|
||||
public PublishMessageBody() {
|
||||
this.result = new PublishMessageBodyNotification();
|
||||
|
||||
}
|
||||
public PublishMessageBody(String method) {
|
||||
this();
|
||||
this.result.setMethod(method);
|
||||
}
|
||||
public PublishMessageBody(String method, List<String> params) {
|
||||
this(method);
|
||||
this.result.setParams(params);
|
||||
}
|
||||
|
||||
public String getJsonrpc() {
|
||||
return jsonrpc;
|
||||
}
|
||||
|
||||
public void setJsonrpc(String jsonrpc) {
|
||||
this.jsonrpc = jsonrpc;
|
||||
}
|
||||
|
||||
public PublishMessageBodyNotification getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(PublishMessageBodyNotification result) {
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PublishMessageBodyNotification {
|
||||
private String method;
|
||||
private List<String> params;
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public List<String> getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(List<String> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public void addParams(String param) {
|
||||
if (null == this.params) {
|
||||
this.params = new ArrayList<>();
|
||||
}
|
||||
this.params.add(param);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.loafle.overflow.central.commons.model;
|
||||
|
||||
import io.grpc.Context;
|
||||
import io.grpc.Metadata;
|
||||
|
||||
import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
|
||||
|
||||
public class SessionMetadata {
|
||||
/*
|
||||
digits: 0-9
|
||||
uppercase letters: A-Z (normalized to lower)
|
||||
lowercase letters: a-z
|
||||
special characters: -_.
|
||||
*/
|
||||
|
||||
public static final String CLIENT_TYPE_KEY = "OVERFLOW_GRPC_CLIENT_TYPE";
|
||||
public static final String SESSION_ID_KEY = "OVERFLOW_GRPC_SESSION_ID";
|
||||
public static final String TARGET_ID_KEY = "OVERFLOW_GRPC_TARGET_ID";
|
||||
|
||||
public static final Context.Key<String> CTX_CLIENT_TYPE_KEY = Context.key(CLIENT_TYPE_KEY);
|
||||
public static final Context.Key<String> CTX_SESSION_ID_KEY = Context.key(SESSION_ID_KEY);
|
||||
public static final Context.Key<String> CTX_TARGET_ID_KEY = Context.key(TARGET_ID_KEY);
|
||||
|
||||
public static final Metadata.Key<String> METADATA_CLIENT_TYPE_KEY = Metadata.Key.of(CLIENT_TYPE_KEY, ASCII_STRING_MARSHALLER);
|
||||
public static final Metadata.Key<String> METADATA_SESSION_ID_KEY = Metadata.Key.of(SESSION_ID_KEY, ASCII_STRING_MARSHALLER);
|
||||
public static final Metadata.Key<String> METADATA_TARGET_ID_KEY = Metadata.Key.of(TARGET_ID_KEY, ASCII_STRING_MARSHALLER);
|
||||
|
||||
public static ClientType getClientType() {
|
||||
return ClientType.valueOf(CTX_CLIENT_TYPE_KEY.get());
|
||||
}
|
||||
public static String getSessionID() {
|
||||
return CTX_SESSION_ID_KEY.get();
|
||||
}
|
||||
public static String getTargetID() {
|
||||
return CTX_TARGET_ID_KEY.get();
|
||||
}
|
||||
|
||||
public static enum ClientType {
|
||||
MEMBER("MEMBER"),
|
||||
PROBE("PROBE");
|
||||
|
||||
final private String name;
|
||||
|
||||
private ClientType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.commons.service;
|
||||
|
||||
public interface MessagePublisher {
|
||||
void publishToDomainMembers(final long domainID, final String method, final Object... params);
|
||||
void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params);
|
||||
|
||||
void publishToMember(final String memberID, final String method, final Object... params);
|
||||
void publishToMemberSession(final String memberSessionID, final String method, final Object... params);
|
||||
|
||||
void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params);
|
||||
void publishToProbe(final String probeKey, final String method, final Object... params);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.central.commons.stereotype;
|
||||
|
||||
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 ProbeAPI {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.central.commons.stereotype;
|
||||
|
||||
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 WebappAPI {
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.loafle.overflow.central.commons.utils;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.Mail;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.ui.velocity.VelocityEngineUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 30.
|
||||
*/
|
||||
@Service("EmailSender")
|
||||
public class EmailSender {
|
||||
|
||||
@Autowired
|
||||
private JavaMailSender mailSender;
|
||||
|
||||
@Autowired
|
||||
private VelocityEngine velocityEngine;
|
||||
|
||||
private String key = "loafle@RandomKey";
|
||||
private String initVector = "loafleInitVector";
|
||||
|
||||
|
||||
public void sendSimpleEmail(Mail mail) throws MailException {
|
||||
|
||||
SimpleMailMessage message1 = new SimpleMailMessage();
|
||||
message1.setTo(mail.getMailTo());
|
||||
message1.setSubject(mail.getMailSubject());
|
||||
message1.setText(getContentFromTemplate(mail.getModel()));
|
||||
message1.setFrom("geek@loafle.com");
|
||||
|
||||
mailSender.send(message1);
|
||||
}
|
||||
|
||||
public void sendMailWithAttachment(Mail mail) throws MessagingException {
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
// pass 'true' to the constructor to create a multipart message
|
||||
MimeMessageHelper helper = new MimeMessageHelper(message, true);
|
||||
|
||||
helper.setTo(mail.getMailTo());
|
||||
helper.setSubject(mail.getMailSubject());
|
||||
helper.setText(mail.getMailContent());
|
||||
helper.setFrom("geek@loafle.com");
|
||||
// FileSystemResource file = new FileSystemResource(new File(mail.getAttachments()));
|
||||
// helper.addAttachment("Invoice", file);
|
||||
|
||||
mailSender.send(message);
|
||||
}
|
||||
|
||||
public String encrypt(String value) {
|
||||
try {
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
||||
|
||||
byte[] encrypted = cipher.doFinal(value.getBytes());
|
||||
System.out.println("encrypted string: "
|
||||
+ Base64.encodeBase64String(encrypted));
|
||||
|
||||
return Base64.encodeBase64String(encrypted);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String decrypt(String encrypted) {
|
||||
try {
|
||||
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
|
||||
|
||||
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
|
||||
|
||||
return new String(original);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getContentFromTemplate(Map<String, Object> model) {
|
||||
StringBuffer content = new StringBuffer();
|
||||
try {
|
||||
content.append(VelocityEngineUtils.mergeTemplateIntoString(velocityEngine,"/templates/email-template.vm", "UTF-8", model));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.commons.utils;
|
||||
|
||||
import com.fasterxml.uuid.EthernetAddress;
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import com.fasterxml.uuid.impl.TimeBasedGenerator;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 27.
|
||||
*/
|
||||
public class GenerateKey {
|
||||
private static TimeBasedGenerator generator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
|
||||
|
||||
public static synchronized String getKey() {
|
||||
|
||||
String[] uuids = generator.generate().toString().split("-");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
for ( int idx = 0; idx < uuids.length; idx++ ) {
|
||||
sb.append(uuids[idx]);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.commons.utils;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.PageParams;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 8. 25.
|
||||
*/
|
||||
public class PageUtil {
|
||||
private static Sort.Direction getSortDirection(String sortDirection) {
|
||||
if(sortDirection.equalsIgnoreCase("ascending")) {
|
||||
return Sort.Direction.ASC;
|
||||
}
|
||||
return Sort.Direction.DESC;
|
||||
}
|
||||
|
||||
public static PageRequest getPageRequest(PageParams pageParams) {
|
||||
if(pageParams.getSortCol().isEmpty()) pageParams.setSortCol("id");
|
||||
if(pageParams.getSortDirection().isEmpty()) pageParams.setSortDirection("descending");
|
||||
|
||||
return new PageRequest(pageParams.getPageNo(), pageParams.getCountPerPage(),
|
||||
new Sort(PageUtil.getSortDirection(pageParams.getSortDirection()), pageParams.getSortCol()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.loafle.overflow.central.commons.utils;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 23.
|
||||
*/
|
||||
public class StringConvertor {
|
||||
|
||||
public static String intToIp(long i) {
|
||||
return ((i >> 24 ) & 0xFF) + "." +
|
||||
((i >> 16 ) & 0xFF) + "." +
|
||||
((i >> 8 ) & 0xFF) + "." +
|
||||
( i & 0xFF);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.loafle.overflow.central.module.apikey.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.apikey.model.ApiKey;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 1.
|
||||
*/
|
||||
@Repository
|
||||
public interface ApiKeyDAO extends JpaRepository<ApiKey, Long> {
|
||||
|
||||
ApiKey findByApiKey(String apiKey);
|
||||
|
||||
ApiKey findByDomain(Domain domain);
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.loafle.overflow.central.module.apikey.model;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "API_KEY", schema = "public")
|
||||
public class ApiKey {
|
||||
private long id;
|
||||
private String apiKey;
|
||||
private Date createDate;
|
||||
private Domain domain;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "API_KEY", nullable = false, unique = true,length = 50)
|
||||
public String getApiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
public void setApiKey(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name="CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DOMAIN_ID", nullable=false)
|
||||
public Domain getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public boolean equals(Object o) {
|
||||
// if (this == o) return true;
|
||||
// if (o == null || getClass() != o.getClass()) return false;
|
||||
//
|
||||
// TblApiKey tblApiKey = (TblApiKey) o;
|
||||
//
|
||||
// if (id != tblApiKey.id) return false;
|
||||
// if (domainId != tblApiKey.domainId) return false;
|
||||
// if (apiKey != null ? !apiKey.equals(tblApiKey.apiKey) : tblApiKey.apiKey != null) return false;
|
||||
// if (createDate != null ? !createDate.equals(tblApiKey.createDate) : tblApiKey.createDate != null) return false;
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int hashCode() {
|
||||
// int result = (int) (id ^ (id >>> 32));
|
||||
// result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0);
|
||||
// result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
|
||||
// result = 31 * result + (int) (domainId ^ (domainId >>> 32));
|
||||
// return result;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.loafle.overflow.central.module.apikey.service;
|
||||
|
||||
import com.loafle.overflow.central.module.apikey.dao.ApiKeyDAO;
|
||||
import com.loafle.overflow.central.module.apikey.model.ApiKey;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
@Service("ApiKeyService")
|
||||
public class ApiKeyService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ApiKeyDAO apiKeyDAO;
|
||||
|
||||
|
||||
public ApiKey regist(ApiKey apiKey) {
|
||||
|
||||
return this.apiKeyDAO.save(apiKey);
|
||||
}
|
||||
|
||||
public ApiKey readByDomain(Domain domain) {
|
||||
return this.apiKeyDAO.findByDomain(domain);
|
||||
}
|
||||
|
||||
public boolean check(String apiKey) {
|
||||
|
||||
ApiKey retApiKey = this.apiKeyDAO.findByApiKey(apiKey);
|
||||
|
||||
if(retApiKey == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ApiKey readByApiKey(String apiKey) {
|
||||
return this.apiKeyDAO.findByApiKey(apiKey);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.loafle.overflow.central.module.auth.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Repository
|
||||
public interface AuthCrawlerDAO extends JpaRepository<AuthCrawler, Long> {
|
||||
AuthCrawler findByCrawlerAndTarget(MetaCrawler metaCrawler, Target target);
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.loafle.overflow.central.module.auth.model;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "AUTH_CRAWLER", schema = "public")
|
||||
public class AuthCrawler {
|
||||
private long id;
|
||||
private MetaCrawler crawler;
|
||||
private Target target;
|
||||
private String authJson;
|
||||
private Date createDate;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CRAWLER_ID", nullable = false)
|
||||
public MetaCrawler getCrawler() {
|
||||
return crawler;
|
||||
}
|
||||
|
||||
public void setCrawler(MetaCrawler crawler) {
|
||||
this.crawler = crawler;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@JoinColumn(name = "TARGET_ID", nullable = false)
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(Target target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Column(name = "AUTH_JSON", nullable = false)
|
||||
public String getAuthJson() {
|
||||
return authJson;
|
||||
}
|
||||
|
||||
public void setAuthJson(String authJson) {
|
||||
this.authJson = authJson;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.loafle.overflow.central.module.auth.service;
|
||||
|
||||
import com.loafle.overflow.central.module.auth.dao.AuthCrawlerDAO;
|
||||
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.infra.service.InfraService;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 30.
|
||||
*/
|
||||
@Service("AuthCrawlerService")
|
||||
public class AuthCrawlerService {
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerDAO authCrawlerDAO;
|
||||
|
||||
@Autowired
|
||||
private InfraService infraService;
|
||||
|
||||
public AuthCrawler regist(AuthCrawler authCrawler) {
|
||||
|
||||
AuthCrawler dbAuthCrawler = this.authCrawlerDAO.findByCrawlerAndTarget(authCrawler.getCrawler(), authCrawler.getTarget());
|
||||
|
||||
if(authCrawler == null) {
|
||||
return this.authCrawlerDAO.save(authCrawler);
|
||||
}
|
||||
|
||||
dbAuthCrawler.setAuthJson(authCrawler.getAuthJson());
|
||||
dbAuthCrawler.setCrawler(authCrawler.getCrawler());
|
||||
dbAuthCrawler.setTarget(authCrawler.getTarget());
|
||||
|
||||
return this.authCrawlerDAO.save(dbAuthCrawler);
|
||||
}
|
||||
|
||||
public boolean checkAuthCrawler(long infraId, MetaCrawler crawler, String authJson) {
|
||||
|
||||
Infra infra = this.infraService.read(infraId);
|
||||
|
||||
// FIXME: Check Crawler on Probe
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public AuthCrawler readAuth(MetaCrawler metaCrawler, Target target) {
|
||||
|
||||
return this.authCrawlerDAO.findByCrawlerAndTarget(metaCrawler, target);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryHost {
|
||||
private String firstScanRange;
|
||||
private String lastScanRange;
|
||||
private List<String> excludeHosts;
|
||||
private List<String> includeHosts;
|
||||
|
||||
private DiscoveryPort discoveryPort;
|
||||
|
||||
public String getFirstScanRange() {
|
||||
return firstScanRange;
|
||||
}
|
||||
|
||||
public void setFirstScanRange(String firstScanRange) {
|
||||
this.firstScanRange = firstScanRange;
|
||||
}
|
||||
|
||||
public String getLastScanRange() {
|
||||
return lastScanRange;
|
||||
}
|
||||
|
||||
public void setLastScanRange(String lastScanRange) {
|
||||
this.lastScanRange = lastScanRange;
|
||||
}
|
||||
|
||||
public List<String> getExcludeHosts() {
|
||||
return excludeHosts;
|
||||
}
|
||||
|
||||
public void setExcludeHosts(List<String> excludeHosts) {
|
||||
this.excludeHosts = excludeHosts;
|
||||
}
|
||||
|
||||
public List<String> getIncludeHosts() {
|
||||
return includeHosts;
|
||||
}
|
||||
|
||||
public void setIncludeHosts(List<String> includeHosts) {
|
||||
this.includeHosts = includeHosts;
|
||||
}
|
||||
|
||||
public DiscoveryPort getDiscoveryPort() {
|
||||
return discoveryPort;
|
||||
}
|
||||
|
||||
public void setDiscoveryPort(DiscoveryPort discoveryPort) {
|
||||
this.discoveryPort = discoveryPort;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryPort {
|
||||
private int firstScanRange;
|
||||
private int lastScanRange;
|
||||
private List<Integer> excludePorts;
|
||||
private boolean includeTCP;
|
||||
private boolean includeUDP;
|
||||
|
||||
private DiscoveryService discoveryService;
|
||||
|
||||
public int getFirstScanRange() {
|
||||
return firstScanRange;
|
||||
}
|
||||
|
||||
public void setFirstScanRange(int firstScanRange) {
|
||||
this.firstScanRange = firstScanRange;
|
||||
}
|
||||
|
||||
public int getLastScanRange() {
|
||||
return lastScanRange;
|
||||
}
|
||||
|
||||
public void setLastScanRange(int lastScanRange) {
|
||||
this.lastScanRange = lastScanRange;
|
||||
}
|
||||
|
||||
public List<Integer> getExcludePorts() {
|
||||
return excludePorts;
|
||||
}
|
||||
|
||||
public void setExcludePorts(List<Integer> excludePorts) {
|
||||
this.excludePorts = excludePorts;
|
||||
}
|
||||
|
||||
public boolean isIncludeTCP() {
|
||||
return includeTCP;
|
||||
}
|
||||
|
||||
public void setIncludeTCP(boolean includeTCP) {
|
||||
this.includeTCP = includeTCP;
|
||||
}
|
||||
|
||||
public boolean isIncludeUDP() {
|
||||
return includeUDP;
|
||||
}
|
||||
|
||||
public void setIncludeUDP(boolean includeUDP) {
|
||||
this.includeUDP = includeUDP;
|
||||
}
|
||||
|
||||
public DiscoveryService getDiscoveryService() {
|
||||
return discoveryService;
|
||||
}
|
||||
|
||||
public void setDiscoveryService(DiscoveryService discoveryService) {
|
||||
this.discoveryService = discoveryService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryService {
|
||||
private List<String> includeServices;
|
||||
|
||||
public List<String> getIncludeServices() {
|
||||
return includeServices;
|
||||
}
|
||||
|
||||
public void setIncludeServices(List<String> includeServices) {
|
||||
this.includeServices = includeServices;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 29.
|
||||
*/
|
||||
public class DiscoveryStartInfo {
|
||||
String startIp;
|
||||
String endIP;
|
||||
String excludeIp;
|
||||
String startPort;
|
||||
String endPort;
|
||||
List<String> services;
|
||||
|
||||
public String getStartIp() {
|
||||
return startIp;
|
||||
}
|
||||
|
||||
public void setStartIp(String startIp) {
|
||||
this.startIp = startIp;
|
||||
}
|
||||
|
||||
public String getEndIP() {
|
||||
return endIP;
|
||||
}
|
||||
|
||||
public void setEndIP(String endIP) {
|
||||
this.endIP = endIP;
|
||||
}
|
||||
|
||||
public String getExcludeIp() {
|
||||
return excludeIp;
|
||||
}
|
||||
|
||||
public void setExcludeIp(String excludeIp) {
|
||||
this.excludeIp = excludeIp;
|
||||
}
|
||||
|
||||
public String getStartPort() {
|
||||
return startPort;
|
||||
}
|
||||
|
||||
public void setStartPort(String startPort) {
|
||||
this.startPort = startPort;
|
||||
}
|
||||
|
||||
public String getEndPort() {
|
||||
return endPort;
|
||||
}
|
||||
|
||||
public void setEndPort(String endPort) {
|
||||
this.endPort = endPort;
|
||||
}
|
||||
|
||||
public List<String> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<String> services) {
|
||||
this.services = services;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryZone {
|
||||
private List<String> excludePatterns;
|
||||
|
||||
private DiscoveryHost discoveryHost;
|
||||
|
||||
public List<String> getExcludePatterns() {
|
||||
return excludePatterns;
|
||||
}
|
||||
|
||||
public void setExcludePatterns(List<String> excludePatterns) {
|
||||
this.excludePatterns = excludePatterns;
|
||||
}
|
||||
|
||||
public DiscoveryHost getDiscoveryHost() {
|
||||
return discoveryHost;
|
||||
}
|
||||
|
||||
public void setDiscoveryHost(DiscoveryHost discoveryHost) {
|
||||
this.discoveryHost = discoveryHost;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
|
||||
public class Host {
|
||||
private long id;
|
||||
private String ip;
|
||||
private String mac;
|
||||
private String os;
|
||||
private Date discoveredDate;
|
||||
|
||||
private Zone zone;
|
||||
|
||||
public Host(){}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(String os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Zone getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 27.
|
||||
*/
|
||||
|
||||
|
||||
import com.loafle.overflow.central.module.discovery.type.PortType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
|
||||
public class Port {
|
||||
|
||||
|
||||
private long id;
|
||||
private PortType portType;
|
||||
private int portNumber;
|
||||
private Date discoveredDate;
|
||||
|
||||
private Host host;
|
||||
|
||||
public Port() {}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PortType getPortType() {
|
||||
return portType;
|
||||
}
|
||||
|
||||
public void setPortType(PortType portType) {
|
||||
this.portType = portType;
|
||||
}
|
||||
|
||||
public int getPortNumber() {
|
||||
return portNumber;
|
||||
}
|
||||
|
||||
public void setPortNumber(int portNumber) {
|
||||
this.portNumber = portNumber;
|
||||
}
|
||||
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Host getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(Host host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
|
||||
public class Service {
|
||||
private long id;
|
||||
private String cryptoType;
|
||||
private String serviceName;
|
||||
private Date discoveredDate;
|
||||
|
||||
private Port port;
|
||||
|
||||
public Service() {}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCryptoType() {
|
||||
return cryptoType;
|
||||
}
|
||||
|
||||
public void setCryptoType(String cryptoType) {
|
||||
this.cryptoType = cryptoType;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Port getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Port port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.loafle.overflow.central.module.discovery.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 10. 31.
|
||||
*/
|
||||
public class Zone {
|
||||
private long id;
|
||||
private String network;
|
||||
private String ip;
|
||||
private String iface;
|
||||
private String mac;
|
||||
private Date discoveredDate;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNetwork() {
|
||||
return network;
|
||||
}
|
||||
|
||||
public void setNetwork(String network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getIface() {
|
||||
return iface;
|
||||
}
|
||||
|
||||
public void setIface(String iface) {
|
||||
this.iface = iface;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package com.loafle.overflow.central.module.discovery.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.SessionMetadata;
|
||||
import com.loafle.overflow.central.commons.service.MessagePublisher;
|
||||
import com.loafle.overflow.central.commons.stereotype.ProbeAPI;
|
||||
import com.loafle.overflow.central.commons.stereotype.WebappAPI;
|
||||
import com.loafle.overflow.central.module.discovery.model.DiscoveryHost;
|
||||
import com.loafle.overflow.central.module.discovery.model.DiscoveryPort;
|
||||
import com.loafle.overflow.central.module.discovery.model.DiscoveryStartInfo;
|
||||
import com.loafle.overflow.central.module.discovery.model.DiscoveryZone;
|
||||
import com.loafle.overflow.central.module.discovery.model.Host;
|
||||
import com.loafle.overflow.central.module.discovery.model.Port;
|
||||
import com.loafle.overflow.central.module.discovery.model.Zone;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 28.
|
||||
*/
|
||||
@Service("DiscoveryService")
|
||||
public class DiscoveryService {
|
||||
|
||||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
public void startDiscovery(DiscoveryStartInfo startInfo) throws IOException {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
String json = objectMapper.writeValueAsString(startInfo);
|
||||
|
||||
System.out.println("Start Discovery");
|
||||
System.out.println(json);
|
||||
// this.messagePublisher.publishToProbe("/auth", noAuthProbe.getTempProbeKey(), "NoAuthProbeService.acceptNoAuthProbe", probe.getProbeKey());
|
||||
}
|
||||
|
||||
// public boolean testDiscovery(int types, String obj) {
|
||||
|
||||
// Domain domain = new Domain();
|
||||
// domain.setId(1);
|
||||
|
||||
// // int typeInt = Integer.valueOf(types);
|
||||
// switch (types) {
|
||||
// case 1 :
|
||||
// messagePublisher.publishToDomainMembers(domain, "DiscoveryService.discoveryIngHost", obj);
|
||||
// break;
|
||||
// case 2 :
|
||||
// messagePublisher.publishToDomain("/webapp", domain, "DiscoveryService.discoveryIngPort", obj);
|
||||
// break;
|
||||
// case 3 :
|
||||
// messagePublisher.publishToDomain("/webapp", domain, "DiscoveryService.discoveryIngService", obj);
|
||||
// break;
|
||||
// }
|
||||
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@WebappAPI
|
||||
public void discoverZone(String probeID, DiscoveryZone discoveryZone) {
|
||||
String requesterSessionID = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverZone", requesterSessionID, discoveryZone);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverHost(String probeID, Zone zone, DiscoveryHost discoveryHost) {
|
||||
String requesterSessionID = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverHost", requesterSessionID, zone, discoveryHost);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverPort(String probeID, Host host, DiscoveryPort discoveryPort) {
|
||||
String requesterSessionID = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverPort", requesterSessionID, host, discoveryPort);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverService(String probeID, Port port, com.loafle.overflow.central.module.discovery.model.DiscoveryService discoveryService) {
|
||||
String requesterSessionID = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe(probeID, "DiscoveryService.DiscoverService", requesterSessionID, port, discoveryService);
|
||||
}
|
||||
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredZone(String requesterSessionID, Zone zone) {
|
||||
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredZone", zone);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredHost(String requesterSessionID, Host host) {
|
||||
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredHost", host);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredPort(String requesterSessionID, Port port) {
|
||||
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredPort", port);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredService(String requesterSessionID, com.loafle.overflow.central.module.discovery.model.Service service) {
|
||||
messagePublisher.publishToMemberSession(requesterSessionID, "DiscoveryService.discoveredService", service);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.loafle.overflow.central.module.discovery.type;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 27.
|
||||
*/
|
||||
public enum PortType {
|
||||
TCP("TCP"),
|
||||
UDP("UDP"),
|
||||
TLS("TLS");
|
||||
|
||||
private String stringValue;
|
||||
PortType(String string) {stringValue = string;}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.module.domain.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface DomainDAO extends JpaRepository<Domain, Long> {
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.loafle.overflow.central.module.domain.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.domain.model.DomainMember;
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface DomainMemberDAO extends JpaRepository<DomainMember, Long> {
|
||||
|
||||
@Query("SELECT dm from DomainMember dm where dm.member.email = (:email)")
|
||||
DomainMember findByMemberEmail(@Param("email") String email);
|
||||
|
||||
@Query("SELECT dm.domain from DomainMember dm where dm.member = (:member)")
|
||||
Domain findDomainByMember(@Param("member") Member member);
|
||||
|
||||
@Query("SELECT dm.member from DomainMember dm where dm.domain = (:domain)")
|
||||
List<Member> findAllMemberByDomain(@Param("domain") Domain domain);
|
||||
|
||||
@Query("SELECT dm.member from DomainMember dm where dm.domain.id = (:domainID)")
|
||||
List<Member> findAllMemberByDomainID(@Param("domainID") long domainID);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.loafle.overflow.central.module.domain.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "DOMAIN", schema = "public")
|
||||
public class Domain {
|
||||
private long id;
|
||||
private String name;
|
||||
private Date createDate;
|
||||
|
||||
public Domain() {
|
||||
}
|
||||
public Domain(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "NAME", nullable = true, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.loafle.overflow.central.module.domain.model;
|
||||
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "DOMAIN_MEMBER", schema = "public")
|
||||
public class DomainMember {
|
||||
private long id;
|
||||
private Timestamp createDate;
|
||||
private Member member;
|
||||
private Domain domain;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Timestamp getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Timestamp createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MEMBER_ID", nullable = false)
|
||||
public Member getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void setMember(Member member) {
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DOMAIN_ID", nullable = false)
|
||||
public Domain getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.loafle.overflow.central.module.domain.service;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.domain.model.DomainMember;
|
||||
import com.loafle.overflow.central.module.member.dao.MemberDAO;
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
@Service("DomainMemberService")
|
||||
public class DomainMemberService {
|
||||
|
||||
@Autowired
|
||||
private DomainMemberDAO domainMemberDAO;
|
||||
|
||||
@Autowired
|
||||
private MemberDAO memberDAO;
|
||||
|
||||
public void regist(DomainMember domainMember) {
|
||||
this.domainMemberDAO.save(domainMember);
|
||||
}
|
||||
|
||||
public Domain readDomainByMemberID(long id) {
|
||||
Member member = this.memberDAO.findOne(id);
|
||||
return this.domainMemberDAO.findDomainByMember(member);
|
||||
}
|
||||
|
||||
public DomainMember readByMemberEmail(String email) {
|
||||
return this.domainMemberDAO.findByMemberEmail(email);
|
||||
}
|
||||
|
||||
public List<Member> readAllMemberByDomain(Domain domain) {
|
||||
return this.domainMemberDAO.findAllMemberByDomain(domain);
|
||||
}
|
||||
|
||||
public List<Member> readAllMemberByDomainID(final long domainID) {
|
||||
return this.domainMemberDAO.findAllMemberByDomainID(domainID);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.loafle.overflow.central.module.domain.service;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.dao.DomainDAO;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 6. 28.
|
||||
*/
|
||||
@Service("DomainService")
|
||||
public class DomainService {
|
||||
|
||||
@Autowired
|
||||
private DomainDAO domainDAO;
|
||||
|
||||
public void regist(Domain domain) {
|
||||
this.domainDAO.save(domain);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.loafle.overflow.central.module.email.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.email.model.EmailAuth;
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by geek@loafle.com on 17. 6. 6.
|
||||
*/
|
||||
@Repository
|
||||
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
|
||||
EmailAuth findByEmailAuthKey(String emailAuthKey);
|
||||
|
||||
List<EmailAuth> findByMember(Member member);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.email.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 11. 22.
|
||||
*/
|
||||
public class EmailOverAuthException extends OverflowRuntimeException {
|
||||
public EmailOverAuthException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EmailOverAuthException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.loafle.overflow.central.module.email.model;
|
||||
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "EMAIL_AUTH", schema = "public")
|
||||
public class EmailAuth {
|
||||
private long id;
|
||||
private String emailAuthKey;
|
||||
private Date createDate;
|
||||
private Date authConfirmDate;
|
||||
private Member member;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "EMAIL_AUTH_KEY", nullable = true, length = 50)
|
||||
public String getEmailAuthKey() {
|
||||
return emailAuthKey;
|
||||
}
|
||||
|
||||
public void setEmailAuthKey(String emailAuthKey) {
|
||||
this.emailAuthKey = emailAuthKey;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "AUTH_CONFIRM_DATE", nullable = true, insertable = true, updatable = true)
|
||||
public Date getAuthConfirmDate() {
|
||||
return authConfirmDate;
|
||||
}
|
||||
|
||||
public void setAuthConfirmDate(Date authConfirmDate) {
|
||||
this.authConfirmDate = authConfirmDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MEMBER_ID", nullable = false)
|
||||
public Member getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void setMember(Member member) {
|
||||
this.member = member;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
package com.loafle.overflow.central.module.email.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.Mail;
|
||||
import com.loafle.overflow.central.commons.utils.EmailSender;
|
||||
import com.loafle.overflow.central.module.domain.dao.DomainDAO;
|
||||
import com.loafle.overflow.central.module.domain.dao.DomainMemberDAO;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.domain.model.DomainMember;
|
||||
import com.loafle.overflow.central.module.email.dao.EmailAuthDAO;
|
||||
import com.loafle.overflow.central.module.email.exception.EmailOverAuthException;
|
||||
import com.loafle.overflow.central.module.email.model.EmailAuth;
|
||||
import com.loafle.overflow.central.module.member.dao.MemberDAO;
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaMemberStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 6. 28.
|
||||
*/
|
||||
@Service("EmailAuthService")
|
||||
public class EmailAuthService {
|
||||
|
||||
@Autowired
|
||||
private EmailAuthDAO emailAuthDAO;
|
||||
|
||||
@Autowired
|
||||
private MemberDAO memberDAO;
|
||||
|
||||
@Autowired
|
||||
private DomainDAO domainDAO;
|
||||
|
||||
@Autowired
|
||||
private DomainMemberDAO domainMemberDAO;
|
||||
|
||||
@Autowired
|
||||
private EmailSender emailSender;
|
||||
|
||||
|
||||
public EmailAuth sendEmailByMember(long memberId, String memberEmail) throws UnsupportedEncodingException, MailException {
|
||||
|
||||
EmailAuth auth = new EmailAuth();
|
||||
auth.setMember(new Member(memberId));
|
||||
// Todo AuthKey Generation
|
||||
|
||||
String en = emailSender.encrypt(memberEmail);
|
||||
auth.setEmailAuthKey(en);
|
||||
|
||||
String encode = URLEncoder.encode(en, "UTF-8");
|
||||
|
||||
// System.out.println("encode = [" + encode + "]");
|
||||
Mail mail = new Mail();
|
||||
mail.setMailTo(memberEmail);
|
||||
mail.setMailSubject("Confirm Email");
|
||||
mail.setMailContent("http://127.0.0.1:19080/account/check_email?key="+ encode +"\r\nConfirm Email");
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
model.put("firstName", auth.getMember().getName());
|
||||
model.put("lastName", auth.getMember().getCompanyName());
|
||||
model.put("location", "Seoul");
|
||||
model.put("signature", "www.loafle.com");
|
||||
|
||||
mail.setModel(model);
|
||||
emailSender.sendSimpleEmail(mail);
|
||||
|
||||
this.emailAuthDAO.save(auth);
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
public EmailAuth read(long id) {
|
||||
return this.emailAuthDAO.findOne(id);
|
||||
}
|
||||
|
||||
public EmailAuth readByAuthKey(String authKey) throws UnsupportedEncodingException {
|
||||
System.out.println("authKey = [" + authKey + "]");
|
||||
String deStr = URLDecoder.decode(authKey, "UTF-8");
|
||||
System.out.println("deStr = [" + deStr + "]");
|
||||
|
||||
EmailAuth auth = this.emailAuthDAO.findByEmailAuthKey(deStr);
|
||||
|
||||
// Todo Compare email date and current date
|
||||
|
||||
if (auth != null) {
|
||||
|
||||
// Over 12 hours of validity of e-mail authentication.
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
cal.setTime(auth.getCreateDate());
|
||||
cal.add(Calendar.HOUR, 12);
|
||||
Date futureDate = cal.getTime();
|
||||
|
||||
Date nowDate = new Date();
|
||||
|
||||
if (!nowDate.before(futureDate)) {
|
||||
throw new EmailOverAuthException("The authentication expiration time has passed.");
|
||||
}
|
||||
|
||||
auth.setAuthConfirmDate(new Date());
|
||||
this.emailAuthDAO.save(auth);
|
||||
auth.getMember().setStatus(new MetaMemberStatus((short)2));
|
||||
this.memberDAO.save(auth.getMember());
|
||||
|
||||
Domain domain = new Domain();
|
||||
domain.setName(auth.getMember().getCompanyName());
|
||||
Domain domain1 = this.domainDAO.save(domain);
|
||||
|
||||
DomainMember domainMember = new DomainMember();
|
||||
domainMember.setDomain(domain1);
|
||||
domainMember.setMember(auth.getMember());
|
||||
this.domainMemberDAO.save(domainMember);
|
||||
}
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
// dZQgXM1o/Cx48X8DM+6ec/oPfqA2l/LdWtijOZ2EnWk=
|
||||
// dZQgXM1o/Cx48X8DM 6ec/oPfqA2l/LdWtijOZ2EnWk=
|
||||
|
||||
public List<EmailAuth> readByMember(long memberId) {
|
||||
return this.emailAuthDAO.findByMember(new Member(memberId));
|
||||
}
|
||||
|
||||
public EmailAuth modify(EmailAuth emailAuth) {
|
||||
return this.emailAuthDAO.save(emailAuth);
|
||||
}
|
||||
|
||||
// Todo Send Email Refactoring
|
||||
public EmailAuth sendEmailResetPassword(Member member) throws UnsupportedEncodingException, MailException {
|
||||
EmailAuth auth = new EmailAuth();
|
||||
auth.setMember(member);
|
||||
// Todo AuthKey Generation
|
||||
|
||||
String en = emailSender.encrypt(member.getEmail());
|
||||
auth.setEmailAuthKey(en);
|
||||
|
||||
String encode = URLEncoder.encode(en, "UTF-8");
|
||||
|
||||
// System.out.println("encode = [" + encode + "]");
|
||||
Mail mail = new Mail();
|
||||
mail.setMailTo(member.getEmail());
|
||||
mail.setMailSubject("Reset Password Email");
|
||||
mail.setMailContent("http://127.0.0.1:9091/#/account/reset_password?key="+ encode +"\r\nConfirm Email");
|
||||
Map<String, Object> model = new HashMap<>();
|
||||
model.put("firstName", auth.getMember().getName());
|
||||
model.put("lastName", auth.getMember().getCompanyName());
|
||||
model.put("location", "Seoul");
|
||||
model.put("signature", "www.loafle.com");
|
||||
|
||||
mail.setModel(model);
|
||||
emailSender.sendSimpleEmail(mail);
|
||||
|
||||
this.emailAuthDAO.save(auth);
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.crawler.config.Crawler;
|
||||
import com.loafle.overflow.crawler.config.Keys;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService;
|
||||
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("GenerateUtil")
|
||||
public class GenerateUtil {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemKeyService metaSensorItemKeyService;
|
||||
|
||||
|
||||
|
||||
private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null;
|
||||
|
||||
public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler metaCrawler) {
|
||||
|
||||
if(this.mappingMap == null) {
|
||||
this.mappingMap = new HashMap<>();
|
||||
}
|
||||
|
||||
Map<Integer, MetaSensorItemKey> resultMap = this.mappingMap.get(metaCrawler.getId());
|
||||
|
||||
if(resultMap != null) {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
resultMap = this.metaSensorItemKeyService.readAllMapByCrawler(metaCrawler);
|
||||
this.mappingMap.put(metaCrawler.getId(), resultMap);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Crawler getCrawler(MetaCrawler metaCrawler) {
|
||||
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setName(metaCrawler.getName());
|
||||
|
||||
String container = "";
|
||||
|
||||
if(metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
|
||||
|| metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
container = "java_proxy";
|
||||
}
|
||||
else {
|
||||
container = "network_proxy";
|
||||
}
|
||||
|
||||
crawler.setContainer(container);
|
||||
|
||||
return crawler;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap) {
|
||||
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>();
|
||||
|
||||
MetaSensorItemKey itemKey = null;
|
||||
|
||||
for(SensorItem sItem : sensorItems) {
|
||||
itemKey = keyMap.get(sItem.getItem().getId());
|
||||
if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
}
|
||||
metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
}
|
||||
|
||||
return metricMap;
|
||||
}
|
||||
|
||||
public Keys createKeys(MetaSensorItemKey itemKey) {
|
||||
Keys keys = new Keys();
|
||||
keys.setKey(itemKey.getKey());
|
||||
keys.setMetric(itemKey.getItem().getKey());
|
||||
return keys;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||
import com.loafle.overflow.crawler.config.Config;
|
||||
import com.loafle.overflow.crawler.config.Connection;
|
||||
import com.loafle.overflow.crawler.config.Crawler;
|
||||
import com.loafle.overflow.crawler.config.Schedule;
|
||||
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
|
||||
import com.loafle.overflow.central.module.auth.service.AuthCrawlerService;
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraHost;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraHostGenerator")
|
||||
public class InfraHostGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private InfraHostWMIGenerator infraHostWMIGenerator;
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerService authCrawlerService;
|
||||
|
||||
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws IOException {
|
||||
|
||||
InfraHost infraHost = (InfraHost)infra;
|
||||
|
||||
Config config = new Config();
|
||||
config.setId(String.valueOf(dbSensor.getId()));
|
||||
|
||||
com.loafle.overflow.crawler.config.Target target = this.createTarget(infraHost, dbSensor);
|
||||
|
||||
if(target == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
config.setTarget(target);
|
||||
|
||||
// FIXME: Interval
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setInterval("5");
|
||||
config.setSchedule(schedule);
|
||||
|
||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
||||
config.setCrawler(crawler);
|
||||
|
||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
||||
|
||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, config);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.writeValueAsString(config);
|
||||
}
|
||||
|
||||
private com.loafle.overflow.crawler.config.Target createTarget(InfraHost infraHost, Sensor dbSensor) throws IOException {
|
||||
|
||||
AuthCrawler authCrawler = this.authCrawlerService.readAuth(dbSensor.getCrawler(), dbSensor.getTarget());
|
||||
|
||||
if(authCrawler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
com.loafle.overflow.crawler.config.Target target = new com.loafle.overflow.crawler.config.Target();
|
||||
Connection connection = new Connection();
|
||||
connection.setIp(StringConvertor.intToIp(infraHost.getIp()));
|
||||
|
||||
HashMap<String,String> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference<HashMap<String,String>>() {});
|
||||
|
||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
connection.setPort("135");
|
||||
connection.setPortType("tcp");
|
||||
connection.setSsl(false);
|
||||
|
||||
target.setConnection(connection);
|
||||
|
||||
Map<String, Object> auth = new HashMap<>();
|
||||
auth.put("id", optionMap.get("ID"));
|
||||
auth.put("pw", optionMap.get("PassWord"));
|
||||
|
||||
target.setAuth(auth);
|
||||
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.crawler.config.*;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraHostWMIGenerator")
|
||||
public class InfraHostWMIGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws IOException {
|
||||
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
// MetaSensorItemKey itemKey = null;
|
||||
//
|
||||
// for(SensorItem sItem : sensorItems) {
|
||||
// itemKey = keyMap.get(sItem.getItem().getId());
|
||||
// if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
// metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
// }
|
||||
// metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
// }
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
Item item = null;
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
|
||||
Map<String, Object> extendMap = new HashMap<>();
|
||||
extendMap.put("nameSpace", "root/cimv2");
|
||||
extendMap.put("wmicPath", "/home/snoop/temp/wmic");
|
||||
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
for(Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) {
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
stringBuffer.setLength(0);
|
||||
|
||||
stringBuffer.append("SELECT ");
|
||||
|
||||
for(int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
|
||||
tempItemKey = elems.getValue().get(indexI);
|
||||
stringBuffer.append(tempItemKey.getKey());
|
||||
if(indexI + 1 < elems.getValue().size()) {
|
||||
stringBuffer.append(", ");
|
||||
}
|
||||
|
||||
// keys = new Keys();
|
||||
// keys.setKey(tempItemKey.getKey());
|
||||
// keys.setMetric(tempItemKey.getItem().getKey());
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
|
||||
|
||||
List<String> arrayColumns = null;
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
if(json != null && json.length() > 0) {
|
||||
HashMap<String,Object> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("appends");
|
||||
if(obj != null) {
|
||||
List<String> appendsList = (List<String>)obj;
|
||||
for(String append : appendsList) {
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(append);
|
||||
}
|
||||
}
|
||||
|
||||
stringBuffer.append(" FROM ");
|
||||
stringBuffer.append(elems.getKey());
|
||||
|
||||
obj = optionMap.get("where");
|
||||
if(obj != null) {
|
||||
String where = (String)obj;
|
||||
stringBuffer.append(" WHERE ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
|
||||
obj = optionMap.get("arrayColumns");
|
||||
if(obj != null) {
|
||||
arrayColumns = (List<String>)obj;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
stringBuffer.append(" FROM ");
|
||||
stringBuffer.append(elems.getKey());
|
||||
}
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(stringBuffer.toString());
|
||||
queryInfo.setExtend(extendMap);
|
||||
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setParseDirection("col");
|
||||
mappingInfo.setArrayColumns(arrayColumns);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
|
||||
itemList.add(item);
|
||||
|
||||
}
|
||||
|
||||
config.setItems(itemList);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.StringConvertor;
|
||||
import com.loafle.overflow.crawler.config.*;
|
||||
import com.loafle.overflow.central.module.auth.model.AuthCrawler;
|
||||
import com.loafle.overflow.central.module.auth.service.AuthCrawlerService;
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraService;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaCrawler;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.meta.type.MetaCrawlerEnum;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraServiceGenerator")
|
||||
public class InfraServiceGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceMysqlGenerator infraServiceMysqlGenerator;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceJMXGenerator infraServiceJMXGenerator;
|
||||
|
||||
@Autowired
|
||||
private AuthCrawlerService authCrawlerService;
|
||||
|
||||
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws IOException {
|
||||
com.loafle.overflow.central.module.infra.model.InfraService infraService = (com.loafle.overflow.central.module.infra.model.InfraService)infra;
|
||||
|
||||
Config config = new Config();
|
||||
config.setId(String.valueOf(dbSensor.getId()));
|
||||
|
||||
Target target = this.createTarget(infraService, dbSensor);
|
||||
|
||||
if(target == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
config.setTarget(target);
|
||||
|
||||
// FIXME: Interval
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setInterval("5");
|
||||
config.setSchedule(schedule);
|
||||
|
||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getCrawler());
|
||||
config.setCrawler(crawler);
|
||||
|
||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getCrawler());
|
||||
|
||||
if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, config);
|
||||
} else if (dbSensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, config);
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
return objectMapper.writeValueAsString(config);
|
||||
}
|
||||
|
||||
private Target createTarget(InfraService infraService, Sensor sensor) throws IOException {
|
||||
|
||||
AuthCrawler authCrawler = this.authCrawlerService.readAuth(sensor.getCrawler(), sensor.getTarget());
|
||||
|
||||
if(authCrawler == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Target target = new com.loafle.overflow.crawler.config.Target();
|
||||
Connection connection = new Connection();
|
||||
connection.setIp(StringConvertor.intToIp(infraService.getHost().getIp()));
|
||||
connection.setPort(String.valueOf(infraService.getPort()));
|
||||
connection.setPortType(infraService.getPortType());
|
||||
connection.setSsl(infraService.isTlsType());
|
||||
|
||||
target.setConnection(connection);
|
||||
|
||||
HashMap<String,String> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference<HashMap<String,String>>() {});
|
||||
|
||||
Map<String, Object> auth = new HashMap<>();
|
||||
|
||||
if(sensor.getCrawler().getId() == MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
auth.put("url", "jdbc:mysql://"+ StringConvertor.intToIp(infraService.getHost().getIp())+":"+String.valueOf(infraService.getPort()));
|
||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
} else if (sensor.getCrawler().getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
connection.setPort("9840");
|
||||
}
|
||||
|
||||
target.setAuth(auth);
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.crawler.config.*;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 9. 11.
|
||||
*/
|
||||
@Service("InfraServiceJMXGenerator")
|
||||
public class InfraServiceJMXGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws IOException {
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
Item item = null;
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
Map<String, Object> extendMap = new HashMap<>();
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
|
||||
for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet()) {
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
buffer.setLength(0);
|
||||
|
||||
buffer.append(elms.getKey());
|
||||
|
||||
for (int idx = 0; idx < elms.getValue().size(); idx++) {
|
||||
tempItemKey = elms.getValue().get(idx);
|
||||
|
||||
buffer.append(tempItemKey.getKey());
|
||||
|
||||
keys = new Keys();
|
||||
keys.setKey(tempItemKey.getKey());
|
||||
keys.setMetric(tempItemKey.getItem().getKey());
|
||||
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
List<String> aliases = null;
|
||||
List<String> arrayCol = null;
|
||||
|
||||
if (json != null && json.length() > 0) {
|
||||
HashMap<String, Object> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("aliases");
|
||||
|
||||
if (obj != null) {
|
||||
aliases = (List<String>)obj;
|
||||
}
|
||||
|
||||
obj = optionMap.get("arrayColumns");
|
||||
if (obj != null) {
|
||||
arrayCol = (List<String>)obj;
|
||||
}
|
||||
}
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(tempItemKey.getFroms());
|
||||
queryInfo.setExtend(extendMap);
|
||||
|
||||
extendMap.put("aliases", aliases);
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setArrayColumns(arrayCol);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
itemList.add(item);
|
||||
}
|
||||
config.setItems(itemList);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.crawler.config.*;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraServiceMysqlGenerator")
|
||||
public class InfraServiceMysqlGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, Config config) throws IOException {
|
||||
|
||||
|
||||
// List<Keys> keysList = new ArrayList<>();
|
||||
// for(SensorItem sItem : sensorItems) {
|
||||
// keys = new Keys();
|
||||
// keys.setMetric(sItem.getItem().getKey());
|
||||
// keys.setKey(KeyMap.get(sItem.getItem().getId()).getKey());
|
||||
// keysList.add(keys);
|
||||
// }
|
||||
// item.setKeys(keysList);
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
Item item = null;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for(Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) {
|
||||
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
stringBuffer.setLength(0);
|
||||
|
||||
stringBuffer.append(elems.getKey());
|
||||
|
||||
stringBuffer.append(" where ");
|
||||
for(int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
tempItemKey = elems.getValue().get(indexI);
|
||||
|
||||
stringBuffer.append("variable_name = '");
|
||||
stringBuffer.append(tempItemKey.getKey());
|
||||
stringBuffer.append("'");
|
||||
|
||||
if(indexI + 1 < elems.getValue().size()) {
|
||||
stringBuffer.append(" or ");
|
||||
}
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<String> keyColumns = null;
|
||||
String valueColumn = null;
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
if(json != null && json.length() > 0) {
|
||||
HashMap<String,Object> optionMap;
|
||||
optionMap = new ObjectMapper().readValue(json, new TypeReference<HashMap<String,Object>>() {});
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("valueColumn");
|
||||
if(obj != null) {
|
||||
valueColumn = (String)obj;
|
||||
}
|
||||
|
||||
obj = optionMap.get("keyColumns");
|
||||
if(obj != null) {
|
||||
keyColumns = (List<String>)obj;
|
||||
}
|
||||
}
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(stringBuffer.toString());
|
||||
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setParseDirection("row");
|
||||
mappingInfo.setValueColumn(valueColumn);
|
||||
mappingInfo.setKeyColumns(keyColumns);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
|
||||
itemList.add(item);
|
||||
|
||||
}
|
||||
|
||||
config.setItems(itemList);
|
||||
|
||||
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
//
|
||||
// return objectMapper.writeValueAsString(config);
|
||||
}
|
||||
|
||||
// public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList, QueryInfo queryInfo, MappingInfo mappingInfo) {
|
||||
//
|
||||
// switch (metaCrawler.getId()) {
|
||||
// case 11: // mysql
|
||||
// {
|
||||
// String query = "show status where ";
|
||||
//// queryInfo.setQuery("show status where ");
|
||||
//
|
||||
// Keys keys = null;
|
||||
// for(int indexI = 0 ; indexI < keysList.size(); ++indexI) {
|
||||
// keys = keysList.get(indexI);
|
||||
// query += "variable_name = '";
|
||||
// query += keys.getKey();
|
||||
// query += "'";
|
||||
// if(indexI + 1 < keysList.size()) {
|
||||
// query += " or ";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// queryInfo.setQuery(query);
|
||||
//
|
||||
// mappingInfo.setParseDirection("row");
|
||||
// mappingInfo.setValueColumn("Value");
|
||||
//
|
||||
// List<String> keyColumns = new ArrayList<>();
|
||||
// keyColumns.add("Variable_name");
|
||||
//
|
||||
// mappingInfo.setKeyColumns(keyColumns);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.PageParams;
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.infra.service.InfraService;
|
||||
import com.loafle.overflow.central.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.central.module.sensor.model.SensorItem;
|
||||
import com.loafle.overflow.central.module.sensor.service.SensorItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("SensorConfigGenerator")
|
||||
public class SensorConfigGenerator {
|
||||
|
||||
@Autowired
|
||||
private SensorItemService sensorItemService;
|
||||
|
||||
@Autowired
|
||||
private InfraService infraService;
|
||||
|
||||
@Autowired
|
||||
private InfraHostGenerator infraHostGenerator;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceGenerator infraServiceGenerator;
|
||||
|
||||
|
||||
public String generate(Sensor sensor) throws IOException {
|
||||
PageParams pageParams = new PageParams();
|
||||
pageParams.setPageNo(0);
|
||||
pageParams.setCountPerPage(Integer.MAX_VALUE);
|
||||
pageParams.setSortCol("id");
|
||||
pageParams.setSortDirection("descending");
|
||||
Page<SensorItem> dbItemList = this.sensorItemService.readAllBySensor(sensor, pageParams);
|
||||
|
||||
List<SensorItem> sensorItems = dbItemList.getContent();
|
||||
|
||||
if(sensorItems.size() <= 0) {
|
||||
return "";
|
||||
}
|
||||
Sensor dbSensor = sensorItems.get(0).getSensor();
|
||||
|
||||
Infra infra = this.infraService.readByTarget(dbSensor.getTarget());
|
||||
|
||||
// 7 = Infra OS Service
|
||||
if(infra.getInfraType().getId() == 7) {
|
||||
return this.infraServiceGenerator.process(dbSensor, sensorItems, infra);
|
||||
}
|
||||
if(infra.getInfraType().getId() == 2) {
|
||||
return this.infraHostGenerator.process(dbSensor, sensorItems, infra);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.loafle.overflow.central.module.history.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.history.model.History;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 8. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface HistoryDAO extends JpaRepository<History, Long> {
|
||||
|
||||
Page<History> findAllByProbe(Probe probe, Pageable pageable);
|
||||
|
||||
@Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}")
|
||||
Page<History> findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable);
|
||||
|
||||
Page<History> findAllByDomain(@Param("domain") Domain domain, Pageable pageRequest);
|
||||
|
||||
@Query("SELECT h FROM History h WHERE h.domain.id = :#{#domain.id} and h.type.id = :#{#type.id}")
|
||||
Page<History> findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest);
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package com.loafle.overflow.central.module.history.model;
|
||||
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "HISTORY", schema = "public")
|
||||
public class History {
|
||||
private long id;
|
||||
private Date createDate;
|
||||
private MetaHistoryType type;
|
||||
private String message;
|
||||
private Probe probe;
|
||||
private Member member;
|
||||
private Domain domain;
|
||||
|
||||
//private MetaResultType resultType; // i'm not sure this is necessary
|
||||
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TYPE_ID", nullable = false)
|
||||
public MetaHistoryType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MetaHistoryType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Column(name = "MESSAGE", nullable = false, length = 255)
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PROBE_ID", nullable = false)
|
||||
public Probe getProbe() {
|
||||
return probe;
|
||||
}
|
||||
|
||||
public void setProbe(Probe probe) {
|
||||
this.probe = probe;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MEMBER_ID", nullable = false)
|
||||
public Member getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
public void setMember(Member member) {
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "DOMAIN_ID", nullable = false)
|
||||
public Domain getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(Domain domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
History that = (History) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (id ^ (id >>> 32));
|
||||
result = 31 * result + (createDate != null ? createDate.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.loafle.overflow.central.module.history.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.PageParams;
|
||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.history.dao.HistoryDAO;
|
||||
import com.loafle.overflow.central.module.history.model.History;
|
||||
import com.loafle.overflow.central.module.meta.model.MetaHistoryType;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("HistoryService")
|
||||
public class HistoryService {
|
||||
|
||||
@Autowired
|
||||
private HistoryDAO historyDAO;
|
||||
|
||||
public History regist(History history) {
|
||||
return this.historyDAO.save(history);
|
||||
}
|
||||
|
||||
|
||||
public Page<History> readAllByProbeAndType(Probe probe, MetaHistoryType type, PageParams pageParams) {
|
||||
return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams));
|
||||
}
|
||||
|
||||
public Page<History> readAllByProbe(Probe probe, PageParams pageParams) {
|
||||
return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams));
|
||||
}
|
||||
|
||||
public Page<History> readAllByDomain(Domain domain, PageParams pageParams) {
|
||||
return this.historyDAO.findAllByDomain(domain, PageUtil.getPageRequest(pageParams));
|
||||
}
|
||||
|
||||
public Page<History> readAllByDomainAndType(Domain domain, MetaHistoryType type, PageParams pageParams) {
|
||||
return this.historyDAO.findAllByDomainAndType(domain, type, PageUtil.getPageRequest(pageParams));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraDAO extends JpaRepository<Infra, Long> {
|
||||
List<Infra> findAllByProbe(Probe probe);
|
||||
|
||||
Page<Infra> findAllByProbe(Probe probe, Pageable pageable);
|
||||
|
||||
@Query("SELECT i FROM INFRA i WHERE i.probe IN (:probeList) AND i.target != NULL")
|
||||
Page<Infra> findAllByProbeList(@Param("probeList") List<Probe> probeList, Pageable pageable);
|
||||
|
||||
|
||||
@Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)")
|
||||
List<Target> findAllTargetByProbeList(@Param("probeList") List<Probe> probeList);
|
||||
|
||||
Infra findByTarget(Target target);
|
||||
|
||||
// List<Infra> findAllByProbe(List<Probe> probeList);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraHost;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraHostDAO extends JpaRepository<InfraHost, Long> {
|
||||
InfraHost findByIp(long ip);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraMachine;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraMachineDAO extends JpaRepository<InfraMachine, Long> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSApplication;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraOSApplicationDAO extends JpaRepository<InfraOSApplication, Long> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOS;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraOSDAO extends JpaRepository<InfraOS, Long> {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSDaemon;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraOSDaemonDAO extends JpaRepository<InfraOSDaemon, Long> {
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSPort;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraOSPortDAO extends JpaRepository<InfraOSPort, Long> {
|
||||
|
||||
@Query("SELECT p from com.loafle.overflow.central.module.infra.model.InfraOSPort p WHERE p.os.id = (:osId) AND p.port = (:portNumber) AND p.portType = (:portType)")
|
||||
InfraOSPort findByPort(@Param("osId") long osId,@Param("portNumber") int portNumber,@Param("portType") String portType);
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.model.InfraService;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface InfraServiceDAO extends JpaRepository<InfraService, Long> {
|
||||
|
||||
@Query("SELECT ins from com.loafle.overflow.central.module.infra.model.InfraService ins WHERE ins.host.id = (:hostId) AND ins.port = (:portNumber) AND ins.portType = (:portType)")
|
||||
InfraService findByService(@Param("hostId") long hostId,@Param("portNumber") int portNumber,@Param("portType") String portType);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.infra.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 14.
|
||||
*/
|
||||
public class InfraNotFoundException extends OverflowRuntimeException {
|
||||
public InfraNotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InfraNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
|
||||
import com.loafle.overflow.central.module.meta.model.MetaInfraType;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA")
|
||||
@Table(name = "INFRA", schema = "public")
|
||||
@Inheritance(strategy = InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name = "INFRA_TYPE", discriminatorType = DiscriminatorType.INTEGER)
|
||||
public abstract class Infra {
|
||||
private long id;
|
||||
private MetaInfraType infraType;
|
||||
// private long childId;
|
||||
private Date createDate;
|
||||
private Probe probe;
|
||||
private Target target;
|
||||
|
||||
// private InfraChild infraChild;
|
||||
|
||||
// private InfraHost infraHost;
|
||||
// private InfraMachine infraMachine;
|
||||
// private InfraOS infraOS;
|
||||
|
||||
/*
|
||||
private long id;
|
||||
private MetaInfraType infraType;
|
||||
private long childId;
|
||||
private Date createDate;
|
||||
private Probe probeId;
|
||||
private Target targetId;
|
||||
*/
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "CHILD_ID", nullable = false, insertable = false, updatable = false)
|
||||
// public InfraHost getInfraChild() {
|
||||
// return infraChild;
|
||||
// }
|
||||
//
|
||||
// public void setInfraChild(InfraChild infraChild) {
|
||||
// this.infraChild = infraChild;
|
||||
// }
|
||||
|
||||
// @OneToOne
|
||||
// @JoinColumn(name = "CHILD_ID")
|
||||
// public InfraChild getInfraChild() {
|
||||
// return infraChild;
|
||||
// }
|
||||
//
|
||||
// public void setInfraChild(InfraChild infraChild) {
|
||||
// this.infraChild = infraChild;
|
||||
// }
|
||||
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "HOST_ID")
|
||||
// public InfraHost getInfraHost() {
|
||||
// return infraHost;
|
||||
// }
|
||||
//
|
||||
// public void setInfraHost(InfraHost infraHost) {
|
||||
// this.infraHost = infraHost;
|
||||
// }
|
||||
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "MACHINE_ID")
|
||||
// public InfraMachine getInfraMachine() {
|
||||
// return infraMachine;
|
||||
// }
|
||||
//
|
||||
// public void setInfraMachine(InfraMachine infraMachine) {
|
||||
// this.infraMachine = infraMachine;
|
||||
// }
|
||||
//
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "OS_ID")
|
||||
// public InfraOS getInfraOS() {
|
||||
// return infraOS;
|
||||
// }
|
||||
//
|
||||
// public void setInfraOS(InfraOS infraOS) {
|
||||
// this.infraOS = infraOS;
|
||||
// }
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TYPE_ID", nullable = false)
|
||||
public MetaInfraType getInfraType() {
|
||||
return infraType;
|
||||
}
|
||||
|
||||
public void setInfraType(MetaInfraType infraType) {
|
||||
this.infraType = infraType;
|
||||
}
|
||||
|
||||
// @Basic
|
||||
// @Column(name = "CHILD_ID", nullable = false)
|
||||
// public long getChildId() {
|
||||
// return childId;
|
||||
// }
|
||||
//
|
||||
// public void setChildId(long childId) {
|
||||
// this.childId = childId;
|
||||
// }
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "PROBE_ID", nullable = true)
|
||||
public Probe getProbe() {
|
||||
return probe;
|
||||
}
|
||||
|
||||
public void setProbe(Probe probe) {
|
||||
this.probe = probe;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "TARGET_ID", nullable = true)
|
||||
public Target getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(Target target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
// public static Infra CreateInfraByType(long id, Class c) {
|
||||
//
|
||||
// Infra infra = new Infra();
|
||||
//// infra.setChildId(id);
|
||||
//
|
||||
// MetaInfraType infraType = new MetaInfraType();
|
||||
// if(c == InfraMachine.class) {
|
||||
// infraType.setId(1);
|
||||
// }
|
||||
// else if(c == InfraHost.class) {
|
||||
// infraType.setId(2);
|
||||
// }
|
||||
// else if(c == InfraOS.class) {
|
||||
// infraType.setId(3);
|
||||
// }
|
||||
// else if(c == InfraOSApplication.class) {
|
||||
// infraType.setId(4);
|
||||
// }
|
||||
// else if(c == InfraOSDaemon.class) {
|
||||
// infraType.setId(5);
|
||||
// }
|
||||
// else if(c == InfraOSPort.class) {
|
||||
// infraType.setId(6);
|
||||
// }
|
||||
// else if(c == InfraService.class) {
|
||||
// infraType.setId(7);
|
||||
// }
|
||||
//
|
||||
// infra.setInfraType(infraType);
|
||||
//
|
||||
// return infra;
|
||||
// }
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_HOST")
|
||||
@Table(name = "INFRA_HOST", schema = "public")
|
||||
@DiscriminatorValue("2")
|
||||
public class InfraHost extends Infra {
|
||||
// private long id;
|
||||
private InfraOS os;
|
||||
private long ip;
|
||||
private long mac;
|
||||
private Date createDate;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OS_ID", nullable = true)
|
||||
public InfraOS getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(InfraOS os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "IP", nullable = true)
|
||||
public long getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(long ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "MAC", nullable = true)
|
||||
public long getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(long mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_MACHINE")
|
||||
@Table(name = "INFRA_MACHINE", schema = "public")
|
||||
@DiscriminatorValue("1")
|
||||
public class InfraMachine extends Infra {
|
||||
// private long id;
|
||||
|
||||
private String meta;
|
||||
private Date createDate;
|
||||
|
||||
/*
|
||||
private long id;
|
||||
private String meta;
|
||||
private Date createDate;
|
||||
*/
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@Basic
|
||||
@Column(name = "META", nullable = true, length = 255)
|
||||
public String getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
|
||||
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_OS")
|
||||
@Table(name = "INFRA_OS", schema = "public")
|
||||
@DiscriminatorValue("3")
|
||||
public class InfraOS extends Infra {
|
||||
// private long id;
|
||||
private InfraMachine machine;
|
||||
private String meta;
|
||||
private Date createDate;
|
||||
private MetaInfraVendor vendor;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "MACHINE_ID", nullable = true)
|
||||
public InfraMachine getMachine() {
|
||||
return machine;
|
||||
}
|
||||
|
||||
public void setMachine(InfraMachine machine) {
|
||||
this.machine = machine;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "META", nullable = true, length = 255)
|
||||
public String getMeta() {
|
||||
return meta;
|
||||
}
|
||||
|
||||
public void setMeta(String meta) {
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "VENDOR_ID", nullable = true)
|
||||
public MetaInfraVendor getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(MetaInfraVendor vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_OS_APPLICATION")
|
||||
@Table(name = "INFRA_OS_APPLICATION", schema = "public")
|
||||
@DiscriminatorValue("4")
|
||||
public class InfraOSApplication extends Infra {
|
||||
// private long id;
|
||||
private InfraOS os;
|
||||
private String name;
|
||||
private Date createDate;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OS_ID", nullable = true)
|
||||
public InfraOS getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(InfraOS os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "NAME", nullable = true, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_OS_DAEMON")
|
||||
@Table(name = "INFRA_OS_DAEMON", schema = "public")
|
||||
@DiscriminatorValue("5")
|
||||
public class InfraOSDaemon extends Infra {
|
||||
// private long id;
|
||||
private InfraOS os;
|
||||
private String name;
|
||||
private Date createDate;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OS_ID", nullable = true)
|
||||
public InfraOS getOs() {
|
||||
return os;
|
||||
}
|
||||
|
||||
public void setOs(InfraOS os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "NAME", nullable = true, length = 50)
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
|
||||
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_OS_PORT")
|
||||
@Table(name = "INFRA_OS_PORT", schema = "public")
|
||||
@DiscriminatorValue("6")
|
||||
public class InfraOSPort extends Infra {
|
||||
// private long id;
|
||||
private InfraOS os;
|
||||
private Date createDate;
|
||||
private Integer port;
|
||||
private String portType;
|
||||
private MetaInfraVendor vendor;
|
||||
private boolean tlsType;
|
||||
//
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "OS_ID", nullable = true)
|
||||
public InfraOS getOs() {
|
||||
return this.os;
|
||||
}
|
||||
|
||||
public void setOs(InfraOS os) {
|
||||
this.os = os;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PORT", nullable = true)
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PORT_TYPE", nullable = true)
|
||||
public String getPortType() {
|
||||
return portType;
|
||||
}
|
||||
|
||||
public void setPortType(String portType) {
|
||||
this.portType = portType;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "VENDOR_ID", nullable = true)
|
||||
public MetaInfraVendor getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(MetaInfraVendor vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "TLS_TYPE", nullable = true)
|
||||
public boolean isTlsType() {
|
||||
return tlsType;
|
||||
}
|
||||
|
||||
public void setTlsType(boolean tlsType) {
|
||||
this.tlsType = tlsType;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.loafle.overflow.central.module.infra.model;
|
||||
|
||||
|
||||
import com.loafle.overflow.central.module.meta.model.MetaInfraVendor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 22.
|
||||
*/
|
||||
@Entity(name = "INFRA_SERVICE")
|
||||
@Table(name = "INFRA_SERVICE", schema = "public")
|
||||
@DiscriminatorValue("7")
|
||||
public class InfraService extends Infra{
|
||||
// private long id;
|
||||
private InfraHost host;
|
||||
private String portType;
|
||||
private Integer port;
|
||||
private MetaInfraVendor vendor;
|
||||
private Date createDate;
|
||||
private boolean tlsType;
|
||||
|
||||
// @Id
|
||||
// @GeneratedValue(strategy= GenerationType.IDENTITY)
|
||||
// public long getId() {
|
||||
// return id;
|
||||
// }
|
||||
//
|
||||
// public void setId(long id) {
|
||||
// this.id = id;
|
||||
// }
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "HOST_ID", nullable = true)
|
||||
public InfraHost getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(InfraHost host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PORT_TYPE", nullable = true)
|
||||
public String getPortType() {
|
||||
return portType;
|
||||
}
|
||||
|
||||
public void setPortType(String portType) {
|
||||
this.portType = portType;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "PORT", nullable = true)
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "VENDOR_ID", nullable = true)
|
||||
public MetaInfraVendor getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(MetaInfraVendor vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
@Column(name = "CREATE_DATE", nullable = true, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "TLS_TYPE", nullable = true)
|
||||
public boolean isTlsType() {
|
||||
return tlsType;
|
||||
}
|
||||
|
||||
public void setTlsType(boolean tlsType) {
|
||||
this.tlsType = tlsType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraHostDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraHost;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraHostService")
|
||||
public class InfraHostService {
|
||||
|
||||
@Autowired
|
||||
InfraHostDAO infraHostDAO;
|
||||
|
||||
public InfraHost regist(InfraHost infraHost) {
|
||||
return this.infraHostDAO.save(infraHost);
|
||||
}
|
||||
|
||||
public InfraHost read(long id) {
|
||||
return this.infraHostDAO.findOne(id);
|
||||
}
|
||||
|
||||
public InfraHost readByIp(long ip) {
|
||||
return this.infraHostDAO.findByIp(ip);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraMachineDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraMachine;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
@Service("InfraMachineService")
|
||||
public class InfraMachineService {
|
||||
@Autowired
|
||||
InfraMachineDAO infraMachineDAO;
|
||||
|
||||
public InfraMachine regist(InfraMachine infraMachine) {
|
||||
return this.infraMachineDAO.save(infraMachine);
|
||||
}
|
||||
|
||||
public InfraMachine read(long id) {
|
||||
return this.infraMachineDAO.findOne(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraOSApplicationDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSApplication;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraOSApplicationService")
|
||||
public class InfraOSApplicationService {
|
||||
|
||||
@Autowired
|
||||
InfraOSApplicationDAO infraOSApplicationDAO;
|
||||
|
||||
public InfraOSApplication regist(InfraOSApplication infraOSApplication) {
|
||||
return this.infraOSApplicationDAO.save(infraOSApplication);
|
||||
}
|
||||
|
||||
public InfraOSApplication read(long id) {
|
||||
return this.infraOSApplicationDAO.findOne(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraOSDaemonDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSDaemon;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraOSDaemonService")
|
||||
public class InfraOSDaemonService {
|
||||
|
||||
@Autowired
|
||||
InfraOSDaemonDAO infraOSDaemonDAO;
|
||||
|
||||
public InfraOSDaemon regist(InfraOSDaemon infraOSDaemon) {
|
||||
return this.infraOSDaemonDAO.save(infraOSDaemon);
|
||||
}
|
||||
|
||||
public InfraOSDaemon read(long id) {
|
||||
return this.infraOSDaemonDAO.findOne(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraOSPortDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOSPort;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraOSPortService")
|
||||
public class InfraOSPortService {
|
||||
|
||||
@Autowired
|
||||
InfraOSPortDAO infraOSPortDAO;
|
||||
|
||||
public InfraOSPort regist(InfraOSPort infraOSPort) {
|
||||
return this.infraOSPortDAO.save(infraOSPort);
|
||||
}
|
||||
|
||||
public InfraOSPort read(long id) {
|
||||
return this.infraOSPortDAO.findOne(id);
|
||||
}
|
||||
|
||||
public InfraOSPort readByPort(long osId, int portNumber, String portType) {
|
||||
return this.infraOSPortDAO.findByPort(osId, portNumber, portType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraOSDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraOS;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraOSService")
|
||||
public class InfraOSService {
|
||||
|
||||
@Autowired
|
||||
InfraOSDAO infraOSDAO;
|
||||
|
||||
public InfraOS regist(InfraOS infraOS) {
|
||||
return this.infraOSDAO.save(infraOS);
|
||||
}
|
||||
|
||||
public InfraOS read(long id) {
|
||||
return this.infraOSDAO.findOne(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.model.PageParams;
|
||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||
import com.loafle.overflow.central.module.domain.model.Domain;
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.Infra;
|
||||
import com.loafle.overflow.central.module.probe.exception.ProbeNotFoundException;
|
||||
import com.loafle.overflow.central.module.probe.model.Probe;
|
||||
import com.loafle.overflow.central.module.probe.service.ProbeService;
|
||||
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
||||
import com.loafle.overflow.central.module.target.model.Target;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
|
||||
@Service("InfraService")
|
||||
public class InfraService {
|
||||
|
||||
@Autowired
|
||||
InfraDAO infraDAO;
|
||||
|
||||
@Autowired
|
||||
SensorDAO sensorDAO;
|
||||
|
||||
@Autowired
|
||||
private ProbeService probeService;
|
||||
|
||||
public Infra regist(Infra infra) {
|
||||
return this.infraDAO.save(infra);
|
||||
}
|
||||
|
||||
public Infra read(long id) {
|
||||
Infra infra = this.infraDAO.findOne(id);
|
||||
infra.getTarget().setSensors(this.sensorDAO.findAllByTarget(infra.getTarget()));
|
||||
return infra;
|
||||
}
|
||||
|
||||
public Page<Infra> readAllByProbe(Probe probe, PageParams pageParams) {
|
||||
return this.infraDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams));
|
||||
}
|
||||
|
||||
public Page<Infra> readAllByDomain(Domain domain, PageParams pageParams) {
|
||||
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
||||
|
||||
if(probeList == null || probeList.size() <= 0) {
|
||||
throw new ProbeNotFoundException();
|
||||
}
|
||||
|
||||
Page<Infra> infraList = this.infraDAO.findAllByProbeList(probeList, PageUtil.getPageRequest(pageParams));
|
||||
for (Infra infra: infraList) {
|
||||
infra.getTarget().setSensors(this.sensorDAO.findAllByTarget(infra.getTarget()));
|
||||
}
|
||||
return infraList;
|
||||
}
|
||||
|
||||
|
||||
public List<Target> readAllTargetByDomain(Domain domain) {
|
||||
|
||||
List<Probe> probeList = this.probeService.readAllByDomain(domain);
|
||||
|
||||
if(probeList == null || probeList.size() <= 0) {
|
||||
throw new ProbeNotFoundException();
|
||||
}
|
||||
|
||||
return this.infraDAO.findAllTargetByProbeList(probeList);
|
||||
}
|
||||
|
||||
public List<Target> readAllTargetByProbeList(List<Probe> probeList) {
|
||||
return this.infraDAO.findAllTargetByProbeList(probeList);
|
||||
// return null;
|
||||
}
|
||||
|
||||
public Infra readByTarget(Target target) {
|
||||
return this.infraDAO.findByTarget(target);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.loafle.overflow.central.module.infra.service;
|
||||
|
||||
import com.loafle.overflow.central.module.infra.dao.InfraServiceDAO;
|
||||
import com.loafle.overflow.central.module.infra.model.InfraService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 6. 28.
|
||||
*/
|
||||
@Service("InfraServiceService")
|
||||
public class InfraServiceService {
|
||||
@Autowired
|
||||
InfraServiceDAO infraServiceDAO;
|
||||
|
||||
public com.loafle.overflow.central.module.infra.model.InfraService regist(com.loafle.overflow.central.module.infra.model.InfraService infraService) {
|
||||
return this.infraServiceDAO.save(infraService);
|
||||
}
|
||||
|
||||
public com.loafle.overflow.central.module.infra.model.InfraService read(long id) {
|
||||
return this.infraServiceDAO.findOne(id);
|
||||
}
|
||||
|
||||
public InfraService readByService(long hostId, int portNumber, String portType) {
|
||||
return this.infraServiceDAO.findByService(hostId, portNumber, portType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 5. 25.
|
||||
*/
|
||||
@Repository
|
||||
public interface MemberDAO extends JpaRepository<Member, Long> {
|
||||
@Query("select m from Member m WHERE m.email = :signinId")
|
||||
Member findByEmail(@Param("signinId") String signinId);
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.loafle.overflow.central.module.member.dao;
|
||||
|
||||
import com.loafle.overflow.central.module.member.model.Member;
|
||||
import com.loafle.overflow.central.module.member.model.MemberTotp;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 8.
|
||||
*/
|
||||
@Repository
|
||||
public interface MemberTotpDAO extends JpaRepository<MemberTotp, Long> {
|
||||
@Query("select m from MemberTotp m WHERE m.secretCode = :secretCode")
|
||||
MemberTotp findBySecretCode(@Param("secretCode") String secretCode);
|
||||
|
||||
|
||||
MemberTotp findByMember(Member member);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class EmailNotConfirmedException extends OverflowRuntimeException {
|
||||
public EmailNotConfirmedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EmailNotConfirmedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 23.
|
||||
*/
|
||||
public class EqualsOldPasswordException extends OverflowRuntimeException {
|
||||
public EqualsOldPasswordException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EqualsOldPasswordException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 8. 18.
|
||||
*/
|
||||
public class JoinedEmailException extends OverflowRuntimeException {
|
||||
public JoinedEmailException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public JoinedEmailException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 11. 22.
|
||||
*/
|
||||
public class PasswordNotStrongException extends OverflowRuntimeException {
|
||||
public PasswordNotStrongException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PasswordNotStrongException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 15.
|
||||
*/
|
||||
public class SecretCodeNotExistException extends OverflowRuntimeException {
|
||||
public SecretCodeNotExistException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SecretCodeNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class SignInIdNotExistException extends OverflowRuntimeException {
|
||||
public SignInIdNotExistException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SignInIdNotExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
public class SignInPwNotMatchException extends OverflowRuntimeException {
|
||||
public SignInPwNotMatchException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SignInPwNotMatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 11. 23.
|
||||
*/
|
||||
public class SigninOverFailedException extends OverflowRuntimeException {
|
||||
public SigninOverFailedException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SigninOverFailedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.loafle.overflow.central.module.member.exception;
|
||||
|
||||
import com.loafle.overflow.central.commons.exception.OverflowRuntimeException;
|
||||
|
||||
/**
|
||||
* Created by geek on 18. 3. 15.
|
||||
*/
|
||||
public class TotpCodeNotMatchException extends OverflowRuntimeException {
|
||||
public TotpCodeNotMatchException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TotpCodeNotMatchException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user