email token duplication check

This commit is contained in:
geek 2018-06-29 18:42:03 +09:00
parent fb239e2249
commit ee5f6ddd99
4 changed files with 83 additions and 15 deletions

View File

@ -317,6 +317,23 @@ public class CentralInfraService implements InfraService {
return infras; return infras;
} }
public List<Infra> testRegistDiscoverd(Long probeID, List<Host> hosts, List<com.loafle.overflow.model.discovery.Service> services) throws OverflowException {
List<Infra> infras = new ArrayList<>();
if (null != hosts) {
for (Host host : hosts) {
infras.add(this.registByHost(probeID, host));
}
}
if (null != services) {
for (com.loafle.overflow.model.discovery.Service service : services) {
infras.add(this.registByService(probeID, service));
}
}
return infras;
}
public InfraZone registInfraZoneByInfraHostIP(Long probeID, InfraHostIP infraHostIP) throws OverflowException { public InfraZone registInfraZoneByInfraHostIP(Long probeID, InfraHostIP infraHostIP) throws OverflowException {
if (null == infraHostIP) { if (null == infraHostIP) {
throw new OverflowException("InfraHostIP is not valid"); throw new OverflowException("InfraHostIP is not valid");

View File

@ -0,0 +1,15 @@
package com.loafle.overflow.central.module.meta.dao;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaCollectionItemMapping;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MetaCollectionItemMappingDAO extends JpaRepository<MetaCollectionItemMapping, Short> {
List<MetaCollectionItemMapping> findAllByMetaDisplayItemMappingId(Long metaDisplayItemMappingID) throws OverflowException;
List<MetaCollectionItemMapping> findAllByMetaCollectionItemId(Long metaCollectionItemID) throws OverflowException;
}

View File

@ -0,0 +1,32 @@
package com.loafle.overflow.central.module.meta.service;
import com.loafle.overflow.central.module.meta.dao.MetaCollectionItemMappingDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaCollectionItemMapping;
import com.loafle.overflow.service.central.meta.MetaCollectionItemMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("MetaCollectionItemMappingService")
public class CentralMetaCollectionItemMappingService implements MetaCollectionItemMappingService {
@Autowired
MetaCollectionItemMappingDAO metaCollectionItemMappingDAO;
@Override
public List<MetaCollectionItemMapping> readAll() throws OverflowException {
return this.metaCollectionItemMappingDAO.findAll();
}
@Override
public List<MetaCollectionItemMapping> readAllByMetaDisplayItemMappingID(Long metaDisplayItemMappingID) throws OverflowException {
return this.metaCollectionItemMappingDAO.findAllByMetaDisplayItemMappingId(metaDisplayItemMappingID);
}
@Override
public List<MetaCollectionItemMapping> readAllByMetaCollectionItemID(Long metaCollectionItemID) throws OverflowException {
return this.metaCollectionItemMappingDAO.findAllByMetaCollectionItemId(metaCollectionItemID);
}
}

View File

@ -12,6 +12,7 @@ import com.loafle.overflow.model.meta.MetaIPType;
import com.loafle.overflow.model.meta.MetaPortType; import com.loafle.overflow.model.meta.MetaPortType;
import com.loafle.overflow.service.central.infra.InfraService; import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.meta.MetaCryptoTypeService; import com.loafle.overflow.service.central.meta.MetaCryptoTypeService;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -26,11 +27,15 @@ import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test") @ActiveProfiles("test")
@ContextConfiguration(classes = { AppConfigTest.class }) @ContextConfiguration(classes = { AppConfigTest.class })
@Ignore
public class CentralInfraServiceTest { public class CentralInfraServiceTest {
@Autowired @Autowired
InfraService infraService; InfraService infraService;
@Autowired
CentralInfraService centralInfraService;
@Autowired @Autowired
MetaCryptoTypeService metaCryptoTypeService; MetaCryptoTypeService metaCryptoTypeService;
@ -47,50 +52,49 @@ public class CentralInfraServiceTest {
MetaCryptoType cryptoType = null; MetaCryptoType cryptoType = null;
Zone zone = new Zone(); Zone zone = new Zone();
zone.setAddress("192.168.10.101/24"); zone.setAddress("192.168.1.103/24");
zone.setDiscoveredDate(new Date()); zone.setDiscoveredDate(new Date());
zone.setIface("enf03"); zone.setIface("enf03");
zone.setMac("44:8a:5b:44:8c:e4"); zone.setMac("44:8a:5b:44:8c:e4");
zone.setMetaIPType(MetaIPType.Enum.V4.to()); zone.setMetaIPType(MetaIPType.Enum.V4.to());
zone.setNetwork("192.168.10.0/24"); zone.setNetwork("192.168.1.0/24");
// for (int i = 1; i < 6; i++) { // for (int i = 1; i < 6; i++) {
host = new Host(); host = new Host();
host.setMetaIPType(MetaIPType.Enum.V4.to()); host.setMetaIPType(MetaIPType.Enum.V4.to());
host.getMetaIPType().setKey("V4"); host.getMetaIPType().setKey("V4");
host.setAddress("192.168.10.12"); host.setAddress("192.168.1.103");
host.setMac("44:8a:5b:44:8c:e7"); host.setMac("44:8a:5b:44:8c:e4");
host.setDiscoveredDate(new Date()); host.setDiscoveredDate(new Date());
host.setZone(zone); host.setZone(zone);
for (int j = 24; j < 25; j++) { // for (int j = 22; j < 25; j++) {
port = new Port(); port = new Port();
port.setDiscoveredDate(new Date()); port.setDiscoveredDate(new Date());
port.setHost(host); port.setHost(host);
port.setMetaPortType(MetaPortType.Enum.TCP.to()); port.setMetaPortType(MetaPortType.Enum.TCP.to());
port.setPortNumber(j); port.setPortNumber(22);
for (int x = 24; x < 25; x++) { // for (int x = 24; x < 25; x++) {
service = new Service(); service = new Service();
cryptoType = new MetaCryptoType(); cryptoType = new MetaCryptoType();
cryptoType.setKey("UNKNOWN"); cryptoType.setKey("TLS");
cryptoType.setId(Short.valueOf((short) 2)); cryptoType.setId(Short.valueOf((short) 17));
cryptoType.setName("Unknown"); cryptoType.setName("TLS");
service.setMetaCryptoType(cryptoType); service.setMetaCryptoType(cryptoType);
service.setPort(port); service.setPort(port);
service.setDiscoveredDate(new Date()); service.setDiscoveredDate(new Date());
service.setKey("Unknown"); service.setKey("SSH");
services.add(service); services.add(service);
} // }
port.setServiceList(services); port.setServiceList(services);
ports.add(port); ports.add(port);
} // }
host.setPortList(ports); host.setPortList(ports);
hosts.add(host); hosts.add(host);
// } // }
// List<Infra> infras = this.infraService.registDiscoverd(Long.valueOf((long)1), List<Infra> infras = this.centralInfraService.testRegistDiscoverd(Long.valueOf((long)1), hosts, services);
// hosts, services);
// System.out.println("CentralInfraServiceTest Infra List Size: " + // System.out.println("CentralInfraServiceTest Infra List Size: " +
// infras.size()); // infras.size());
} }