From 278a3cc0e29e5c7e99600af5997a3c6039a7698a Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 6 Apr 2018 21:46:02 +0900 Subject: [PATCH] ing --- .gitignore | 88 + .vscode/launch.json | 27 + .vscode/settings.json | 3 + Dockerfile | 28 + build/docker-compose.yml | 30 + build/docker/bin/docker-entrypoint.sh | 9 + build/docker/conf/cache.properties | 3 + build/docker/conf/database.properties | 11 + build/docker/conf/logback.xml | 34 + build/docker/conf/mail.properties | 14 + build/docker/conf/redis.properties | 4 + build/docker/conf/velocity.properties | 6 + pom.xml | 361 ++++ .../com/loafle/overflow/central/Central.java | 21 + .../commons/exception/OverflowException.java | 21 + .../exception/OverflowRuntimeException.java | 11 + .../overflow/central/commons/model/Mail.java | 108 ++ .../central/commons/model/PageParams.java | 44 + .../central/commons/model/PublishMessage.java | 119 ++ .../commons/model/SessionMetadata.java | 51 + .../commons/service/MessagePublisher.java | 12 + .../central/commons/stereotype/ProbeAPI.java | 11 + .../central/commons/stereotype/WebappAPI.java | 11 + .../central/commons/utils/EmailSender.java | 112 ++ .../central/commons/utils/GenerateKey.java | 25 + .../central/commons/utils/PageUtil.java | 25 + .../commons/utils/StringConvertor.java | 15 + .../central/module/apikey/dao/ApiKeyDAO.java | 18 + .../central/module/apikey/model/ApiKey.java | 81 + .../module/apikey/service/ApiKeyService.java | 44 + .../module/auth/dao/AuthCrawlerDAO.java | 15 + .../module/auth/model/AuthCrawler.java | 72 + .../auth/service/AuthCrawlerService.java | 53 + .../module/discovery/model/DiscoveryHost.java | 52 + .../module/discovery/model/DiscoveryPort.java | 61 + .../discovery/model/DiscoveryService.java | 15 + .../discovery/model/DiscoveryStartInfo.java | 63 + .../module/discovery/model/DiscoveryZone.java | 25 + .../central/module/discovery/model/Host.java | 67 + .../central/module/discovery/model/Port.java | 68 + .../module/discovery/model/Service.java | 60 + .../central/module/discovery/model/Zone.java | 63 + .../discovery/service/DiscoveryService.java | 111 ++ .../module/discovery/type/PortType.java | 18 + .../central/module/domain/dao/DomainDAO.java | 12 + .../module/domain/dao/DomainMemberDAO.java | 30 + .../central/module/domain/model/Domain.java | 52 + .../module/domain/model/DomainMember.java | 59 + .../domain/service/DomainMemberService.java | 46 + .../module/domain/service/DomainService.java | 20 + .../module/email/dao/EmailAuthDAO.java | 20 + .../exception/EmailOverAuthException.java | 16 + .../central/module/email/model/EmailAuth.java | 69 + .../email/service/EmailAuthService.java | 164 ++ .../generator/service/GenerateUtil.java | 102 ++ .../generator/service/InfraHostGenerator.java | 106 ++ .../service/InfraHostWMIGenerator.java | 136 ++ .../service/InfraServiceGenerator.java | 114 ++ .../service/InfraServiceJMXGenerator.java | 101 ++ .../service/InfraServiceMysqlGenerator.java | 152 ++ .../service/SensorConfigGenerator.java | 65 + .../module/history/dao/HistoryDAO.java | 30 + .../central/module/history/model/History.java | 116 ++ .../history/service/HistoryService.java | 41 + .../central/module/infra/dao/InfraDAO.java | 34 + .../module/infra/dao/InfraHostDAO.java | 13 + .../module/infra/dao/InfraMachineDAO.java | 12 + .../infra/dao/InfraOSApplicationDAO.java | 12 + .../central/module/infra/dao/InfraOSDAO.java | 12 + .../module/infra/dao/InfraOSDaemonDAO.java | 12 + .../module/infra/dao/InfraOSPortDAO.java | 17 + .../module/infra/dao/InfraServiceDAO.java | 17 + .../exception/InfraNotFoundException.java | 16 + .../central/module/infra/model/Infra.java | 183 ++ .../central/module/infra/model/InfraHost.java | 69 + .../module/infra/model/InfraMachine.java | 55 + .../central/module/infra/model/InfraOS.java | 72 + .../infra/model/InfraOSApplication.java | 58 + .../module/infra/model/InfraOSDaemon.java | 57 + .../module/infra/model/InfraOSPort.java | 94 + .../module/infra/model/InfraService.java | 93 + .../infra/service/InfraHostService.java | 29 + .../infra/service/InfraMachineService.java | 24 + .../service/InfraOSApplicationService.java | 25 + .../infra/service/InfraOSDaemonService.java | 25 + .../infra/service/InfraOSPortService.java | 29 + .../module/infra/service/InfraOSService.java | 25 + .../module/infra/service/InfraService.java | 84 + .../infra/service/InfraServiceService.java | 27 + .../central/module/member/dao/MemberDAO.java | 16 + .../module/member/dao/MemberTotpDAO.java | 20 + .../exception/EmailNotConfirmedException.java | 13 + .../exception/EqualsOldPasswordException.java | 16 + .../exception/JoinedEmailException.java | 16 + .../exception/PasswordNotStrongException.java | 16 + .../SecretCodeNotExistException.java | 16 + .../exception/SignInIdNotExistException.java | 13 + .../exception/SignInPwNotMatchException.java | 13 + .../exception/SigninOverFailedException.java | 16 + .../exception/TotpCodeNotMatchException.java | 16 + .../central/module/member/model/Member.java | 133 ++ .../module/member/model/MemberTotp.java | 86 + .../module/member/service/MemberService.java | 287 ++++ .../member/service/MemberTotpService.java | 120 ++ .../module/meta/dao/MetaCrawlerDAO.java | 13 + .../meta/dao/MetaCrawlerInputItemDAO.java | 17 + .../module/meta/dao/MetaHistoryTypeDAO.java | 13 + .../module/meta/dao/MetaInfraTypeDAO.java | 13 + .../module/meta/dao/MetaInfraVendorDAO.java | 17 + .../module/meta/dao/MetaInputTypeDAO.java | 13 + .../module/meta/dao/MetaMemberStatusDAO.java | 13 + .../meta/dao/MetaNoAuthProbeStatusDAO.java | 12 + .../module/meta/dao/MetaNotificationDAO.java | 13 + .../meta/dao/MetaProbeArchitectureDAO.java | 13 + .../module/meta/dao/MetaProbeOsDAO.java | 13 + .../module/meta/dao/MetaProbePackageDAO.java | 17 + .../module/meta/dao/MetaProbeStatusDAO.java | 12 + .../module/meta/dao/MetaProbeTaskTypeDAO.java | 13 + .../module/meta/dao/MetaProbeVersionDAO.java | 13 + .../meta/dao/MetaSensorDisplayItemDAO.java | 17 + .../meta/dao/MetaSensorDisplayMappingDAO.java | 21 + .../module/meta/dao/MetaSensorItemDAO.java | 13 + .../module/meta/dao/MetaSensorItemKeyDAO.java | 18 + .../meta/dao/MetaSensorItemTypeDAO.java | 13 + .../meta/dao/MetaSensorItemUnitDAO.java | 12 + .../module/meta/dao/MetaSensorStatusDAO.java | 12 + .../module/meta/dao/MetaVendorCrawlerDAO.java | 17 + .../dao/MetaVendorCrawlerSensorItemDAO.java | 13 + .../module/meta/model/MetaCrawler.java | 63 + .../meta/model/MetaCrawlerInputItem.java | 167 ++ .../module/meta/model/MetaHistoryType.java | 53 + .../module/meta/model/MetaInfraType.java | 45 + .../module/meta/model/MetaInfraVendor.java | 106 ++ .../module/meta/model/MetaInputType.java | 55 + .../module/meta/model/MetaMemberStatus.java | 44 + .../meta/model/MetaNoAuthProbeStatus.java | 43 + .../module/meta/model/MetaNotification.java | 54 + .../meta/model/MetaProbeArchitecture.java | 45 + .../module/meta/model/MetaProbeOs.java | 45 + .../module/meta/model/MetaProbePackage.java | 68 + .../module/meta/model/MetaProbeStatus.java | 43 + .../module/meta/model/MetaProbeTaskType.java | 56 + .../module/meta/model/MetaProbeVersion.java | 46 + .../meta/model/MetaSensorDisplayItem.java | 118 ++ .../meta/model/MetaSensorDisplayMapping.java | 45 + .../module/meta/model/MetaSensorItem.java | 64 + .../module/meta/model/MetaSensorItemKey.java | 105 ++ .../module/meta/model/MetaSensorItemType.java | 63 + .../module/meta/model/MetaSensorItemUnit.java | 61 + .../module/meta/model/MetaSensorStatus.java | 43 + .../module/meta/model/MetaVendorCrawler.java | 76 + .../model/MetaVendorCrawlerSensorItem.java | 91 + .../service/MetaCrawlerInputItemService.java | 24 + .../meta/service/MetaCrawlerService.java | 22 + .../meta/service/MetaHistoryTypeService.java | 30 + .../meta/service/MetaInfraTypeService.java | 22 + .../meta/service/MetaInfraVendorService.java | 24 + .../meta/service/MetaInputTypeService.java | 23 + .../meta/service/MetaMemberStatusService.java | 23 + .../service/MetaNoAuthProbeStatusService.java | 21 + .../service/MetaProbeArchitectureService.java | 23 + .../meta/service/MetaProbeOsService.java | 23 + .../meta/service/MetaProbePackageService.java | 24 + .../meta/service/MetaProbeStatusService.java | 23 + .../service/MetaProbeTaskTypeService.java | 22 + .../meta/service/MetaProbeVersionService.java | 22 + .../service/MetaSensorDisplayItemService.java | 31 + .../MetaSensorDisplayMappingService.java | 28 + .../service/MetaSensorItemKeyService.java | 39 + .../meta/service/MetaSensorItemService.java | 24 + .../service/MetaSensorItemTypeService.java | 30 + .../service/MetaSensorItemUnitService.java | 19 + .../meta/service/MetaSensorStatusService.java | 23 + .../MetaVendorCrawlerSensorItemService.java | 12 + .../service/MetaVendorCrawlerService.java | 28 + .../module/meta/type/MetaCrawlerEnum.java | 44 + .../noauthprobe/dao/NoAuthProbeDAO.java | 25 + .../module/noauthprobe/model/NoAuthProbe.java | 138 ++ .../service/NoAuthProbeService.java | 140 ++ .../notification/dao/NotificationDAO.java | 29 + .../notification/model/Notification.java | 89 + .../service/NotificationService.java | 62 + .../central/module/probe/dao/ProbeDAO.java | 21 + .../module/probe/dao/ProbeHostDAO.java | 15 + .../module/probe/dao/ProbeTaskDAO.java | 17 + .../exception/ProbeNotFoundException.java | 16 + .../central/module/probe/model/Probe.java | 190 +++ .../central/module/probe/model/ProbeHost.java | 48 + .../central/module/probe/model/ProbeTask.java | 143 ++ .../probe/service/ProbeHostService.java | 25 + .../module/probe/service/ProbeService.java | 53 + .../probe/service/ProbeTaskService.java | 27 + .../central/module/sensor/dao/SensorDAO.java | 29 + .../module/sensor/dao/SensorItemDAO.java | 16 + .../sensor/dao/SensorItemDependencyDAO.java | 18 + .../central/module/sensor/model/Sensor.java | 104 ++ .../module/sensor/model/SensorItem.java | 62 + .../sensor/model/SensorItemDependency.java | 48 + .../service/SensorItemDependencyService.java | 43 + .../sensor/service/SensorItemService.java | 59 + .../module/sensor/service/SensorService.java | 131 ++ .../central/module/target/dao/TargetDAO.java | 22 + .../exception/TargetNotFoundException.java | 16 + .../central/module/target/model/Target.java | 98 ++ .../service/TargetDiscoveryService.java | 222 +++ .../module/target/service/TargetService.java | 36 + .../central/module/websocket/UiWebsocket.java | 35 + .../central/proxy/ProxyServerInterceptor.java | 22 + .../central/proxy/ServiceInvoker.java | 203 +++ .../overflow/central/proxy/ServiceProxy.java | 106 ++ .../exception/InvalidParameterException.java | 15 + .../exception/InvalidRequestException.java | 15 + .../exception/NoSuchMethodException.java | 15 + .../exception/NoSuchServiceException.java | 15 + .../redis/service/RedisMessagePublisher.java | 131 ++ .../overflow/central/spring/AppConfig.java | 53 + .../central/spring/CacheConfiguration.java | 26 + .../central/spring/JdbcConfiguration.java | 103 ++ .../central/spring/MailConfiguration.java | 81 + .../central/spring/RedisConfiguration.java | 56 + src/main/resources/local/cache.properties | 3 + src/main/resources/local/database.properties | 11 + src/main/resources/local/init.sql | 1518 +++++++++++++++++ src/main/resources/local/mail.properties | 14 + src/main/resources/local/redis.properties | 4 + src/main/resources/local/velocity.properties | 6 + src/main/resources/signup_email.vm | 13 + .../java/com/loafle/overflow/CentralTest.java | 14 + .../commons/utils/EmailSenderTest.java | 43 + .../commons/utils/StringConvertorTest.java | 17 + .../apikey/service/ApiKeyServiceTest.java | 81 + .../auth/service/AuthCrawlerServiceTest.java | 65 + .../service/DomainMemberServiceTest.java | 66 + .../domain/service/DomainServiceTest.java | 38 + .../email/service/EmailAuthServiceTest.java | 54 + .../history/service/HistoryServiceTest.java | 75 + .../module/infra/dao/InfraDAOTest.java | 39 + .../infra/service/InfraHostServiceTest.java | 72 + .../service/InfraMachineServiceTest.java | 55 + .../InfraOSApplicationServiceTest.java | 61 + .../service/InfraOSDaemonServiceTest.java | 59 + .../infra/service/InfraOSPortServiceTest.java | 58 + .../infra/service/InfraOSServiceTest.java | 59 + .../service/InfraServiceServiceTest.java | 68 + .../infra/service/InfraServiceTest.java | 107 ++ .../module/member/dao/MemberDAOTest.java | 56 + .../module/member/dao/MemberTotpDAOTest.java | 50 + .../member/service/MemberServiceTest.java | 120 ++ .../member/service/MemberTotpServiceTest.java | 68 + .../MetaCrawlerInputItemServiceTest.java | 39 + .../meta/service/MetaCrawlerServiceTest.java | 36 + .../service/MetaHistoryTypeServiceTest.java | 74 + .../service/MetaInfraTypeServiceTest.java | 35 + .../service/MetaInfraVendorServiceTest.java | 38 + .../service/MetaInputTypeServiceTest.java | 35 + .../service/MetaMemberStatusServiceTest.java | 35 + .../MetaNoAuthProbeStatusServiceTest.java | 33 + .../MetaProbeArchitectureServiceTest.java | 34 + .../meta/service/MetaProbeOsServiceTest.java | 35 + .../service/MetaProbePackageServiceTest.java | 39 + .../service/MetaProbeStatusServiceTest.java | 34 + .../service/MetaProbeTaskTypeServiceTest.java | 35 + .../service/MetaProbeVersionServiceTest.java | 36 + .../MetaSensorDisplayItemServiceTest.java | 39 + .../MetaSensorDisplayMappingServiceTest.java | 32 + .../service/MetaSensorItemKeyServiceTest.java | 37 + .../service/MetaSensorItemServiceTest.java | 34 + .../MetaSensorItemTypeServiceTest.java | 33 + .../MetaSensorItemUnitServiceTest.java | 88 + .../service/MetaSensorStatusServiceTest.java | 35 + .../service/MetaVendorCrawlerServiceTest.java | 60 + .../service/NoAuthProbeServiceTest.java | 159 ++ .../service/NotificationServiceTest.java | 52 + .../probe/service/ProbeHostServiceTest.java | 57 + .../probe/service/ProbeServiceTest.java | 105 ++ .../probe/service/ProbeTaskServiceTest.java | 63 + .../sensor/service/SensorItemServiceTest.java | 59 + .../sensor/service/SensorServiceTest.java | 142 ++ .../module/target/dao/TargetDAOTest.java | 36 + .../service/TargetDiscoveryServiceTest.java | 135 ++ .../target/service/TargetServiceTest.java | 48 + .../central/proxy/ServiceInvokerTest.java | 64 + .../central/spring/AppConfigTest.java | 62 + src/test/resources/cache.properties | 3 + src/test/resources/database.properties | 11 + src/test/resources/dh.json | 173 ++ src/test/resources/logback.xml | 17 + src/test/resources/mail.properties | 14 + src/test/resources/redis.properties | 4 + 289 files changed, 15788 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 Dockerfile create mode 100644 build/docker-compose.yml create mode 100644 build/docker/bin/docker-entrypoint.sh create mode 100644 build/docker/conf/cache.properties create mode 100644 build/docker/conf/database.properties create mode 100644 build/docker/conf/logback.xml create mode 100644 build/docker/conf/mail.properties create mode 100644 build/docker/conf/redis.properties create mode 100644 build/docker/conf/velocity.properties create mode 100644 pom.xml create mode 100644 src/main/java/com/loafle/overflow/central/Central.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/exception/OverflowException.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/exception/OverflowRuntimeException.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/model/Mail.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/model/PageParams.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/model/PublishMessage.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/model/SessionMetadata.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/service/MessagePublisher.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/stereotype/ProbeAPI.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/stereotype/WebappAPI.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/utils/EmailSender.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/utils/GenerateKey.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java create mode 100644 src/main/java/com/loafle/overflow/central/commons/utils/StringConvertor.java create mode 100644 src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java create mode 100644 src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java create mode 100644 src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryStartInfo.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/discovery/type/PortType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/email/dao/EmailAuthDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/email/exception/EmailOverAuthException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/email/model/EmailAuth.java create mode 100644 src/main/java/com/loafle/overflow/central/module/email/service/EmailAuthService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/GenerateUtil.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostWMIGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceJMXGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceMysqlGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/generator/service/SensorConfigGenerator.java create mode 100644 src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/history/model/History.java create mode 100644 src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraHostDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraMachineDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSApplicationDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDaemonDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSPortDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/dao/InfraServiceDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/exception/InfraNotFoundException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/Infra.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraHost.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraMachine.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraOS.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSApplication.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSDaemon.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSPort.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/model/InfraService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraHostService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraMachineService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSPortService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/infra/service/InfraServiceService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/dao/MemberDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/EmailNotConfirmedException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/EqualsOldPasswordException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/JoinedEmailException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/PasswordNotStrongException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/SecretCodeNotExistException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/SignInIdNotExistException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/SignInPwNotMatchException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/SigninOverFailedException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/exception/TotpCodeNotMatchException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/model/Member.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/model/MemberTotp.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/service/MemberService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/member/service/MemberTotpService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerInputItemDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaHistoryTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraVendorDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInputTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaMemberStatusDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNoAuthProbeStatusDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNotificationDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeArchitectureDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeOsDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbePackageDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeStatusDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeTaskTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeVersionDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayItemDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayMappingDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemKeyDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemTypeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemUnitDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorStatusDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerSensorItemDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawler.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawlerInputItem.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaHistoryType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraVendor.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaInputType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaMemberStatus.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaNoAuthProbeStatus.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaNotification.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeArchitecture.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeOs.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbePackage.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeStatus.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeTaskType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeVersion.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayItem.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayMapping.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItem.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemKey.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemType.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemUnit.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorStatus.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawler.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawlerSensorItem.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerSensorItemService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/meta/type/MetaCrawlerEnum.java create mode 100644 src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java create mode 100644 src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java create mode 100644 src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/model/Target.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java create mode 100644 src/main/java/com/loafle/overflow/central/module/websocket/UiWebsocket.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/ProxyServerInterceptor.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/ServiceInvoker.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/ServiceProxy.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/exception/InvalidParameterException.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/exception/InvalidRequestException.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchMethodException.java create mode 100644 src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchServiceException.java create mode 100644 src/main/java/com/loafle/overflow/central/redis/service/RedisMessagePublisher.java create mode 100644 src/main/java/com/loafle/overflow/central/spring/AppConfig.java create mode 100644 src/main/java/com/loafle/overflow/central/spring/CacheConfiguration.java create mode 100644 src/main/java/com/loafle/overflow/central/spring/JdbcConfiguration.java create mode 100644 src/main/java/com/loafle/overflow/central/spring/MailConfiguration.java create mode 100644 src/main/java/com/loafle/overflow/central/spring/RedisConfiguration.java create mode 100644 src/main/resources/local/cache.properties create mode 100644 src/main/resources/local/database.properties create mode 100644 src/main/resources/local/init.sql create mode 100644 src/main/resources/local/mail.properties create mode 100644 src/main/resources/local/redis.properties create mode 100644 src/main/resources/local/velocity.properties create mode 100644 src/main/resources/signup_email.vm create mode 100644 src/test/java/com/loafle/overflow/CentralTest.java create mode 100644 src/test/java/com/loafle/overflow/central/commons/utils/EmailSenderTest.java create mode 100644 src/test/java/com/loafle/overflow/central/commons/utils/StringConvertorTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/apikey/service/ApiKeyServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/domain/service/DomainMemberServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/domain/service/DomainServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/email/service/EmailAuthServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/history/service/HistoryServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/dao/InfraDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraHostServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraMachineServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSPortServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/member/dao/MemberDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/notification/service/NotificationServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/probe/service/ProbeHostServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/probe/service/ProbeServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/probe/service/ProbeTaskServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/sensor/service/SensorItemServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/target/dao/TargetDAOTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/module/target/service/TargetServiceTest.java create mode 100644 src/test/java/com/loafle/overflow/central/proxy/ServiceInvokerTest.java create mode 100644 src/test/java/com/loafle/overflow/central/spring/AppConfigTest.java create mode 100644 src/test/resources/cache.properties create mode 100644 src/test/resources/database.properties create mode 100644 src/test/resources/dh.json create mode 100644 src/test/resources/logback.xml create mode 100644 src/test/resources/mail.properties create mode 100644 src/test/resources/redis.properties diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..60af490 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..81d81a5 --- /dev/null +++ b/.vscode/launch.json @@ -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 + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1133129 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "automatic" +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3d26758 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM openjdk:8-jdk-alpine +MAINTAINER Loafle + +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"] \ No newline at end of file diff --git a/build/docker-compose.yml b/build/docker-compose.yml new file mode 100644 index 0000000..75d0a41 --- /dev/null +++ b/build/docker-compose.yml @@ -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 \ No newline at end of file diff --git a/build/docker/bin/docker-entrypoint.sh b/build/docker/bin/docker-entrypoint.sh new file mode 100644 index 0000000..44af60c --- /dev/null +++ b/build/docker/bin/docker-entrypoint.sh @@ -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 "$@" \ No newline at end of file diff --git a/build/docker/conf/cache.properties b/build/docker/conf/cache.properties new file mode 100644 index 0000000..fda34c0 --- /dev/null +++ b/build/docker/conf/cache.properties @@ -0,0 +1,3 @@ +# Caffeine +cache.cache-names:memberListByDomain,memberListByProbeKey +cache.caffeine.spec: initialCapacity=100,maximumSize=500,expireAfterAccess=5m,recordStats \ No newline at end of file diff --git a/build/docker/conf/database.properties b/build/docker/conf/database.properties new file mode 100644 index 0000000..e8c1188 --- /dev/null +++ b/build/docker/conf/database.properties @@ -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 diff --git a/build/docker/conf/logback.xml b/build/docker/conf/logback.xml new file mode 100644 index 0000000..3f73f47 --- /dev/null +++ b/build/docker/conf/logback.xml @@ -0,0 +1,34 @@ + + + central + + + + + central-%d{yyyy-MM-dd'T'HH:mm}.%i.log.zip + + + 1024kb + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + + + \ No newline at end of file diff --git a/build/docker/conf/mail.properties b/build/docker/conf/mail.properties new file mode 100644 index 0000000..99f696d --- /dev/null +++ b/build/docker/conf/mail.properties @@ -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=* + + diff --git a/build/docker/conf/redis.properties b/build/docker/conf/redis.properties new file mode 100644 index 0000000..26fc4d8 --- /dev/null +++ b/build/docker/conf/redis.properties @@ -0,0 +1,4 @@ +# Redis +redis.host=192.168.1.50 +redis.port=6379 +redis.channels=/webapp,/probe,/auth \ No newline at end of file diff --git a/build/docker/conf/velocity.properties b/build/docker/conf/velocity.properties new file mode 100644 index 0000000..c298824 --- /dev/null +++ b/build/docker/conf/velocity.properties @@ -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 \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a5128a7 --- /dev/null +++ b/pom.xml @@ -0,0 +1,361 @@ + + + 4.0.0 + + + com.loafle + maven_parent_jar + 1.0.0-RELEASE + + + com.loafle.overflow + central + jar + 1.0.0-SNAPSHOT + com.loafle.overflow.central + + + 1.2.0 + 2.9.0 + 2.5.6 + 3.2.0 + 4.3.9.RELEASE + 1.11.4.RELEASE + 1.8.7.RELEASE + 4.2.3.RELEASE + 5.2.10.Final + 1.4.7 + 1.6.0 + 1.9.13 + 1.7 + docker.loafle.net/overflow + 1.1.2 + 3.1.5 + + + + + io.grpc + grpc-netty + ${grpc.version} + + + io.grpc + grpc-protobuf + ${grpc.version} + + + io.grpc + grpc-stub + ${grpc.version} + + + org.mockito + mockito-core + 1.9.5 + test + + + + + org.springframework.data + spring-data-jpa + ${spring.data.jpa.version} + + + + + org.springframework.data + spring-data-redis + ${spring.data.redis.version} + + + + + + org.springframework + spring-test + ${spring.version} + test + + + + + org.springframework + spring-context-support + ${spring.version} + + + + + + org.postgresql + postgresql + 9.4-1200-jdbc41 + + + + org.codehaus.jackson + jackson-mapper-asl + ${jackson.mapper.version} + + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + + + + org.hibernate + hibernate-core + ${hibernate.version} + + + + + org.springframework.security + spring-security-crypto + ${spring.crypto.version} + + + + + + javax.mail + mail + ${javax.mail.version} + + + + javax.mail + javax.mail-api + ${javax.mail-api.version} + + + + org.apache.velocity + velocity + ${apache.velocity.version} + + + + commons-codec + commons-codec + 1.5 + + + + + redis.clients + jedis + ${jedis.version} + + + + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} + + + + + + com.loafle + overflow_api_server + 1.0.0-SNAPSHOT + + + + com.loafle.overflow + crawler + 1.0.0-SNAPSHOT + + + + com.warrenstrange + googleauth + ${googleauth.version} + + + + com.fasterxml.uuid + java-uuid-generator + ${fasterxml.uuid.verion} + + + + + + + src/main/resources/${environment} + true + + + + + src/test/resources + true + + + + + + kr.motd.maven + os-maven-plugin + 1.5.0.Final + + + + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + false + runtime + ${project.build.directory}/lib + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.0 + + com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + + compile + compile-custom + + + + + + com.google.protobuf + protobuf-java + ${protoc.version} + + + + + + cz.habarta.typescript-generator + typescript-generator-maven-plugin + 1.25.322 + + + generate + + generate + + process-classes + + + + jackson2 + + com.loafle.overflow.central.module.**.model.* + + module + implementationFile + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + com.loafle.overflow.central.Central + + + + + + + com.spotify + dockerfile-maven-plugin + 1.3.4 + + + build + + build + + + + + true + com.loafle.overflow.central.Central + + + ${docker.registry.name}/${project.artifactId} + ${project.version} + + + + + + + + + + + + + + + + + + + + + + local + + true + + + local + + + + development + + development + + + + staging + + staging + + + + production + + production + + + + \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/Central.java b/src/main/java/com/loafle/overflow/central/Central.java new file mode 100644 index 0000000..442240c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/Central.java @@ -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(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/exception/OverflowException.java b/src/main/java/com/loafle/overflow/central/commons/exception/OverflowException.java new file mode 100644 index 0000000..7f8d275 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/exception/OverflowException.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/exception/OverflowRuntimeException.java b/src/main/java/com/loafle/overflow/central/commons/exception/OverflowRuntimeException.java new file mode 100644 index 0000000..60b6972 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/exception/OverflowRuntimeException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/model/Mail.java b/src/main/java/com/loafle/overflow/central/commons/model/Mail.java new file mode 100644 index 0000000..8891044 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/model/Mail.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/model/PageParams.java b/src/main/java/com/loafle/overflow/central/commons/model/PageParams.java new file mode 100644 index 0000000..0d1c523 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/model/PageParams.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/model/PublishMessage.java b/src/main/java/com/loafle/overflow/central/commons/model/PublishMessage.java new file mode 100644 index 0000000..4a7d6aa --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/model/PublishMessage.java @@ -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 targets; + private PublishMessageBody message; + + public void setTargetType(TargetType targetType) { + this.targetType = targetType; + } + + public TargetType getTargetType() { + return this.targetType; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + public void addTarget(String target) { + if (null == targets) { + targets = new ArrayList<>(); + } + targets.add(target); + } + + public List 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 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 params; + + public String getMethod() { + return method; + } + + public void setMethod(String method) { + this.method = method; + } + + public List getParams() { + return params; + } + + public void setParams(List params) { + this.params = params; + } + + public void addParams(String param) { + if (null == this.params) { + this.params = new ArrayList<>(); + } + this.params.add(param); + } + + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/model/SessionMetadata.java b/src/main/java/com/loafle/overflow/central/commons/model/SessionMetadata.java new file mode 100644 index 0000000..8ca7122 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/model/SessionMetadata.java @@ -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 CTX_CLIENT_TYPE_KEY = Context.key(CLIENT_TYPE_KEY); + public static final Context.Key CTX_SESSION_ID_KEY = Context.key(SESSION_ID_KEY); + public static final Context.Key CTX_TARGET_ID_KEY = Context.key(TARGET_ID_KEY); + + public static final Metadata.Key METADATA_CLIENT_TYPE_KEY = Metadata.Key.of(CLIENT_TYPE_KEY, ASCII_STRING_MARSHALLER); + public static final Metadata.Key METADATA_SESSION_ID_KEY = Metadata.Key.of(SESSION_ID_KEY, ASCII_STRING_MARSHALLER); + public static final Metadata.Key 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; + } + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/service/MessagePublisher.java b/src/main/java/com/loafle/overflow/central/commons/service/MessagePublisher.java new file mode 100644 index 0000000..78e2de6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/service/MessagePublisher.java @@ -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); +} diff --git a/src/main/java/com/loafle/overflow/central/commons/stereotype/ProbeAPI.java b/src/main/java/com/loafle/overflow/central/commons/stereotype/ProbeAPI.java new file mode 100644 index 0000000..7e29759 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/stereotype/ProbeAPI.java @@ -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 { +} diff --git a/src/main/java/com/loafle/overflow/central/commons/stereotype/WebappAPI.java b/src/main/java/com/loafle/overflow/central/commons/stereotype/WebappAPI.java new file mode 100644 index 0000000..feb636b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/stereotype/WebappAPI.java @@ -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 { +} diff --git a/src/main/java/com/loafle/overflow/central/commons/utils/EmailSender.java b/src/main/java/com/loafle/overflow/central/commons/utils/EmailSender.java new file mode 100644 index 0000000..0e3bee7 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/utils/EmailSender.java @@ -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 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(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/commons/utils/GenerateKey.java b/src/main/java/com/loafle/overflow/central/commons/utils/GenerateKey.java new file mode 100644 index 0000000..7fcede9 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/utils/GenerateKey.java @@ -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(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java b/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java new file mode 100644 index 0000000..4d348ee --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/utils/PageUtil.java @@ -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())); + } +} diff --git a/src/main/java/com/loafle/overflow/central/commons/utils/StringConvertor.java b/src/main/java/com/loafle/overflow/central/commons/utils/StringConvertor.java new file mode 100644 index 0000000..ab01f99 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/commons/utils/StringConvertor.java @@ -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); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java b/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java new file mode 100644 index 0000000..aa6e5dd --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/apikey/dao/ApiKeyDAO.java @@ -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 findByApiKey(String apiKey); + + ApiKey findByDomain(Domain domain); +} diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java b/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java new file mode 100644 index 0000000..e14cf14 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/apikey/model/ApiKey.java @@ -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; +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java b/src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java new file mode 100644 index 0000000..d9bff23 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/apikey/service/ApiKeyService.java @@ -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); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java b/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java new file mode 100644 index 0000000..6cee4cc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/auth/dao/AuthCrawlerDAO.java @@ -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 findByCrawlerAndTarget(MetaCrawler metaCrawler, Target target); +} diff --git a/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java b/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java new file mode 100644 index 0000000..ec7f8ac --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/auth/model/AuthCrawler.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java b/src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java new file mode 100644 index 0000000..67903ba --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerService.java @@ -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); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java new file mode 100644 index 0000000..9bf0453 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryHost.java @@ -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 excludeHosts; + private List 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 getExcludeHosts() { + return excludeHosts; + } + + public void setExcludeHosts(List excludeHosts) { + this.excludeHosts = excludeHosts; + } + + public List getIncludeHosts() { + return includeHosts; + } + + public void setIncludeHosts(List includeHosts) { + this.includeHosts = includeHosts; + } + + public DiscoveryPort getDiscoveryPort() { + return discoveryPort; + } + + public void setDiscoveryPort(DiscoveryPort discoveryPort) { + this.discoveryPort = discoveryPort; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java new file mode 100644 index 0000000..22d2608 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryPort.java @@ -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 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 getExcludePorts() { + return excludePorts; + } + + public void setExcludePorts(List 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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java new file mode 100644 index 0000000..ef565f5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryService.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.module.discovery.model; + +import java.util.List; + +public class DiscoveryService { + private List includeServices; + + public List getIncludeServices() { + return includeServices; + } + + public void setIncludeServices(List includeServices) { + this.includeServices = includeServices; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryStartInfo.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryStartInfo.java new file mode 100644 index 0000000..27e0796 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryStartInfo.java @@ -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 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 getServices() { + return services; + } + + public void setServices(List services) { + this.services = services; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java new file mode 100644 index 0000000..7b00c6a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/DiscoveryZone.java @@ -0,0 +1,25 @@ +package com.loafle.overflow.central.module.discovery.model; + +import java.util.List; + +public class DiscoveryZone { + private List excludePatterns; + + private DiscoveryHost discoveryHost; + + public List getExcludePatterns() { + return excludePatterns; + } + + public void setExcludePatterns(List excludePatterns) { + this.excludePatterns = excludePatterns; + } + + public DiscoveryHost getDiscoveryHost() { + return discoveryHost; + } + + public void setDiscoveryHost(DiscoveryHost discoveryHost) { + this.discoveryHost = discoveryHost; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java new file mode 100644 index 0000000..e887f35 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/Host.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java new file mode 100644 index 0000000..8cb7e2c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/Port.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java new file mode 100644 index 0000000..59eb988 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/Service.java @@ -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; + } + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java b/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java new file mode 100644 index 0000000..834dd17 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/model/Zone.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java new file mode 100644 index 0000000..48b8d23 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/service/DiscoveryService.java @@ -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); + } + +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/discovery/type/PortType.java b/src/main/java/com/loafle/overflow/central/module/discovery/type/PortType.java new file mode 100644 index 0000000..67fe74f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/discovery/type/PortType.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java new file mode 100644 index 0000000..cb896eb --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainDAO.java @@ -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 { +} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java new file mode 100644 index 0000000..f5d3c8f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/dao/DomainMemberDAO.java @@ -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 { + + @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 findAllMemberByDomain(@Param("domain") Domain domain); + + @Query("SELECT dm.member from DomainMember dm where dm.domain.id = (:domainID)") + List findAllMemberByDomainID(@Param("domainID") long domainID); +} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java b/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java new file mode 100644 index 0000000..88f220a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/model/Domain.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java b/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java new file mode 100644 index 0000000..2422f63 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/model/DomainMember.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java b/src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java new file mode 100644 index 0000000..58d61a6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/service/DomainMemberService.java @@ -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 readAllMemberByDomain(Domain domain) { + return this.domainMemberDAO.findAllMemberByDomain(domain); + } + + public List readAllMemberByDomainID(final long domainID) { + return this.domainMemberDAO.findAllMemberByDomainID(domainID); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java b/src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java new file mode 100644 index 0000000..286e54e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/domain/service/DomainService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/email/dao/EmailAuthDAO.java b/src/main/java/com/loafle/overflow/central/module/email/dao/EmailAuthDAO.java new file mode 100644 index 0000000..a12fd40 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/email/dao/EmailAuthDAO.java @@ -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 findByEmailAuthKey(String emailAuthKey); + + List findByMember(Member member); + +} + diff --git a/src/main/java/com/loafle/overflow/central/module/email/exception/EmailOverAuthException.java b/src/main/java/com/loafle/overflow/central/module/email/exception/EmailOverAuthException.java new file mode 100644 index 0000000..cf818bc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/email/exception/EmailOverAuthException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/email/model/EmailAuth.java b/src/main/java/com/loafle/overflow/central/module/email/model/EmailAuth.java new file mode 100644 index 0000000..3f764b6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/email/model/EmailAuth.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/email/service/EmailAuthService.java b/src/main/java/com/loafle/overflow/central/module/email/service/EmailAuthService.java new file mode 100644 index 0000000..51ecb1f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/email/service/EmailAuthService.java @@ -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 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 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 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; + } + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/GenerateUtil.java b/src/main/java/com/loafle/overflow/central/module/generator/service/GenerateUtil.java new file mode 100644 index 0000000..f9a46bb --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/GenerateUtil.java @@ -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> mappingMap = null; + + public Map initMappingMap(MetaCrawler metaCrawler) { + + if(this.mappingMap == null) { + this.mappingMap = new HashMap<>(); + } + + Map 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> sortItems(List sensorItems, Map keyMap) { + + Map> 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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostGenerator.java new file mode 100644 index 0000000..cb53f60 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostGenerator.java @@ -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 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 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 optionMap; + optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference>() {}); + + if(dbSensor.getCrawler().getId() == MetaCrawlerEnum.WMI_CRAWLER.getValue()) { + connection.setPort("135"); + connection.setPortType("tcp"); + connection.setSsl(false); + + target.setConnection(connection); + + Map auth = new HashMap<>(); + auth.put("id", optionMap.get("ID")); + auth.put("pw", optionMap.get("PassWord")); + + target.setAuth(auth); + + } + + return target; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostWMIGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostWMIGenerator.java new file mode 100644 index 0000000..13c054b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraHostWMIGenerator.java @@ -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 sensorItems, Map keyMap, Sensor dbSensor, Config config) throws IOException { + + Map> 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 itemList = new ArrayList<>(); + Item item = null; + QueryInfo queryInfo = null; + MappingInfo mappingInfo = null; + + StringBuffer stringBuffer = new StringBuffer(); + + Map extendMap = new HashMap<>(); + extendMap.put("nameSpace", "root/cimv2"); + extendMap.put("wmicPath", "/home/snoop/temp/wmic"); + + + List keysList = null; + MetaSensorItemKey tempItemKey = null; + Keys keys = null; + for(Map.Entry> 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 arrayColumns = null; + + String json = tempItemKey.getOption(); + if(json != null && json.length() > 0) { + HashMap optionMap; + optionMap = new ObjectMapper().readValue(json, new TypeReference>() {}); + + Object obj = null; + obj = optionMap.get("appends"); + if(obj != null) { + List appendsList = (List)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)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); + + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceGenerator.java new file mode 100644 index 0000000..f3879bc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceGenerator.java @@ -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 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 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 optionMap; + optionMap = new ObjectMapper().readValue(authCrawler.getAuthJson(), new TypeReference>() {}); + + Map 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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceJMXGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceJMXGenerator.java new file mode 100644 index 0000000..17b318e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceJMXGenerator.java @@ -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 sensorItems, Map keyMap, Sensor dbSensor, Config config) throws IOException { + Map> metricMap = null; + metricMap = this.generateUtil.sortItems(sensorItems, keyMap); + + List itemList = new ArrayList<>(); + Item item = null; + QueryInfo queryInfo = null; + MappingInfo mappingInfo = null; + + StringBuffer buffer = new StringBuffer(); + + Map extendMap = new HashMap<>(); + + List keysList = null; + MetaSensorItemKey tempItemKey = null; + Keys keys = null; + + for (Map.Entry> 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 aliases = null; + List arrayCol = null; + + if (json != null && json.length() > 0) { + HashMap optionMap; + optionMap = new ObjectMapper().readValue(json, new TypeReference>() {}); + + Object obj = null; + obj = optionMap.get("aliases"); + + if (obj != null) { + aliases = (List)obj; + } + + obj = optionMap.get("arrayColumns"); + if (obj != null) { + arrayCol = (List)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); + } + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceMysqlGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceMysqlGenerator.java new file mode 100644 index 0000000..263d743 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/InfraServiceMysqlGenerator.java @@ -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 sensorItems, Map keyMap, Sensor dbSensor, Config config) throws IOException { + + +// List 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> metricMap = null; + metricMap = this.generateUtil.sortItems(sensorItems, keyMap); + + List itemList = new ArrayList<>(); + + QueryInfo queryInfo = null; + MappingInfo mappingInfo = null; + + List keysList = null; + MetaSensorItemKey tempItemKey = null; + Keys keys = null; + Item item = null; + StringBuffer stringBuffer = new StringBuffer(); + for(Map.Entry> 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 keyColumns = null; + String valueColumn = null; + + String json = tempItemKey.getOption(); + if(json != null && json.length() > 0) { + HashMap optionMap; + optionMap = new ObjectMapper().readValue(json, new TypeReference>() {}); + + Object obj = null; + obj = optionMap.get("valueColumn"); + if(obj != null) { + valueColumn = (String)obj; + } + + obj = optionMap.get("keyColumns"); + if(obj != null) { + keyColumns = (List)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 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 keyColumns = new ArrayList<>(); +// keyColumns.add("Variable_name"); +// +// mappingInfo.setKeyColumns(keyColumns); +// } +// break; +// } +// +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/generator/service/SensorConfigGenerator.java b/src/main/java/com/loafle/overflow/central/module/generator/service/SensorConfigGenerator.java new file mode 100644 index 0000000..7f23b75 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/generator/service/SensorConfigGenerator.java @@ -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 dbItemList = this.sensorItemService.readAllBySensor(sensor, pageParams); + + List 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; + } + + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java new file mode 100644 index 0000000..8fc6ed3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/history/dao/HistoryDAO.java @@ -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 { + + Page findAllByProbe(Probe probe, Pageable pageable); + + @Query("SELECT h FROM History h WHERE h.probe.id = :#{#probe.id} and h.type.id = :#{#type.id}") + Page findAllByProbeAndType(@Param("probe") Probe probe, @Param("type") MetaHistoryType type, Pageable pageable); + + Page 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 findAllByDomainAndType(@Param("domain") Domain domain, @Param("type") MetaHistoryType type, Pageable pageRequest); +} diff --git a/src/main/java/com/loafle/overflow/central/module/history/model/History.java b/src/main/java/com/loafle/overflow/central/module/history/model/History.java new file mode 100644 index 0000000..2a80826 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/history/model/History.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java b/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java new file mode 100644 index 0000000..b733721 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/history/service/HistoryService.java @@ -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 readAllByProbeAndType(Probe probe, MetaHistoryType type, PageParams pageParams) { + return this.historyDAO.findAllByProbeAndType(probe, type, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByProbe(Probe probe, PageParams pageParams) { + return this.historyDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByDomain(Domain domain, PageParams pageParams) { + return this.historyDAO.findAllByDomain(domain, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByDomainAndType(Domain domain, MetaHistoryType type, PageParams pageParams) { + return this.historyDAO.findAllByDomainAndType(domain, type, PageUtil.getPageRequest(pageParams)); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java new file mode 100644 index 0000000..062c136 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraDAO.java @@ -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 { + List findAllByProbe(Probe probe); + + Page findAllByProbe(Probe probe, Pageable pageable); + + @Query("SELECT i FROM INFRA i WHERE i.probe IN (:probeList) AND i.target != NULL") + Page findAllByProbeList(@Param("probeList") List probeList, Pageable pageable); + + + @Query("SELECT DISTINCT i.target FROM INFRA i WHERE i.probe IN (:probeList)") + List findAllTargetByProbeList(@Param("probeList") List probeList); + + Infra findByTarget(Target target); + +// List findAllByProbe(List probeList); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraHostDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraHostDAO.java new file mode 100644 index 0000000..8ce27a1 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraHostDAO.java @@ -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 findByIp(long ip); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraMachineDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraMachineDAO.java new file mode 100644 index 0000000..c497973 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraMachineDAO.java @@ -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 { +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSApplicationDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSApplicationDAO.java new file mode 100644 index 0000000..7d29d55 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSApplicationDAO.java @@ -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 { +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDAO.java new file mode 100644 index 0000000..0f8ba0e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDAO.java @@ -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 { +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDaemonDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDaemonDAO.java new file mode 100644 index 0000000..756d06c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSDaemonDAO.java @@ -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 { +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSPortDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSPortDAO.java new file mode 100644 index 0000000..1d61c89 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraOSPortDAO.java @@ -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 { + + @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); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraServiceDAO.java b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraServiceDAO.java new file mode 100644 index 0000000..9c0ead9 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/dao/InfraServiceDAO.java @@ -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 { + + @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); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/infra/exception/InfraNotFoundException.java b/src/main/java/com/loafle/overflow/central/module/infra/exception/InfraNotFoundException.java new file mode 100644 index 0000000..4bc55f8 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/exception/InfraNotFoundException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/Infra.java b/src/main/java/com/loafle/overflow/central/module/infra/model/Infra.java new file mode 100644 index 0000000..d1064fc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/Infra.java @@ -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; +// } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraHost.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraHost.java new file mode 100644 index 0000000..7763a31 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraHost.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraMachine.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraMachine.java new file mode 100644 index 0000000..7a0bc62 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraMachine.java @@ -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; + } + +} + diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOS.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOS.java new file mode 100644 index 0000000..52ae385 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOS.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSApplication.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSApplication.java new file mode 100644 index 0000000..3d8935b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSApplication.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSDaemon.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSDaemon.java new file mode 100644 index 0000000..18c0175 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSDaemon.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSPort.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSPort.java new file mode 100644 index 0000000..316e48e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraOSPort.java @@ -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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/model/InfraService.java b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraService.java new file mode 100644 index 0000000..7ecb14d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/model/InfraService.java @@ -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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraHostService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraHostService.java new file mode 100644 index 0000000..c1a9505 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraHostService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraMachineService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraMachineService.java new file mode 100644 index 0000000..fc89ad6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraMachineService.java @@ -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); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationService.java new file mode 100644 index 0000000..26d65fd --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonService.java new file mode 100644 index 0000000..755839a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSPortService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSPortService.java new file mode 100644 index 0000000..7457d08 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSPortService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSService.java new file mode 100644 index 0000000..4e36bef --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraOSService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraService.java new file mode 100644 index 0000000..974faa1 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraService.java @@ -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 readAllByProbe(Probe probe, PageParams pageParams) { + return this.infraDAO.findAllByProbe(probe, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByDomain(Domain domain, PageParams pageParams) { + List probeList = this.probeService.readAllByDomain(domain); + + if(probeList == null || probeList.size() <= 0) { + throw new ProbeNotFoundException(); + } + + Page infraList = this.infraDAO.findAllByProbeList(probeList, PageUtil.getPageRequest(pageParams)); + for (Infra infra: infraList) { + infra.getTarget().setSensors(this.sensorDAO.findAllByTarget(infra.getTarget())); + } + return infraList; + } + + + public List readAllTargetByDomain(Domain domain) { + + List probeList = this.probeService.readAllByDomain(domain); + + if(probeList == null || probeList.size() <= 0) { + throw new ProbeNotFoundException(); + } + + return this.infraDAO.findAllTargetByProbeList(probeList); + } + + public List readAllTargetByProbeList(List probeList) { + return this.infraDAO.findAllTargetByProbeList(probeList); +// return null; + } + + public Infra readByTarget(Target target) { + return this.infraDAO.findByTarget(target); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/InfraServiceService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraServiceService.java new file mode 100644 index 0000000..34a9413 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/InfraServiceService.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/dao/MemberDAO.java b/src/main/java/com/loafle/overflow/central/module/member/dao/MemberDAO.java new file mode 100644 index 0000000..d1c5c78 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/dao/MemberDAO.java @@ -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 { + @Query("select m from Member m WHERE m.email = :signinId") + Member findByEmail(@Param("signinId") String signinId); +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAO.java b/src/main/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAO.java new file mode 100644 index 0000000..38c531e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAO.java @@ -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 { + @Query("select m from MemberTotp m WHERE m.secretCode = :secretCode") + MemberTotp findBySecretCode(@Param("secretCode") String secretCode); + + + MemberTotp findByMember(Member member); +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/EmailNotConfirmedException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/EmailNotConfirmedException.java new file mode 100644 index 0000000..407031e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/EmailNotConfirmedException.java @@ -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); + } +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/EqualsOldPasswordException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/EqualsOldPasswordException.java new file mode 100644 index 0000000..98a672e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/EqualsOldPasswordException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/JoinedEmailException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/JoinedEmailException.java new file mode 100644 index 0000000..9ef43fc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/JoinedEmailException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/PasswordNotStrongException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/PasswordNotStrongException.java new file mode 100644 index 0000000..3760f7b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/PasswordNotStrongException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/SecretCodeNotExistException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/SecretCodeNotExistException.java new file mode 100644 index 0000000..39e9a75 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/SecretCodeNotExistException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/SignInIdNotExistException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/SignInIdNotExistException.java new file mode 100644 index 0000000..55af0e4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/SignInIdNotExistException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/SignInPwNotMatchException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/SignInPwNotMatchException.java new file mode 100644 index 0000000..7667e2c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/SignInPwNotMatchException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/SigninOverFailedException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/SigninOverFailedException.java new file mode 100644 index 0000000..52c1d83 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/SigninOverFailedException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/exception/TotpCodeNotMatchException.java b/src/main/java/com/loafle/overflow/central/module/member/exception/TotpCodeNotMatchException.java new file mode 100644 index 0000000..327775b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/exception/TotpCodeNotMatchException.java @@ -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); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/model/Member.java b/src/main/java/com/loafle/overflow/central/module/member/model/Member.java new file mode 100644 index 0000000..e4288d7 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/model/Member.java @@ -0,0 +1,133 @@ +package com.loafle.overflow.central.module.member.model; + + +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import org.codehaus.jackson.annotate.JsonIgnore; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "MEMBER", schema = "public") +public class Member { + private long id; + private String email; + private String pw; + private String name; + private String phone; + private String companyName; + private Date createDate; + private MetaMemberStatus status; + private int signinFailCount; + private boolean totpType; + + public Member() { + } + + public Member(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 = "EMAIL", nullable = false, length = 50) + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Basic + @JsonIgnore + @Column(name = "PW", nullable = true, length = 64) + public String getPw() { + return pw; + } + + public void setPw(String pw) { + this.pw = pw; + } + + @Basic + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Basic + @Column(name = "PHONE", nullable = true, length = 50) + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + @Basic + @Column(name = "COMPANY_NAME", nullable = true, length = 50) + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + @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 = "STATUS_ID", nullable = false) + public MetaMemberStatus getStatus() { + return status; + } + + public void setStatus(MetaMemberStatus status) { + this.status = status; + } + + @Column(name = "SIGNIN_FAIL_COUNT", nullable = true, columnDefinition = "int default 0") + public int getSigninFailCount(){ + return this.signinFailCount; + } + + public void setSigninFailCount(int failCount) { + this.signinFailCount = failCount; + } + + @Basic + @Column(name = "TOTP_TYPE", nullable = false, columnDefinition = "boolean default false") + public boolean isTotpType() { + return totpType; + } + + public void setTotpType(boolean totpType) { + this.totpType = totpType; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/model/MemberTotp.java b/src/main/java/com/loafle/overflow/central/module/member/model/MemberTotp.java new file mode 100644 index 0000000..7787ebb --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/model/MemberTotp.java @@ -0,0 +1,86 @@ +package com.loafle.overflow.central.module.member.model; + +import org.codehaus.jackson.annotate.JsonIgnore; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by geek on 18. 3. 8. + */ +@Entity +@Table(name = "MEMBER_TOTP", schema = "public") +public class MemberTotp { + private long id; + private Member member; + private String secretCode; + private Date createDate; + private Date updateDate; + private String otpAuth; + + public MemberTotp() { + } + + public MemberTotp(long id) { + this.id = id; + } + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "MEMBER_ID", nullable = false) + public Member getMember() { + return member; + } + + public void setMember(Member member) { + this.member = member; + } + + @Basic + @Column(name = "SECRET_CODE", nullable = false, length = 20) + public String getSecretCode() { + return secretCode; + } + + public void setSecretCode(String secretCode) { + this.secretCode = secretCode; + } + + @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; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "UPDATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = true) + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + @Transient + public String getOtpAuth() { + return otpAuth; + } + + public void setOtpAuth(String otpAuthURL) { + this.otpAuth = otpAuthURL; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/central/module/member/service/MemberService.java new file mode 100644 index 0000000..e60dc5a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/service/MemberService.java @@ -0,0 +1,287 @@ +package com.loafle.overflow.central.module.member.service; + +import com.loafle.overflow.central.commons.model.SessionMetadata; +import com.loafle.overflow.central.commons.stereotype.WebappAPI; +import com.loafle.overflow.central.commons.utils.EmailSender; +import com.loafle.overflow.central.module.apikey.model.ApiKey; +import com.loafle.overflow.central.module.apikey.service.ApiKeyService; +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.domain.model.DomainMember; +import com.loafle.overflow.central.module.domain.service.DomainMemberService; +import com.loafle.overflow.central.module.email.service.EmailAuthService; +import com.loafle.overflow.central.module.member.dao.MemberDAO; +import com.loafle.overflow.central.module.member.exception.*; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.service.ProbeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.mail.MailException; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; + +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Created by geek on 17. 6. 28. + */ +@Service("MemberService") +public class MemberService { + + @Autowired + private MemberDAO memberDAO; + + @Autowired + private EmailAuthService emailAuthService; + + @Autowired + private EmailSender emailSender; + + @Autowired + private ApiKeyService apiKeyService; + + @Autowired + private DomainMemberService domainMemberService; + + @Autowired + private ProbeService probeService; + + private BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + + public DomainMember signin(String signinId, String signinPw) { + Member m = this.memberDAO.findByEmail(signinId); + + if ( null == m ) { + throw new SignInIdNotExistException(); + } + + if ( m.getStatus().getId() == 1 ) { + throw new EmailNotConfirmedException(); + } + + Boolean match = passwordEncoder.matches(signinPw, m.getPw()); + if(!match) { + if (m.getSigninFailCount() > 10) { + throw new SigninOverFailedException("Login failed 10 times"); + } + m.setSigninFailCount(m.getSigninFailCount()+1); + this.modify(m); + throw new SignInPwNotMatchException(); + } + + m.setSigninFailCount(0); + this.modify(m); + + DomainMember dm = domainMemberService.readByMemberEmail(m.getEmail()); + + // Todo Signin History + return dm; + } + + public Member signup(Member member, String pw) throws UnsupportedEncodingException { + + Member isMember = this.memberDAO.findByEmail(member.getEmail()); + + if (null != isMember && isMember.getId() > 0) { + throw new JoinedEmailException(); + } + + boolean checkPass = this.isPasswordStrong(pw); + + if (!checkPass) { + throw new PasswordNotStrongException( + "Passwords must contain at least one uppercase letter, " + + "special character, lowercase letter, and number, " + + "and must be at least 6 characters long."); + } + member.setPw(passwordEncoder.encode(pw)); + + if (member.getStatus() == null) { + member.setStatus(new MetaMemberStatus((short) 1)); + } + + Member resMember = this.memberDAO.save(member); + + try { + this.emailAuthService.sendEmailByMember(member.getId(), member.getEmail()); + } catch (MailException e) { + // Todo ReSend Mail + e.printStackTrace(); + } + + return resMember; + } + + public Member sendEmailForPassword(String email) throws UnsupportedEncodingException { + Member member = this.memberDAO.findByEmail(email); + + if (null == member) { + throw new SignInIdNotExistException(); + } + + try { + this.emailAuthService.sendEmailResetPassword(member); + } catch (MailException e) { + // Todo ReSend Mail + e.printStackTrace(); + } + + return member; + } + + public Member resetPassword(String encodeEmail, String pw) throws UnsupportedEncodingException { + String deStr = URLDecoder.decode(encodeEmail, "UTF-8"); + + String deEmail = this.emailSender.decrypt(deStr); + Member member = this.memberDAO.findByEmail(deEmail); + + if (null == member) { + throw new SignInIdNotExistException(); + } + + boolean checkPass = this.isPasswordStrong(pw); + + if (!checkPass) { + throw new PasswordNotStrongException( + "Passwords must contain at least one uppercase letter, " + + "special character, lowercase letter, and number, " + + "and must be at least 6 characters long."); + } + member.setPw(passwordEncoder.encode(pw)); + + return this.modify(member); + } + + public void signout(Member member) { + // Todo websocket session remove + } + + @WebappAPI + public Member modify(Member member, String pw) { + String email = SessionMetadata.getTargetID(); + Member preMember = this.memberDAO.findByEmail(member.getEmail()); + + if (null != pw && !pw.equals("")) { + boolean checkPass = this.isPasswordStrong(pw); + + if (!checkPass) { + throw new PasswordNotStrongException( + "Passwords must contain at least one uppercase letter, " + + "special character, lowercase letter, and number, " + + "and must be at least 6 characters long."); + } + + Boolean match = passwordEncoder.matches(member.getPw(), preMember.getPw()); + if(!match) { + member.setPw(passwordEncoder.encode(pw)); + } + } else { + member.setPw(preMember.getPw()); + } + + if (member.getStatus() == null || member.getStatus().getId() < 0) { + member.getStatus().setId(preMember.getStatus().getId()); + } + return this.modify(member); + } + + private Member modify(Member member) { + return this.memberDAO.save(member); + } + + public Member confirmPw(String signinId, String signinPw) { + Member preMember = this.memberDAO.findByEmail(signinId); + + String encodePw = passwordEncoder.encode(signinPw); + Boolean match = passwordEncoder.matches(encodePw, preMember.getPw()); + + if (!match) { + throw new SignInPwNotMatchException(); + } + + return preMember; + } + + public Member forgotPassword(String signinId, String newPw) { + Member preMember = this.memberDAO.findByEmail(signinId); + + if (null == preMember) { + throw new SignInIdNotExistException(); + } + + Member cMember = this.modify(preMember, newPw); + + return cMember; + } + + public Member read(long memberId) { + if (memberId <= 0) { + throw new SignInIdNotExistException(); + } + + Member resMember = this.memberDAO.findOne(memberId); + return resMember; + } + + @WebappAPI + public void withdrawal(Member member) { + String email = SessionMetadata.getTargetID(); + + // Todo DB delete? + } + + public void emailConfirm(Member member) { + + } + + public List readAllByProbeKey(String probeKey) { + + Probe probe = this.probeService.readByProbeKey(probeKey); + + if(probe == null) { + return null; + } + + return this.domainMemberService.readAllMemberByDomain(probe.getDomain()); + } + + public List readAllByApiKey(String apikey) { + + ApiKey apiKey = this.apiKeyService.readByApiKey(apikey); + + if(apiKey == null) { + return null; + } + + return this.domainMemberService.readAllMemberByDomain(apiKey.getDomain()); + } + + public List readAllByDomain(Domain domain) { + + return this.domainMemberService.readAllMemberByDomain(domain); + } + + public List readAllByDomainID(final long domainID) { + + return this.domainMemberService.readAllMemberByDomainID(domainID); + } + + private static final String PASSWORD_REGEXP = "(" + + "(?=.*[a-z])" + + "(?=.*\\d)" + + "(?=.*[A-Z])" + + "(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?])" + + "." + + "{6,40}" + + ")"; + private Pattern pattern = Pattern.compile(PASSWORD_REGEXP); + + protected boolean isPasswordStrong(String pass) { + Matcher m = pattern.matcher(pass); + return m.matches(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/member/service/MemberTotpService.java b/src/main/java/com/loafle/overflow/central/module/member/service/MemberTotpService.java new file mode 100644 index 0000000..846abd4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/member/service/MemberTotpService.java @@ -0,0 +1,120 @@ +package com.loafle.overflow.central.module.member.service; + +import com.loafle.overflow.central.module.member.dao.MemberTotpDAO; +import com.loafle.overflow.central.module.member.exception.SecretCodeNotExistException; +import com.loafle.overflow.central.module.member.exception.SignInIdNotExistException; +import com.loafle.overflow.central.module.member.exception.TotpCodeNotMatchException; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.member.model.MemberTotp; +import com.warrenstrange.googleauth.GoogleAuthenticator; +import com.warrenstrange.googleauth.GoogleAuthenticatorKey; +import org.apache.http.client.utils.URIBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by geek on 18. 3. 8. + */ +@Service("MemberTotpService") +public class MemberTotpService { + @Autowired + private MemberTotpDAO totpDAO; + + public void regist(Member member, String secretCode, String code) throws Exception { + + if (null == member || 0 >= member.getId()) { + throw new SignInIdNotExistException("Not Null Member ID"); + } + + if (!this.checkCode(secretCode, code) ) { + throw new TotpCodeNotMatchException("Not Equal"); + } + + MemberTotp totp = new MemberTotp(); + totp.setMember(member); + totp.setSecretCode(secretCode); + + this.totpDAO.save(totp); + } + + public MemberTotp modify(MemberTotp totp) { + if ( null == totp.getSecretCode() || totp.getSecretCode().equals("")) { + throw new SecretCodeNotExistException("No secret code exists"); + } + if (null == totp.getMember() || 0 < totp.getMember().getId()) { + throw new SignInIdNotExistException("There is no member ID in the TOTP table."); + } + + return this.totpDAO.save(totp); + } + + public void remove(long id) throws Exception { + this.totpDAO.delete(id); + } + + public MemberTotp read(long id) throws Exception { + return this.totpDAO.findOne(id); + } + + public boolean checkCodeForMember(Member member, String code) throws Exception { + MemberTotp totp = this.totpDAO.findByMember(member); + if (null == totp && (totp.getSecretCode() == null || totp.getSecretCode().equals("")) ) { + throw new SignInIdNotExistException("Error TotpMember"); + } + return this.checkCode(totp.getSecretCode(), code); + } + + public boolean checkCode(String secretCode, String code) throws Exception { + GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(); + int codeInt = Integer.parseInt(code); + boolean isCheck = googleAuthenticator.authorize(secretCode, codeInt); + + if (!isCheck) { + throw new TotpCodeNotMatchException("Invalid Code"); + } + + return isCheck; + } + + public Map createTotp(Member member) { + Map returnMap = new HashMap<>(); + + GoogleAuthenticator googleAuthenticator = new GoogleAuthenticator(); + final GoogleAuthenticatorKey key = googleAuthenticator.createCredentials(); + + String secret = key.getKey(); +// List scratchCodes = key.getScratchCodes(); +// String otpAuthURL = GoogleAuthenticatorQRGenerator.getOtpAuthURL("overFlow", member.getEmail(), key); + URIBuilder uri = (new URIBuilder()).setScheme("otpauth") + .setHost("totp") + .setPath("/" + formatLabel("overFlow", member.getEmail())) + .setParameter("secret", key.getKey()); + + returnMap.put("key", secret); + returnMap.put("uri", uri.toString()); + + return returnMap; + } + + private String formatLabel(String issuer, String accountName) { + if(accountName != null && accountName.trim().length() != 0) { + StringBuilder sb = new StringBuilder(); + if(issuer != null) { + if(issuer.contains(":")) { + throw new IllegalArgumentException("Issuer cannot contain the ':' character."); + } + + sb.append(issuer); + sb.append(":"); + } + + sb.append(accountName); + return sb.toString(); + } else { + throw new IllegalArgumentException("Account name must not be empty."); + } + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerDAO.java new file mode 100644 index 0000000..3cae4ec --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaCrawlerDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerInputItemDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerInputItemDAO.java new file mode 100644 index 0000000..b678fdd --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaCrawlerInputItemDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaCrawlerInputItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaCrawlerInputItemDAO extends JpaRepository { + + List findAllByCrawler(MetaCrawler crawler); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaHistoryTypeDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaHistoryTypeDAO.java new file mode 100644 index 0000000..53e5c67 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaHistoryTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaHistoryType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaHistoryTypeDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraTypeDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraTypeDAO.java new file mode 100644 index 0000000..6a23340 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaInfraTypeDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraVendorDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraVendorDAO.java new file mode 100644 index 0000000..b22fe9c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInfraVendorDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaInfraVendorDAO extends JpaRepository { + + List findAllByInfraType(MetaInfraType infraType); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInputTypeDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInputTypeDAO.java new file mode 100644 index 0000000..f71d625 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaInputTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaInputType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaInputTypeDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaMemberStatusDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaMemberStatusDAO.java new file mode 100644 index 0000000..7238c24 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaMemberStatusDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaMemberStatusDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNoAuthProbeStatusDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNoAuthProbeStatusDAO.java new file mode 100644 index 0000000..a1d6b4c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNoAuthProbeStatusDAO.java @@ -0,0 +1,12 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by snoop on 17. 6. 26. + */ +@Repository +public interface MetaNoAuthProbeStatusDAO extends JpaRepository { +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNotificationDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNotificationDAO.java new file mode 100644 index 0000000..625a134 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaNotificationDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaNotification; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaNotificationDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeArchitectureDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeArchitectureDAO.java new file mode 100644 index 0000000..8f3839d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeArchitectureDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeArchitecture; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaProbeArchitectureDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeOsDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeOsDAO.java new file mode 100644 index 0000000..4f98e69 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeOsDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaProbeOsDAO extends JpaRepository { + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbePackageDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbePackageDAO.java new file mode 100644 index 0000000..8e4f4a8 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbePackageDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import com.loafle.overflow.central.module.meta.model.MetaProbePackage; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaProbePackageDAO extends JpaRepository { + + List findAllByOs(MetaProbeOs metaProbeOs); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeStatusDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeStatusDAO.java new file mode 100644 index 0000000..a5fc69d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeStatusDAO.java @@ -0,0 +1,12 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by snoop on 17. 6. 26. + */ +@Repository +public interface MetaProbeStatusDAO extends JpaRepository { +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeTaskTypeDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeTaskTypeDAO.java new file mode 100644 index 0000000..222eff0 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeTaskTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaProbeTaskTypeDAO extends JpaRepository{ + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeVersionDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeVersionDAO.java new file mode 100644 index 0000000..419fe18 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaProbeVersionDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaProbeVersion; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaProbeVersionDAO extends JpaRepository{ + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayItemDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayItemDAO.java new file mode 100644 index 0000000..9eeb283 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayItemDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 9. 20. + */ +@Repository +public interface MetaSensorDisplayItemDAO extends JpaRepository { + public List findAllByCrawler(MetaCrawler crawler); + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayMappingDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayMappingDAO.java new file mode 100644 index 0000000..32ffeeb --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorDisplayMappingDAO.java @@ -0,0 +1,21 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayMapping; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +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. 11. 7. + */ +@Repository +public interface MetaSensorDisplayMappingDAO extends JpaRepository { + + @Query("SELECT m.itemKey from MetaSensorDisplayMapping m where m.displayItem = (:displayItem)") + public List findAllByDisplayItem(@Param("displayItem") MetaSensorDisplayItem displayItem); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemDAO.java new file mode 100644 index 0000000..c9b1f35 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaSensorItemDAO extends JpaRepository{ + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemKeyDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemKeyDAO.java new file mode 100644 index 0000000..8ab5804 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemKeyDAO.java @@ -0,0 +1,18 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by snoop on 17. 8. 29. + */ +@Repository +public interface MetaSensorItemKeyDAO extends JpaRepository { + +// @Query("SELECT msik.item.id, msik.key from MetaSensorItemKey msik WHERE msik.crawler.id = (:metaCrawler.id)") + List findAllByCrawler(MetaCrawler metaCrawler); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemTypeDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemTypeDAO.java new file mode 100644 index 0000000..78f915c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemTypeDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItemType; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaSensorItemTypeDAO extends JpaRepository{ + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemUnitDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemUnitDAO.java new file mode 100644 index 0000000..9e3a6ae --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorItemUnitDAO.java @@ -0,0 +1,12 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItemUnit; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 9. 20. + */ +@Repository +public interface MetaSensorItemUnitDAO extends JpaRepository { +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorStatusDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorStatusDAO.java new file mode 100644 index 0000000..954d0ac --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaSensorStatusDAO.java @@ -0,0 +1,12 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorStatus; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by snoop on 17. 6. 26. + */ +@Repository +public interface MetaSensorStatusDAO extends JpaRepository { +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerDAO.java new file mode 100644 index 0000000..620d5c6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.module.meta.model.MetaVendorCrawler; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaVendorCrawlerDAO extends JpaRepository{ + + List findAllByInfraVendor(MetaInfraVendor infraVendor); +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerSensorItemDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerSensorItemDAO.java new file mode 100644 index 0000000..59fd828 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaVendorCrawlerSensorItemDAO.java @@ -0,0 +1,13 @@ +package com.loafle.overflow.central.module.meta.dao; + +import com.loafle.overflow.central.module.meta.model.MetaVendorCrawlerSensorItem; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by insanity on 17. 6. 23. + */ +@Repository +public interface MetaVendorCrawlerSensorItemDAO extends JpaRepository{ + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawler.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawler.java new file mode 100644 index 0000000..841b6c6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawler.java @@ -0,0 +1,63 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_CRAWLER", schema = "public") +public class MetaCrawler { + private short id; + private Date createDate; + private String name; + private String description; + + public MetaCrawler(short id) { + this.id = id; + } + + public MetaCrawler() { + + } + + @Id + public short getId() { + return id; + } + + public void setId(short 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; + } + + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "DESCRIPTION", nullable = true, length = 100) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawlerInputItem.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawlerInputItem.java new file mode 100644 index 0000000..785315c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaCrawlerInputItem.java @@ -0,0 +1,167 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_CRAWLER_INPUT_ITEM", schema = "public") +public class MetaCrawlerInputItem { + private int id; + private MetaInputType inputType; + private MetaCrawler crawler; + private String description; + private String name; + private Date createDate; + private boolean required; + private String defaultValue; + private String pattern; + private String keyName; + private String keyValue; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + @ManyToOne + @JoinColumn(name = "TYPE_ID", nullable = false) + public MetaInputType getInputType() { + return inputType; + } + + public void setInputType(MetaInputType inputType) { + this.inputType = inputType; + } + + @ManyToOne + @JoinColumn(name = "CRAWLER_ID", nullable = false) + public MetaCrawler getCrawler() { + return crawler; + } + + public void setCrawler(MetaCrawler crawler) { + this.crawler = crawler; + } + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @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; + } + + @Column(name = "REQUIRED", nullable = false) + public boolean isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } + + @Column(name = "DEFAULT_VALUE", nullable = true, length = 50) + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + + @Column(name = "PATTERN", nullable = true, length = 50) + public String getPattern() { + return pattern; + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + + @Column(name = "KEY_NAME", nullable = true, length = 50) + public String getKeyName() { + return keyName; + } + + public void setKeyName(String keyName) { + this.keyName = keyName; + } + + + @Column(name = "KEY_VALUE", nullable = true, length = 50) + public String getKeyValue() { + return keyValue; + } + + public void setKeyValue(String keyValue) { + this.keyValue = keyValue; + } + +// @Override +// public boolean equals(Object o) { +// if (this == o) return true; +// if (o == null || getClass() != o.getClass()) return false; +// +// MetaCrawlerInputItem that = (MetaCrawlerInputItem) o; +// +// if (id != that.id) return false; +// if (typeId != that.typeId) return false; +// if (crawlerId != that.crawlerId) return false; +// if (required != that.required) return false; +// if (desc != null ? !desc.equals(that.desc) : that.desc != null) return false; +// if (name != null ? !name.equals(that.name) : that.name != null) return false; +// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; +// if (defaultValue != null ? !defaultValue.equals(that.defaultValue) : that.defaultValue != null) return false; +// if (pattern != null ? !pattern.equals(that.pattern) : that.pattern != null) return false; +// if (keyName != null ? !keyName.equals(that.keyName) : that.keyName != null) return false; +// if (keyValue != null ? !keyValue.equals(that.keyValue) : that.keyValue != null) return false; +// +// return true; +// } +// +// @Override +// public int hashCode() { +// int result = id; +// result = 31 * result + (int) typeId; +// result = 31 * result + (int) crawlerId; +// result = 31 * result + (desc != null ? desc.hashCode() : 0); +// result = 31 * result + (name != null ? name.hashCode() : 0); +// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); +// result = 31 * result + (required ? 1 : 0); +// result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0); +// result = 31 * result + (pattern != null ? pattern.hashCode() : 0); +// result = 31 * result + (keyName != null ? keyName.hashCode() : 0); +// result = 31 * result + (keyValue != null ? keyValue.hashCode() : 0); +// return result; +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaHistoryType.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaHistoryType.java new file mode 100644 index 0000000..afb5045 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaHistoryType.java @@ -0,0 +1,53 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_HISTORY_TYPE", schema = "public") +public class MetaHistoryType { + private int id; + private String name; + private Date createDate; + + public MetaHistoryType() { + + } + + public MetaHistoryType(int id) { + this.id = id; + } + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraType.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraType.java new file mode 100644 index 0000000..9dccf64 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraType.java @@ -0,0 +1,45 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_INFRA_TYPE", schema = "public") +public class MetaInfraType { + private int id; + private String name; + private Date createDate; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + @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) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraVendor.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraVendor.java new file mode 100644 index 0000000..9115dbc --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInfraVendor.java @@ -0,0 +1,106 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_INFRA_VENDOR", schema = "public") +public class MetaInfraVendor { + private int id; + private String name; + private Date createDate; + private MetaInfraType infraType; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + + @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; + } + + + @ManyToOne + @JoinColumn(name = "TYPE_ID", nullable=false) + public MetaInfraType getInfraType() { + return infraType; + } + + public void setInfraType(MetaInfraType infraType) { + this.infraType = infraType; + } + + + public static MetaInfraVendor CreateInfraVendorByOS(String osName) { + + MetaInfraVendor vendor = new MetaInfraVendor(); + + if(osName == null || osName.length() <= 0) { + vendor.setId(28); // FIXME: Unknown + return vendor; + } + + if(osName.equals("Windows")) { + vendor.setId(26); + } + else if(osName.equals("Linux")) { + vendor.setId(28); // ubuntu + } else { + vendor.setId(28); // FIXME: Unknown + } + + return vendor; + } + + public static MetaInfraVendor CreateInfraVendorByPort(int portNumber) { + return null; + } + + public static MetaInfraVendor CreateInfraVendorByService(String serviceName) { + + MetaInfraVendor vendor = new MetaInfraVendor(); + + if(serviceName.equals("mysql")) { + vendor.setId(39); + } + else if(serviceName.equals("portgresql")) { + vendor.setId(39); + } + else if(serviceName.equals("wmi")) { + vendor.setId(39); + } + else if(serviceName.equals("snmpv2")) { + vendor.setId(39); + } + else { + vendor.setId(43); // unknown + } + + + return vendor; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInputType.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInputType.java new file mode 100644 index 0000000..0ad039d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaInputType.java @@ -0,0 +1,55 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_INPUT_TYPE", schema = "public") +public class MetaInputType { + private short id; + private String name; + private String description; + private Date createDate; + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @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; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaMemberStatus.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaMemberStatus.java new file mode 100644 index 0000000..7c8d5b6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaMemberStatus.java @@ -0,0 +1,44 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_MEMBER_STATUS", schema = "public") +public class MetaMemberStatus { + private short id; + private String name; + + public MetaMemberStatus() { + + } + + public MetaMemberStatus(short id) { + this.id = id; + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "Name", nullable = false, length = 10) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNoAuthProbeStatus.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNoAuthProbeStatus.java new file mode 100644 index 0000000..f14aaba --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNoAuthProbeStatus.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Created by snoop on 17. 6. 26. + */ +@Entity +@Table(name = "META_NOAUTH_PROBE_STATUS", schema = "public") +public class MetaNoAuthProbeStatus { + private short id; + private String name; + + public MetaNoAuthProbeStatus() { + + } + + public MetaNoAuthProbeStatus(short id) { + this.id = id; + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "Name", nullable = false, length = 10) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNotification.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNotification.java new file mode 100644 index 0000000..bddb57e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaNotification.java @@ -0,0 +1,54 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_NOTIFICATION", schema = "public") +public class MetaNotification { + private long id; + private Date createDate; + private String name; + private String description; + + @Id + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeArchitecture.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeArchitecture.java new file mode 100644 index 0000000..118968c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeArchitecture.java @@ -0,0 +1,45 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_PROBE_ARCHITECTURE", schema = "public") +public class MetaProbeArchitecture { + private short id; + private String architecture; + private Date createDate; + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "ARCHITECTURE", nullable = true, length = 10) + public String getArchitecture() { + return architecture; + } + + public void setArchitecture(String architecture) { + this.architecture = architecture; + } + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeOs.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeOs.java new file mode 100644 index 0000000..971947c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeOs.java @@ -0,0 +1,45 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_PROBE_OS", schema = "public") +public class MetaProbeOs { + private short id; + private String name; + private Date createDate; + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbePackage.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbePackage.java new file mode 100644 index 0000000..cfbeb07 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbePackage.java @@ -0,0 +1,68 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_PROBE_PACKAGE", schema = "public") +public class MetaProbePackage { + private long id; + private MetaProbeVersion version; + private MetaProbeOs os; + private MetaProbeArchitecture architecture; + private Date createDate; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "VERSION_ID", nullable = false) + public MetaProbeVersion getVersion() { + return version; + } + + public void setVersion(MetaProbeVersion version) { + this.version = version; + } + + @ManyToOne + @JoinColumn(name = "OS_ID", nullable = false) + public MetaProbeOs getOs() { + return os; + } + + public void setOs(MetaProbeOs os) { + this.os = os; + } + + @ManyToOne + @JoinColumn(name = "ARCHITECTURE_ID", nullable = false) + public MetaProbeArchitecture getArchitecture() { + return architecture; + } + + public void setArchitecture(MetaProbeArchitecture architecture) { + this.architecture = architecture; + } + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeStatus.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeStatus.java new file mode 100644 index 0000000..c03e9f3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeStatus.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Created by snoop on 17. 6. 26. + */ +@Entity +@Table(name = "META_PROBE_STATUS", schema = "public") +public class MetaProbeStatus { + private short id; + private String name; + + public MetaProbeStatus() { + + } + + public MetaProbeStatus(short id) { + this.id = id; + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "Name", nullable = false, length = 10) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeTaskType.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeTaskType.java new file mode 100644 index 0000000..faedfec --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeTaskType.java @@ -0,0 +1,56 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_PROBE_TASK_TYPE", schema = "public") +public class MetaProbeTaskType { + private short id; + private String name; + private String description; + private Date createDate; + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "NAME", nullable = false, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "DESCRIPTION", nullable = false, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @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; + } + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeVersion.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeVersion.java new file mode 100644 index 0000000..407ea4e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaProbeVersion.java @@ -0,0 +1,46 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_PROBE_VERSION", schema = "public") +public class MetaProbeVersion { + private short id; + private String version; + private Date createDate; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "VERSION", nullable = true, length = 10) + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayItem.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayItem.java new file mode 100644 index 0000000..2345c92 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayItem.java @@ -0,0 +1,118 @@ +package com.loafle.overflow.central.module.meta.model; + + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by insanity on 17. 9. 20. + */ +@Entity +@Table(name = "META_SENSOR_DISPLAY_ITEM", schema = "public") +public class MetaSensorDisplayItem { + + private long id; + private String key; + private String displayName; + private String description; + private MetaCrawler crawler; + private MetaSensorItemUnit unit; + private Date createDate; + private boolean isDefault; + private MetaSensorItemType itemType; + + public MetaSensorDisplayItem() { + + } + public MetaSensorDisplayItem(long id) { + this.id = id; + } + + @Id + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "KEY", nullable = false) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + @Column(name = "DISPLAY_NAME", nullable = false) + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Column(name = "DESCRIPTION", nullable = false) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + @ManyToOne + @JoinColumn(name = "CRAWLER_ID", nullable = false) + public MetaCrawler getCrawler() { + return crawler; + } + + public void setCrawler(MetaCrawler crawler) { + this.crawler = crawler; + } + + @ManyToOne + @JoinColumn(name = "UNIT_ID", nullable = true) + public MetaSensorItemUnit getUnit() { + return unit; + } + + public void setUnit(MetaSensorItemUnit unit) { + this.unit = unit; + } + + @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; + } + + + @Basic + @Column(name="IS_DEFAULT", nullable = false, columnDefinition = "boolean default false") + public boolean getDefault() { + return isDefault; + } + + public void setDefault(boolean aDefault) { + isDefault = aDefault; + } + + @ManyToOne + @JoinColumn(name = "TYPE_ID", nullable = false) + public MetaSensorItemType getItemType() { + return itemType; + } + + public void setItemType(MetaSensorItemType itemType) { + this.itemType = itemType; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayMapping.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayMapping.java new file mode 100644 index 0000000..c741f2b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorDisplayMapping.java @@ -0,0 +1,45 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; + +/** + * Created by insanity on 17. 11. 7. + */ +@Entity +@Table(name = "META_SENSOR_DISPLAY_MAPPING", schema = "public") +public class MetaSensorDisplayMapping { + + private long id; + private MetaSensorDisplayItem displayItem; + private MetaSensorItemKey itemKey; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "DISPLAY_ITEM_ID", nullable = false) + public MetaSensorDisplayItem getDisplayItem() { + return displayItem; + } + + public void setDisplayItem(MetaSensorDisplayItem displayItem) { + this.displayItem = displayItem; + } + + @ManyToOne + @JoinColumn(name = "ITEM_KEY_ID", nullable = false) + public MetaSensorItemKey getItemKey() { + return itemKey; + } + + public void setItemKey(MetaSensorItemKey itemKey) { + this.itemKey = itemKey; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItem.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItem.java new file mode 100644 index 0000000..5638f01 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItem.java @@ -0,0 +1,64 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_SENSOR_ITEM", schema = "public") +public class MetaSensorItem { + private int id; + private String key; + private String name; + private Date createDate; + + @Id + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + +// @Column(name = "TYPE_ID", nullable = false) +// public short getTypeId() { +// return typeId; +// } +// +// public void setTypeId(short typeId) { +// this.typeId = typeId; +// } + + + @Column(name = "KEY", nullable = true, length = 100) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + @Column(name = "NAME", nullable = true, length = 100) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemKey.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemKey.java new file mode 100644 index 0000000..4647feb --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemKey.java @@ -0,0 +1,105 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by snoop on 17. 8. 29. + */ +@Entity +@Table(name = "META_SENSOR_ITEM_KEY", schema = "public") +public class MetaSensorItemKey { + private long id; + private MetaSensorItem item; + private String key; + private String froms; + private String option; + private MetaCrawler crawler; + private Date createDate; + private MetaSensorItemUnit unit; + + public MetaSensorItemKey() { + + } + + public MetaSensorItemKey(long id) { + this.id = id; + } + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "ITEM_ID", nullable = false) + public MetaSensorItem getItem() { + return item; + } + + public void setItem(MetaSensorItem item) { + this.item = item; + } + + @Column(name = "KEY", nullable = false, length = 100) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + @Column(name = "FROMS", nullable = false, length = 100) + public String getFroms() { + return froms; + } + + public void setFroms(String froms) { + this.froms = froms; + } + + @Column(name = "OPTION_JSON", nullable = true) + public String getOption() { + return option; + } + + public void setOption(String option) { + this.option = option; + } + + @ManyToOne + @JoinColumn(name = "CRAWLER_ID", nullable = false) + public MetaCrawler getCrawler() { + return crawler; + } + + public void setCrawler(MetaCrawler crawler) { + this.crawler = crawler; + } + + @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 = "UNIT_ID", nullable = true) + public MetaSensorItemUnit getUnit() { + return unit; + } + + public void setUnit(MetaSensorItemUnit unit) { + this.unit = unit; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemType.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemType.java new file mode 100644 index 0000000..9cc09ca --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemType.java @@ -0,0 +1,63 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_SENSOR_ITEM_TYPE", schema = "public") +public class MetaSensorItemType { + private short id; + private String name; + private String description; + private Date createDate; + + public MetaSensorItemType() { + } + + public MetaSensorItemType(short id) { + this.id = id; + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "NAME", nullable = true, length = 50) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemUnit.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemUnit.java new file mode 100644 index 0000000..e875c51 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorItemUnit.java @@ -0,0 +1,61 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by insanity on 17. 9. 19. + */ +@Entity +@Table(name = "META_SENSOR_ITEM_UNIT", schema = "public") +public class MetaSensorItemUnit { + private short id; + private String unit; + private Date createDate; + private String mark; + + public MetaSensorItemUnit(short id) { + this.id = id; + } + + public MetaSensorItemUnit() { + + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + @Column(name = "UNIT", nullable = false) + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + @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; + } + + @Column(name = "MARK", nullable = false) + public String getMark() { + return mark; + } + + public void setMark(String mark) { + this.mark = mark; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorStatus.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorStatus.java new file mode 100644 index 0000000..b751c8d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaSensorStatus.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * Created by snoop on 17. 6. 26. + */ +@Entity +@Table(name = "META_SENSOR_STATUS", schema = "public") +public class MetaSensorStatus { + private short id; + private String name; + + public MetaSensorStatus() { + + } + + public MetaSensorStatus(short id) { + this.id = id; + } + + @Id + public short getId() { + return id; + } + + public void setId(short id) { + this.id = id; + } + + + @Column(name = "Name", nullable = false, length = 10) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawler.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawler.java new file mode 100644 index 0000000..1c69c1f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawler.java @@ -0,0 +1,76 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_VENDOR_CRAWLER", schema = "public") +public class MetaVendorCrawler { + private int id; + private MetaCrawler crawler; + private MetaInfraVendor infraVendor; + private Date createDate; + + @Id + public int getId() { + return id; + } + + public void setId(int 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 + @JoinColumn(name = "VENDOR_ID", nullable = false) + public MetaInfraVendor getInfraVendor() { + return infraVendor; + } + + public void setInfraVendor(MetaInfraVendor infraVendor) { + this.infraVendor = infraVendor; + } + + // @Basic +// @Column(name = "CRAWLER_ID", nullable = false) +// public short getCrawlerId() { +// return crawlerId; +// } +// +// public void setCrawlerId(short crawlerId) { +// this.crawlerId = crawlerId; +// } +// +// @Basic +// @Column(name = "VENDOR_ID", nullable = false) +// public int getVendorId() { +// return vendorId; +// } +// +// public void setVendorId(int vendorId) { +// this.vendorId = vendorId; +// } + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawlerSensorItem.java b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawlerSensorItem.java new file mode 100644 index 0000000..982d4bd --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/model/MetaVendorCrawlerSensorItem.java @@ -0,0 +1,91 @@ +package com.loafle.overflow.central.module.meta.model; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "META_VENDOR_CRAWLER_SENSOR_ITEM", schema = "public") +public class MetaVendorCrawlerSensorItem { + private long id; + private String interval; + private String warnCondition; + private Date createDate; + private MetaSensorItem sensorItem; + private MetaInfraVendor vendor; + private short crawlerId; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + + @Column(name = "INTERVAL", nullable = true, length = 50) + public String getInterval() { + return interval; + } + + public void setInterval(String interval) { + this.interval = interval; + } + + + @Column(name = "WARN_CONDITION", nullable = true, length = 50) + public String getWarnCondition() { + return warnCondition; + } + + public void setWarnCondition(String warnCondition) { + this.warnCondition = warnCondition; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CREATE_DATE", nullable = false) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + + @ManyToOne + @JoinColumn(name = "ITEM_ID", nullable = false) + public MetaSensorItem getSensorItem() { + return sensorItem; + } + + public void setSensorItem(MetaSensorItem sensorItem) { + this.sensorItem = sensorItem; + } + + @ManyToOne + @JoinColumn(name = "VENDOR_ID", nullable = false) + public MetaInfraVendor getVendor() { + return vendor; + } + + public void setVendor(MetaInfraVendor vendor) { + this.vendor = vendor; + } + + @Basic + @Column(name = "CRAWLER_ID", nullable = false) + public short getCrawlerId() { + return crawlerId; + } + + public void setCrawlerId(short crawlerId) { + this.crawlerId = crawlerId; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemService.java new file mode 100644 index 0000000..b1bde5c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemService.java @@ -0,0 +1,24 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaCrawlerInputItemDAO; +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaCrawlerInputItem; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaCrawlerInputItemService") +public class MetaCrawlerInputItemService { + + @Autowired + private MetaCrawlerInputItemDAO crawlerInputItemDAO; + + public List readAllByMetaCrawler(MetaCrawler metaCrawler) { + return this.crawlerInputItemDAO.findAllByCrawler(metaCrawler); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerService.java new file mode 100644 index 0000000..68bae7f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerService.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaCrawlerDAO; +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaCrawlerService") +public class MetaCrawlerService { + + @Autowired + private MetaCrawlerDAO crawlerDAO; + + public List readAll() { + return this.crawlerDAO.findAll(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeService.java new file mode 100644 index 0000000..e802c81 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeService.java @@ -0,0 +1,30 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaHistoryTypeDAO; +import com.loafle.overflow.central.module.meta.model.MetaHistoryType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaHistoryTypeService") +public class MetaHistoryTypeService { + + @Autowired + private MetaHistoryTypeDAO hisotyTypeDAO; + + public List readAll() { + return this.hisotyTypeDAO.findAll(); + } + + public MetaHistoryType regist(MetaHistoryType type) { + return this.hisotyTypeDAO.save(type); + } + + public List registAll(List types) { + return this.hisotyTypeDAO.save(types); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeService.java new file mode 100644 index 0000000..b0f3543 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeService.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaInfraTypeDAO; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaInfraTypeService") +public class MetaInfraTypeService { + + @Autowired + private MetaInfraTypeDAO infraTypeDAO; + + public List readAll() { + return this.infraTypeDAO.findAll(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorService.java new file mode 100644 index 0000000..2770e83 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorService.java @@ -0,0 +1,24 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaInfraVendorDAO; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaInfraVendorService") +public class MetaInfraVendorService { + + @Autowired + private MetaInfraVendorDAO infraVendorDAO; + + public List readAllByMetaInfraType(MetaInfraType infraType) { + return this.infraVendorDAO.findAllByInfraType(infraType); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeService.java new file mode 100644 index 0000000..beee828 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaInputTypeDAO; +import com.loafle.overflow.central.module.meta.model.MetaInputType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaInputTypeService") +public class MetaInputTypeService { + + @Autowired + private MetaInputTypeDAO inputTypeDAO; + + public List readAll() { + return this.inputTypeDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusService.java new file mode 100644 index 0000000..2da3199 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaMemberStatusDAO; +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaMemberStatusService") +public class MetaMemberStatusService { + + @Autowired + private MetaMemberStatusDAO memberStatusDAO; + + public List readAll() { + return this.memberStatusDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusService.java new file mode 100644 index 0000000..6c3ade5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusService.java @@ -0,0 +1,21 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaNoAuthProbeStatusDAO; +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaNoAuthProbeStatusService") +public class MetaNoAuthProbeStatusService { + @Autowired + private MetaNoAuthProbeStatusDAO noAuthProbeStatusDAO; + + public List readAll() { + return this.noAuthProbeStatusDAO.findAll(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureService.java new file mode 100644 index 0000000..b8b938c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbeArchitectureDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeArchitecture; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbeArchitectureService") +public class MetaProbeArchitectureService { + + @Autowired + private MetaProbeArchitectureDAO probeArchitectureDAO; + + public List readAll() { + return this.probeArchitectureDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsService.java new file mode 100644 index 0000000..fec0600 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbeOsDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbeOsService") +public class MetaProbeOsService { + + @Autowired + private MetaProbeOsDAO probeOsDAO; + + public List readAll() { + return this.probeOsDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageService.java new file mode 100644 index 0000000..2870c42 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageService.java @@ -0,0 +1,24 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbePackageDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import com.loafle.overflow.central.module.meta.model.MetaProbePackage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbePackageService") +public class MetaProbePackageService { + + @Autowired + private MetaProbePackageDAO probePackageDAO; + + public List readAllByOs(MetaProbeOs metaProbeOs) { + return this.probePackageDAO.findAllByOs(metaProbeOs); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusService.java new file mode 100644 index 0000000..bd8fbe4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbeStatusDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbeStatusService") +public class MetaProbeStatusService { + + @Autowired + private MetaProbeStatusDAO probeStatusDAO; + + public List readAll() { + return this.probeStatusDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeService.java new file mode 100644 index 0000000..3fd582d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeService.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbeTaskTypeDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbeTaskTypeService") +public class MetaProbeTaskTypeService { + + @Autowired + private MetaProbeTaskTypeDAO probeTaskTypeDAO; + + public List readAll() { + return this.probeTaskTypeDAO.findAll(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionService.java new file mode 100644 index 0000000..99a21e1 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionService.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaProbeVersionDAO; +import com.loafle.overflow.central.module.meta.model.MetaProbeVersion; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaProbeVersionService") +public class MetaProbeVersionService { + + @Autowired + private MetaProbeVersionDAO probeVersionDAO; + + public List readAll() { + return this.probeVersionDAO.findAll(); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemService.java new file mode 100644 index 0000000..50acbf0 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemService.java @@ -0,0 +1,31 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayItemDAO; +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by insanity on 17. 9. 20. + */ + +@Service("MetaSensorDisplayItemService") +public class MetaSensorDisplayItemService { + @Autowired + private MetaSensorDisplayItemDAO displayItemDAO; + + public MetaSensorDisplayItem regist(MetaSensorDisplayItem item) { + return this.displayItemDAO.save(item); + } + + public MetaSensorDisplayItem read(long id) { + return this.displayItemDAO.findOne(id); + } + + public List readAllByCrawler(MetaCrawler crawler) { + return this.displayItemDAO.findAllByCrawler(crawler); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingService.java new file mode 100644 index 0000000..4f42465 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingService.java @@ -0,0 +1,28 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayMappingDAO; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayMapping; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by insanity on 17. 11. 7. + */ +@Service("MetaSensorDisplayMappingService") +public class MetaSensorDisplayMappingService { + @Autowired + private MetaSensorDisplayMappingDAO mappingDAO; + + public MetaSensorDisplayMapping regist(MetaSensorDisplayMapping m) { + return this.mappingDAO.save(m); + } + + public List findAllByDisplayItem(MetaSensorDisplayItem displayItem) { + return this.mappingDAO.findAllByDisplayItem(displayItem); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyService.java new file mode 100644 index 0000000..50e785d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyService.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorItemKeyDAO; +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by snoop on 17. 8. 29. + */ +@Service("MetaSensorItemKeyService") +public class MetaSensorItemKeyService { + + @Autowired + private MetaSensorItemKeyDAO metaSensorItemKeyDAO; + + public List readAllByCrawler(MetaCrawler metaCrawler) { + return this.metaSensorItemKeyDAO.findAllByCrawler(metaCrawler); + } + + + public Map readAllMapByCrawler(MetaCrawler metaCrawler) { + + Map resultMap = new HashMap<>(); + + List resultList = this.metaSensorItemKeyDAO.findAllByCrawler(metaCrawler); + + for(MetaSensorItemKey oa : resultList) { + resultMap.put(oa.getItem().getId(), oa); + } + + return resultMap; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemService.java new file mode 100644 index 0000000..d0e6eff --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemService.java @@ -0,0 +1,24 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorItemDAO; +import com.loafle.overflow.central.module.meta.model.MetaSensorItem; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaSensorItemService") +public class MetaSensorItemService { + + @Autowired + private MetaSensorItemDAO metaSensorItemDAO; + + + public List readAll() { + return this.metaSensorItemDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeService.java new file mode 100644 index 0000000..33ac84b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeService.java @@ -0,0 +1,30 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorItemTypeDAO; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaSensorItemTypeService") +public class MetaSensorItemTypeService { + + @Autowired + private MetaSensorItemTypeDAO sensorItemTypeDAO; + + public List readAll() { + return this.sensorItemTypeDAO.findAll(); + } + + public MetaSensorItemType regist(MetaSensorItemType type){ + return this.sensorItemTypeDAO.save(type); + } + + public List registAll(List list) { + return this.sensorItemTypeDAO.save(list); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitService.java new file mode 100644 index 0000000..3c79284 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitService.java @@ -0,0 +1,19 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorItemUnitDAO; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemUnit; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by insanity on 17. 9. 20. + */ +@Service("MetaSensorItemUnitService") +public class MetaSensorItemUnitService { + @Autowired + private MetaSensorItemUnitDAO sensorItemUnitDAO; + + public MetaSensorItemUnit regist(MetaSensorItemUnit sensorItemUnit) { + return this.sensorItemUnitDAO.save(sensorItemUnit); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusService.java new file mode 100644 index 0000000..12a052c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusService.java @@ -0,0 +1,23 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaSensorStatusDAO; +import com.loafle.overflow.central.module.meta.model.MetaSensorStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaSensorStatusService") +public class MetaSensorStatusService { + + @Autowired + private MetaSensorStatusDAO sensorStatusDAO; + + List readAll() { + return this.sensorStatusDAO.findAll(); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerSensorItemService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerSensorItemService.java new file mode 100644 index 0000000..0867450 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerSensorItemService.java @@ -0,0 +1,12 @@ +package com.loafle.overflow.central.module.meta.service; + +import org.springframework.stereotype.Service; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaVendorCrawlerSensorItemService") +public class MetaVendorCrawlerSensorItemService { + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerService.java new file mode 100644 index 0000000..8796f85 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerService.java @@ -0,0 +1,28 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.dao.MetaVendorCrawlerDAO; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.module.meta.model.MetaVendorCrawler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@Service("MetaVendorCrawlerService") +public class MetaVendorCrawlerService { + + @Autowired + private MetaVendorCrawlerDAO crawlerDAO; + + public List readAllByInfraVendor(MetaInfraVendor infraVendor) { + + return this.crawlerDAO.findAllByInfraVendor(infraVendor); + } + + public MetaVendorCrawler regist(MetaVendorCrawler metaVendorCrawler) { + return this.crawlerDAO.save(metaVendorCrawler); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/meta/type/MetaCrawlerEnum.java b/src/main/java/com/loafle/overflow/central/module/meta/type/MetaCrawlerEnum.java new file mode 100644 index 0000000..8b8aa91 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/meta/type/MetaCrawlerEnum.java @@ -0,0 +1,44 @@ +package com.loafle.overflow.central.module.meta.type; + +/** + * Created by snoop on 17. 9. 8. + */ +public enum MetaCrawlerEnum { + + ACTIVEDIRECTORY_CRAWLER((short)1), + CASSANDRA_CRAWLER((short)2), + DHCP_CRAWLER((short)3), + DNS_CRAWLER((short)4), + FTP_CRAWLER((short)5), + HTTP_CRAWLER((short)6), + IMAP_CRAWLER((short)7), + LDAP_CRAWLER((short)8), + MONGODB_CRAWLER((short)9), + MSSQL_CRAWLER((short)10), + MYSQL_CRAWLER((short)11), + NETBIOS_CRAWLER((short)12), + ORACLE_CRAWLER((short)13), + POP_CRAWLER((short)14), + POSTGRESQL_CRAWLER((short)15), + REDIS_CRAWLER((short)16), + JMX_CRAWLER((short)17), + SMB_CRAWLER((short)18), + SMTP_CRAWLER((short)19), + SNMP_CRAWLER((short)20), + SSH_CRAWLER((short)21), + TELNET_CRAWLER((short)22), + WMI_CRAWLER((short)23), + UNKNOWN_CRAWLER((short)24); + + + private short value; + + private MetaCrawlerEnum(short value) { + this.value = value; + } + + public short getValue() { + return this.value; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java new file mode 100644 index 0000000..59c2ac6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/dao/NoAuthProbeDAO.java @@ -0,0 +1,25 @@ +package com.loafle.overflow.central.module.noauthprobe.dao; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe; +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. 5. 30. + */ +@Repository +public interface NoAuthProbeDAO extends JpaRepository { +// NoAuthProbeDeprecate findByTempKey(NoAuthProbeDeprecate noAuthAgent); +// List findAllByNoAuth(NoAuthProbeDeprecate noAuthAgent); + +// @Query("SELECT n FROM NoAuthProbe n WHERE n.tempProbeKey = :tempProbeKey") + NoAuthProbe findByTempProbeKey(String tempProbeKey); +// @Query("select m from Member m WHERE m.email = :#{#m2.email}") + @Query("SELECT n FROM NoAuthProbe n WHERE n.domain.id = :#{#domain.id} and n.status.id = 3") // 3 = Process + List findAllByDomain(@Param("domain") Domain domain); +} diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java new file mode 100644 index 0000000..b6ecc12 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/model/NoAuthProbe.java @@ -0,0 +1,138 @@ +package com.loafle.overflow.central.module.noauthprobe.model; + + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +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 = "NOAUTH_PROBE", schema = "public") +public class NoAuthProbe { + private long id; + private String description; + private MetaNoAuthProbeStatus status; + private String tempProbeKey; + private Date createDate; + private String apiKey; + private Domain domain; + private Probe probe; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "DESCRIPTION", nullable = true, length = 1000) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ManyToOne + @JoinColumn(name = "STATUS", nullable = false) + public MetaNoAuthProbeStatus getStatus() { + return status; + } + + public void setStatus(MetaNoAuthProbeStatus status) { + this.status = status; + } + + @Column(name = "TEMP_PROBE_KEY", nullable = false, length = 50, unique = true) + public String getTempProbeKey() { + return tempProbeKey; + } + + public void setTempProbeKey(String tempProbeKey) { + this.tempProbeKey = tempProbeKey; + } + + @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; + } + + @Column(name = "API_KEY", nullable = true, length = 50) + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + @ManyToOne + @JoinColumn(name = "DOMAIN_ID", nullable=false) + public Domain getDomain() { + return domain; + } + + public void setDomain(Domain domain) { + this.domain = domain; + } + + @ManyToOne + @JoinColumn(name = "PROBE_ID", nullable = true) + public Probe getProbe() { + return probe; + } + + public void setProbe(Probe probe) { + this.probe = probe; + } + +// @Override +// public boolean equals(Object o) { +// if (this == o) return true; +// if (o == null || getClass() != o.getClass()) return false; +// +// NoAuthProbe that = (NoAuthProbe) o; +// +// if (id != that.id) return false; +// if (domainId != that.domainId) return false; +// if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false; +// if (macAddress != null ? !macAddress.equals(that.macAddress) : that.macAddress != null) return false; +// if (ipAddress != null ? !ipAddress.equals(that.ipAddress) : that.ipAddress != null) return false; +// if (status != null ? !status.equals(that.status) : that.status != null) return false; +// if (tempProbeKey != null ? !tempProbeKey.equals(that.tempProbeKey) : that.tempProbeKey != null) return false; +// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; +// if (apiKey != null ? !apiKey.equals(that.apiKey) : that.apiKey != null) return false; +// if (probeId != null ? !probeId.equals(that.probeId) : that.probeId != null) return false; +// +// return true; +// } +// +// @Override +// public int hashCode() { +// int result = (int) (id ^ (id >>> 32)); +// result = 31 * result + (hostName != null ? hostName.hashCode() : 0); +// result = 31 * result + (macAddress != null ? macAddress.hashCode() : 0); +// result = 31 * result + (ipAddress != null ? ipAddress.hashCode() : 0); +// result = 31 * result + (status != null ? status.hashCode() : 0); +// result = 31 * result + (tempProbeKey != null ? tempProbeKey.hashCode() : 0); +// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); +// result = 31 * result + (apiKey != null ? apiKey.hashCode() : 0); +// result = 31 * result + (int) (domainId ^ (domainId >>> 32)); +// result = 31 * result + (probeId != null ? probeId.hashCode() : 0); +// return result; +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java new file mode 100644 index 0000000..7b31efa --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeService.java @@ -0,0 +1,140 @@ +package com.loafle.overflow.central.module.noauthprobe.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.commons.utils.GenerateKey; +import com.loafle.overflow.central.module.apikey.model.ApiKey; +import com.loafle.overflow.central.module.apikey.service.ApiKeyService; +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.domain.model.DomainMember; +import com.loafle.overflow.central.module.domain.service.DomainMemberService; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.member.service.MemberService; +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; +import com.loafle.overflow.central.module.noauthprobe.dao.NoAuthProbeDAO; +import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.service.ProbeService; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service("NoAuthProbeService") +public class NoAuthProbeService { + + @Autowired + private NoAuthProbeDAO noAuthProbeDAO; + + @Autowired + private ApiKeyService apiKeyService; + + @Autowired + private ProbeService probeService; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private MessagePublisher messagePublisher; + + @Autowired + private DomainMemberService domainMemberService; + + @ProbeAPI + public NoAuthProbe regist(NoAuthProbe noAuthProbe) { + + ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey()); + noAuthProbe.setDomain(apiKey.getDomain()); + + noAuthProbe.setTempProbeKey(GenerateKey.getKey()); + noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short)3)); + + messagePublisher.publishToDomainMembers(apiKey.getDomain().getId(), "NoAuthProbeService.regist", noAuthProbe); + + return this.noAuthProbeDAO.save(noAuthProbe); + } + + + public List readAllByDomain(Domain domain) { + + return this.noAuthProbeDAO.findAllByDomain(domain); + } + + public NoAuthProbe read(long id) { + return this.noAuthProbeDAO.findOne(id); + } + + @WebappAPI + public List acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException { + String memberEmail = SessionMetadata.getTargetID(); + + // Todo domain injection & member injection + + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + String encryptKey = passwordEncoder.encode(UUID.randomUUID().toString()); + + ApiKey apiKey = apiKeyService.readByApiKey(noAuthProbe.getApiKey()); + DomainMember domainMember = domainMemberService.readByMemberEmail(memberEmail); + + Probe probe = new Probe(); + probe.setEncryptionKey(encryptKey); + probe.setProbeKey(GenerateKey.getKey()); + + probe.setDomain(new Domain(apiKey.getDomain().getId())); + probe.setAuthorizeMember(new Member(domainMember.getMember().getId())); + probe.setStatus(new MetaProbeStatus((short)1)); + + Map objMap = this.objectMapper.readValue(noAuthProbe.getDescription(), new TypeReference>() {}); + Map hostMap = (Map)objMap.get("host"); + Map netMap = (Map)objMap.get("network"); + +// String dispName = noAuth.getHostName().isEmpty() ? +// StringConvertor.intToIp(noAuth.getIpAddress()) : noAuth.getHostName(); + String dispName = hostMap.get("name"); + dispName += " probe"; + probe.setDisplayName(dispName); + + String addrStr = netMap.get("address"); + + String[] addrArr = addrStr.split("\\|"); + + probe.setCidr(addrArr[0]); + + noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 1)); + + this.probeService.regist(probe); + this.noAuthProbeDAO.save(noAuthProbe); + + messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Accept", probe.getProbeKey()); + + return this.readAllByDomain(noAuthProbe.getDomain()); + } + + @WebappAPI + public List denyNoauthProbe(NoAuthProbe noAuthProbe) { + noAuthProbe.setStatus(new MetaNoAuthProbeStatus((short) 2)); + this.noAuthProbeDAO.save(noAuthProbe); + + messagePublisher.publishToNoAuthProbe(noAuthProbe.getTempProbeKey(), "NoAuthProbeService.Deny"); + + return this.readAllByDomain(noAuthProbe.getDomain()); + } + + public NoAuthProbe readByTempKey(String tempKey) { + return this.noAuthProbeDAO.findByTempProbeKey(tempKey); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java b/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java new file mode 100644 index 0000000..524c925 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/notification/dao/NotificationDAO.java @@ -0,0 +1,29 @@ +package com.loafle.overflow.central.module.notification.dao; + +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.notification.model.Notification; +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. 8. 25. + */ +@Repository +public interface NotificationDAO extends JpaRepository { + + List findAllByMember(Member member); + + Page findAllByMember(Member member, Pageable pageRequest); + + @Query("SELECT n FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL") + Page findAllUnconfirmedByMember(@Param("member") Member member, Pageable pageRequest); + + @Query("SELECT COUNT(n) FROM Notification n WHERE n.member.id = :#{#member.id} and n.confirmDate IS NULL") + int findAllUnconfirmedCountByMember(@Param("member") Member member); +} diff --git a/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java b/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java new file mode 100644 index 0000000..a557e21 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/notification/model/Notification.java @@ -0,0 +1,89 @@ +package com.loafle.overflow.central.module.notification.model; + +import com.loafle.overflow.central.module.member.model.Member; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by insanity on 17. 8. 25. + */ +@Entity +@Table(name = "NOTIFICATION", schema = "public") +public class Notification { + private long id; + private Date createDate; + private String title; + private String message; + private Member member; + private Date confirmDate; + private String url; + + @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; + } + + @Column(name = "TITLE", nullable = false, length = 50) + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Column(name = "MESSAGE", nullable = false, length = 255) + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @ManyToOne + @JoinColumn(name = "MEMBER_ID", nullable = false) + public Member getMember() { + return member; + } + + public void setMember(Member member) { + this.member = member; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "CONFIRM_DATE", nullable = true) + public Date getConfirmDate() { + return confirmDate; + } + + public void setConfirmDate(Date confirmDate) { + this.confirmDate = confirmDate; + } + + + @Column(name = "URL", nullable = false, length = 255) + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java b/src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java new file mode 100644 index 0000000..b262a88 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/notification/service/NotificationService.java @@ -0,0 +1,62 @@ +package com.loafle.overflow.central.module.notification.service; + +import com.loafle.overflow.central.commons.model.PageParams; +import com.loafle.overflow.central.commons.utils.PageUtil; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.notification.dao.NotificationDAO; +import com.loafle.overflow.central.module.notification.model.Notification; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * Created by insanity on 17. 8. 25. + */ +@Service("NotificationService") +public class NotificationService { + + @Autowired + private NotificationDAO notificationDAO; + + public Notification regist(Notification notification) { + return this.notificationDAO.save(notification); + } + + public Page readAllByMember(Member member, PageParams pageParams) { + return this.notificationDAO.findAllByMember(member, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllUnconfirmedByMember(Member member, PageParams pageParams) { + return this.notificationDAO.findAllUnconfirmedByMember(member, PageUtil.getPageRequest(pageParams)); + } + + public int readUnconfirmedCount(Member member) { + return this.notificationDAO.findAllUnconfirmedCountByMember(member); + } + + public Page markAllAsRead(Member member, PageParams pageParams) { + List list = this.notificationDAO.findAllByMember(member); + for (Notification n : list) { + n.setConfirmDate(new Date()); + } + this.notificationDAO.save(list); + return this.readAllByMember(member, pageParams); + } + + public Page markAllAsUnread(Member member, PageParams pageParams) { + List list = this.notificationDAO.findAllByMember(member); + for (Notification n : list) { + n.setConfirmDate(null); + } + this.notificationDAO.save(list); + return this.readAllByMember(member, pageParams); + } + + public Notification markAsRead(Notification notification) { + notification.setConfirmDate(new Date()); + return this.notificationDAO.save(notification); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java new file mode 100644 index 0000000..34fafee --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeDAO.java @@ -0,0 +1,21 @@ +package com.loafle.overflow.central.module.probe.dao; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.probe.model.Probe; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +/** + * Created by insanity on 17. 5. 29. + */ +@Repository +public interface ProbeDAO extends JpaRepository { +// public List findAgentListByMemberId(Member member); + + Probe findByProbeKey(String probeKey); + + List findAllByDomainOrderByIdDesc(Domain domain); +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java new file mode 100644 index 0000000..6ebcd63 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.module.probe.dao; + +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeHost; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by snoop on 17. 8. 21. + */ +@Repository +public interface ProbeHostDAO extends JpaRepository { + + ProbeHost findByProbe(Probe probe); +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java new file mode 100644 index 0000000..914e5c5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeTaskDAO.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.module.probe.dao; + +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeTask; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 26. + */ +@Repository +public interface ProbeTaskDAO extends JpaRepository { + + List findAllByProbe(Probe probe); +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java b/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java new file mode 100644 index 0000000..b164e2f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/exception/ProbeNotFoundException.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.central.module.probe.exception; + +import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; + +/** + * Created by snoop on 17. 9. 14. + */ +public class ProbeNotFoundException extends OverflowRuntimeException { + public ProbeNotFoundException() { + super(); + } + + public ProbeNotFoundException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java b/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java new file mode 100644 index 0000000..f4b79e4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/model/Probe.java @@ -0,0 +1,190 @@ +package com.loafle.overflow.central.module.probe.model; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.infra.model.Infra; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; + +import javax.persistence.*; +import java.util.Date; +import java.util.List; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "PROBE", schema = "public") +public class Probe { + + private long id; + private MetaProbeStatus status; + private String description; + private Date createDate; + private Domain domain; + private String probeKey; + private String encryptionKey; + private String displayName; + private String cidr; + private Date authorizeDate; + private Member authorizeMember; + + private List targets; + +// private InfraHost host; +// private int targetCount; +// private int sensorCount; + + public Probe() { + + } + + public Probe(long id) { + this.id = id; + } + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "STATUS", nullable = false) + public MetaProbeStatus getStatus() { + return status; + } + + public void setStatus(MetaProbeStatus status) { + this.status = status; + } + + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @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; + } + + + @Column(name = "PROBE_KEY", nullable = false, unique = true) + public String getProbeKey() { + return probeKey; + } + + public void setProbeKey(String probeKey) { + this.probeKey = probeKey; + } + + + @Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true) + public String getEncryptionKey() { + return encryptionKey; + } + + public void setEncryptionKey(String encryptionKey) { + this.encryptionKey = encryptionKey; + } + + + @Transient + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } + + // @Column(name = "TARGET_COUNT", nullable = false) +// public int getTargetCount() { +// return targetCount; +// } +// +// public void setTargetCount(int targetCount) { +// this.targetCount = targetCount; +// } +// +// @Column(name = "SENSOR_COUNT", nullable = false) +// public int getSensorCount() { +// return sensorCount; +// } +// +// public void setSensorCount(int sensorCount) { +// this.sensorCount = sensorCount; +// } + + @Column(name = "DISPLAY_NAME") + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Column(name = "CIDR") + public String getCidr() { + return cidr; + } + + public void setCidr(String cidr) { + this.cidr = cidr; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "AUTHORIZE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) + public Date getAuthorizeDate() { + return authorizeDate; + } + + public void setAuthorizeDate(Date authorizeDate) { + this.authorizeDate = authorizeDate; + } + + @ManyToOne + @JoinColumn(name = "AUTHORIZE_MEMBER_ID", nullable = false) + public Member getAuthorizeMember() { + return authorizeMember; + } + + public void setAuthorizeMember(Member authorizeMember) { + this.authorizeMember = authorizeMember; + } +// +// @ManyToOne +// @JoinColumn(name = "HOST_ID", nullable = false) +// public InfraHost getHost() { +// return host; +// } +// +// public void setHost(InfraHost host) { +// this.host = host; +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java new file mode 100644 index 0000000..7746473 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeHost.java @@ -0,0 +1,48 @@ +package com.loafle.overflow.central.module.probe.model; + +import com.loafle.overflow.central.module.infra.model.InfraHost; + +import javax.persistence.*; + +/** + * Created by insanity on 17. 8. 21. + */ + +@Entity +@Table(name = "PROBE_INFRAHOST", schema = "public") +public class ProbeHost { + + private long id; + private Probe probe; + private InfraHost host; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @OneToOne + @JoinColumn(name = "PROBE_ID", nullable = false) + public Probe getProbe() { + return probe; + } + + public void setProbe(Probe probe) { + this.probe = probe; + } + + @OneToOne + @JoinColumn(name = "HOST_ID", nullable = false) + public InfraHost getHost() { + return host; + } + + public void setHost(InfraHost infraHost) { + this.host = infraHost; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java new file mode 100644 index 0000000..ad2533e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/model/ProbeTask.java @@ -0,0 +1,143 @@ +package com.loafle.overflow.central.module.probe.model; + + +import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "PROBE_TASK", schema = "public") +public class ProbeTask { + private long id; + private MetaProbeTaskType taskType; + private Probe probe; + private String data; + private Date createDate; + private Date sendDate; + private Date startDate; + private Date endDate; + private Boolean succeed; + + @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 MetaProbeTaskType getTaskType() { + return taskType; + } + + public void setTaskType(MetaProbeTaskType taskType) { + this.taskType = taskType; + } + + @ManyToOne + @JoinColumn(name = "PROBE_ID", nullable = false) + public Probe getProbe() { + return probe; + } + + public void setProbe(Probe probe) { + this.probe = probe; + } + + @Column(name = "DATA", nullable = true, length = 255) + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + + @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; + } + + @Column(name = "SEND_DATE", nullable = true) + public Date getSendDate() { + return sendDate; + } + + public void setSendDate(Date sendDate) { + this.sendDate = sendDate; + } + + @Column(name = "START_DATE", nullable = true) + public Date getStartDate() { + return startDate; + } + + public void setStartDate(Date startDate) { + this.startDate = startDate; + } + + @Column(name = "END_DATE", nullable = true) + public Date getEndDate() { + return endDate; + } + + public void setEndDate(Date endDate) { + this.endDate = endDate; + } + + @Column(name = "SUCCEED", nullable = true) + public Boolean getSucceed() { + return succeed; + } + + public void setSucceed(Boolean succeed) { + this.succeed = succeed; + } + +// @Override +// public boolean equals(Object o) { +// if (this == o) return true; +// if (o == null || getClass() != o.getClass()) return false; +// +// ProbeTask that = (ProbeTask) o; +// +// if (id != that.id) return false; +// if (typeId != that.typeId) return false; +// if (probeId != that.probeId) return false; +// if (data != null ? !data.equals(that.data) : that.data != null) return false; +// if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; +// if (sendDate != null ? !sendDate.equals(that.sendDate) : that.sendDate != null) return false; +// if (startDate != null ? !startDate.equals(that.startDate) : that.startDate != null) return false; +// if (endDate != null ? !endDate.equals(that.endDate) : that.endDate != null) return false; +// if (succeed != null ? !succeed.equals(that.succeed) : that.succeed != null) return false; +// +// return true; +// } +// +// @Override +// public int hashCode() { +// int result = (int) (id ^ (id >>> 32)); +// result = 31 * result + (int) typeId; +// result = 31 * result + (int) (probeId ^ (probeId >>> 32)); +// result = 31 * result + (data != null ? data.hashCode() : 0); +// result = 31 * result + (createDate != null ? createDate.hashCode() : 0); +// result = 31 * result + (sendDate != null ? sendDate.hashCode() : 0); +// result = 31 * result + (startDate != null ? startDate.hashCode() : 0); +// result = 31 * result + (endDate != null ? endDate.hashCode() : 0); +// result = 31 * result + (succeed != null ? succeed.hashCode() : 0); +// return result; +// } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java new file mode 100644 index 0000000..1a48c23 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeHostService.java @@ -0,0 +1,25 @@ +package com.loafle.overflow.central.module.probe.service; + +import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeHost; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Created by snoop on 17. 8. 21. + */ +@Service("ProbeHostService") +public class ProbeHostService { + + @Autowired + private ProbeHostDAO probeHostDAO; + + public ProbeHost readByProbe(Probe probe) { + return this.probeHostDAO.findByProbe(probe); + } + + public ProbeHost regist(ProbeHost probeHost) { + return this.probeHostDAO.save(probeHost); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java new file mode 100644 index 0000000..3f21543 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeService.java @@ -0,0 +1,53 @@ +package com.loafle.overflow.central.module.probe.service; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.infra.dao.InfraDAO; +import com.loafle.overflow.central.module.probe.dao.ProbeDAO; +import com.loafle.overflow.central.module.probe.model.Probe; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service("ProbeService") +public class ProbeService { + + @Autowired + private ProbeDAO probeDAO; + @Autowired + private InfraDAO infraDAO; + + public Probe regist(Probe probe) { + return this.probeDAO.save(probe); + } + + public List regist(List probes) { + return this.probeDAO.save(probes); + } + + public List readAllByDomain(Domain domain) { + List probes = this.probeDAO.findAllByDomainOrderByIdDesc(domain); + for(Probe probe : probes) { + probe.setTargets(this.infraDAO.findAllByProbe(probe)); + } + return probes; + } + + public Probe read(long id) { + Probe probe = this.probeDAO.findOne(id); + probe.setTargets(this.infraDAO.findAllByProbe(probe)); + return probe; + } + + public Probe readByProbeKey(String probeKey) { + + return this.probeDAO.findByProbeKey(probeKey); + } + + public Probe modify(Probe probe) { + return this.probeDAO.save(probe); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java new file mode 100644 index 0000000..51bee6f --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/ProbeTaskService.java @@ -0,0 +1,27 @@ +package com.loafle.overflow.central.module.probe.service; + +import com.loafle.overflow.central.module.probe.dao.ProbeTaskDAO; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeTask; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service("ProbeTaskService") +public class ProbeTaskService { + + @Autowired + private ProbeTaskDAO probeTaskDAO; + + public ProbeTask regist(ProbeTask probeTask) { + return this.probeTaskDAO.save(probeTask); + } + + public List readAllByProbe(Probe probe) { + return this.probeTaskDAO.findAllByProbe(probe); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java new file mode 100644 index 0000000..235a7fd --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorDAO.java @@ -0,0 +1,29 @@ +package com.loafle.overflow.central.module.sensor.dao; + + +import com.loafle.overflow.central.module.sensor.model.Sensor; +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 root on 17. 6. 9. + */ +@Repository +public interface SensorDAO extends JpaRepository { + + + Page findAllByTarget(Target target, Pageable pageable); + List findAllByTarget(Target target); + + @Query("SELECT s from Sensor s WHERE s.target in (:targetList)") + Page findAllByTargetList(@Param("targetList") List targetList, Pageable pageable); +// List findAllByTargetList(List targets); + +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java new file mode 100644 index 0000000..b9d847c --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDAO.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.central.module.sensor.dao; + +import com.loafle.overflow.central.module.sensor.model.Sensor; +import com.loafle.overflow.central.module.sensor.model.SensorItem; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * Created by root on 17. 6. 9. + */ +@Repository +public interface SensorItemDAO extends JpaRepository { + Page findAllBySensor(Sensor sensor, Pageable pageable); +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java new file mode 100644 index 0000000..797a307 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/dao/SensorItemDependencyDAO.java @@ -0,0 +1,18 @@ +package com.loafle.overflow.central.module.sensor.dao; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import com.loafle.overflow.central.module.sensor.model.SensorItemDependency; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by insanity on 17. 9. 20. + */ +@Repository +public interface SensorItemDependencyDAO extends JpaRepository { + + List findAllByDisplayItem(MetaSensorDisplayItem displayItem); +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java new file mode 100644 index 0000000..ec2e376 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/model/Sensor.java @@ -0,0 +1,104 @@ +package com.loafle.overflow.central.module.sensor.model; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorStatus; +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 root on 17. 6. 22. + */ +@Entity +@Table(name = "SENSOR", schema = "public") +public class Sensor { + private long id; + private Date createDate; + private String description; + private MetaSensorStatus status; + private Target target; + private MetaCrawler crawler; + private String crawlerInputItems; + private short itemCount = 0; + + @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; + } + + @Column(name = "DESCRIPTION", nullable = true, length = 50) + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @ManyToOne + @JoinColumn(name = "STATUS") + public MetaSensorStatus getStatus() { + return status; + } + + public void setStatus(MetaSensorStatus status) { + this.status = status; + } + + @ManyToOne + @OnDelete(action = OnDeleteAction.CASCADE) + @JoinColumn(name = "TARGET_ID", nullable = false) + public Target getTarget() { + return target; + } + + public void setTarget(Target target) { + this.target = target; + } + + @ManyToOne + @JoinColumn(name = "CRAWLER_ID", nullable = false) + public MetaCrawler getCrawler() { + return crawler; + } + + public void setCrawler(MetaCrawler crawler) { + this.crawler = crawler; + } + + @Column(name = "CRAWLER_INPUT_ITEMS", nullable = true, length = 50) + public String getCrawlerInputItems() { + return crawlerInputItems; + } + + public void setCrawlerInputItems(String crawlerInputItems) { + this.crawlerInputItems = crawlerInputItems; + } + + @Column(name = "ITEM_COUNT", nullable = false) + public short getItemCount() { + return itemCount; + } + + public void setItemCount(short itemCount) { + this.itemCount = itemCount; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java new file mode 100644 index 0000000..278d0d6 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItem.java @@ -0,0 +1,62 @@ +package com.loafle.overflow.central.module.sensor.model; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "SENSOR_ITEM", schema = "public") +public class SensorItem { + private long id; + private Sensor sensor; + private MetaSensorDisplayItem item; + private Date createDate; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @ManyToOne + @JoinColumn(name = "SENSOR_ID", nullable = false) + @OnDelete(action = OnDeleteAction.CASCADE) + public Sensor getSensor() { + return this.sensor; + } + + public void setSensor(Sensor sensor) { + this.sensor = sensor; + } + + @ManyToOne + @JoinColumn(name = "ITEM_ID", nullable = false) + public MetaSensorDisplayItem getItem() { + return item; + } + + public void setItem(MetaSensorDisplayItem item) { + this.item = item; + } + + @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; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java new file mode 100644 index 0000000..9f077f3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/model/SensorItemDependency.java @@ -0,0 +1,48 @@ +package com.loafle.overflow.central.module.sensor.model; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; + +import javax.persistence.*; + +/** + * Created by insanity on 17. 9. 20. + */ +@Entity +@Table(name = "SENSOR_ITEM_DEPENDENCY", schema = "public") +public class SensorItemDependency { + private long id; + private MetaSensorDisplayItem displayItem; + private MetaSensorItemKey sensorItem; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + + @ManyToOne + @JoinColumn(name = "DISPLAY_ITEM_ID", nullable = false) + public MetaSensorDisplayItem getDisplayItem() { + return displayItem; + } + + public void setDisplayItem(MetaSensorDisplayItem displayItem) { + this.displayItem = displayItem; + } + + @ManyToOne + @JoinColumn(name = "SENSOR_ITEM_ID", nullable = false) + public MetaSensorItemKey getSensorItem() { + return sensorItem; + } + + public void setSensorItem(MetaSensorItemKey sensorItem) { + this.sensorItem = sensorItem; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java new file mode 100644 index 0000000..646b793 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemDependencyService.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.central.module.sensor.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO; +import com.loafle.overflow.central.module.sensor.model.SensorItemDependency; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by insanity on 17. 9. 20. + */ + +@Service("SensorItemDependencyService") +public class SensorItemDependencyService { + + @Autowired + private SensorItemDependencyDAO sensorItemDependencyDAO; + + public SensorItemDependency regist(SensorItemDependency dependency) { + return this.sensorItemDependencyDAO.save(dependency); + } + + public List readAllByDisplayItem(MetaSensorDisplayItem displayItem) { + return this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem); + } + + public Map> readAllByDisplayItems(List displayItems) { + + Map> map = new HashMap>(); + + for (MetaSensorDisplayItem displayItem : displayItems) { + List itemKeys = this.sensorItemDependencyDAO.findAllByDisplayItem(displayItem); + map.put(displayItem.getKey(), itemKeys); + } + + return map; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java new file mode 100644 index 0000000..a3ed86e --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorItemService.java @@ -0,0 +1,59 @@ +package com.loafle.overflow.central.module.sensor.service; + +import com.loafle.overflow.central.commons.model.PageParams; +import com.loafle.overflow.central.commons.utils.PageUtil; +import com.loafle.overflow.central.module.sensor.dao.SensorDAO; +import com.loafle.overflow.central.module.sensor.dao.SensorItemDAO; +import com.loafle.overflow.central.module.sensor.model.Sensor; +import com.loafle.overflow.central.module.sensor.model.SensorItem; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; + +/** + * Created by insanity on 17. 6. 28. + */ +@Service("SensorItemService") +public class SensorItemService { + + @Autowired + private SensorItemDAO sensorItemDAO; + @Autowired + private SensorDAO sensorDAO; + + @Transactional + public SensorItem regist(SensorItem sensorItem) { + Sensor s = sensorDAO.findOne(sensorItem.getSensor().getId()); + s.setItemCount((short)(s.getItemCount() + 1)); + this.sensorDAO.save(s); + return this.sensorItemDAO.save(sensorItem); + } + + @Transactional + public boolean registAll(List sensorItemList) { + Sensor s = sensorDAO.findOne(sensorItemList.get(0).getSensor().getId()); + s.setItemCount((short)sensorItemList.size()); + this.sensorDAO.save(s); + this.sensorItemDAO.save(sensorItemList); + return true; + } + + public SensorItem read(String id) { + return this.sensorItemDAO.findOne(Long.valueOf(id)); + } + + public Page readAllBySensor(Sensor sensor, PageParams pageParams) { + return this.sensorItemDAO.findAllBySensor(sensor, PageUtil.getPageRequest(pageParams)); + } + + @Transactional + public void remove(SensorItem sensorItem) { + Sensor s = sensorItem.getSensor(); + s.setItemCount((short)(s.getItemCount() - 1)); + this.sensorDAO.save(s); + this.sensorItemDAO.delete(sensorItem); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java new file mode 100644 index 0000000..18ef432 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/SensorService.java @@ -0,0 +1,131 @@ +package com.loafle.overflow.central.module.sensor.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.generator.service.SensorConfigGenerator; +import com.loafle.overflow.central.module.infra.exception.InfraNotFoundException; +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.MetaSensorStatus; +import com.loafle.overflow.central.module.meta.service.MetaSensorItemKeyService; +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.sensor.model.Sensor; +import com.loafle.overflow.central.module.sensor.model.SensorItem; +import com.loafle.overflow.central.module.target.exception.TargetNotFoundException; +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 javax.transaction.Transactional; +import java.io.IOException; +import java.util.List; + +/** + * Created by insanity on 17. 6. 28. + */ +@Service("SensorService") +public class SensorService { + + @Autowired + SensorDAO sensorDAO; + + @Autowired + private ProbeService probeService; + + @Autowired + private InfraService infraService; + + @Autowired + private SensorItemService sensorItemService; + + @Autowired + private MetaSensorItemKeyService metaSensorItemKeyService; + + @Autowired + private SensorConfigGenerator sensorConfigGenerator; + + public Sensor regist(Sensor sensor) { + return this.sensorDAO.save(sensor); + } + +// public List readAllByTarget(Target target, PageParams pageParams) { +// return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams)); +// } + + public Page readAllByDomain(Domain domain, PageParams pageParams) { + + List probeList = this.probeService.readAllByDomain(domain); + + if(probeList == null || probeList.size() <= 0) { + throw new ProbeNotFoundException(); + } + + List targetList = this.infraService.readAllTargetByProbeList(probeList); + + if(targetList == null || targetList.size() <= 0) { + throw new TargetNotFoundException(); + } + + return this.sensorDAO.findAllByTargetList(targetList, PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByInfra(long infraId, PageParams pageParams) { + Infra dbInfra = this.infraService.read(infraId); + + if(dbInfra == null || dbInfra.getTarget() == null) { + throw new InfraNotFoundException(); + } + + return this.sensorDAO.findAllByTarget(dbInfra.getTarget(), PageUtil.getPageRequest(pageParams)); + } + + public Page readAllByTarget(Target target, PageParams pageParams) { + return this.sensorDAO.findAllByTarget(target, PageUtil.getPageRequest(pageParams)); + } + + public Sensor read(String id) { + return this.sensorDAO.findOne(Long.valueOf(id)); + } + + public void remove(Sensor sensor) { + this.sensorDAO.delete(sensor); + } + + public Sensor start(Sensor sensor) { + MetaSensorStatus status = new MetaSensorStatus((short)1); + sensor.setStatus(status); + return this.sensorDAO.save(sensor); + } + + public Sensor stop(Sensor sensor) { + MetaSensorStatus status = new MetaSensorStatus((short)2); + sensor.setStatus(status); + return this.sensorDAO.save(sensor); + } + + @Transactional + public Sensor registSensorConfig(Sensor sensor, List sensorItemList, String etcJson) { + + this.sensorDAO.save(sensor); + + for(SensorItem sensorItem : sensorItemList) { + sensorItem.setSensor(sensor); + } + + this.sensorItemService.registAll(sensorItemList); + + return sensor; + } + + public String generateSensorConfig(Sensor sensor) throws IOException { + + return this.sensorConfigGenerator.generate(sensor); + + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java b/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java new file mode 100644 index 0000000..1aa85c0 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/dao/TargetDAO.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.module.target.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.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. 5. + */ +@Repository +public interface TargetDAO extends JpaRepository { +// List findAllByProbe(Probe probe);] + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java b/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java new file mode 100644 index 0000000..3bfe1b4 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/exception/TargetNotFoundException.java @@ -0,0 +1,16 @@ +package com.loafle.overflow.central.module.target.exception; + +import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; + +/** + * Created by snoop on 17. 9. 14. + */ +public class TargetNotFoundException extends OverflowRuntimeException { + public TargetNotFoundException() { + super(); + } + + public TargetNotFoundException(String message) { + super(message); + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/model/Target.java b/src/main/java/com/loafle/overflow/central/module/target/model/Target.java new file mode 100644 index 0000000..871af7d --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/model/Target.java @@ -0,0 +1,98 @@ +package com.loafle.overflow.central.module.target.model; + +import com.loafle.overflow.central.module.sensor.model.Sensor; + +import javax.persistence.*; +import java.util.Date; +import java.util.List; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "TARGET", schema = "public") +public class Target { + + private long id; + private Date createDate; + private String displayName; + private String description; + + private List sensors; + + /* + private long id; + private Date createDate; + private String displayName; + private String description; + */ + + @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; + } + + @Column(name = "DISPLAY_NAME") + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + @Column(name = "DESCRIPTION") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + +// @ManyToOne +// @JoinColumn(name = "PROBE_ID", nullable = false) +// @OnDelete(action = OnDeleteAction.CASCADE) +// public Probe getProbe() { +// return probe; +// } +// +// public void setProbe(Probe probe) { +// this.probe = probe; +// } +// +// @ManyToOne +// @JoinColumn(name = "INFRA_ID", nullable = false) +// public Infra getInfra() { +// return infra; +// } +// +// public void setInfra(Infra infra) { +// this.infra = infra; +// } + + @Transient + public List getSensors() { + return sensors; + } + + public void setSensors(List sensors) { + this.sensors = sensors; + } +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java new file mode 100644 index 0000000..81ce02a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryService.java @@ -0,0 +1,222 @@ +package com.loafle.overflow.central.module.target.service; + +import com.loafle.overflow.central.commons.utils.StringConvertor; +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.type.PortType; +import com.loafle.overflow.central.module.infra.model.*; +import com.loafle.overflow.central.module.infra.model.InfraService; +import com.loafle.overflow.central.module.infra.service.*; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.target.model.Target; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@Service("TargetDiscoveryService") +public class TargetDiscoveryService { + + @Autowired + private TargetService targetService; + + @Autowired + private InfraMachineService infraMachineService; + + @Autowired + private InfraOSService infraOSService; + + @Autowired + private InfraHostService infraHostService; + + @Autowired + private com.loafle.overflow.central.module.infra.service.InfraService infraService; + + @Autowired + private InfraOSPortService infraOSPortService; + + @Autowired + private InfraServiceService infraServiceService; + + // @Transactional + // public boolean saveAllTarget(List hosts, Probe probe) { + + // InfraHost infraHost = null; + + // for(Host host : hosts) { + + // infraHost = this.createAndReadHost(host, probe); + + // this.createPort(infraHost, host, probe); + + // } + // return true; + // } + + // private void createService(InfraHost infraHost, Port port, Probe probe) { + + // if(port.getServices() == null) { + // return; + // } + + // MetaInfraType typeService = new MetaInfraType(); + // typeService.setId(7); + + // String portType = "UDP"; + + // if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) { + // portType = "TCP"; + // } + + // for(com.loafle.overflow.central.module.discovery.model.Service service : port.getServices()) { + + // InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType); + + // if(dbInfraService != null) { + // if(service.isTarget() && dbInfraService.getTarget() == null) { + // Target targetService = new Target(); + // targetService.setDisplayName(service.getServiceName() + "-Service"); + // this.targetService.regist(targetService); + // dbInfraService.setTarget(targetService); + // this.infraServiceService.regist(dbInfraService); + // } + // continue; + // } + + // InfraService infraService = new InfraService(); + // infraService.setHost(infraHost); + // infraService.setPort(port.getPortNumber()); + // infraService.setPortType(portType); + // infraService.setInfraType(typeService); + // infraService.setProbe(probe); + + // if (port.getPortType() == PortType.TLS) { + // infraService.setTlsType(true); + // } + // infraService.setVendor(MetaInfraVendor.CreateInfraVendorByService(service.getServiceName())); + + // if(service.isTarget()) { + // Target targetService = new Target(); + // targetService.setDisplayName(service.getServiceName() + "-Service"); + // this.targetService.regist(targetService); + // infraService.setTarget(targetService); + // } + + // this.infraServiceService.regist(infraService); + + // } + + // } + + // private void createPort(InfraHost infraHost, Host host, Probe probe) { + + // if(host.getPorts() == null) { + // return; + // } + + // String portType = "UDP"; + + // MetaInfraType typePort = new MetaInfraType(); + // typePort.setId(6); + + // InfraOS infraOS = infraHost.getOs(); + + // for(Port port : host.getPorts()) { + + // if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) { + // portType = "TCP"; + // } + + // InfraOSPort dbInfraOSPort = this.infraOSPortService.readByPort(infraOS.getId(), port.getPortNumber(), portType); + // if(dbInfraOSPort == null) { + // InfraOSPort infraOSPort = new InfraOSPort(); + // infraOSPort.setOs(infraOS); + // infraOSPort.setPort(port.getPortNumber()); + // infraOSPort.setPortType(portType); + // infraOSPort.setProbe(probe); + // infraOSPort.setInfraType(typePort); + + // if (port.getPortType() == PortType.TLS) { + // infraOSPort.setTlsType(true); + // } + // infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber())); + // this.infraOSPortService.regist(infraOSPort); + // } + + // this.createService(infraHost, port, probe); + // } + // } + + // private InfraHost createAndReadHost(Host host, Probe probe) { + + // InfraHost infraHost = this.infraHostService.readByIp(host.getIp()); + // if(infraHost != null) { + + // if(host.isTarget() && infraHost.getTarget() == null) { + // Target target = new Target(); + // target.setDisplayName(String.valueOf(host.getIp()) + "-Host"); + + // this.targetService.regist(target); + // infraHost.setTarget(target); + // this.infraHostService.regist(infraHost); + // } + + // return infraHost; + // } else { + // MetaInfraType typeMachine = new MetaInfraType(); + // typeMachine.setId(1); // 1 = Machine; + + // MetaInfraType typeOS = new MetaInfraType(); + // typeOS.setId(3); // 3 = Os + + // MetaInfraType typeHost = new MetaInfraType(); + // typeHost.setId(2); // 2 = Host + + // InfraMachine infraMachine = new InfraMachine(); + // infraMachine.setProbe(probe); + // infraMachine.setInfraType(typeMachine); + // infraMachine.setMeta(StringConvertor.intToIp(host.getIp())+"-MACHINE"); + // this.infraMachineService.regist(infraMachine); + + // InfraOS infraOS = new InfraOS(); + // infraOS.setMachine(infraMachine); + // infraOS.setVendor(MetaInfraVendor.CreateInfraVendorByOS(host.getOs())); + // infraOS.setInfraType(typeOS); + // infraOS.setProbe(probe); + // infraOS.setMeta(StringConvertor.intToIp(host.getIp())+"-OS"); + // this.infraOSService.regist(infraOS); + + // InfraHost newInfraHost = new InfraHost(); + // newInfraHost.setIp(host.getIp()); + // newInfraHost.setMac(host.getMac()); + // newInfraHost.setOs(infraOS); + // newInfraHost.setInfraType(typeHost); + // newInfraHost.setProbe(probe); + + // if(host.isTarget()) { + // Target target = new Target(); + // target.setDisplayName(StringConvertor.intToIp(host.getIp()) + "-Host"); + + // this.targetService.regist(target); + // newInfraHost.setTarget(target); + // } + + // this.infraHostService.regist(newInfraHost); + // infraHost = newInfraHost; + // } + + + + // return infraHost; + // } + + + + +} diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java b/src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java new file mode 100644 index 0000000..256ed70 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/target/service/TargetService.java @@ -0,0 +1,36 @@ +package com.loafle.overflow.central.module.target.service; + +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.target.dao.TargetDAO; +import com.loafle.overflow.central.module.target.model.Target; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 28. + */ +@Service("TargetService") +public class TargetService { + + @Autowired + private TargetDAO targetDAO; + + public Target regist(Target target) { + return this.targetDAO.save(target); + } + + public Target read(String id) { + return this.targetDAO.findOne(Long.valueOf(id)); + } + +// public List readAllByProbe(Probe probe) { +// return this.targetDAO.findAllByProbe(probe); +// } + + public void remove(Target target) { + this.targetDAO.delete(target); + } + +} diff --git a/src/main/java/com/loafle/overflow/central/module/websocket/UiWebsocket.java b/src/main/java/com/loafle/overflow/central/module/websocket/UiWebsocket.java new file mode 100644 index 0000000..cf583c8 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/module/websocket/UiWebsocket.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.websocket; + +import javax.persistence.*; +import java.util.Date; + +/** + * Created by root on 17. 6. 22. + */ +@Entity +@Table(name = "UI_WEBSOCKET", schema = "public") +public class UiWebsocket { + private long id; + private Date createDate; + + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Basic + @Column(name = "CREATE_DATE", nullable = true) + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/ProxyServerInterceptor.java b/src/main/java/com/loafle/overflow/central/proxy/ProxyServerInterceptor.java new file mode 100644 index 0000000..a553cc2 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/ProxyServerInterceptor.java @@ -0,0 +1,22 @@ +package com.loafle.overflow.central.proxy; + +import com.loafle.overflow.central.commons.model.SessionMetadata; +import io.grpc.*; + +public class ProxyServerInterceptor implements ServerInterceptor { + + @Override + public ServerCall.Listener interceptCall(ServerCall call, Metadata headers, ServerCallHandler next) { + String clientType = headers.get(SessionMetadata.METADATA_CLIENT_TYPE_KEY); + String sessionID = headers.get(SessionMetadata.METADATA_SESSION_ID_KEY); + String targetID = headers.get(SessionMetadata.METADATA_TARGET_ID_KEY); + + Context ctx = Context.current().withValues( + SessionMetadata.CTX_CLIENT_TYPE_KEY, clientType, + SessionMetadata.CTX_SESSION_ID_KEY, sessionID, + SessionMetadata.CTX_TARGET_ID_KEY, targetID + ); + + return Contexts.interceptCall(ctx, call, headers, next); + } +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/ServiceInvoker.java b/src/main/java/com/loafle/overflow/central/proxy/ServiceInvoker.java new file mode 100644 index 0000000..5bfd1e5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/ServiceInvoker.java @@ -0,0 +1,203 @@ +package com.loafle.overflow.central.proxy; + +import com.google.gson.internal.Primitives; +import com.google.protobuf.ByteString; +import com.loafle.overflow.central.commons.exception.OverflowException; +import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; +import com.loafle.overflow.central.proxy.exception.InvalidParameterException; +import com.loafle.overflow.central.proxy.exception.InvalidRequestException; +import com.loafle.overflow.central.proxy.exception.NoSuchMethodException; +import com.loafle.overflow.central.proxy.exception.NoSuchServiceException; +import io.grpc.Status; +import io.grpc.StatusRuntimeException; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.JavaType; +import org.springframework.aop.support.AopUtils; +import org.springframework.beans.BeansException; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.lang.reflect.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by crusader on 17. 6. 30. + */ +@Component +public class ServiceInvoker { +// @Autowired + private ApplicationContext context; + + private ObjectMapper objectMapper; + + private Map serviceCacheMap; + + public ServiceInvoker(ApplicationContext context) { + this.context = context; + objectMapper = new ObjectMapper(); + objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + serviceCacheMap = new HashMap<>(); + } + + private static class Cache { + private ServiceCache serviceCache; + private Map methodCacheMap; + + private Cache(Object bean) { + serviceCache = new ServiceCache(); + serviceCache.bean = bean; + + methodCacheMap = new HashMap<>(10); + } + + private Object getBean() { + return serviceCache.bean; + } + + private MethodCache getMethodCache(String methodName) throws NoSuchMethodException { + MethodCache methodCache = methodCacheMap.get(methodName); + if (null != methodCache) { + return methodCache; + } + + Method method = getMethod(methodName); + if (null == method) { + throw new NoSuchMethodException(); + } + methodCache = new MethodCache(); + methodCacheMap.put(methodName, methodCache); + + methodCache.method = method; + methodCache.returnClazz = method.getReturnType(); + + int paramCount = method.getParameterCount(); + if (0 == paramCount) { + return methodCache; + } + + methodCache.parameterTypes = method.getGenericParameterTypes(); + + return methodCache; + } + + private Method getMethod(String methodName) { + Class clazz = AopUtils.getTargetClass(serviceCache.bean); + Method[] methods = clazz.getMethods(); + + Method targetMethod = null; + for(Method m : methods){ + if (methodName.equals(m.getName())) { + targetMethod = m; + break; + } + } + return targetMethod; + } + + private static class ServiceCache { + private Object bean; + private Map methodCacheMap; + } + private static class MethodCache { + private Method method; + private Class returnClazz; + private Type[] parameterTypes; + } + } + + private Cache getServiceCache(String serviceName) throws NoSuchServiceException { + Cache serviceCache = serviceCacheMap.get(serviceName); + if (null != serviceCache) { + return serviceCache; + } + try { + Object bean = context.getBean(serviceName); + serviceCache = new Cache(bean); + serviceCacheMap.put(serviceName, serviceCache); + } catch (BeansException e) { + throw new NoSuchServiceException(); + } + + return serviceCache; + } + + private Object getValue(Type parameterType, String json) throws InvalidParameterException { + JavaType targetType = objectMapper.getTypeFactory().constructType(parameterType); + if (!Primitives.isPrimitive(parameterType) && !parameterType.getTypeName().equals(String.class.getName())) { + try { + return objectMapper.readValue(json, targetType); + } catch (IOException e) { + throw new InvalidParameterException(); + } + } + return objectMapper.convertValue(json, targetType); + } + + + private Object[] getParameters(Type[] parameterTypes, List params) throws InvalidParameterException { + if (null == parameterTypes || null == params) { + return null; + } + + if (parameterTypes.length != params.size()) { + throw new IllegalArgumentException(); + } + + Object[] result = new Object[parameterTypes.length]; + + for (int i = 0; i < parameterTypes.length; i++) { + result[i] = getValue(parameterTypes[i], params.get(i).toStringUtf8()); + } + + return result; + } + + + public String invoke(String serviceName, String methodName, List params) throws OverflowException, OverflowRuntimeException { + Cache serviceCache = getServiceCache(serviceName); + Cache.MethodCache methodCache = serviceCache.getMethodCache(methodName); + + if (null == methodCache.parameterTypes) { + if (null != params && 0 < params.size()) { + throw new InvalidParameterException(); + } + } else { + if (methodCache.parameterTypes.length != params.size()) { + throw new InvalidParameterException(); + } + } + + Object[] parameters = null; + if (null != methodCache.parameterTypes && 0 < methodCache.parameterTypes.length) { + parameters = getParameters(methodCache.parameterTypes, params); + } + + Object result = null; + String jsonInString = null; + try { + result = methodCache.method.invoke(serviceCache.getBean(), parameters); + } catch (IllegalAccessException e) { + throw new InvalidRequestException(); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + if (t instanceof OverflowRuntimeException) { + throw (OverflowRuntimeException)t; + } + throw new InvalidRequestException(); + } + + try { + jsonInString = objectMapper.writeValueAsString(result); + } catch (IOException e) { + throw new InvalidRequestException(); + } + + return jsonInString; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/ServiceProxy.java b/src/main/java/com/loafle/overflow/central/proxy/ServiceProxy.java new file mode 100644 index 0000000..0c47be9 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/ServiceProxy.java @@ -0,0 +1,106 @@ +package com.loafle.overflow.central.proxy; + +import com.loafle.overflow.api.OverflowApiServerGrpc; +import com.loafle.overflow.api.ServerInput; +import com.loafle.overflow.api.ServerOutput; +import com.loafle.overflow.central.commons.exception.OverflowException; +import com.loafle.overflow.central.commons.exception.OverflowRuntimeException; +import io.grpc.*; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; + +import java.io.IOException; +import java.util.logging.Logger; + +/** + * Created by insanity on 17. 6. 28. + */ +public class ServiceProxy { + private static final Logger logger = Logger.getLogger(ServiceProxy.class.getName()); + + private io.grpc.Server server; + private ApplicationContext ctx; + + public void start(int port) throws IOException { + ctx = new AnnotationConfigApplicationContext("com.loafle.overflow"); + + ProxyServerInterceptor proxyServerInterceptor = new ProxyServerInterceptor(); + + server = ServerBuilder.forPort(port) + .addService(ServerInterceptors.intercept(new ServiceImpl(new ServiceInvoker(ctx)), proxyServerInterceptor)) + .build() + .start(); + logger.info("Server started, listening on " + port); + Runtime.getRuntime().addShutdownHook(new Thread() { + @Override + public void run() { + // Use stderr here since the logger may have been reset by its JVM shutdown hook. + System.err.println("*** shutting down gRPC server since JVM is shutting down"); + ServiceProxy.this.stop(); + System.err.println("*** server shut down"); + } + }); + } + + public void stop() { + if (server != null) { + server.shutdown(); + } + } + + public void blockUntilShutdown() throws InterruptedException { + if (server != null) { + server.awaitTermination(); + } + } + + static class ServiceImpl extends OverflowApiServerGrpc.OverflowApiServerImplBase { + + private ServiceInvoker serviceInvoker; + + ServiceImpl(ServiceInvoker serviceInvoker) { + this.serviceInvoker = serviceInvoker; + } + + @Override + public void exec(ServerInput request, + io.grpc.stub.StreamObserver responseObserver) { + + String result = null; + try { + result = this.serviceInvoker.invoke(request.getTarget(), request.getMethod(), request.getParamsList().asByteStringList()); + + ServerOutput reply = ServerOutput.newBuilder() + .setResult(result) + .build(); + responseObserver.onNext(reply); + responseObserver.onCompleted(); + } catch (OverflowException e) { + logger.warning(getExceptionMessage(request, e)); + responseObserver.onError(convertException(e)); + } catch (OverflowRuntimeException e) { + logger.warning(getExceptionMessage(request, e)); + responseObserver.onError(convertException(e)); + } + + } + + private String getExceptionMessage(ServerInput request, Exception e) { + return String.format("Target: %s, Method:%s, Params:%s, ex:%s", request.getTarget(), request.getMethod(), request.getParamsList().asByteStringList(), e.toString()); + } + + protected StatusRuntimeException convertException(OverflowRuntimeException e) { + String message = String.format("%s|%s", e.getClass().getSimpleName(), e.getMessage()); + Status status = Status.fromCode(Status.Code.INTERNAL).withDescription(message); + return new StatusRuntimeException(status); + } + + protected StatusException convertException(OverflowException e) { + String message = String.format("%s|%s", e.getClass().getSimpleName(), e.getMessage()); + Status status = Status.fromCode(e.getCode()).withDescription(message); + return new StatusException(status); + } + + } + +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidParameterException.java b/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidParameterException.java new file mode 100644 index 0000000..63d0f46 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidParameterException.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.proxy.exception; + +import com.loafle.overflow.central.commons.exception.OverflowException; +import io.grpc.Status; + +public class InvalidParameterException extends OverflowException { + private static final Status.Code code = Status.Code.INVALID_ARGUMENT; + public InvalidParameterException() { + super(code); + } + + public InvalidParameterException(String message) { + super(code, message); + } +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidRequestException.java b/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidRequestException.java new file mode 100644 index 0000000..49f2b7a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/exception/InvalidRequestException.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.proxy.exception; + +import com.loafle.overflow.central.commons.exception.OverflowException; +import io.grpc.Status; + +public class InvalidRequestException extends OverflowException { + private static final Status.Code code = Status.Code.UNKNOWN; + public InvalidRequestException() { + super(code); + } + + public InvalidRequestException(String message) { + super(code, message); + } +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchMethodException.java b/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchMethodException.java new file mode 100644 index 0000000..722b984 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchMethodException.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.proxy.exception; + +import com.loafle.overflow.central.commons.exception.OverflowException; +import io.grpc.Status; + +public class NoSuchMethodException extends OverflowException { + private static final Status.Code code = Status.Code.UNIMPLEMENTED; + public NoSuchMethodException() { + super(code); + } + + public NoSuchMethodException(String message) { + super(code, message); + } +} diff --git a/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchServiceException.java b/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchServiceException.java new file mode 100644 index 0000000..86593d3 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/proxy/exception/NoSuchServiceException.java @@ -0,0 +1,15 @@ +package com.loafle.overflow.central.proxy.exception; + +import com.loafle.overflow.central.commons.exception.OverflowException; +import io.grpc.Status; + +public class NoSuchServiceException extends OverflowException { + private static final Status.Code code = Status.Code.UNIMPLEMENTED; + public NoSuchServiceException() { + super(code); + } + + public NoSuchServiceException(String message) { + super(code, message); + } +} diff --git a/src/main/java/com/loafle/overflow/central/redis/service/RedisMessagePublisher.java b/src/main/java/com/loafle/overflow/central/redis/service/RedisMessagePublisher.java new file mode 100644 index 0000000..0ec9ea5 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/redis/service/RedisMessagePublisher.java @@ -0,0 +1,131 @@ +package com.loafle.overflow.central.redis.service; + +import com.loafle.overflow.central.commons.model.PublishMessage; +import com.loafle.overflow.central.commons.service.MessagePublisher; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.member.service.MemberService; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.stereotype.Service; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +public class RedisMessagePublisher implements MessagePublisher { + private static final String CHANNEL_WEBAPP = "/webapp"; + private static final String CHANNEL_NOAUTH_PROBE = "/auth"; + private static final String CHANNEL_PROBE = "/probe"; + + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private ObjectMapper objectMapper; + @Autowired + private MemberService memberService; + + private Map topics; + + public RedisMessagePublisher() { + } + + public RedisMessagePublisher(final RedisTemplate redisTemplate, final Map topics) { + this.redisTemplate = redisTemplate; + this.topics = topics; + } + + public void publishToDomainMembers(final long domainID, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.MEMBER); + message.setTargets(getMemberListByDomainID(domainID)); + this.publish(CHANNEL_WEBAPP, message, method, params); + } + public void publishToDomainMembersByProbeKey(final String probeKey, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.MEMBER); + message.setTargets(getMemberListByProbeKey(probeKey)); + this.publish(CHANNEL_WEBAPP, message, method, params); + } + + public void publishToMember(final String memberID, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.MEMBER); + message.addTarget(memberID); + this.publish(CHANNEL_WEBAPP, message, method, params); + } + public void publishToMemberSession(final String memberSessionID, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.MEMBER_SESSION); + message.addTarget(memberSessionID); + this.publish(CHANNEL_WEBAPP, message, method, params); + } + + public void publishToNoAuthProbe(final String tempProbeKey, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.PROBE); + message.addTarget(tempProbeKey); + this.publish(CHANNEL_NOAUTH_PROBE, message, method, params); + } + + public void publishToProbe(final String probeKey, final String method, final Object... params) { + PublishMessage message = new PublishMessage(); + message.setTargetType(PublishMessage.TargetType.PROBE); + message.addTarget(probeKey); + this.publish(CHANNEL_PROBE, message, method, params); + } + + + @Cacheable("memberListByDomain") + protected List getMemberListByDomainID(final long domainID) { + return this.getMemberList(memberService.readAllByDomainID(domainID)); + } + + @Cacheable("memberListByProbeKey") + protected List getMemberListByProbeKey(final String probeKey) { + return this.getMemberList(memberService.readAllByProbeKey(probeKey)); + } + + protected List getMemberList(final List members) { + List results = new ArrayList<>(members.size()); + for (Member member: members) { + results.add(member.getEmail()); + } + + return results; + } + + protected void publish(final String channel, PublishMessage message, final String method, Object... params) { + ChannelTopic topic = this.topics.get(channel); + message.setMessage(new PublishMessage.PublishMessageBody(method, this.getMessageBody(params))); + + try { + String json = this.objectMapper.writeValueAsString(message); + redisTemplate.convertAndSend(topic.getTopic(), json); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + protected List getMessageBody(final Object... params) { + List results = new ArrayList<>(params.length); + try { + for (Object param : params) { + if (param.getClass().equals(String.class)) { + results.add((String)param); + } else { + results.add(objectMapper.writeValueAsString(param)); + } + } + } catch (IOException e) { + e.printStackTrace(); + } + return results; + } + +} diff --git a/src/main/java/com/loafle/overflow/central/spring/AppConfig.java b/src/main/java/com/loafle/overflow/central/spring/AppConfig.java new file mode 100644 index 0000000..ccf4505 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/spring/AppConfig.java @@ -0,0 +1,53 @@ +package com.loafle.overflow.central.spring; + +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.context.annotation.*; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; + +/** + * Created by insanity on 17. 6. 13. + */ +@Configuration +@ComponentScan(basePackages = {"com.loafle.overflow"}, excludeFilters = @ComponentScan.Filter({Configuration.class})) +@Import({ + JdbcConfiguration.class, + MailConfiguration.class, + RedisConfiguration.class, + CacheConfiguration.class +}) +@PropertySource({ + "classpath:database.properties", + "classpath:mail.properties", + "classpath:redis.properties", + "classpath:cache.properties" +}) +public class AppConfig { +// @Bean +// public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { +// PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); +//// ppc.setLocation(new ClassPathResource("database.properties")); +// ppc.setLocations(new Resource[] { +// new ClassPathResource("database.properties"), +// new ClassPathResource("mail.properties"), +// new ClassPathResource("redis.properties") +// }); +// ppc.setIgnoreUnresolvablePlaceholders(true); +// +// return ppc; +// } + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Bean + public ObjectMapper getObjectMapper() { + + ObjectMapper objectMapper = new ObjectMapper(); + + objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + return objectMapper; + } +} diff --git a/src/main/java/com/loafle/overflow/central/spring/CacheConfiguration.java b/src/main/java/com/loafle/overflow/central/spring/CacheConfiguration.java new file mode 100644 index 0000000..d23209b --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/spring/CacheConfiguration.java @@ -0,0 +1,26 @@ +package com.loafle.overflow.central.spring; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.caffeine.CaffeineCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@EnableCaching +@Configuration +public class CacheConfiguration { + @Value("#{'${cache.cache-names}'.split(',')}") + private String[] cacheNames; + @Value("${cache.caffeine.spec}") + private String spec; + + @Bean + public CacheManager cacheManager() { + //A EhCache based Cache manager + CaffeineCacheManager cacheManager = new CaffeineCacheManager(cacheNames); + cacheManager.setAllowNullValues(false); + cacheManager.setCacheSpecification(spec); + return cacheManager; + } +} diff --git a/src/main/java/com/loafle/overflow/central/spring/JdbcConfiguration.java b/src/main/java/com/loafle/overflow/central/spring/JdbcConfiguration.java new file mode 100644 index 0000000..6e4b54a --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/spring/JdbcConfiguration.java @@ -0,0 +1,103 @@ +package com.loafle.overflow.central.spring; + +import org.codehaus.jackson.map.ObjectMapper; +import org.hibernate.cfg.Environment; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.jdbc.datasource.init.DataSourceInitializer; +import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.annotation.TransactionManagementConfigurer; + +import javax.persistence.EntityManager; +import javax.sql.DataSource; +import java.util.Properties; + + +/** + * Created by root on 17. 6. 13. + */ +@Configuration +@EnableTransactionManagement +@EnableJpaRepositories(basePackages = {"com.loafle.overflow"}) +public class JdbcConfiguration implements TransactionManagementConfigurer { + @Value("${datasource.driver-class-name}") + private String driver; + @Value("${datasource.url}") + private String url; + @Value("${datasource.username}") + private String username; + @Value("${datasource.password}") + private String password; + @Value("${jpa.hibernate.dialect}") + private String dialect; + @Value("${jpa.hibernate.ddl-auto}") + private String hbm2ddlAuto; + + @Bean + public DataSource configureDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName(driver); + dataSource.setUrl(url); + dataSource.setUsername(username); + dataSource.setPassword(password); + return dataSource; + } + + @Bean + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean(); + entityManagerFactoryBean.setDataSource(configureDataSource()); + entityManagerFactoryBean.setPackagesToScan("com.loafle.overflow"); + entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); + + Properties jpaProperties = new Properties(); + jpaProperties.put(Environment.DIALECT, dialect); + jpaProperties.put(Environment.HBM2DDL_AUTO, hbm2ddlAuto); + jpaProperties.put(Environment.SHOW_SQL, true); + + entityManagerFactoryBean.setJpaProperties(jpaProperties); + + return entityManagerFactoryBean; + } + + + + @Bean + @Qualifier(value = "transactionManager") + public PlatformTransactionManager annotationDrivenTransactionManager() { + return new JpaTransactionManager(); + } + + @Bean + public EntityManager entityManager() { + return entityManagerFactory().getObject().createEntityManager(); + } + + @Bean + public DataSourceInitializer dataSourceInitializer(DataSource dataSource) { + DataSourceInitializer initializer = new DataSourceInitializer(); + initializer.setDataSource(dataSource); + + ClassPathResource initSqlResource = new ClassPathResource("/init.sql"); + if (initSqlResource.exists()) { + ResourceDatabasePopulator databasePopulator = new ResourceDatabasePopulator(); + databasePopulator.addScript(initSqlResource); + databasePopulator.setIgnoreFailedDrops(true); + initializer.setDatabasePopulator(databasePopulator); + } else { + initializer.setEnabled(false); + } + + return initializer; + } +} diff --git a/src/main/java/com/loafle/overflow/central/spring/MailConfiguration.java b/src/main/java/com/loafle/overflow/central/spring/MailConfiguration.java new file mode 100644 index 0000000..09e43ab --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/spring/MailConfiguration.java @@ -0,0 +1,81 @@ +package com.loafle.overflow.central.spring; + +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.exception.VelocityException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.ui.velocity.VelocityEngineFactory; + +import java.io.IOException; +import java.util.Properties; + +/** + * Created by geek on 17. 6. 28. + */ +@Configuration +@ComponentScan(basePackages = "com.loafle.overflow") +public class MailConfiguration { + + @Value("${mail.host}") + private String host; + @Value("${mail.port}") + private int port; + @Value("${mail.username}") + private String username; + @Value("${mail.password}") + private String password; + @Value("${mail.protocol}") + private String protocol; + + @Bean + public JavaMailSenderImpl mailSender() { + JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); + + mailSender.setHost(this.host); + mailSender.setPort(this.port); + mailSender.setUsername(this.username); + mailSender.setPassword(this.password); + mailSender.setProtocol(this.protocol); + + mailSender.setJavaMailProperties(getJavaMailProperties()); + + return mailSender; + } + + @Bean + public Properties getJavaMailProperties() { + Properties javaMailProperties = new Properties(); + javaMailProperties.put("mail.smtp.starttls.enable", true); + javaMailProperties.put("mail.smtp.auth", true); + javaMailProperties.put("mail.transport.protocol", "smtp"); + javaMailProperties.put("mail.debug", "true"); + javaMailProperties.put("mail.smtps.ssl.checkserveridentity", true); + javaMailProperties.put("mail.smtps.ssl.trust", "*"); + + return javaMailProperties; + } + + + @Bean + public VelocityEngine getVelocityEngine() throws VelocityException, IOException { + Properties properties = new Properties(); + properties.load(this.getClass().getResourceAsStream("/velocity.properties")); + return new VelocityEngine(properties); + } + +} + +// +// @Value("${mail.properties.mail.smtp.auth}") +// private boolean smtpAuth; +// @Value("${mail.properties.mail.smtp.starttls.enable}") +// private boolean ttlEnable; +// @Value("${mail.transport.protocol}") +// private String transProtocol; +// @Value("${mail.smtps.ssl.checkserveridentity}") +// private boolean checkserver; +// @Value("${mail.smtps.ssl.trust}") +// private String sslTrust; diff --git a/src/main/java/com/loafle/overflow/central/spring/RedisConfiguration.java b/src/main/java/com/loafle/overflow/central/spring/RedisConfiguration.java new file mode 100644 index 0000000..b08a996 --- /dev/null +++ b/src/main/java/com/loafle/overflow/central/spring/RedisConfiguration.java @@ -0,0 +1,56 @@ +package com.loafle.overflow.central.spring; + +import com.loafle.overflow.central.commons.service.MessagePublisher; +import com.loafle.overflow.central.redis.service.RedisMessagePublisher; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.listener.ChannelTopic; +import org.springframework.data.redis.serializer.GenericToStringSerializer; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Configuration +public class RedisConfiguration { + @Value("${redis.host}") + private String host; + @Value("${redis.port}") + private int port; + @Value("#{'${redis.channels}'.split(',')}") + private List channels; + + @Bean + JedisConnectionFactory jedisConnectionFactory() { + JedisConnectionFactory jedisConFactory = new JedisConnectionFactory(); + jedisConFactory.setHostName(host); + jedisConFactory.setPort(port); + return jedisConFactory; + } + + @Bean + public RedisTemplate redisTemplate() { + final RedisTemplate template = new RedisTemplate(); + template.setConnectionFactory(jedisConnectionFactory()); + template.setValueSerializer(new GenericToStringSerializer(Object.class)); + return template; + } + + @Bean + MessagePublisher messagePublisher() { + return new RedisMessagePublisher(redisTemplate(), topics()); + } + + @Bean + Map topics() { + Map topicMap = new HashMap<>(this.channels.size()); + for (String channel: this.channels) { + topicMap.put(channel, new ChannelTopic(channel)); + } + return topicMap; + } + +} diff --git a/src/main/resources/local/cache.properties b/src/main/resources/local/cache.properties new file mode 100644 index 0000000..fda34c0 --- /dev/null +++ b/src/main/resources/local/cache.properties @@ -0,0 +1,3 @@ +# Caffeine +cache.cache-names:memberListByDomain,memberListByProbeKey +cache.caffeine.spec: initialCapacity=100,maximumSize=500,expireAfterAccess=5m,recordStats \ No newline at end of file diff --git a/src/main/resources/local/database.properties b/src/main/resources/local/database.properties new file mode 100644 index 0000000..e8c1188 --- /dev/null +++ b/src/main/resources/local/database.properties @@ -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 diff --git a/src/main/resources/local/init.sql b/src/main/resources/local/init.sql new file mode 100644 index 0000000..c8658fb --- /dev/null +++ b/src/main/resources/local/init.sql @@ -0,0 +1,1518 @@ +INSERT INTO public.meta_member_status (id,"name") VALUES ( +1,'NOAUTH'); +INSERT INTO public.meta_member_status (id,"name") VALUES ( +2,'NORMAL'); +INSERT INTO public.meta_member_status (id,"name") VALUES ( +3,'DIAPAUSE'); +INSERT INTO public.meta_member_status (id,"name") VALUES ( +4,'WITHDRAWAL'); + +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +1,'2017-06-25 17:31:42.770','MACHINE'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +2,'2017-06-25 17:31:42.894','HOST'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +3,'2017-06-25 17:31:42.906','OS'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +4,'2017-06-25 17:31:42.906','OS_APPLICATION'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +5,'2017-06-25 17:31:42.906','OS_DAEMON'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +6,'2017-06-25 17:31:42.906','OS_PORT'); +INSERT INTO public.meta_infra_type (id,create_date,"name") VALUES ( +7,'2017-06-25 17:31:42.906','OS_SERVICE'); + +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 1,'2017-07-27 15:26:52.985','APPLE',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 2,'2017-07-27 15:26:52.985','MICROSOFT',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 3,'2017-07-27 15:26:52.985','ASUS',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 4,'2017-07-27 15:26:52.985','HP',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 5,'2017-07-27 15:26:52.985','DELL',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 6,'2017-07-27 15:26:52.985','LENOVO',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 7,'2017-07-27 15:26:52.985','ACER',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 8,'2017-07-27 15:26:52.985','SAMSUNG',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 9,'2017-07-27 15:26:52.985','LG',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 10,'2017-07-27 15:26:52.985','CISCO',1); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 11,'2017-07-27 15:26:52.985','Windows',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 12,'2017-07-27 15:26:52.985','Linux',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 13,'2017-07-27 15:26:52.985','Mac OS',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 14,'2017-07-27 15:26:52.985','Ubuntu',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 15,'2017-07-27 15:26:52.985','Cent OS',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 16,'2017-07-27 15:26:52.985','Fedora',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 17,'2017-07-27 15:26:52.985','Red Hat',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 18,'2017-07-27 15:26:52.985','Debian',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 19,'2017-07-27 15:26:52.985','SUSE',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 20,'2017-07-27 15:26:52.985','Core OS',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 21,'2017-07-27 15:26:52.985','Amazon Linux',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 22,'2017-07-27 15:26:52.985','Kubernetes',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 23,'2017-07-27 15:26:52.985','Docker',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 24,'2017-07-27 15:26:52.985','iOS',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 25,'2017-07-27 15:26:52.985','Android',2); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 26,'2017-07-27 15:26:52.985','Windows',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 27,'2017-07-27 15:26:52.985','Mac OS',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 28,'2017-07-27 15:26:52.985','Ubuntu',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 29,'2017-07-27 15:26:52.985','Cent OS',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 30,'2017-07-27 15:26:52.985','Fedora',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 31,'2017-07-27 15:26:52.985','Red Hat',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 32,'2017-07-27 15:26:52.985','Debian',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 33,'2017-07-27 15:26:52.985','SUSE',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 34,'2017-07-27 15:26:52.985','Core OS',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 35,'2017-07-27 15:26:52.985','Amazon Linux',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 36,'2017-07-27 15:26:52.985','Kubernetes',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 37,'2017-07-27 15:26:52.985','Docker',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 38,'2017-07-27 15:26:52.985','iOS',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 39,'2017-07-27 15:26:52.985','Android',3); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 40,'2017-07-27 15:26:52.985','ACTIVEDIRECTORY',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 41,'2017-07-27 15:26:52.985','CASSANDRA',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 42,'2017-07-27 15:26:52.985','DHCP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 43,'2017-07-27 15:26:52.985','DNS',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 44,'2017-07-27 15:26:52.985','FTP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 45,'2017-07-27 15:26:52.985','HTTP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 46,'2017-07-27 15:26:52.985','IMAP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 47,'2017-07-27 15:26:52.985','LDAP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 48,'2017-07-27 15:26:52.985','MONGODB',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 49,'2017-07-27 15:26:52.985','MSSQL',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 50,'2017-07-27 15:26:52.985','MYSQL',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 51,'2017-07-27 15:26:52.985','NETBIOS',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 52,'2017-07-27 15:26:52.985','ORACLE',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 53,'2017-07-27 15:26:52.985','POP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 54,'2017-07-27 15:26:52.985','POSTGRESQL',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 55,'2017-07-27 15:26:52.985','REDIS',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 56,'2017-07-27 15:26:52.985','RMI',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 57,'2017-07-27 15:26:52.985','SMB',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 58,'2017-07-27 15:26:52.985','SMTP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 59,'2017-07-27 15:26:52.985','SNMP',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 60,'2017-07-27 15:26:52.985','SSH',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 61,'2017-07-27 15:26:52.985','TELNET',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 62,'2017-07-27 15:26:52.985','WMI',7); +-- INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +-- 63,'2017-07-27 15:26:52.985','UNKNOWN',7); + +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +1,'2017-07-27 15:26:52.985','ACTIVEDIRECTORY',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +2,'2017-07-27 15:26:52.985','CASSANDRA',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +3,'2017-07-27 15:26:52.985','DHCP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +4,'2017-07-27 15:26:52.985','DNS',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +5,'2017-07-27 15:26:52.985','FTP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +6,'2017-07-27 15:26:52.985','HTTP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +7,'2017-07-27 15:26:52.985','IMAP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +8,'2017-07-27 15:26:52.985','LDAP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +9,'2017-07-27 15:26:52.985','MONGODB',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +10,'2017-07-27 15:26:52.985','MSSQL',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +11,'2017-07-27 15:26:52.985','MYSQL',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +12,'2017-07-27 15:26:52.985','NETBIOS',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +13,'2017-07-27 15:26:52.985','ORACLE',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +14,'2017-07-27 15:26:52.985','POP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +15,'2017-07-27 15:26:52.985','POSTGRESQL',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +16,'2017-07-27 15:26:52.985','REDIS',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +17,'2017-07-27 15:26:52.985','RMI',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +18,'2017-07-27 15:26:52.985','SMB',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +19,'2017-07-27 15:26:52.985','SMTP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +20,'2017-07-27 15:26:52.985','SNMP',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +21,'2017-07-27 15:26:52.985','SSH',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +22,'2017-07-27 15:26:52.985','TELNET',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +23,'2017-07-27 15:26:52.985','WMI',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +24,'2017-07-27 15:26:52.985','UNKNOWN',7); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +25,'2017-11-10 15:26:52.985','SSH',2); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +26,'2017-11-10 15:26:52.985','WMI',2); +INSERT INTO public.meta_infra_vendor (id,create_date,name,type_id) VALUES ( +27,'2017-11-10 15:26:52.985','SNMP',2); + + +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +1,'2017-06-30 12:56:08.791','ACTIVEDIRECTORY','ACTIVEDIRECTORY_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +2,'2017-06-30 12:56:08.791','CASSANDRA','CASSANDRA_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +3,'2017-06-30 12:56:08.791','DHCP','DHCP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +4,'2017-06-30 12:56:08.791','DNS','DNS_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +5,'2017-06-30 12:56:08.791','FTP','FTP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +6,'2017-06-30 12:56:08.791','HTTP','HTTP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +7,'2017-06-30 12:56:08.791','IMAP','IMAP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +8,'2017-06-30 12:56:08.791','LDAP','LDAP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +9,'2017-06-30 12:56:08.791','MONGODB','MONGODB_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +10,'2017-06-30 12:56:08.791','MSSQL','MSSQL_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +11,'2017-06-30 12:56:08.791','MYSQL','MYSQL_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +12,'2017-06-30 12:56:08.791','NETBIOS','NETBIOS_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +13,'2017-06-30 12:56:08.791','ORACLE','ORACLE_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +14,'2017-06-30 12:56:08.791','POP','POP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +15,'2017-06-30 12:56:08.791','POSTGRESQL','POSTGRESQL_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +16,'2017-06-30 12:56:08.791','REDIS','REDIS_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +17,'2017-06-30 12:56:08.791','JMX','JMX_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +18,'2017-06-30 12:56:08.791','SMB','SMB_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +19,'2017-06-30 12:56:08.791','SMTP','SMTP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +20,'2017-06-30 12:56:08.791','SNMP','SNMP_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +21,'2017-06-30 12:56:08.791','SSH','SSH_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +22,'2017-06-30 12:56:08.791','TELNET','TELNET_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +23,'2017-06-30 12:56:08.791','WMI','WMI_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +24,'2017-06-30 12:56:08.791','UNKNOWN','UNKNOWN_CRAWLER'); +INSERT INTO public.meta_crawler (id,create_date,description,name) VALUES ( +25,'2017-06-30 12:56:08.791','SNMP V3','SNMPV3_CRAWLER'); + + +INSERT INTO public.meta_input_type (id,create_date,description,"name") VALUES ( +1,'2017-06-25 17:00:53.861','TEXT','TEXT_TYPE'); +INSERT INTO public.meta_input_type (id,create_date,description,"name") VALUES ( +2,'2017-06-25 17:00:53.893','PASSWORD','PASSWORD_TYPE'); +INSERT INTO public.meta_input_type (id,create_date,description,"name") VALUES ( +3,'2017-06-25 17:00:53.901','NUMBER','NUMBER_TYPE'); +INSERT INTO public.meta_input_type (id,create_date,description,"name") VALUES ( +4,'2017-06-25 17:00:53.910','BOOLEAN','BOOLEAN_TYPE'); +INSERT INTO public.meta_input_type (id,create_date,description,"name") VALUES ( +5,'2017-06-25 17:00:53.920','SELECT','SELECT_TYPE'); + + +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'1','2017-06-25 17:01','Loafle','Windows Account ID','','','ID','','TRUE','23','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'2','2017-06-25 17:01','','Windows Account PW','','','PassWord','','TRUE','23','2'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'3','2017-06-25 17:01','public','SNMP V2 Community','','','Community','','TRUE','20','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'4','2017-06-25 17:01','mysqldb','MYSQL DB Name','','','DB Name','','TRUE','11','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'5','2017-06-25 17:01','Loafle','MYSQL Account ID','','','ID','','TRUE','11','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'6','2017-06-25 17:01','','MYSQL Account PW','','','PassWord','','TRUE','11','2'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'7','2017-06-25 17:01','Loafle','JMX Account ID','','','ID','','TRUE','17','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'8','2017-06-25 17:01','','JMX Account PW','','','PassWord','','TRUE','17','2'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'9','2017-09-11 18:41','MD5','SNMP V3 Auth Type','','MD5|SHA','AuthType','','TRUE','25','5'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'10','2017-09-11 18:41','Loafle','SNMP V3 User ID','','','ID','','TRUE','25','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'11','2017-09-11 18:41','','SNMP V3 PassWord','','','PassWord','','TRUE','25','2'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'12','2017-09-11 18:41','DES','SNMP V3 Encryption Type','','DES|AES','Encryption Type','','TRUE','25','5'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'13','2017-09-11 18:41','Loafle','SNMP V3 Encryption Key','','','Encryption Key','','TRUE','25','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'14','2017-06-25 17:01','redis','Redis DB Name','','','DB Name','','TRUE','16','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'15','2017-06-25 17:01','Loafle','Redis Account ID','','','ID','','TRUE','16','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'16','2017-06-25 17:01','','Redis Account PW','','','PassWord','','TRUE','16','2'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'17','2017-06-25 17:01','Loafle','SSH User','','','ID','','TRUE','21','1'); +INSERT INTO meta_crawler_input_item (id,create_date,default_value,description,key_name,key_value,name,pattern,required,crawler_id,type_id) VALUES ( +'18','2017-06-25 17:01','','SSH PW','','','PassWord','','TRUE','21','2'); + + +INSERT INTO public.meta_probe_architecture (id,architecture,create_date) VALUES ( +1,'x86-64bit','2017-06-25 16:48:15.317'); +INSERT INTO public.meta_probe_architecture (id,architecture,create_date) VALUES ( +2,NULL,'2017-06-25 16:48:15.350'); + +INSERT INTO public.meta_probe_os (id,create_date,"name") VALUES ( +1,'2017-06-25 16:48:28.617','Windows'); +INSERT INTO public.meta_probe_os (id,create_date,"name") VALUES ( +2,'2017-06-25 16:48:28.683','Debian'); +INSERT INTO public.meta_probe_os (id,create_date,"name") VALUES ( +3,'2017-06-25 16:48:28.699','Ubuntu'); +INSERT INTO public.meta_probe_os (id,create_date,"name") VALUES ( +4,'2017-06-25 16:48:28.708','Fedora'); + + +INSERT INTO public.meta_probe_version (id,create_date,"version") VALUES ( +1,'2017-06-25 16:48:00.520','1.0.0'); +INSERT INTO public.meta_probe_version (id,create_date,"version") VALUES ( +2,'2017-06-25 16:48:00.558','1.1.0'); + + +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +1,'2017-06-25 16:59:59.194',1,1,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +2,'2017-06-25 16:59:59.216',1,2,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +3,'2017-06-25 16:59:59.255',1,3,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +4,'2017-06-25 16:59:59.268',1,4,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +5,'2017-06-25 16:59:59.279',2,1,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +6,'2017-06-25 16:59:59.307',2,2,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +7,'2017-06-25 16:59:59.317',2,3,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +8,'2017-06-25 16:59:59.330',2,4,1); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +9,'2017-06-25 16:59:59.363',1,1,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +10,'2017-06-25 16:59:59.395',1,2,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +11,'2017-06-25 16:59:59.416',1,3,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +12,'2017-06-25 16:59:59.446',1,4,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +13,'2017-06-25 16:59:59.468',2,1,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +14,'2017-06-25 16:59:59.484',2,2,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +15,'2017-06-25 16:59:59.507',2,3,2); +INSERT INTO public.meta_probe_package (id,create_date,architecture_id,os_id,version_id) VALUES ( +16,'2017-06-25 16:59:59.522',2,4,2); + +INSERT INTO public.meta_probe_status (id,"name") VALUES ( +1,'INITIAL'); +INSERT INTO public.meta_probe_status (id,"name") VALUES ( +2,'NORMAL'); + +INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES ( +1,'ACCEPT'); +INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES ( +2,'DENY'); +INSERT INTO public.meta_noauth_probe_status (id,"name") VALUES ( +3,'PROCESS'); + +INSERT INTO public.meta_probe_task_type (id,create_date,description,"name") VALUES ( +1,'2017-06-26 15:58:02.397','DISCOVERY START','DISCOVERY'); + +INSERT INTO public.meta_sensor_status (id,"name") VALUES ( +1,'RUNNING'); +INSERT INTO public.meta_sensor_status (id,"name") VALUES ( +2,'STOPPED'); + +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +1,'2017-06-26 19:49:00.000','','CPU'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +2,'2017-06-26 19:49:00.000','','Memory'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +3,'2017-06-26 19:49:00.000','','Disk IO'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +4,'2017-06-26 19:49:00.000','','File System'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +5,'2017-06-26 19:49:00.000','','Network'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +6,'2017-06-26 19:49:00.000','','Process'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +7,'2017-06-26 19:49:00.000','','Server'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +8,'2017-06-26 19:49:00.000','','Client'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +9,'2017-06-26 19:49:00.000','','Persistence'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +10,'2017-06-26 19:49:00.000','','Stats'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +11,'2017-06-26 19:49:00.000','','Replication'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +12,'2017-06-26 19:49:00.000','','Cluster'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +13,'2017-06-26 19:49:00.000','','Keyspace'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +14,'2017-06-26 19:49:00.000','','InnoDB'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +15,'2017-06-26 19:49:00.000','','Net'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +16,'2017-06-26 19:49:00.000','','Performance'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +17,'2017-06-26 19:49:00.000','','Thread'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +18,'2017-06-26 19:49:00.000','','GlobalRequestProcessor'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +19,'2017-06-26 19:49:00.000','','Servlet'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +20,'2017-06-26 19:49:00.000','','StringCache'); +INSERT INTO public.meta_sensor_item_type (id,create_date,description,"name") VALUES ( +21,'2017-06-26 19:49:00.000','','JspMonitor'); + +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +0,'2017-09-20 14:16:26.213','',''); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +1,'2017-09-20 14:16:26.213','%','Percentage'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +2,'2017-09-20 14:16:26.256','Bytes','Byte'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +3,'2017-09-20 14:16:26.272','KB','KByte'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +4,'2017-09-20 14:16:26.289','MB','MByte'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +5,'2017-09-20 14:16:26.305','GB','GByte'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +6,'2017-09-20 14:16:26.321','','Count'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +7,'2017-09-20 14:16:26.339','Jiffies','Jiffy'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +8,'2017-09-20 14:16:26.355','BPS','Byte Per Second'); +INSERT INTO public.meta_sensor_item_unit (id,create_date,mark,unit) VALUES ( +9,'2017-09-20 14:16:26.372','PPS','Packet Per Second'); + +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'123','2017-11-06 00:00:00','cpu.usage.user',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'124','2017-11-06 00:00:00','cpu.usage.nice',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'125','2017-11-06 00:00:00','cpu.usage.system',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'126','2017-11-06 00:00:00','cpu.usage.idle',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'127','2017-11-06 00:00:00','cpu.usage.iowait',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'128','2017-11-06 00:00:00','cpu.usage.irq',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'129','2017-11-06 00:00:00','cpu.usage.softirq',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'130','2017-11-06 00:00:00','cpu.usage.steal',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'131','2017-11-06 00:00:00','cpu.usage.guest',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'132','2017-11-06 00:00:00','cpu.usage.gnice',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'133','2017-11-06 00:00:00','cpu.usage.processor',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'134','2017-11-06 00:00:00','cpu.usage.privilege',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'135','2017-11-06 00:00:00','mem.usage.total',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'136','2017-11-06 00:00:00','mem.usage.free',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'137','2017-11-06 00:00:00','mem.usage.available',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'138','2017-11-06 00:00:00','mem.usage.buffers',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'139','2017-11-06 00:00:00','mem.usage.cached',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'140','2017-11-06 00:00:00','mem.swap.usage.total',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'141','2017-11-06 00:00:00','mem.swap.usage.free',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'142','2017-11-06 00:00:00','mem.swap.usage.cached',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'143','2017-11-06 00:00:00','mem.virtual.usage.total',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'144','2017-11-06 00:00:00','mem.virtual.usage.free',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'145','2017-11-06 00:00:00','mem.paging.usage.total',''); +INSERT INTO public.meta_sensor_item (id,create_date,"key",name) VALUES ( +'146','2017-11-06 00:00:00','mem.paging.usage.free',''); + +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'119','2017-06-26 19:49:00','cat /proc/stat','user','','21','123','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'120','2017-06-26 19:49:00','cat /proc/stat','nice','','21','124','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'121','2017-06-26 19:49:00','cat /proc/stat','system','','21','125','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'122','2017-06-26 19:49:00','cat /proc/stat','idle','','21','126','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'123','2017-06-26 19:49:00','cat /proc/stat','iowait','','21','127','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'124','2017-06-26 19:49:00','cat /proc/stat','irq','','21','128','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'125','2017-06-26 19:49:00','cat /proc/stat','softirq','','21','129','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'126','2017-06-26 19:49:00','cat /proc/stat','steal','','21','130','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'127','2017-06-26 19:49:01','cat /proc/stat','guest','','21','131','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'128','2017-06-26 19:49:02','cat /proc/stat','gnice','','21','132','7'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'129','2017-06-26 19:49:03','Win32_PerfFormattedData_PerfOS_Processor','PercentIdleTime','{"where": "Name=''_Total''"}','23','126','1'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'130','2017-06-26 19:49:04','Win32_PerfFormattedData_PerfOS_Processor','PercentProcessorTime','{"where": "Name=''_Total''"}','23','133','1'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'131','2017-06-26 19:49:04','Win32_PerfFormattedData_PerfOS_Processor','PercentUserTime','{"where": "Name=''_Total''"}','23','123','1'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'132','2017-06-26 19:49:04','Win32_PerfFormattedData_PerfOS_Processor','PercentPrivilegedTime','{"where": "Name=''_Total''"}','23','134','1'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'133','2017-06-26 19:49:04','cat /proc/meminfo','total','','21','135','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'134','2017-06-26 19:49:04','cat /proc/meminfo','free','','21','136','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'135','2017-06-26 19:49:04','cat /proc/meminfo','available','','21','137','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'136','2017-06-26 19:49:04','cat /proc/meminfo','buffers','','21','138','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'137','2017-06-26 19:49:04','cat /proc/meminfo','cached','','21','139','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'138','2017-06-26 19:49:04','cat /proc/meminfo','swapTotal','','21','140','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'139','2017-06-26 19:49:04','cat /proc/meminfo','swapFree','','21','141','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'140','2017-06-26 19:49:04','cat /proc/meminfo','swapCached','','21','142','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'141','2017-06-26 19:49:04','Win32_OperatingSystem ','TotalVisibleMemorySize','','23','135','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'142','2017-06-26 19:49:04','Win32_OperatingSystem ','FreePhysicalMemory','','23','136','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'143','2017-06-26 19:49:04','Win32_OperatingSystem ','TotalVirtualMemorySize','','23','143','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'144','2017-06-26 19:49:04','Win32_OperatingSystem ','FreeVirtualMemory','','23','144','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'145','2017-06-26 19:49:04','Win32_OperatingSystem ','SizeStoredInPagingFiles','','23','145','3'); +INSERT INTO meta_sensor_item_key (id,create_date,froms,"key",option_json,crawler_id,item_id,unit_id) VALUES ( +'146','2017-06-26 19:49:04','Win32_OperatingSystem ','FreeSpaceInPagingFiles','','23','146','3'); + + +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'1','2017-11-07 16:08:59','true','','CPU Total usage (%)','ssh.cpu.usage.total','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'2','2017-11-07 16:08:59','false','','CPU User (%)','ssh.cpu.usage.user','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'3','2017-11-07 16:08:59','false','','CPU Nice (%)','ssh.cpu.usage.nice','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'4','2017-11-07 16:08:59','false','','CPU System (%)','ssh.cpu.usage.system','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'5','2017-11-07 16:08:59','false','','CPU Idle (%)','ssh.cpu.usage.idle','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'6','2017-11-07 16:08:59','false','','CPU IO wait (%)','ssh.cpu.usage.iowait','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'7','2017-11-07 16:08:59','false','','CPU IRQ (%)','ssh.cpu.usage.irq','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'8','2017-11-07 16:08:59','false','','CPU Soft IRQ (%)','ssh.cpu.usage.softirq','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'9','2017-11-07 16:08:59','false','','CPU Steal (%)','ssh.cpu.usage.steal','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'10','2017-11-07 16:08:59','false','','CPU Guest (%)','ssh.cpu.usage.guest','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'11','2017-11-07 16:08:59','false','','CPU Guest Nice (%)','ssh.cpu.usage.gnice','21','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'12','2017-11-07 16:08:59','true','','CPU Total usage (%)','wmi.cpu.usage.total','23','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'13','2017-11-07 16:08:59','false','','CPU Idle (%)','wmi.cpu.usage.idle','23','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'14','2017-11-07 16:08:59','false','','CPU Processor (%)','wmi.cpu.usage.processor','23','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'15','2017-11-07 16:08:59','false','','CPU User (%)','wmi.cpu.usage.user','23','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'16','2017-11-07 16:08:59','false','','CPU Privilege (%)','wmi.cpu.usage.privilege','23','1','1'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'17','2017-11-07 16:08:59','true','','Memory Total Usage (%)','ssh.mem.usage.total','21','1','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'18','2017-11-07 16:08:59','false','','Memory Free space (mb)','ssh.mem.usage.free','21','4','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'19','2017-11-07 16:08:59','false','','Buffered Memory (mb)','ssh.mem.usage.buffers','21','4','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'20','2017-11-07 16:08:59','false','','Cached Memory (mb)','ssh.mem.usage.cached','21','4','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'21','2017-11-07 16:08:59','true','','Swap Total Usage (%)','ssh.mem.swap.usage.total','21','1','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'22','2017-11-07 16:08:59','false','','Cached Swap (mb)','ssh.mem.swap.usage.cached','21','4','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'23','2017-11-07 16:08:59','true','','Memory Total usage (%)','wmi.mem.usage.total','23','1','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'24','2017-11-07 16:08:59','false','','Virtual Memory Usage (%)','wmi.mem.virtual.usage.total','23','1','2'); +INSERT INTO meta_sensor_display_item (id,create_date,is_default,description,display_name,"key",crawler_id,unit_id,type_id) VALUES ( +'25','2017-11-07 16:08:59','false','','Paging Usage (%)','wmi.mem.paging.usage.total','23','1','2'); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (201, '2017-11-07 16:08:59', true, 'The rate of connections to the server.', 'Connections', 'MYSQL.NET.CONNECTIONS', 11, 15, 6); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (202, '2017-11-07 16:08:59', true, 'The rate of data reads and writes.', 'Reads & Writes', 'MYSQL.INNODB.READSWRITES', 11, 14, 6); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (203, '2017-11-07 16:08:59', true, 'Fraction of time spent (ms/s) acquring row locks.', 'Row Lock Time (ms/s)', 'MYSQL.INNODB.ROW_LOCK_TIME', 11, 14, 0); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (204, '2017-11-07 16:08:59', true, 'The number of times per second a row lock had to be waited for.', 'Row Lock Waits', 'MYSQL.INNODB.ROW_LOCK_WAITS', 11, 14, 6); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (205, '2017-11-07 16:08:59', true, 'The rate of slow queries.', 'Slow Queries', 'MYSQL.PERFORMANCE.SLOW_QUERIES', 11, 16, 6); +INSERT INTO meta_sensor_display_item (id, create_date, is_default, description, display_name, key, crawler_id, type_id, unit_id) VALUES (206, '2017-11-07 16:08:59', true, 'The rate of queries.', 'Queries', 'MYSQL.PERFORMANCE.QUERIES', 11, 16, 6); + + + +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'1','1','119'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'2','1','120'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'3','1','121'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'4','1','122'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'5','1','123'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'6','1','124'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'7','1','125'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'8','1','126'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'9','1','127'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'10','1','128'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'11','2','119'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'12','3','120'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'13','4','121'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'14','5','122'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'15','6','123'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'16','7','124'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'17','8','125'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'18','9','126'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'19','10','127'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'20','11','128'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'21','12','129'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'22','12','130'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'23','12','131'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'24','12','132'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'25','13','129'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'26','14','130'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'27','15','131'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'28','16','132'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'29','17','133'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'30','17','134'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'31','17','135'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'32','17','136'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'33','17','137'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'34','18','134'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'35','19','136'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'36','20','137'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'37','21','138'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'38','21','139'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'39','21','140'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'40','22','140'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'41','23','141'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'42','23','142'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'43','23','143'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'44','23','144'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'45','23','145'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'46','23','146'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'47','24','143'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'48','24','144'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'49','25','145'); +INSERT INTO meta_sensor_display_mapping (id,display_item_id,item_key_id) VALUES ( +'50','25','146'); + +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 1,'2017-07-27 15:29:48.634',23,26); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 2,'2017-07-27 15:29:48.634',20,26); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 3,'2017-07-27 15:29:48.634',20,28); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 4,'2017-07-27 15:29:48.634',20,29); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 5,'2017-07-27 15:29:48.634',20,30); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 6,'2017-07-27 15:29:48.634',20,31); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 7,'2017-07-27 15:29:48.634',20,32); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 8,'2017-07-27 15:29:48.634',1,40); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 9,'2017-07-27 15:29:48.634',2,41); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 10,'2017-07-27 15:29:48.634',3,42); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 11,'2017-07-27 15:29:48.634',4,43); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 12,'2017-07-27 15:29:48.634',5,44); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 13,'2017-07-27 15:29:48.634',6,45); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 14,'2017-07-27 15:29:48.634',7,46); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 15,'2017-07-27 15:29:48.634',8,47); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 16,'2017-07-27 15:29:48.634',9,48); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 17,'2017-07-27 15:29:48.634',10,49); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 18,'2017-07-27 15:29:48.634',11,50); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 19,'2017-07-27 15:29:48.634',12,51); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 20,'2017-07-27 15:29:48.634',13,52); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 21,'2017-07-27 15:29:48.634',14,53); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 22,'2017-07-27 15:29:48.634',15,54); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 23,'2017-07-27 15:29:48.634',16,55); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 24,'2017-07-27 15:29:48.634',17,56); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 25,'2017-07-27 15:29:48.634',18,57); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 26,'2017-07-27 15:29:48.634',19,58); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 27,'2017-07-27 15:29:48.634',20,59); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 28,'2017-07-27 15:29:48.634',21,60); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 29,'2017-07-27 15:29:48.634',22,61); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 30,'2017-07-27 15:29:48.634',23,62); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 31,'2017-07-27 15:29:48.634',24,63); +-- +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 32,'2017-07-27 15:29:48.634',25,26); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 33,'2017-07-27 15:29:48.634',25,28); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 34,'2017-07-27 15:29:48.634',25,29); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 35,'2017-07-27 15:29:48.634',25,30); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 36,'2017-07-27 15:29:48.634',25,31); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 37,'2017-07-27 15:29:48.634',25,32); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 32,'2017-07-27 15:29:48.634',25,26); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 33,'2017-07-27 15:29:48.634',25,28); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 34,'2017-07-27 15:29:48.634',25,29); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 35,'2017-07-27 15:29:48.634',25,30); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 36,'2017-07-27 15:29:48.634',25,31); +-- INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +-- 37,'2017-07-27 15:29:48.634',25,32); + +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +1,'2017-07-27 15:29:48.634',1,1); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +2,'2017-07-27 15:29:48.634',2,2); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +3,'2017-07-27 15:29:48.634',3,3); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +4,'2017-07-27 15:29:48.634',4,4); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +5,'2017-07-27 15:29:48.634',5,5); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +6,'2017-07-27 15:29:48.634',6,6); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +7,'2017-07-27 15:29:48.634',7,7); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +8,'2017-07-27 15:29:48.634',8,8); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +9,'2017-07-27 15:29:48.634',9,9); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +10,'2017-07-27 15:29:48.634',10,10); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +11,'2017-07-27 15:29:48.634',11,11); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +12,'2017-07-27 15:29:48.634',12,12); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +13,'2017-07-27 15:29:48.634',13,13); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +14,'2017-07-27 15:29:48.634',14,14); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +15,'2017-07-27 15:29:48.634',15,15); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +16,'2017-07-27 15:29:48.634',16,16); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +17,'2017-07-27 15:29:48.634',17,17); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +18,'2017-07-27 15:29:48.634',18,18); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +19,'2017-07-27 15:29:48.634',19,19); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +20,'2017-07-27 15:29:48.634',20,20); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +21,'2017-07-27 15:29:48.634',21,21); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +22,'2017-07-27 15:29:48.634',22,22); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +23,'2017-07-27 15:29:48.634',23,23); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +24,'2017-07-27 15:29:48.634',24,24); +INSERT INTO public.meta_vendor_crawler (id,create_date,crawler_id,vendor_id) VALUES ( +25,'2017-07-27 15:29:48.634',25,20); + +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +1,'2017-08-23 13:28:26.966','Member'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +2,'2017-08-23 13:28:26.966','Probe'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +3,'2017-08-23 13:28:26.966','Discovery'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +4,'2017-08-23 13:28:26.966','Target'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +5,'2017-08-23 13:28:26.966','Crawler'); +INSERT INTO public.meta_history_type (id,create_date,"name") VALUES ( +6,'2017-08-23 13:28:26.966','Sensor'); + + + + + + + + + + +INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +'loafle','2017-06-26 11:07:27.625','overflow@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); + +INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +'loafle','2017-06-26 11:07:27.625','insanity@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); + +INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +'loafle','2017-06-26 11:07:27.625','snoop@loafle.com','overFlow','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); + +INSERT INTO public."member" (company_name,create_date,email,"name",phone,pw,status_id) VALUES ( +'loafle','2017-06-26 11:07:27.625','geekdev@naver.com','geek','000-000-0000','$2a$10$G2bbjoX9.fOnxJx/8DZqPujFYrEQtIEB.f98/8K20XiGWEhwPakZ.',2); + +INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES ( +'2017-06-27 15:28:48.895','2017-06-26 15:28:48.895','dbseogns1234',1); + +INSERT INTO public.email_auth (auth_confirm_date,create_date,email_auth_key,member_id) VALUES ( +'2017-12-26 15:28:48.895','2017-11-22 12:28:48.895','dbseogns1234',2); + +INSERT INTO public."domain" (create_date,"name") VALUES ( +'2017-06-26 11:25:44.866','overFlow''s domain'); + +INSERT INTO public."domain" (create_date,"name") VALUES ( +'2017-06-26 11:25:44.866','insanity''s domain'); + +INSERT INTO public."domain" (create_date,"name") VALUES ( +'2017-06-26 11:25:44.866','snoop''s domain'); + +INSERT INTO public."domain" (create_date,"name") VALUES ( +'2017-06-26 11:25:44.866','geek''s domain'); + +INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( +'2017-06-26 11:27:43.023',1,1); +INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( +'2017-06-26 11:27:43.023',2,2); +INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( +'2017-06-26 11:27:43.023',3,3); +INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES ( +'2017-06-26 11:27:43.023',4,4); + +-- Member TOTP Insert SQL +-- INSERT INTO public.member_totp (create_date, secret_code, update_date, member_id) VALUES( +-- '2018-03-09 16:39:57.304', 'EDPBZLDATGZP7NX2', '2018-03-09 16:39:57.304', 2); +-- Member TOTP Insert SQL + + +INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( +'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1); + +INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( +'bf78f1f4319611e897713222d3c76cf6','2017-06-26 13:02:28.347',2); + +INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( +'05cf2947319911e898993222d3c76cf6','2017-06-26 13:02:28.347',3); + +INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( +'09c8c54f319911e8a41f3222d3c76cf6','2017-06-26 13:02:28.347',4); + +INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,authorize_member_id,domain_id,status) VALUES ( +'2017-08-21 14:48:31.563','192.168.1.0/24','2017-08-21 14:48:31.563','snoop probe','test probe 111111','8c51fa9c5bcc11e7980a080027658d13','899fdd145bcc11e7b611080027658d13',1,1,1); + +INSERT INTO public.probe (authorize_date,cidr,create_date,description,display_name,encryption_key,probe_key,authorize_member_id,domain_id,status) VALUES ( +'2017-08-21 15:00:09.691','192.168.2.0/24','2017-08-21 15:00:09.691','insanity probe','test probe 22222','f1f72c8d2a814580bb7c4615ec43a6a8','95d8bcdc739741dca74c4a0e489e0774',1,1,1); + +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','Machine Target','ghost target'); +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','OS target','ghost target'); +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','Host target','ghost target'); +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','Service target','ghost target'); +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','OS App target','ghost target'); +INSERT INTO public.target (create_date,description,display_name) VALUES ( +'2017-07-27 20:18:09.555','OS Daemon target','ghost target'); + +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +1,'2017-08-21 12:59:10.244',1,1,1); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +3,'2017-08-21 13:05:24.883',3,1,2); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +2,'2017-08-21 14:20:01.830',2,1,3); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +7,'2017-08-21 14:24:26.525',7,1,4); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +4,'2017-08-21 14:27:19.474',4,1,5); +INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES ( +5,'2017-08-21 14:28:48.761',5,1,6); + + +INSERT INTO public.infra_machine (meta,id) VALUES ( +'i am a infra machine',1); + +-- INSERT INTO public.infra_os (meta,id,machine_id,vendor_id) VALUES ( +-- '',2,1,26); + +INSERT INTO public.infra_os (meta,id,machine_id,vendor_id) VALUES ( +'',2,1,24); + +INSERT INTO public.infra_host (ip,mac,id,os_id) VALUES ( +3232235980,8796753988883,3,2); + +-- INSERT INTO public.infra_service (port,port_type,tls_type,id,host_id,vendor_id) VALUES ( +-- 80,'TCP',false,4,3,45); + +INSERT INTO public.infra_service (port,port_type,tls_type,id,host_id,vendor_id) VALUES ( +80,'TCP',false,4,3,24); + +INSERT INTO public.infra_os_application ("name",id,os_id) VALUES ( +'Apache',5,2); + +INSERT INTO public.infra_os_daemon ("name",id,os_id) VALUES ( +'Apache',6,2); + +insert into public.PROBE_INFRAHOST (HOST_ID, PROBE_ID) values (3, 1); + + +INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES ( +NULL,'2017-06-26 20:19:07.009','My sensor 11111',1,1,1,3); +INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES ( +NULL,'2017-06-26 20:19:07.074','My sensor 22222',1,2,1,1); +INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES ( +NULL,'2017-08-28 16:17:05.506','OS_SERVICE-MYSQL_CRAWLER',11,1,4,2); +INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES ( +NULL,'2017-09-05 12:26:02.738','HOST-WMI_CRAWLER',23,1,3,1); +INSERT INTO public.sensor (crawler_input_items,create_date,description,crawler_id,status,target_id,item_count) VALUES ( +NULL,'2017-09-11 12:26:02.738','SERVICE-JMX_CRAWLER',17,1,4,4); + +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-06-26 20:21:16.626',1,1); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-06-26 20:21:50.988',2,2); +-- +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',5,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',6,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',7,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',8,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',9,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',10,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',11,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',12,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',13,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',14,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',15,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',16,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',17,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',18,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',19,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',20,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',21,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',22,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',23,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',24,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',25,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',26,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',27,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',28,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',29,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',30,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',31,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',32,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',33,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',34,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',35,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',36,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',37,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',38,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',39,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',40,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',41,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',42,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',43,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',44,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',45,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',46,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',47,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',48,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',49,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',50,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',51,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',52,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',53,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',54,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',55,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',56,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',57,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',58,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',59,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',60,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',61,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',62,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',63,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',64,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',65,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',66,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',67,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',68,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',69,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',70,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',71,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',72,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',73,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',74,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',75,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',76,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',77,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',78,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',79,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',80,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',81,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',82,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',83,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',84,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',85,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',86,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',87,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',88,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',89,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',90,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',91,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',92,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',93,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-08-28 16:17:05.506',94,3); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',95,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',96,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',97,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',98,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',99,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',100,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',101,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',102,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',103,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',104,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',105,4); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-05 12:26:02.738',106,4); +-- +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',107,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',108,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',109,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',110,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',111,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',112,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',113,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',114,5); +--INSERT INTO public.sensor_item (create_date,item_id,sensor_id) VALUES ( +--'2017-09-11 12:26:02.738',115,5); + +INSERT INTO public.noauth_probe (api_key,create_date,description,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','{"host":{"name":"geek-ubuntu","os":"linux","paltform":"ubuntu","platformFamily":"debian","platformVersion":"","kernelVersion":"4.4.0-93-generic","hostID":"03000200-0400-0500-0006-000700080009"},"network":{"name":"enp3s0","address":"192.168.1.103/24|fe80::36c0:6c3e:6006:dd23/64","gateway":"192.168.1.254","macAddress":"44:8a:5b:f1:f1:f3"}}','1cf2555c57d511e79714080027658d13',1,NULL,3); + +INSERT INTO public.noauth_probe (api_key,create_date,description,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d14','2017-08-11 12:43:46.877','{"host":{"name":"insanity-ubuntu","os":"linux","paltform":"ubuntu","platformFamily":"debian","platformVersion":"","kernelVersion":"4.4.0-93-generic","hostID":"4C4C4544-0044-4A10-8039-C7C04F595031"},"network":{"name":"enp3s0","address":"192.168.1.105/24|fe80::36c0:6c3e:6006:dd23/64","gateway":"192.168.1.254","macAddress":"44:8a:5b:f1:f1:f3"}}','1cf2555c57d511e79714080027658d14',1,NULL,3); + +INSERT INTO public.noauth_probe (api_key,create_date,description,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d15','2017-08-11 12:43:46.877','{"host":{"name":"snoop-ubuntu","os":"linux","paltform":"ubuntu","platformFamily":"debian","platformVersion":"","kernelVersion":"4.4.0-93-generic","hostID":"DE60E4C3-347A-4D38-AEAB-1760471665EA"},"network":{"name":"enp3s0","address":"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64","gateway":"192.168.1.254","macAddress":"44:8a:5b:f1:f1:f3"}}','1cf2555c57d511e79714080027658d15',1,NULL,3); + + + + + + +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +1,'2017-08-24 18:33:25.427','Test History 0',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +2,'2017-08-24 18:33:25.472','Test History 1',1,1,1,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +3,'2017-08-24 18:33:25.493','Test History 2',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +4,'2017-08-24 18:33:25.518','Test History 3',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +5,'2017-08-24 18:33:25.543','Test History 4',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +6,'2017-08-24 18:33:25.563','Test History 5',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +7,'2017-08-24 18:33:25.582','Test History 6',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +8,'2017-08-24 18:33:25.601','Test History 7',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +9,'2017-08-24 18:33:25.621','Test History 8',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +10,'2017-08-24 18:33:25.641','Test History 9',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +11,'2017-08-24 18:33:25.660','Test History 10',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +12,'2017-08-24 18:33:25.674','Test History 11',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +13,'2017-08-24 18:33:25.687','Test History 12',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +14,'2017-08-24 18:33:25.701','Test History 13',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +15,'2017-08-24 18:33:25.714','Test History 14',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +16,'2017-08-24 18:33:25.731','Test History 15',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +17,'2017-08-24 18:33:25.747','Test History 16',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +18,'2017-08-24 18:33:25.762','Test History 17',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +19,'2017-08-24 18:33:25.778','Test History 18',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +20,'2017-08-24 18:33:25.793','Test History 19',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +21,'2017-08-24 18:33:25.808','Test History 20',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +22,'2017-08-24 18:33:25.823','Test History 21',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +23,'2017-08-24 18:33:25.839','Test History 22',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +24,'2017-08-24 18:33:25.854','Test History 23',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +25,'2017-08-24 18:33:25.873','Test History 24',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +26,'2017-08-24 18:33:25.888','Test History 25',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +27,'2017-08-24 18:33:25.902','Test History 26',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +28,'2017-08-24 18:33:25.917','Test History 27',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +29,'2017-08-24 18:33:25.929','Test History 28',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +30,'2017-08-24 18:33:25.942','Test History 29',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +31,'2017-08-24 18:33:25.954','Test History 30',1,1,2,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +32,'2017-08-24 18:33:25.968','Test History 31',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +33,'2017-08-24 18:33:25.981','Test History 32',1,1,1,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +34,'2017-08-24 18:33:25.994','Test History 33',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +35,'2017-08-24 18:33:26.007','Test History 34',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +36,'2017-08-24 18:33:26.021','Test History 35',1,1,2,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +37,'2017-08-24 18:33:26.033','Test History 36',1,1,2,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +38,'2017-08-24 18:33:26.045','Test History 37',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +39,'2017-08-24 18:33:26.059','Test History 38',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +40,'2017-08-24 18:33:26.072','Test History 39',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +41,'2017-08-24 18:33:26.084','Test History 40',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +42,'2017-08-24 18:33:26.097','Test History 41',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +43,'2017-08-24 18:33:26.111','Test History 42',1,1,2,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +44,'2017-08-24 18:33:26.123','Test History 43',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +45,'2017-08-24 18:33:26.135','Test History 44',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +46,'2017-08-24 18:33:26.148','Test History 45',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +47,'2017-08-24 18:33:26.160','Test History 46',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +48,'2017-08-24 18:33:26.173','Test History 47',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +49,'2017-08-24 18:33:26.190','Test History 48',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +50,'2017-08-24 18:33:26.204','Test History 49',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +51,'2017-08-24 18:33:26.219','Test History 50',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +52,'2017-08-24 18:33:26.239','Test History 51',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +53,'2017-08-24 18:33:26.261','Test History 52',1,1,1,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +54,'2017-08-24 18:33:26.560','Test History 53',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +55,'2017-08-24 18:33:26.583','Test History 54',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +56,'2017-08-24 18:33:26.600','Test History 55',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +57,'2017-08-24 18:33:26.617','Test History 56',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +58,'2017-08-24 18:33:26.632','Test History 57',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +59,'2017-08-24 18:33:26.646','Test History 58',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +60,'2017-08-24 18:33:26.661','Test History 59',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +61,'2017-08-24 18:33:26.676','Test History 60',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +62,'2017-08-24 18:33:26.692','Test History 61',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +63,'2017-08-24 18:33:26.708','Test History 62',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +64,'2017-08-24 18:33:26.722','Test History 63',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +65,'2017-08-24 18:33:26.734','Test History 64',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +66,'2017-08-24 18:33:26.747','Test History 65',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +67,'2017-08-24 18:33:26.758','Test History 66',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +68,'2017-08-24 18:33:26.771','Test History 67',1,1,1,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +69,'2017-08-24 18:33:26.784','Test History 68',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +70,'2017-08-24 18:33:26.798','Test History 69',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +71,'2017-08-24 18:33:26.813','Test History 70',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +72,'2017-08-24 18:33:26.834','Test History 71',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +73,'2017-08-24 18:33:26.846','Test History 72',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +74,'2017-08-24 18:33:26.859','Test History 73',1,1,1,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +75,'2017-08-24 18:33:26.873','Test History 74',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +76,'2017-08-24 18:33:26.889','Test History 75',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +77,'2017-08-24 18:33:26.905','Test History 76',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +78,'2017-08-24 18:33:26.921','Test History 77',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +79,'2017-08-24 18:33:26.935','Test History 78',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +80,'2017-08-24 18:33:26.948','Test History 79',1,1,2,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +81,'2017-08-24 18:33:26.961','Test History 80',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +82,'2017-08-24 18:33:26.974','Test History 81',1,1,1,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +83,'2017-08-24 18:33:26.987','Test History 82',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +84,'2017-08-24 18:33:27.000','Test History 83',1,1,1,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +85,'2017-08-24 18:33:27.013','Test History 84',1,1,1,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +86,'2017-08-24 18:33:27.025','Test History 85',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +87,'2017-08-24 18:33:27.038','Test History 86',1,1,1,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +88,'2017-08-24 18:33:27.052','Test History 87',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +89,'2017-08-24 18:33:27.064','Test History 88',1,1,2,3); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +90,'2017-08-24 18:33:27.076','Test History 89',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +91,'2017-08-24 18:33:27.090','Test History 90',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +92,'2017-08-24 18:33:27.106','Test History 91',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +93,'2017-08-24 18:33:27.120','Test History 92',1,1,1,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +94,'2017-08-24 18:33:27.134','Test History 93',1,1,1,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +95,'2017-08-24 18:33:27.149','Test History 94',1,1,1,4); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +96,'2017-08-24 18:33:27.164','Test History 95',1,1,2,6); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +97,'2017-08-24 18:33:27.177','Test History 96',1,1,2,2); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +98,'2017-08-24 18:33:27.191','Test History 97',1,1,1,1); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +99,'2017-08-24 18:33:27.204','Test History 98',1,1,2,5); +INSERT INTO public.history (id,create_date,message,domain_id,member_id,probe_id,type_id) VALUES ( +100,'2017-08-24 18:33:27.217','Test History 99',1,1,1,3); + + +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +1,'2017-08-29 16:39:16.198','2017-08-29 16:39:17.756','Message0','Title0',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +2,'2017-08-29 16:39:16.285','2017-08-29 16:39:17.789','Message1','Title1',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +3,'2017-08-29 16:39:16.306','2017-08-29 16:39:17.807','Message2','Title2',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +4,'2017-08-29 16:39:16.322','2017-08-29 16:39:17.822','Message3','Title3',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +5,'2017-08-29 16:39:16.336','2017-08-29 16:39:17.837','Message4','Title4',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +6,'2017-08-29 16:39:16.350','2017-08-29 16:39:17.852','Message5','Title5',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +7,'2017-08-29 16:39:16.365','2017-08-29 16:39:17.864','Message6','Title6',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +8,'2017-08-29 16:39:16.377','2017-08-29 16:39:17.877','Message7','Title7',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +9,'2017-08-29 16:39:16.391','2017-08-29 16:39:17.890','Message8','Title8',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +10,'2017-08-29 16:39:16.403','2017-08-29 16:39:17.904','Message9','Title9',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +11,'2017-08-29 16:39:16.417','2017-08-29 16:39:17.916','Message10','Title10',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +12,'2017-08-29 16:39:16.430','2017-08-29 16:39:17.929','Message11','Title11',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +13,'2017-08-29 16:39:16.442','2017-08-29 16:39:17.941','Message12','Title12',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +14,'2017-08-29 16:39:16.454','2017-08-29 16:39:17.953','Message13','Title13',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +15,'2017-08-29 16:39:16.467','2017-08-29 16:39:17.966','Message14','Title14',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +16,'2017-08-29 16:39:16.479','2017-08-29 16:39:17.979','Message15','Title15',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +17,'2017-08-29 16:39:16.493','2017-08-29 16:39:17.994','Message16','Title16',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +18,'2017-08-29 16:39:16.508','2017-08-29 16:39:18.008','Message17','Title17',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +19,'2017-08-29 16:39:16.522','2017-08-29 16:39:18.020','Message18','Title18',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +20,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.031','Message19','Title19',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +21,NULL,'2017-08-29 16:39:18.042','Message20','Title20',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +22,NULL,'2017-08-29 16:39:18.051','Message21','Title21',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +23,NULL,'2017-08-29 16:39:18.062','Message22','Title22',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +24,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.072','Message23','Title23',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +25,NULL,'2017-08-29 16:39:18.083','Message24','Title24',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +26,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.096','Message25','Title25',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +27,NULL,'2017-08-29 16:39:18.108','Message26','Title26',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +28,'2017-08-29 16:39:16.533','2017-08-29 16:39:18.118','Message27','Title27',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +29,NULL,'2017-08-29 16:39:18.130','Message28','Title28',1, '/metrics'); +INSERT INTO public.notification (id,confirm_date,create_date,message,title,member_id,url) VALUES ( +30,NULL,'2017-08-29 16:39:18.143','Message29','Title29',1, '/metrics'); + + +INSERT INTO public.auth_crawler (auth_json,create_date,crawler_id,target_id) VALUES ( +'{"Community":"public"}','2017-09-08 18:31:05.126',20,5); +INSERT INTO public.auth_crawler (auth_json,create_date,crawler_id,target_id) VALUES ( +'{"ID":"administrator","PassWord":"dbseogns18"}','2017-09-08 18:31:18.581',23,3); +INSERT INTO public.auth_crawler (auth_json,create_date,crawler_id,target_id) VALUES ( +'{"DB Name":"test","ID":"docker","PassWord":"qwer5795QWER"}','2017-09-08 18:31:37.206',11,4); +INSERT INTO public.auth_crawler (auth_json,create_date,crawler_id,target_id) VALUES ( +'{"ID":"jmxxuser","PassWord":"tomcat"}','2017-09-12 15:11:47.875',17,4); \ No newline at end of file diff --git a/src/main/resources/local/mail.properties b/src/main/resources/local/mail.properties new file mode 100644 index 0000000..99f696d --- /dev/null +++ b/src/main/resources/local/mail.properties @@ -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=* + + diff --git a/src/main/resources/local/redis.properties b/src/main/resources/local/redis.properties new file mode 100644 index 0000000..26fc4d8 --- /dev/null +++ b/src/main/resources/local/redis.properties @@ -0,0 +1,4 @@ +# Redis +redis.host=192.168.1.50 +redis.port=6379 +redis.channels=/webapp,/probe,/auth \ No newline at end of file diff --git a/src/main/resources/local/velocity.properties b/src/main/resources/local/velocity.properties new file mode 100644 index 0000000..c298824 --- /dev/null +++ b/src/main/resources/local/velocity.properties @@ -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 \ No newline at end of file diff --git a/src/main/resources/signup_email.vm b/src/main/resources/signup_email.vm new file mode 100644 index 0000000..ac6dcf3 --- /dev/null +++ b/src/main/resources/signup_email.vm @@ -0,0 +1,13 @@ + + + + + +

Dear ${firstName} ${lastName},

+

Sending Email Velocity Template Test !!!

+

Thanks

+

${signature}

+

${location}

+ + + \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/CentralTest.java b/src/test/java/com/loafle/overflow/CentralTest.java new file mode 100644 index 0000000..5be4267 --- /dev/null +++ b/src/test/java/com/loafle/overflow/CentralTest.java @@ -0,0 +1,14 @@ + +package com.loafle.overflow; +import static org.junit.Assert.*; + +import org.junit.Ignore; +import org.junit.Test; + +@Ignore +public class CentralTest { + @Test + public void testSum() { + fail("Not yet implemented"); + } +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/commons/utils/EmailSenderTest.java b/src/test/java/com/loafle/overflow/central/commons/utils/EmailSenderTest.java new file mode 100644 index 0000000..3d77ca7 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/commons/utils/EmailSenderTest.java @@ -0,0 +1,43 @@ +package com.loafle.overflow.central.commons.utils; + +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.net.URLDecoder; +import java.net.URLEncoder; + +import static org.junit.Assert.*; + +/** + * Created by geek on 17. 9. 5. + */ +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class EmailSenderTest { + + @Autowired + private EmailSender emailSender; + + @Test + public void encrypt() throws Exception { + // dZQgXM1o/Cx48X8DM+6ec/oPfqA2l/LdWtijOZ2EnWk= + String en = this.emailSender.encrypt("geekdev@naver.com"); + String encode = URLEncoder.encode(en, "UTF-8"); + Assert.assertEquals(encode , "dZQgXM1o%2FCx48X8DM%2B6ec%2FoPfqA2l%2FLdWtijOZ2EnWk%3D"); + } + + @Test + public void decrypt() throws Exception { + String decode = URLDecoder.decode("dZQgXM1o%2FCx48X8DM%2B6ec%2FoPfqA2l%2FLdWtijOZ2EnWk%3D", "UTF-8"); + String dn = this.emailSender.decrypt(decode); + Assert.assertEquals(dn , "geekdev@naver.com"); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/commons/utils/StringConvertorTest.java b/src/test/java/com/loafle/overflow/central/commons/utils/StringConvertorTest.java new file mode 100644 index 0000000..82f0d06 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/commons/utils/StringConvertorTest.java @@ -0,0 +1,17 @@ +package com.loafle.overflow.central.commons.utils; + +import org.junit.Test; + +/** + * Created by snoop on 17. 8. 23. + */ +public class StringConvertorTest { + @Test + public void intToIp() throws Exception { + + String ipStr = StringConvertor.intToIp(3232235797L); + + System.out.println(ipStr); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/apikey/service/ApiKeyServiceTest.java b/src/test/java/com/loafle/overflow/central/module/apikey/service/ApiKeyServiceTest.java new file mode 100644 index 0000000..36cbc88 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/apikey/service/ApiKeyServiceTest.java @@ -0,0 +1,81 @@ +package com.loafle.overflow.central.module.apikey.service; + +import com.google.protobuf.Api; +import com.loafle.overflow.central.module.apikey.model.ApiKey; +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class ApiKeyServiceTest { + + @Autowired + private ApiKeyService apiKeyService; + + @Ignore + @Test + public void regist() throws Exception { + + ApiKey apiKey = new ApiKey(); + + apiKey.setApiKey("70124b775bd511e7b059080027658d13"); + + Domain domain = new Domain(); + domain.setId(1); + + apiKey.setDomain(domain); + + this.apiKeyService.regist(apiKey); + + + Assert.assertNotEquals(apiKey.getId(), 0); + } + + @Ignore + @Test + public void check() throws Exception { + +// ApiKey apiKey = this.apiKeyDAO.findByApiKey("52abd6fd57e511e7ac52080027658d13"); + + regist(); + + boolean result= this.apiKeyService.check("70124b775bd511e7b059080027658d13"); + + Assert.assertNotEquals(result, false); + } + + @Ignore + @Test + public void findByDomain() { + + Domain domain = new Domain(); + domain.setId(1); + + ApiKey apiKey = this.apiKeyService.readByDomain(domain); + + Assert.assertNotEquals(apiKey, null); + + } + + @Test + public void readByApiKey() { + + ApiKey apiKey = this.apiKeyService.readByApiKey("52abd6fd57e511e7ac52080027658d13"); + + Assert.assertNotEquals(apiKey, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerServiceTest.java b/src/test/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerServiceTest.java new file mode 100644 index 0000000..0a4919e --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/auth/service/AuthCrawlerServiceTest.java @@ -0,0 +1,65 @@ +package com.loafle.overflow.central.module.auth.service; + +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 com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 8. 30. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class AuthCrawlerServiceTest { + + @Autowired + private AuthCrawlerService authCrawlerService; + + @Test + public void regist() throws Exception { + + AuthCrawler authCrawler = new AuthCrawler(); + + Target target = new Target(); + target.setId(4); + + authCrawler.setTarget(target); + + + MetaCrawler metaCrawler = new MetaCrawler(); + metaCrawler.setId((short)11); + + authCrawler.setCrawler(metaCrawler); + + authCrawler.setAuthJson("{\"DB Name\":\"test\",\"ID\":\"docker\",\"PassWord\":\"qwer5795QWER\"}"); + + + this.authCrawlerService.regist(authCrawler); + + Assert.assertNotEquals(authCrawler.getId(), 0); + + } + + @Test + public void findAuth() { + + MetaCrawler metaCrawler = new MetaCrawler(); + metaCrawler.setId((short)23); + + Target target = new Target(); + target.setId(5); + + + AuthCrawler authCrawler = this.authCrawlerService.readAuth(metaCrawler, target); + + Assert.assertNotEquals(authCrawler, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/domain/service/DomainMemberServiceTest.java b/src/test/java/com/loafle/overflow/central/module/domain/service/DomainMemberServiceTest.java new file mode 100644 index 0000000..fdfc54d --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/domain/service/DomainMemberServiceTest.java @@ -0,0 +1,66 @@ +package com.loafle.overflow.central.module.domain.service; + +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 com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class DomainMemberServiceTest { + + @Autowired + private DomainMemberService domainMemberService; + + @Ignore + @Test + public void regist() throws Exception { + + DomainMember domainMember = new DomainMember(); + + Domain domain = new Domain(); + domain.setId(1); + + Member member = new Member(); + member.setId(1); + + domainMember.setDomain(domain); + domainMember.setMember(member); + + this.domainMemberService.regist(domainMember); + + Assert.assertNotEquals(domainMember.getId(), 0); + + } + + @Test + public void readAllMemberByDomain() { + + Domain domain = new Domain(); + domain.setId(1); + + List members = this.domainMemberService.readAllMemberByDomain(domain); + + Assert.assertNotEquals(members.size(), 0); + + for(Member member : members) { + System.out.println(member.getEmail()); + } + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/domain/service/DomainServiceTest.java b/src/test/java/com/loafle/overflow/central/module/domain/service/DomainServiceTest.java new file mode 100644 index 0000000..f15944e --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/domain/service/DomainServiceTest.java @@ -0,0 +1,38 @@ +package com.loafle.overflow.central.module.domain.service; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class DomainServiceTest { + + @Autowired + private DomainService domainService; + + @Ignore + @Test + public void regist() throws Exception { + + Domain domain = new Domain(); + + domain.setName("overFlow's domain22"); + + this.domainService.regist(domain); + + Assert.assertNotEquals(domain.getId(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/email/service/EmailAuthServiceTest.java b/src/test/java/com/loafle/overflow/central/module/email/service/EmailAuthServiceTest.java new file mode 100644 index 0000000..2e8561c --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/email/service/EmailAuthServiceTest.java @@ -0,0 +1,54 @@ +package com.loafle.overflow.central.module.email.service; + +import com.loafle.overflow.central.module.email.model.EmailAuth; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Calendar; +import java.util.Date; + +/** + * Created by geek on 17. 6. 28. + */ + +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class EmailAuthServiceTest { + + @Autowired + EmailAuthService emailAuthService; + + @Test + @Ignore + public void TestMailSend() throws Exception { + this.emailAuthService.sendEmailByMember((long)1, "geek@loafle.com"); + } + + @Test + public void TestCompareDate() throws Exception { + + Calendar cal = Calendar.getInstance(); + EmailAuth auth = emailAuthService.read(1); + + cal.setTime(auth.getCreateDate()); + cal.add(Calendar.HOUR, 12); + Date futureDate = cal.getTime(); + + Date nowDate = new Date(); + + if (nowDate.before(futureDate)) { + System.out.println("futureDate = " + futureDate); + }else{ + System.out.println("nowDate = " + nowDate); + } +// int dd = nowDate.compareTo(auth.getCreateDate()); +// System.out.println("dd = " + dd); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/history/service/HistoryServiceTest.java b/src/test/java/com/loafle/overflow/central/module/history/service/HistoryServiceTest.java new file mode 100644 index 0000000..e59116c --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/history/service/HistoryServiceTest.java @@ -0,0 +1,75 @@ +package com.loafle.overflow.central.module.history.service; + +import com.loafle.overflow.central.commons.model.PageParams; +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.history.model.History; +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 com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Random; + +/** + * Created by insanity on 17. 8. 23. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class HistoryServiceTest { + + @Autowired + private HistoryService historyService; + + @Test + @Ignore + public void registHistories() { + Random rand = new Random(); + for (int i=0;i<100;i++) { + History h = new History(); + h.setMember(new Member(1)); + h.setProbe(new Probe(rand.nextBoolean() ? 1 : 2)); + h.setDomain(new Domain(1)); + h.setType(new MetaHistoryType(rand.nextInt((6 - 1) + 1) + 1)); + h.setMessage("Test History " + i); + this.historyService.regist(h); + } + } + + +// @Test +// @Ignore +// public void readAllByProbeAndType() { +// List result = this.historyService.readAllByProbeAndType(new Probe(1), new MetaHistoryType(1)); +// Assert.assertNotNull(result); +// } + + @Test + public void readAllByProbe() { + PageParams p = new PageParams(); + p.setPageNo(0); + p.setCountPerPage(10); + p.setSortCol("type.name"); + p.setSortDirection("descending"); + + Page result = this.historyService.readAllByProbe(new Probe(1), p); + for (History h : result.getContent()) { + System.out.println(h.getId()); + } + Assert.assertEquals(10, result.getContent().size()); + } + +// @Test +// @Ignore +// public void readAllByDomain() { +// Page result = this.historyService.readAllByDomain(new Domain(1), 0, 10); +// Assert.assertNotNull(result.getContent()); +// } +} diff --git a/src/test/java/com/loafle/overflow/central/module/infra/dao/InfraDAOTest.java b/src/test/java/com/loafle/overflow/central/module/infra/dao/InfraDAOTest.java new file mode 100644 index 0000000..a4bdbba --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/dao/InfraDAOTest.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.central.module.infra.dao; + +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by snoop on 17. 9. 14. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraDAOTest { + + @Autowired + private InfraDAO infraDAO; + + @Test + public void findAllByProbeList() throws Exception { + + List probes = new ArrayList<>(); + + Probe probe = new Probe(); + probe.setId(1); + + probes.add(probe); + + + this.infraDAO.findAllTargetByProbeList(probes); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraHostServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraHostServiceTest.java new file mode 100644 index 0000000..3a01846 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraHostServiceTest.java @@ -0,0 +1,72 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraHost; +import com.loafle.overflow.central.module.infra.model.InfraOS; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraHostServiceTest { + + @Autowired + private InfraHostService infraHostService; + + @Test +// @Ignore + public void regist() throws Exception { + + InfraHost infraHost = new InfraHost(); + + infraHost.setMac(8796753988883L); + infraHost.setIp(3232235980L); + + InfraOS infraOS = new InfraOS(); + infraOS.setId(2); + + infraHost.setOs(infraOS); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(2); + + + + this.infraHostService.regist(infraHost); + + Assert.assertNotEquals(infraHost.getId(), 0 ); + + } + + @Test + public void read() throws Exception { + + InfraHost infraHost = this.infraHostService.read(1); + + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infraHost); + + System.out.println(json); + + } + + @Test + public void readByIp() { + + InfraHost infraHost = this.infraHostService.readByIp(3232235980L); + + Assert.assertNotEquals(infraHost, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraMachineServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraMachineServiceTest.java new file mode 100644 index 0000000..ee57c1e --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraMachineServiceTest.java @@ -0,0 +1,55 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraMachine; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraMachineServiceTest { + + @Autowired + private InfraMachineService infraMachineService; + +// @Ignore + @Test + public void regist() throws Exception { + + InfraMachine infraMachine = new InfraMachine(); + + infraMachine.setMeta("i am a infra machine"); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(1); + + + this.infraMachineService.regist(infraMachine); + + Assert.assertNotEquals(infraMachine.getId(), 0); + + } + + @Test + public void read() throws Exception { + +// regist(); + + InfraMachine infraMachine = this.infraMachineService.read(1); + + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infraMachine); + System.out.println(json); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationServiceTest.java new file mode 100644 index 0000000..22fa85f --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSApplicationServiceTest.java @@ -0,0 +1,61 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraOS; +import com.loafle.overflow.central.module.infra.model.InfraOSApplication; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraOSApplicationServiceTest { + + @Autowired + private InfraOSApplicationService infraOSApplicationService; + +// @Ignore + @Test + public void regist() throws Exception { + InfraOSApplication infraOSApplication = new InfraOSApplication(); + + infraOSApplication.setName("Apache"); + + InfraOS infraOS = new InfraOS(); + infraOS.setId(2); + + infraOSApplication.setOs(infraOS); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(4); + + this.infraOSApplicationService.regist(infraOSApplication); + + + Assert.assertNotEquals(infraOSApplication.getId(), 0); + + } + + @Test + public void read() throws Exception { + + InfraOSApplication infraOSApplication = this.infraOSApplicationService.read(1); + + Assert.assertNotNull(infraOSApplication); + + ObjectMapper objectMapper = new ObjectMapper(); + + String json = objectMapper.writeValueAsString(infraOSApplication); + System.out.println(json); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonServiceTest.java new file mode 100644 index 0000000..6b00732 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSDaemonServiceTest.java @@ -0,0 +1,59 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraOS; +import com.loafle.overflow.central.module.infra.model.InfraOSDaemon; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraOSDaemonServiceTest { + + @Autowired + private InfraOSDaemonService infraOSDaemonService; + +// @Ignore + @Test + public void regist() throws Exception { + + InfraOSDaemon infraOSDaemon = new InfraOSDaemon(); + infraOSDaemon.setName("Apache"); + + InfraOS infraOS = new InfraOS(); + infraOS.setId(2); + + infraOSDaemon.setOs(infraOS); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(5); + + + this.infraOSDaemonService.regist(infraOSDaemon); + + Assert.assertNotEquals(infraOSDaemon.getId(), 0); + + } + + @Test + public void read() throws Exception { + + InfraOSDaemon infraOSDaemon = this.infraOSDaemonService.read(1); + Assert.assertNotNull(infraOSDaemon); + + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infraOSDaemon); + System.out.println(json); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSPortServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSPortServiceTest.java new file mode 100644 index 0000000..5ca12e9 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSPortServiceTest.java @@ -0,0 +1,58 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraOS; +import com.loafle.overflow.central.module.infra.model.InfraOSPort; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraOSPortServiceTest { + + @Autowired + private InfraOSPortService infraOSPortService; + +// @Ignore + @Test + public void regist() throws Exception { + + InfraOSPort infraOSPort = new InfraOSPort(); + infraOSPort.setTlsType(false); + infraOSPort.setPortType("TCP"); + + InfraOS infraOS = new InfraOS(); + infraOS.setId(1); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(2); + + + infraOSPort.setOs(infraOS); + + // FIXME::vendor??? + + } + + @Test + public void read() throws Exception { + } + + @Test + public void readByPort() { + + InfraOSPort infraOSPort = this.infraOSPortService.readByPort(1, 22, "TCP"); + + Assert.assertNotEquals(infraOSPort, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSServiceTest.java new file mode 100644 index 0000000..a968b2c --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraOSServiceTest.java @@ -0,0 +1,59 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.infra.model.InfraMachine; +import com.loafle.overflow.central.module.infra.model.InfraOS; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraOSServiceTest { + + @Autowired + private InfraOSService infraOSService; + + @Test +// @Ignore + public void registOS() throws Exception { + + InfraOS infraOS = new InfraOS(); + + MetaInfraVendor metaInfraVendor = new MetaInfraVendor(); + metaInfraVendor.setId(26); + + infraOS.setVendor(metaInfraVendor); + infraOS.setMeta(""); + + InfraMachine infraMachine = new InfraMachine(); + infraMachine.setId(1); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(3); + + infraOS.setMachine(infraMachine); + + + + this.infraOSService.regist(infraOS); + } + + @Test + public void read() throws Exception { + + InfraOS infraOS = this.infraOSService.read(1); + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infraOS); + System.out.println(json); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceServiceTest.java new file mode 100644 index 0000000..66e7307 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceServiceTest.java @@ -0,0 +1,68 @@ +package com.loafle.overflow.central.module.infra.service; + + +import com.loafle.overflow.central.module.infra.model.InfraHost; +import com.loafle.overflow.central.module.infra.model.InfraService; +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraServiceServiceTest { + + @Autowired + private InfraServiceService infraServiceService; + +// @Ignore + @Test + public void regist() throws Exception { + + InfraService infraService = new InfraService(); + + infraService.setPort(80); + infraService.setPortType("TCP"); + + InfraHost infraHost = new InfraHost(); + infraHost.setId(3); + + infraService.setHost(infraHost); + infraService.setTlsType(false); + + MetaInfraVendor metaInfraVendor = new MetaInfraVendor(); + metaInfraVendor.setId(45); + + infraService.setVendor(metaInfraVendor); + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(7); + + + this.infraServiceService.regist(infraService); + + Assert.assertNotEquals(infraService.getId(), 0); + } + + @Test + public void read() throws Exception { + } + + + @Test + public void readByService() { + + InfraService infraService = this.infraServiceService.readByService(3, 80, "TCP"); + + Assert.assertNotEquals(infraService, null); + + } +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceTest.java b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceTest.java new file mode 100644 index 0000000..8414e4e --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/infra/service/InfraServiceTest.java @@ -0,0 +1,107 @@ +package com.loafle.overflow.central.module.infra.service; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.infra.model.Infra; +import com.loafle.overflow.central.module.probe.service.ProbeService; +import com.loafle.overflow.central.module.target.model.Target; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.IOException; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class InfraServiceTest { + + @Autowired + private InfraService infraService; + + @Autowired + private ProbeService probeService; + + @Autowired + private InfraMachineService infraMachineService; + + + + @Test + public void tttt() { + + } + + + @Test + public void read() throws Exception { + +// registInfraMachine(); + + Infra infra = this.infraService.read(1); + + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infra); + + System.out.println(json); + } + +// @Test +// public void readAllProbe() throws IOException { +// +// Probe probe = new Probe(); +// probe.setId(1); +// +// List infraList = this.infraService.readAllByProbe(probe); +// +// ObjectMapper objectMapper = new ObjectMapper(); +// String json = objectMapper.writeValueAsString(infraList); +// +// System.out.println(json); +// +// } + + @Test + public void readAllTarget() { + Domain domain = new Domain(); + domain.setId(1); + +// this.infraService.readAllTargetByProbeList() + } + + @Test + public void readByTarget() throws IOException { + Target target = new Target(); + target.setId(1); + + Infra infra = this.infraService.readByTarget(target); + + ObjectMapper objectMapper = new ObjectMapper(); + String json = objectMapper.writeValueAsString(infra); + + System.out.println(json); + } + +// @Test +// public void readAllByProbeList() throws IOException { +// +// Domain domain = new Domain(); +// domain.setId(1); +// +// +// List fl = this.infraService.readAllByDomain(domain); +// +// System.out.println(fl.size()); +// ObjectMapper objectMapper = new ObjectMapper(); +// String json = objectMapper.writeValueAsString(fl); +// +// System.out.println(json); +// +// } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/member/dao/MemberDAOTest.java b/src/test/java/com/loafle/overflow/central/module/member/dao/MemberDAOTest.java new file mode 100644 index 0000000..09385b7 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/member/dao/MemberDAOTest.java @@ -0,0 +1,56 @@ +package com.loafle.overflow.central.module.member.dao; + +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import com.loafle.overflow.central.spring.*; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by geek on 17. 6. 28. + */ + +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MemberDAOTest { + + @Autowired + private MemberDAO repo; + +// @Ignore + @Test + public void createMember() { + Member m = new Member(); + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + m.setName("insanity2"); + m.setCompanyName("loafle"); + m.setPw(passwordEncoder.encode("!@#$qwer1234")); +// m.setPw("!@#$qwer1234"); + m.setPhone("000-000-0000"); + m.setEmail("geekhot@hotmail.co.kr"); + m.setStatus(new MetaMemberStatus((short)1)); + + repo.save(m); + Assert.assertNotEquals(m.getId(), 0); + } + + @Test + public void findByEmail() throws Exception { + Member member = new Member(1); + member.setEmail("overflow@loafle.com"); + + Member rr = repo.findByEmail("overflow@loafle.com"); + Assert.assertNotNull(rr); +// System.out.println("rr.getCompanyName() = " + rr.getCompanyName()); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAOTest.java b/src/test/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAOTest.java new file mode 100644 index 0000000..097aa8c --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/member/dao/MemberTotpDAOTest.java @@ -0,0 +1,50 @@ +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 com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.*; + +/** + * Created by geek on 18. 3. 9. + */ +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MemberTotpDAOTest { + + @Autowired + private MemberTotpDAO dao; + + @Test + public void insertTest() throws Exception { + MemberTotp totp = new MemberTotp(); + totp.setSecretCode("AI6EWOYSZWEBAI2D"); + totp.setMember(new Member(2)); + this.dao.save(totp); + } + @Test + public void findBySecretCode() throws Exception { + } + + @Test + public void findByMember() throws Exception { + MemberTotp totp = new MemberTotp(); + totp.setSecretCode("EDPBZLDATGZP7NX2"); + totp.setMember(new Member(2)); + this.dao.save(totp); + + MemberTotp totp1 = this.dao.findByMember(totp.getMember()); + + assertNotNull(totp1); + } +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java new file mode 100644 index 0000000..3d12b64 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/member/service/MemberServiceTest.java @@ -0,0 +1,120 @@ +package com.loafle.overflow.central.module.member.service; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.member.model.MemberTotp; +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Created by insanity on 17. 6. 28. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MemberServiceTest { + @Autowired + MemberService memberService; + + @Autowired + MemberTotpService totpService; + + + @Test + public void regist() throws Exception { + Member m = new Member(); + m.setPw("!@#$qwer1234"); + m.setStatus(new MetaMemberStatus((short)1)); + m.setCreateDate(new Date()); + m.setCompanyName("Loafle"); + m.setEmail("geekhot@hotmail.co.kr"); + m.setName("administrator"); + m.setPhone("00000000"); + + Member res = this.memberService.signup(m,"!@#$qwer1234"); + Assert.assertNotNull(res); + } + + @Test + public void signin() throws Exception { +// Member m = this.memberService.signin("overflow@loafle.com", "!@#$qwer1234"); +// Assert.assertNotNull(m); + } + + @Test + public void readAllMemberByProbeKey() { + + List members = this.memberService.readAllByProbeKey("95d8bcdc739741dca74c4a0e489e0774"); + + Assert.assertNotEquals(members.size(), 0); + + } + + @Test + public void readAllMemberByApiKey() { + + List members = this.memberService.readAllByApiKey("52abd6fd57e511e7ac52080027658d13"); + + Assert.assertNotEquals(members.size(), 0); + } + + @Test + public void readAllMemberByDomain() { + + Domain domain = new Domain(); + + domain.setId(1); + + List members = this.memberService.readAllByDomain(domain); + + Assert.assertNotEquals(members.size(), 0); + + } + + @Test + public void TestPasswordStrong() { + + String arrpw[] = new String[]{"!@#$Qwer1234", "Zxasqw12!!","@Cosmos@5795"}; +// String pass = "!@#$Qwer1234"; + + boolean check = false; + for (int i = 0; i < arrpw.length; i++) { + check = this.memberService.isPasswordStrong(arrpw[i]); +// System.out.println("check = " + check); + Assert.assertTrue(check); + } + } + +// +// String regex = "(" + +// "(?=.*[a-z])" + +// "(?=.*\\d)" + +// "(?=.*[A-Z])" + +// "(?=.*[!@#$%^&*()_+\\-=\\[\\]{};':\"\\\\|,.<>\\/?])" + +// "." + +// "{6,40}" + +// ")"; + +// @Test +// public void TestPassword() { +// Pattern pattern = Pattern.compile(regex); +// Matcher matcher = pattern.matcher("qwe1231@Q\\"); +// System.out.println("Length"+"qwe1231@Q\\".length()); +// +// System.out.println("matcher.matches() = " + matcher.matches()); +// } +} diff --git a/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java b/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java new file mode 100644 index 0000000..840d6a9 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/member/service/MemberTotpServiceTest.java @@ -0,0 +1,68 @@ +package com.loafle.overflow.central.module.member.service; + +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.member.model.MemberTotp; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Map; + +import static org.junit.Assert.*; + +/** + * Created by geek on 18. 3. 9. + */ +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MemberTotpServiceTest { + + @Autowired + private MemberTotpService totpService; + + @Test + public void regist() throws Exception { + } + + @Test + public void modify() throws Exception { + } + + @Test + public void remove() throws Exception { + } + + @Test + public void read() throws Exception { + } + + @Test + public void checkCode() throws Exception { + MemberTotp totp = new MemberTotp(); + totp.setSecretCode("PN44SRPS5QCGCJNS"); + + boolean isCheck = this.totpService.checkCode("PN44SRPS5QCGCJNS", "125073"); + + System.out.println(isCheck); + + } + + @Test + public void createTotp() throws Exception { + + Member m = new Member(2); + m.setEmail("geekdev@naver.com"); + Map totp = this.totpService.createTotp(m ); + + System.out.println(totp.get("key")); + System.out.println(totp.get("uri")); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemServiceTest.java new file mode 100644 index 0000000..8d7af39 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerInputItemServiceTest.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaCrawlerInputItem; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaCrawlerInputItemServiceTest { + + @Autowired + private MetaCrawlerInputItemService crawlerInputItemService; + + @Test + public void readAllByMetaCrawler() throws Exception { + + MetaCrawler metaCrawler = new MetaCrawler(); + metaCrawler.setId((short)1); + + List crawlerInputItems = this.crawlerInputItemService.readAllByMetaCrawler(metaCrawler); + + Assert.assertNotEquals(crawlerInputItems.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerServiceTest.java new file mode 100644 index 0000000..5057b6a --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaCrawlerServiceTest.java @@ -0,0 +1,36 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaCrawlerServiceTest { + + @Autowired + private MetaCrawlerService service; + + @Test + public void readAll() throws Exception { + List metaCrawlerServices = this.service.readAll(); + + Assert.assertNotEquals(metaCrawlerServices.size(), 0); + + + System.out.println(metaCrawlerServices.size()); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeServiceTest.java new file mode 100644 index 0000000..397fafa --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaHistoryTypeServiceTest.java @@ -0,0 +1,74 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaHistoryType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +@Ignore +public class MetaHistoryTypeServiceTest { + + @Autowired + private MetaHistoryTypeService historyTypeService; + + @Test + public void readAll() throws Exception { + List historyTypes = this.historyTypeService.readAll(); + Assert.assertNotNull(historyTypes); + } + + @Test + public void save() throws Exception { + List list = new ArrayList<>(); + + MetaHistoryType t1 = new MetaHistoryType(); + t1.setId(1); + t1.setName("Member"); + + MetaHistoryType t2 = new MetaHistoryType(); + t2.setId(2); + t2.setName("Probe"); + + MetaHistoryType t3 = new MetaHistoryType(); + t3.setId(3); + t3.setName("Discovery"); + + MetaHistoryType t4 = new MetaHistoryType(); + t4.setId(4); + t4.setName("Target"); + + MetaHistoryType t5 = new MetaHistoryType(); + t5.setId(5); + t5.setName("Crawler"); + + MetaHistoryType t6 = new MetaHistoryType(); + t6.setId(6); + t6.setName("Sensor"); + + //todo: need more + + list.add(t1); + list.add(t2); + list.add(t3); + list.add(t4); + list.add(t5); + list.add(t6); + + List result = this.historyTypeService.registAll(list); + Assert.assertEquals(result.size(), list.size()); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeServiceTest.java new file mode 100644 index 0000000..076294e --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraTypeServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +@Ignore +public class MetaInfraTypeServiceTest { + + @Autowired + private MetaInfraTypeService infraTypeService; + + @Test + public void readAll() throws Exception { + + List metaInfraTypes = this.infraTypeService.readAll(); + + Assert.assertNotEquals(metaInfraTypes.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorServiceTest.java new file mode 100644 index 0000000..da06188 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInfraVendorServiceTest.java @@ -0,0 +1,38 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaInfraType; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaInfraVendorServiceTest { + + @Autowired + private MetaInfraVendorService infraVendorService; + + @Test + public void readAllByMetaInfraType() throws Exception { + + MetaInfraType metaInfraType = new MetaInfraType(); + metaInfraType.setId(1); + + List infraVendors = this.infraVendorService.readAllByMetaInfraType(metaInfraType); + + Assert.assertNotEquals(infraVendors.size(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeServiceTest.java new file mode 100644 index 0000000..a874846 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaInputTypeServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaInputType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaInputTypeServiceTest { + + @Autowired + private MetaInputTypeService inputTypeService; + + @Test + public void readAll() throws Exception { + + List inputTypes = this.inputTypeService.readAll(); + + Assert.assertNotEquals(inputTypes.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusServiceTest.java new file mode 100644 index 0000000..e6549f3 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaMemberStatusServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaMemberStatus; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaMemberStatusServiceTest { + + @Autowired + private MetaMemberStatusService memberStatusService; + + @Test + public void readAll() throws Exception { + + List memberStatuses = this.memberStatusService.readAll(); + + Assert.assertNotEquals(memberStatuses.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusServiceTest.java new file mode 100644 index 0000000..2bee954 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaNoAuthProbeStatusServiceTest.java @@ -0,0 +1,33 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaNoAuthProbeStatusServiceTest { + + @Autowired + private MetaNoAuthProbeStatusService noAuthProbeStatusService; + + @Test + public void readAll() throws Exception { + List metaNoAuthProbeStatuses = this.noAuthProbeStatusService.readAll(); + + Assert.assertNotEquals(metaNoAuthProbeStatuses.size(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureServiceTest.java new file mode 100644 index 0000000..df95651 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeArchitectureServiceTest.java @@ -0,0 +1,34 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeArchitecture; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbeArchitectureServiceTest { + + @Autowired + private MetaProbeArchitectureService probeArchitectureService; + + @Test + public void readAll() throws Exception { + + List probeArchitectures = this.probeArchitectureService.readAll(); + + Assert.assertNotEquals(probeArchitectures.size(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsServiceTest.java new file mode 100644 index 0000000..94bae79 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeOsServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbeOsServiceTest { + + @Autowired + private MetaProbeOsService probeOsService; + + @Test + public void readAll() throws Exception { + + List metaProbeOs = this.probeOsService.readAll(); + + Assert.assertNotEquals(metaProbeOs.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageServiceTest.java new file mode 100644 index 0000000..99a62a6 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbePackageServiceTest.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeOs; +import com.loafle.overflow.central.module.meta.model.MetaProbePackage; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbePackageServiceTest { + + @Autowired + private MetaProbePackageService probePackageService; + + @Test + public void readAllByOs() throws Exception { + + MetaProbeOs metaProbeOs = new MetaProbeOs(); + metaProbeOs.setId((short)1); + + List metaProbePackages = this.probePackageService.readAllByOs(metaProbeOs); + + Assert.assertNotEquals(metaProbePackages.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusServiceTest.java new file mode 100644 index 0000000..7508a85 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeStatusServiceTest.java @@ -0,0 +1,34 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeStatus; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbeStatusServiceTest { + + @Autowired + private MetaProbeStatusService probeStatusService; + + @Test + public void readAll() throws Exception { + + List metaProbeStatuses = this.probeStatusService.readAll(); + + Assert.assertNotEquals(metaProbeStatuses.size(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeServiceTest.java new file mode 100644 index 0000000..1a4a716 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeTaskTypeServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbeTaskTypeServiceTest { + + @Autowired + private MetaProbeTaskTypeService probeTaskTypeService; + + @Test + public void readAll() throws Exception { + + List probeTaskTypes = this.probeTaskTypeService.readAll(); + + Assert.assertNotEquals(probeTaskTypes.size(), 0 ); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionServiceTest.java new file mode 100644 index 0000000..0632222 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaProbeVersionServiceTest.java @@ -0,0 +1,36 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeVersion; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaProbeVersionServiceTest { + + @Autowired + private MetaProbeVersionService probeVersionService; + + @Test + public void readAll() throws Exception { + + List probeVersionList = this.probeVersionService.readAll(); + + Assert.assertNotEquals(probeVersionList.size(), 0); + + } + + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemServiceTest.java new file mode 100644 index 0000000..a2c422d --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayItemServiceTest.java @@ -0,0 +1,39 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemUnit; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; + +/** + * Created by insanity on 17. 11. 7. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorDisplayItemServiceTest { + @Autowired + MetaSensorDisplayItemService service; + + @Test + @Ignore + public void regist() throws Exception { + MetaSensorDisplayItem cpuTotal = new MetaSensorDisplayItem(); + cpuTotal.setId(120); + cpuTotal.setCrawler(new MetaCrawler((short)21)); + cpuTotal.setCreateDate(new Date()); + cpuTotal.setKey("CPU_TOTAL"); + cpuTotal.setDisplayName("CPU Total Usage (%)"); + cpuTotal.setDescription(""); + cpuTotal.setUnit(new MetaSensorItemUnit((short)1)); + service.regist(cpuTotal); + } +} diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingServiceTest.java new file mode 100644 index 0000000..febc2aa --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorDisplayMappingServiceTest.java @@ -0,0 +1,32 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by insanity on 17. 11. 7. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorDisplayMappingServiceTest { + + @Autowired + MetaSensorDisplayMappingService service; + + + @Test + public void read() { + List list = this.service.findAllByDisplayItem(new MetaSensorDisplayItem(1)); + Assert.assertNotNull(list); + } +} diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyServiceTest.java new file mode 100644 index 0000000..a4fcc1d --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemKeyServiceTest.java @@ -0,0 +1,37 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorItemKey; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Map; + +/** + * Created by snoop on 17. 8. 29. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorItemKeyServiceTest { + + @Autowired + private MetaSensorItemKeyService metaSensorItemKeyService; + + + @Test + public void readAllByCrawler() { + MetaCrawler metaCrawler = new MetaCrawler(); + metaCrawler.setId((short)11); + + Map resultMap = this.metaSensorItemKeyService.readAllMapByCrawler(metaCrawler); + + Assert.assertNotEquals(resultMap.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemServiceTest.java new file mode 100644 index 0000000..09e03e0 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemServiceTest.java @@ -0,0 +1,34 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItem; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorItemServiceTest { + + @Autowired + private MetaSensorItemService metaSensorItemService; + + @Test + public void readAll() throws Exception { + + List metaSensorItems = this.metaSensorItemService.readAll(); + + Assert.assertNotEquals(metaSensorItems.size(), 0); + + } + + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeServiceTest.java new file mode 100644 index 0000000..a6bc615 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemTypeServiceTest.java @@ -0,0 +1,33 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItemType; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorItemTypeServiceTest { + + @Autowired + private MetaSensorItemTypeService sensorItemTypeService; + + @Test + @Ignore + public void readAll() throws Exception { + List metaSensorItemTypes = this.sensorItemTypeService.readAll(); + + Assert.assertNotEquals(metaSensorItemTypes.size(), 0); + } + +} diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitServiceTest.java new file mode 100644 index 0000000..ba9042f --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorItemUnitServiceTest.java @@ -0,0 +1,88 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorItemUnit; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorItemUnitServiceTest { + + @Autowired + private MetaSensorItemUnitService service; + + @Test + @Ignore + public void regist() throws Exception { + + MetaSensorItemUnit defaultValue = new MetaSensorItemUnit(); + defaultValue.setId((short)0); + defaultValue.setUnit(""); + defaultValue.setMark(""); + this.service.regist(defaultValue); + + + MetaSensorItemUnit unit1 = new MetaSensorItemUnit(); + unit1.setId((short)1); + unit1.setUnit("Percentage"); + unit1.setMark("%"); + this.service.regist(unit1); + + MetaSensorItemUnit unit2 = new MetaSensorItemUnit(); + unit2.setId((short)2); + unit2.setUnit("Byte"); + unit2.setMark("Bytes"); + this.service.regist(unit2); + + MetaSensorItemUnit unit3 = new MetaSensorItemUnit(); + unit3.setId((short)3); + unit3.setUnit("KByte"); + unit3.setMark("KB"); + this.service.regist(unit3); + + MetaSensorItemUnit unit4 = new MetaSensorItemUnit(); + unit4.setId((short)4); + unit4.setUnit("MByte"); + unit4.setMark("MB"); + this.service.regist(unit4); + + MetaSensorItemUnit unit5 = new MetaSensorItemUnit(); + unit5.setId((short)5); + unit5.setUnit("GByte"); + unit5.setMark("GB"); + this.service.regist(unit5); + + MetaSensorItemUnit unit6 = new MetaSensorItemUnit(); + unit6.setId((short)6); + unit6.setUnit("Count"); + unit6.setMark(""); + this.service.regist(unit6); + + MetaSensorItemUnit unit7 = new MetaSensorItemUnit(); + unit7.setId((short)7); + unit7.setUnit("Jiffy"); + unit7.setMark("Jiffies"); + this.service.regist(unit7); + + MetaSensorItemUnit unit8 = new MetaSensorItemUnit(); + unit8.setId((short)8); + unit8.setUnit("Byte Per Second"); + unit8.setMark("BPS"); + this.service.regist(unit8); + + MetaSensorItemUnit unit9 = new MetaSensorItemUnit(); + unit9.setId((short)9); + unit9.setUnit("Packet Per Second"); + unit9.setMark("PPS"); + this.service.regist(unit9); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusServiceTest.java new file mode 100644 index 0000000..b30cb85 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaSensorStatusServiceTest.java @@ -0,0 +1,35 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorStatus; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaSensorStatusServiceTest { + + @Autowired + private MetaSensorStatusService sensorStatusService; + + @Test + public void readAll() throws Exception { + + List sensorStatuses = this.sensorStatusService.readAll(); + + Assert.assertNotEquals(sensorStatuses.size(), 0); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerServiceTest.java b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerServiceTest.java new file mode 100644 index 0000000..94b31c1 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/meta/service/MetaVendorCrawlerServiceTest.java @@ -0,0 +1,60 @@ +package com.loafle.overflow.central.module.meta.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaInfraVendor; +import com.loafle.overflow.central.module.meta.model.MetaVendorCrawler; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by snoop on 17. 7. 27. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class MetaVendorCrawlerServiceTest { + + @Autowired + private MetaVendorCrawlerService service; + + @Test + public void readAllByInfraVendor() throws Exception { + MetaInfraVendor metaInfraVendor = new MetaInfraVendor(); + + metaInfraVendor.setId(26); + + List metaVendorCrawlers = this.service.readAllByInfraVendor(metaInfraVendor); + + Assert.assertNotEquals(metaVendorCrawlers.size(), 0); + + + } + + @Ignore + @Test + public void regist() throws Exception { + MetaVendorCrawler metaVendorCrawler = new MetaVendorCrawler(); + + MetaCrawler metaCrawler = new MetaCrawler(); + metaCrawler.setId((short)23); + + MetaInfraVendor metaInfraVendor = new MetaInfraVendor(); + metaInfraVendor.setId(42); + + metaVendorCrawler.setCrawler(metaCrawler); + metaVendorCrawler.setInfraVendor(metaInfraVendor); + + metaVendorCrawler.setId(1); + this.service.regist(metaVendorCrawler); + + Assert.assertNotEquals(metaVendorCrawler.getId(), 0); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeServiceTest.java new file mode 100644 index 0000000..97b7816 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/noauthprobe/service/NoAuthProbeServiceTest.java @@ -0,0 +1,159 @@ +package com.loafle.overflow.central.module.noauthprobe.service; + +import com.loafle.overflow.central.commons.service.MessagePublisher; +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.meta.model.MetaNoAuthProbeStatus; +import com.loafle.overflow.central.module.noauthprobe.model.NoAuthProbe; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class NoAuthProbeServiceTest { + + @Autowired + private NoAuthProbeService noAuthProbeService; + + @Autowired + private MessagePublisher messagePublisher; + + @Ignore + @Test + public void regist() throws Exception { + + NoAuthProbe noAuthProbe = new NoAuthProbe(); + + +// noAuthProbe.setHostName("snoop"); +// noAuthProbe.setIpAddress(3232235980L); +// noAuthProbe.setMacAddress(8796753988883L); + noAuthProbe.setDescription("{\"host\":{\"name\":\"snoop-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"DE60E4C3-347A-4D38-AEAB-1760471665EA\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}"); + + noAuthProbe.setApiKey("52abd6fd57e511e7ac52080027658d13"); + + MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus(); + metaNoAuthProbeStatus.setId((short)3); + + noAuthProbe.setStatus(metaNoAuthProbeStatus); + noAuthProbe.setTempProbeKey("ac7f252b5bc811e784ad080027658d13"); + + Domain d = new Domain(); + d.setId(1); + noAuthProbe.setDomain(d); + + this.noAuthProbeService.regist(noAuthProbe); + + Assert.assertNotEquals(noAuthProbe.getId(), 0); + + } + + @Ignore + @Test + public void registForNoAuthProbes() throws Exception { + + NoAuthProbe noAuthProbe = new NoAuthProbe(); + +// noAuthProbe.setHostName("geek"); +// noAuthProbe.setIpAddress(3232235980L); +// noAuthProbe.setMacAddress(8796753988883L); + noAuthProbe.setDescription("{\"host\":{\"name\":\"geek-ubuntu\",\"os\":\"linux\",\"paltform\":\"ubuntu\",\"platformFamily\":\"debian\",\"platformVersion\":\"\",\"kernelVersion\":\"4.4.0-93-generic\",\"hostID\":\"03000200-0400-0500-0006-000700080009\"},\"network\":{\"name\":\"enp3s0\",\"address\":\"192.168.1.103/24|fe80::36c0:6c3e:6006:dd23/64\",\"gateway\":\"192.168.1.254\",\"macAddress\":\"44:8a:5b:f1:f1:f3\"}}"); + noAuthProbe.setApiKey("521abd6fd57e511e7ac52080027658d13"); + + MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus(); + metaNoAuthProbeStatus.setId((short)3); + + noAuthProbe.setStatus(metaNoAuthProbeStatus); + noAuthProbe.setTempProbeKey("a1c7f252b5bc811e784ad080027658d13"); + + Domain d = new Domain(); + d.setId(1); + noAuthProbe.setDomain(d); + + List noAuthProbes = new ArrayList(); + + noAuthProbes.add(noAuthProbe); +// List dd = this.noAuthProbeService.registForNoAuthProbes(noAuthProbes); + +// System.out.println(dd.get(0).getId()); + + Assert.assertNotEquals(noAuthProbes.size(), 2); + + } + + @Ignore + @Test + public void readAllByDomain() throws Exception { + + Domain domain = new Domain(); + domain.setId(1); + + List probes = this.noAuthProbeService.readAllByDomain(domain); + + Assert.assertNotEquals(probes.size(), 0); + + } + +// @Ignore + @Test + public void read() throws Exception { + + NoAuthProbe noAuthProbe = this.noAuthProbeService.read(1); + + Assert.assertNotEquals(noAuthProbe, null); + } + + + @Test + public void acceptProbe() throws IOException { + + NoAuthProbe noAuthProbe = this.noAuthProbeService.read(1); + + this.noAuthProbeService.acceptNoAuthProbe(noAuthProbe); + + } + + @Test + public void ssss() { + String ss = "192.168.1.106/24|fe80::36c0:6c3e:6006:dd23/64"; + + String[] sss = ss.split("\\|"); + + System.out.println(sss[0]); + } + + @Test + public void readByTempKey() { + + NoAuthProbe noAuthProbe = this.noAuthProbeService.readByTempKey("1cf2555c57d511e79714080027658d15"); + + Assert.assertNotEquals(noAuthProbe, null); + + } + + @Test + public void sendWeb() { + + Domain domain = new Domain(); + domain.setId(1); + + List probes = this.noAuthProbeService.readAllByDomain(domain); + + messagePublisher.publishToDomainMembers(domain.getId(), "NoAuthProbeService.regist", probes); + + } + + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/notification/service/NotificationServiceTest.java b/src/test/java/com/loafle/overflow/central/module/notification/service/NotificationServiceTest.java new file mode 100644 index 0000000..6ff09eb --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/notification/service/NotificationServiceTest.java @@ -0,0 +1,52 @@ +package com.loafle.overflow.central.module.notification.service; + +import com.loafle.overflow.central.module.member.model.Member; +import com.loafle.overflow.central.module.notification.model.Notification; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; + +/** + * Created by insanity on 17. 8. 25. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class NotificationServiceTest { + @Autowired + private NotificationService notificationService; + + @Test + public void testRegist() { + for (int i=0; i<30; i++) { + Notification n = new Notification(); + n.setMember(new Member(1)); + n.setTitle("Title"+i); + n.setMessage("Message"+i); + if(i<20) { + n.setConfirmDate(new Date()); + } + this.notificationService.regist(n); + } + } + +// @Test +// @Ignore +// public void testReadAll() { +// this.testRegist(); +// Page notis = this.notificationService.readAllByMember(new Member(1), 0, 10); +// Assert.assertEquals(30, notis.getTotalElements()); +// } +// +// @Test +// @Ignore +// public void testReadAllUnread() { +// this.testRegist(); +// Page notis = this.notificationService.readAllUnconfirmedByMember(new Member(1), 0, 10); +// Assert.assertEquals(15, notis.getTotalElements()); +// } +} diff --git a/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeHostServiceTest.java b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeHostServiceTest.java new file mode 100644 index 0000000..bc8cb8b --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeHostServiceTest.java @@ -0,0 +1,57 @@ +package com.loafle.overflow.central.module.probe.service; + +import com.loafle.overflow.central.module.infra.model.InfraHost; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeHost; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.Assert.*; + +/** + * Created by snoop on 17. 8. 21. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class ProbeHostServiceTest { + + @Autowired + private ProbeHostService probeHostService; + + @Test + public void regist() { + ProbeHost probeHost = new ProbeHost(); + + Probe probe = new Probe(); + probe.setId(1); + + InfraHost infraHost = new InfraHost(); + infraHost.setId(3); + + probeHost.setProbe(probe); + + probeHost.setHost(infraHost); + + this.probeHostService.regist(probeHost); + + Assert.assertNotEquals(probeHost.getId(), 0); + } + + @Test + public void readByProbe() throws Exception { + + Probe probe = new Probe(); + probe.setId(1); + + ProbeHost probeHost = this.probeHostService.readByProbe(probe); + + Assert.assertNotEquals(probeHost, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeServiceTest.java b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeServiceTest.java new file mode 100644 index 0000000..eec0319 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeServiceTest.java @@ -0,0 +1,105 @@ +package com.loafle.overflow.central.module.probe.service; + +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.MetaProbeStatus; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; +import java.util.UUID; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class ProbeServiceTest { + + @Autowired + private ProbeService probeService; + +// @Ignore + @Test + public void regist() throws Exception { + + Probe probe = new Probe(); + + + probe.setDescription("snoop probe"); + + Domain domain = new Domain(); + domain.setId(1); + + probe.setDomain(domain); + + probe.setEncryptionKey(getUUID()); + probe.setProbeKey(getUUID()); + + MetaProbeStatus status = new MetaProbeStatus(); + status.setId((short)1); + + probe.setStatus(status); + + probe.setDisplayName("test probe 22222"); + probe.setCidr("192.168.1.0/24"); +// probe.setAuthorizedDate(new Date()); + + Member member = new Member(); + member.setId(1l); + probe.setAuthorizeMember(member); + +// InfraHost infraHost = new InfraHost(); +// infraHost.setId(1); +// +// probe.setHost(infraHost); + + this.probeService.regist(probe); + + Assert.assertNotEquals(probe.getId(), 0); + } + + public String getUUID() { + return UUID.randomUUID().toString().replaceAll("-", ""); + } + + @Test + public void tttt() { + String uuid = UUID.randomUUID().toString(); + String uuid2 = uuid.replaceAll("-", ""); + + System.out.println(uuid2); + } + + @Test + public void readAllByDomain() throws Exception { + + Domain domain = new Domain(); + domain.setId(1); + + List probes = this.probeService.readAllByDomain(domain); + + Assert.assertEquals(probes.size(), 1); + + } + + @Ignore + @Test + public void readByProbeKey() throws Exception { + + regist(); + + Probe probe = this.probeService.readByProbeKey("899fdd145bcc11e7b611080027658d13"); + + Assert.assertNotEquals(probe, null); + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeTaskServiceTest.java b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeTaskServiceTest.java new file mode 100644 index 0000000..df44804 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/probe/service/ProbeTaskServiceTest.java @@ -0,0 +1,63 @@ +package com.loafle.overflow.central.module.probe.service; + +import com.loafle.overflow.central.module.meta.model.MetaProbeTaskType; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.model.ProbeTask; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class ProbeTaskServiceTest { + + @Autowired + private ProbeTaskService probeTaskService; + + @Ignore + @Test + public void regist() throws Exception { + + ProbeTask probeTask = new ProbeTask(); + + MetaProbeTaskType typeDiscovery = new MetaProbeTaskType(); + typeDiscovery.setId((short)1); + + probeTask.setTaskType(typeDiscovery); + probeTask.setData(""); + + Probe probe = new Probe(); + probe.setId(1); + + probeTask.setProbe(probe); + + this.probeTaskService.regist(probeTask); + + Assert.assertNotEquals(probeTask.getId(), 0); + } + + @Ignore + @Test + public void readAllByProbe() throws Exception { + + regist(); + + Probe probe = new Probe(); + probe.setId(1); + + List probeTasks = this.probeTaskService.readAllByProbe(probe); + + Assert.assertNotEquals(probeTasks.size(), 0 ); + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorItemServiceTest.java b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorItemServiceTest.java new file mode 100644 index 0000000..85e6aed --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorItemServiceTest.java @@ -0,0 +1,59 @@ +package com.loafle.overflow.central.module.sensor.service; + +import com.loafle.overflow.central.module.meta.model.MetaSensorDisplayItem; +import com.loafle.overflow.central.module.sensor.model.Sensor; +import com.loafle.overflow.central.module.sensor.model.SensorItem; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; + +/** + * Created by insanity on 17. 6. 28. + */ +@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class SensorItemServiceTest { + @Autowired + SensorItemService sensorItemService; + + @Ignore + @Test + public void regist() throws Exception { + SensorItem sensorItem = new SensorItem(); + sensorItem.setCreateDate(new Date()); + MetaSensorDisplayItem item = new MetaSensorDisplayItem(); + item.setId(1); + Sensor sensor = new Sensor(); + sensor.setId(1); + sensorItem.setItem(item); + sensorItem.setSensor(sensor); + + SensorItem res = this.sensorItemService.regist(sensorItem); + Assert.assertNotNull(res); + } + + @Test + public void read() throws Exception { + SensorItem res = this.sensorItemService.read("1"); + Assert.assertNotNull(res); + } + +// @Test +// public void readAllBySensor() throws IOException { +// Sensor sensor = new Sensor(); +// sensor.setId(1); +// List sensorItems = this.sensorItemService.readAllBySensor(sensor); +// +// ObjectMapper objectMapper = new ObjectMapper(); +// String json = objectMapper.writeValueAsString(sensorItems); +// System.out.println(json); +// } +} diff --git a/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java new file mode 100644 index 0000000..aaa2f65 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java @@ -0,0 +1,142 @@ +package com.loafle.overflow.central.module.sensor.service; + +import com.loafle.overflow.central.module.meta.model.MetaCrawler; +import com.loafle.overflow.central.module.meta.model.MetaSensorStatus; +import com.loafle.overflow.central.module.sensor.model.Sensor; +import com.loafle.overflow.central.module.target.model.Target; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.IOException; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by insanity on 17. 6. 28. + */ +//@Ignore +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class SensorServiceTest { + @Autowired + SensorService sensorService; + + @Autowired + ObjectMapper objectMapper; + + + @Ignore + @Test + public void regist() throws Exception { + Sensor sensor = new Sensor(); + MetaSensorStatus status = new MetaSensorStatus((short)1); + sensor.setStatus(status); + MetaCrawler crawler = new MetaCrawler(); + crawler.setId((short)1); + sensor.setCrawler(crawler); + Target target = new Target(); + target.setId(1); + sensor.setTarget(target); + sensor.setCreateDate(new Date()); + + Sensor res = this.sensorService.regist(sensor); + Assert.assertNotNull(res); + } + + @Test + public void read() throws Exception { + Sensor res = this.sensorService.read("1"); + Assert.assertNotNull(res); + + ObjectMapper objectMapper = new ObjectMapper(); + +// String json = objectMapper.writeValueAsString(res); + + String json = this.objectMapper.writeValueAsString(res); + + System.out.println(json); + } + + @Test + public void generateSensorConfig() throws IOException { + + Sensor sensor = new Sensor(); + sensor.setId(5); + String result = this.sensorService.generateSensorConfig(sensor); + + System.out.println(result); + + } + + @Test + public void testJsonToMap() throws IOException { + + String json = "{\"interval\":5}"; + + ObjectMapper objectMapper = new ObjectMapper(); + + Map mm = new HashMap<>(); + + mm = objectMapper.readValue(json, HashMap.class); + + System.out.println(mm.get("interval")); + + } + + @Test + public void stringbbb() { + StringBuffer stringBuffer = new StringBuffer(); + + stringBuffer.append("222222222222222222222222222"); + System.out.println(stringBuffer.toString()); + stringBuffer.setLength(0); + System.out.println(stringBuffer.toString()); + stringBuffer.append("3333333333"); + System.out.println(stringBuffer.toString()); + } + +// @Test +// public void readAllByTarget() throws Exception { +// Target target = new Target(); +// target.setId(1); +// List sensors = this.sensorService.readAllByTarget(target); +// +// ObjectMapper objectMapper = new ObjectMapper(); +// +// String json = objectMapper.writeValueAsString(sensors); +// +// System.out.println(json); +// } + +// @Test +// public void readAllByTargetList() { +// +// Domain domain = new Domain(); +// domain.setId(1); +// +// List sl = this.sensorService.readAllByDomain(domain); +// +// Assert.assertNotEquals(sl.size(), 0); +// +// } + +// @Test +// public void readAllByInfra() { +// +// Infra infra = new InfraMachine(); +// infra.setId(1); +// +// List sl = this.sensorService.readAllByInfra(1); +// +// Assert.assertNotEquals(sl.size(), 0); +// +// } +} diff --git a/src/test/java/com/loafle/overflow/central/module/target/dao/TargetDAOTest.java b/src/test/java/com/loafle/overflow/central/module/target/dao/TargetDAOTest.java new file mode 100644 index 0000000..d999a7d --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/target/dao/TargetDAOTest.java @@ -0,0 +1,36 @@ +package com.loafle.overflow.central.module.target.dao; + +import com.loafle.overflow.central.module.domain.model.Domain; +import com.loafle.overflow.central.module.infra.model.Infra; +import com.loafle.overflow.central.module.infra.service.InfraService; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.module.probe.service.ProbeService; +import com.loafle.overflow.central.module.target.model.Target; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 28. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class TargetDAOTest { + + @Autowired + private TargetDAO targetDAO; + + @Autowired + private ProbeService probeService; + + @Autowired + private InfraService infraService; + + +} diff --git a/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java b/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java new file mode 100644 index 0000000..05e5200 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/target/service/TargetDiscoveryServiceTest.java @@ -0,0 +1,135 @@ +package com.loafle.overflow.central.module.target.service; + +import com.loafle.overflow.central.module.discovery.model.Host; +import com.loafle.overflow.central.module.probe.model.Probe; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.aop.support.AopUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ResourceLoader; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; + +/** + * Created by snoop on 17. 6. 28. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class TargetDiscoveryServiceTest { + + @Autowired + private ResourceLoader resourceLoader; + + @Autowired + private TargetDiscoveryService targetDiscoveryService; + + @Ignore + @Test + public void saveAllTarget() throws Exception { + + String json = readFileAsString(resourceLoader.getResource("classpath:dh.json").getURI().getPath()); + + ObjectMapper mapper = new ObjectMapper(); + + mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + List hosts = mapper.readValue(json, mapper.getTypeFactory().constructCollectionType(List.class, Host.class)); + + Probe probe = new Probe(); + probe.setId(1); + +// this.targetDiscoveryService.saveAllTarget(hosts, probe); + } + + private String readFileAsString(String filePath) throws IOException { + StringBuffer fileData = new StringBuffer(); + BufferedReader reader = new BufferedReader( + new FileReader(filePath)); + char[] buf = new char[1024]; + int numRead=0; + while((numRead=reader.read(buf)) != -1){ + String readData = String.valueOf(buf, 0, numRead); + fileData.append(readData); + } + reader.close(); + return fileData.toString(); + } + + + @Ignore + @Test + public void testParam() throws NoSuchMethodException { + + Method m = this.targetDiscoveryService.getClass().getMethod("saveAllTarget", List.class, Probe.class); +// Method m = TargetDiscoveryService.class.getMethod("saveAllTarget", List.class, Probe.class); + + Class clazz = AopUtils.getTargetClass(this.targetDiscoveryService); + Method[] ms = clazz.getMethods(); + + Method sm = null; + for(Method mm : ms){ + if ("saveAllTarget".equals(mm.getName())) { + sm = mm; + break; + } + } + + if (sm != null) { + Type[] ts = sm.getGenericParameterTypes(); + for(Type t : ts){ + if (t instanceof ParameterizedType) { + ParameterizedType pt = (ParameterizedType)t; + System.out.println(pt.getActualTypeArguments()[0].getTypeName()); + } + System.out.println(t.getTypeName()); + + + } + } + + + System.out.println(m.getName()); + Type[] genericParameterTypes = m.getGenericParameterTypes(); + + for(Type genericParameterType : genericParameterTypes){ + if(genericParameterType instanceof ParameterizedType){ + ParameterizedType aType = (ParameterizedType) genericParameterType; + Type[] parameterArgTypes = aType.getActualTypeArguments(); + for(Type parameterArgType : parameterArgTypes){ + Class parameterArgClass = (Class) parameterArgType; + System.out.println("parameterArgClass = " + parameterArgClass); + } + } + } + } + + @Ignore + @Test + public void testName() throws ClassNotFoundException { + + Object o = this.targetDiscoveryService; + + String nnn = o.getClass().getSimpleName(); + System.out.println(nnn); + + + + + + + } + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/module/target/service/TargetServiceTest.java b/src/test/java/com/loafle/overflow/central/module/target/service/TargetServiceTest.java new file mode 100644 index 0000000..1473802 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/module/target/service/TargetServiceTest.java @@ -0,0 +1,48 @@ +package com.loafle.overflow.central.module.target.service; + +import com.loafle.overflow.central.module.target.model.Target; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.util.Date; + +/** + * Created by insanity on 17. 6. 28. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class TargetServiceTest { + @Autowired + TargetService targetService; + + @Ignore + @Test + public void regist() throws Exception { + Target t = new Target(); + t.setCreateDate(new Date()); +// Infra infra = new Infra(); +// infra.setId(1); +// Probe probe = new Probe(); +// probe.setId(1); +// t.setProbe(probe); +// t.setInfra(infra); + t.setDescription("i am target"); + t.setDisplayName("ghost target"); + + Target res = this.targetService.regist(t); + Assert.assertNotNull(res); + } + + @Test + public void read() throws Exception { + Target res = this.targetService.read("1"); + Assert.assertNotNull(res); + } +} diff --git a/src/test/java/com/loafle/overflow/central/proxy/ServiceInvokerTest.java b/src/test/java/com/loafle/overflow/central/proxy/ServiceInvokerTest.java new file mode 100644 index 0000000..b1cd715 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/proxy/ServiceInvokerTest.java @@ -0,0 +1,64 @@ +package com.loafle.overflow.central.proxy; + +import com.google.common.primitives.Primitives; +import com.google.protobuf.ByteString; +import com.loafle.overflow.central.module.target.service.TargetDiscoveryService; +import com.loafle.overflow.central.spring.AppConfigTest; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; + +/** + * Created by crusader on 17. 6. 30. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfigTest.class}) +public class ServiceInvokerTest { + @Autowired + private ServiceInvoker serviceInvoker; + + @Test + public void invoke() throws Throwable { + +// List params = new ArrayList<>(2); +// params.add(ByteString.copyFromUtf8("[{\"id\": 1," + +// "\"ip\":2312132112," + +// "\"mac\":12312312," + +// "\"os\": \"Windows\"," + +// "\"target\":true}]")); +// params.add(ByteString.copyFromUtf8("{\"id\": 1," + +// "\"ip\":2312132112," + +// "\"probeKey\":\"sdfsdfsdfsdfsd\"}")); +// +// serviceInvoker.invoke("TargetDiscoveryService", "saveAllTarget", params); + +// List params2 = new ArrayList<>(1); +// params2.add(ByteString.copyFromUtf8("1")); +// +// serviceInvoker.invoke("InfraOSService", "read", params2); +// +// List params3 = new ArrayList<>(1); +// params3.add(ByteString.copyFromUtf8("1")); +// +// serviceInvoker.invoke("MemberService", "read", params3); +// +// List params4 = new ArrayList<>(2); +// params4.add(ByteString.copyFromUtf8("ddddddfsafsd")); +// params4.add(ByteString.copyFromUtf8("243234234234")); +// +// serviceInvoker.invoke("MemberService", "signin", params4); + + } + + + +} \ No newline at end of file diff --git a/src/test/java/com/loafle/overflow/central/spring/AppConfigTest.java b/src/test/java/com/loafle/overflow/central/spring/AppConfigTest.java new file mode 100644 index 0000000..913ee13 --- /dev/null +++ b/src/test/java/com/loafle/overflow/central/spring/AppConfigTest.java @@ -0,0 +1,62 @@ +package com.loafle.overflow.central.spring; + +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.annotation.*; +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.Resource; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.TestPropertySource; + +import static org.junit.Assert.*; + +/** + * Created by geek on 17. 8. 8. + */ +@Configuration +@ComponentScan(basePackages = {"com.loafle.overflow"}, excludeFilters = @ComponentScan.Filter({Configuration.class})) +@Import({ + JdbcConfiguration.class, + MailConfiguration.class, + RedisConfiguration.class, + CacheConfiguration.class +}) +@TestPropertySource({ + "classpath:database.properties", + "classpath:mail.properties", + "classpath:redis.properties", + "classpath:cache.properties" +}) + +public class AppConfigTest { + +// @Bean +// public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() { +// PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); +//// ppc.setLocation(new ClassPathResource("database.properties")); +// ppc.setLocations(new Resource[] { +// new ClassPathResource("database.properties"), +// new ClassPathResource("mail.properties"), +// new ClassPathResource("redis.properties") +// }); +// ppc.setIgnoreUnresolvablePlaceholders(true); +// +// return ppc; +// } + @Bean + public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { + return new PropertySourcesPlaceholderConfigurer(); + } + + @Bean + public ObjectMapper getObjectMapper() { + + ObjectMapper objectMapper = new ObjectMapper(); + + objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + return objectMapper; + } +} \ No newline at end of file diff --git a/src/test/resources/cache.properties b/src/test/resources/cache.properties new file mode 100644 index 0000000..fda34c0 --- /dev/null +++ b/src/test/resources/cache.properties @@ -0,0 +1,3 @@ +# Caffeine +cache.cache-names:memberListByDomain,memberListByProbeKey +cache.caffeine.spec: initialCapacity=100,maximumSize=500,expireAfterAccess=5m,recordStats \ No newline at end of file diff --git a/src/test/resources/database.properties b/src/test/resources/database.properties new file mode 100644 index 0000000..e8c1188 --- /dev/null +++ b/src/test/resources/database.properties @@ -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 diff --git a/src/test/resources/dh.json b/src/test/resources/dh.json new file mode 100644 index 0000000..c7bb126 --- /dev/null +++ b/src/test/resources/dh.json @@ -0,0 +1,173 @@ +[{ + "firstScanRange": 1, + "lastScanRange": 10000, + "name": "", + "ip": 3232235818, + "mac": 91754662925, + "os":"Windows", + "ports": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "SSH", + "target":true + }], + "portType": "TCP", + "portNumber": 22 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 443 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 80 + }], + "createDate": 1498470178000, + "updateDate": 1498470178000 +}, + { + "firstScanRange": 1, + "lastScanRange": 10000, + "name": "", + "ip": 3232235781, + "mac": 91754660625, + "os":"Windows", + "ports": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "SSH" + }], + "portType": "TCP", + "portNumber": 22 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 80 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 1936 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": null, + "portType": "TCP", + "portNumber": 443 + }], + "createDate": 1498470178000, + "updateDate": 1498470178000 + }, + { + "firstScanRange": 1, + "lastScanRange": 10000, + "name": "", + "ip": 3232235797, + "mac": 91754662913, + "os":"Windows", + "target":true, + "ports": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 80 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "SSH" + }], + "portType": "TCP", + "portNumber": 22 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 3343 + }, + { + "createDate": -62135596800000, + "updateDate": -62135596800000, + "services": [{ + "createDate": -62135596800000, + "updateDate": -62135596800000, + "portType": "TCP", + "serviceName": "HTTP" + }], + "portType": "TCP", + "portNumber": 443 + }], + "createDate": 1498470178000, + "updateDate": 1498470178000 + }, + { + "firstScanRange": 1, + "lastScanRange": 10000, + "name": "", + "ip": 3232235877, + "mac": 75361038758387, + "os":"Windows", + "ports": null, + "createDate": 1498470179000, + "updateDate": 1498470179000 + } + + +] \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml new file mode 100644 index 0000000..e5f98b6 --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,17 @@ + + + central + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{32} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/mail.properties b/src/test/resources/mail.properties new file mode 100644 index 0000000..99f696d --- /dev/null +++ b/src/test/resources/mail.properties @@ -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=* + + diff --git a/src/test/resources/redis.properties b/src/test/resources/redis.properties new file mode 100644 index 0000000..bebb8a1 --- /dev/null +++ b/src/test/resources/redis.properties @@ -0,0 +1,4 @@ +# Redis +redis.host=192.168.1.50 +redis.port=6379 +redis.channels=/web,/probe,/auth \ No newline at end of file