added
discovery model dao
This commit is contained in:
parent
f24263d017
commit
0a5c2b94ed
11
src/main/java/com/loafle/overflow/discovery/dao/HostDao.java
Normal file
11
src/main/java/com/loafle/overflow/discovery/dao/HostDao.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.apikey.model.Apikey;
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Host;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public interface HostDao extends BaseDAO<Host> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Host;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPAHostDao extends JPABaseDAO<Host> implements HostDao {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Port;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPAPortDao extends JPABaseDAO<Port> implements PortDao {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Service;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPAServiceDao extends JPABaseDAO<Service> implements ServiceDao {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
|
||||
import com.loafle.overflow.commons.dao.JPABaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Zone;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public class JPAZoneDao extends JPABaseDAO<Zone> implements ZoneDao {
|
||||
}
|
10
src/main/java/com/loafle/overflow/discovery/dao/PortDao.java
Normal file
10
src/main/java/com/loafle/overflow/discovery/dao/PortDao.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Port;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public interface PortDao extends BaseDAO<Port> {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Service;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public interface ServiceDao extends BaseDAO<Service> {
|
||||
}
|
10
src/main/java/com/loafle/overflow/discovery/dao/ZoneDao.java
Normal file
10
src/main/java/com/loafle/overflow/discovery/dao/ZoneDao.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package com.loafle.overflow.discovery.dao;
|
||||
|
||||
import com.loafle.overflow.commons.dao.BaseDAO;
|
||||
import com.loafle.overflow.discovery.model.Zone;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
public interface ZoneDao extends BaseDAO<Zone> {
|
||||
}
|
115
src/main/java/com/loafle/overflow/discovery/model/Host.java
Normal file
115
src/main/java/com/loafle/overflow/discovery/model/Host.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
package com.loafle.overflow.discovery.model;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Entity
|
||||
public class Host {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
@Column(name = "IP",nullable = false)
|
||||
private long ip;
|
||||
|
||||
@Column(name = "MAC",nullable = false)
|
||||
private long mac;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "ZONE_ID", nullable = false)
|
||||
@JsonIgnore
|
||||
private Zone zone;
|
||||
|
||||
public Zone getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "host",cascade = CascadeType.ALL)
|
||||
private List<Port> ports;
|
||||
|
||||
public List<Port> getPorts() {
|
||||
return ports;
|
||||
}
|
||||
|
||||
public void setPorts(List<Port> ports) {
|
||||
this.ports = ports;
|
||||
}
|
||||
|
||||
@Column(name = "CREATE_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||
private Date createDate;
|
||||
|
||||
@Column(name = "UPDATE_DATE", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false)
|
||||
private Date updateDate;
|
||||
|
||||
|
||||
public Host(){}
|
||||
|
||||
public Host(long ip, long mac){
|
||||
this.ip = ip;
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(long ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public long getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(long mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public void mappingChildren(Zone discoveryZone) {
|
||||
this.setZone(discoveryZone);
|
||||
|
||||
List<Port> ports = this.getPorts();
|
||||
if (ports != null) {
|
||||
for (int j =0 ; j < ports.size() ; ++j) {
|
||||
ports.get(j).mappingChildren(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
123
src/main/java/com/loafle/overflow/discovery/model/Port.java
Normal file
123
src/main/java/com/loafle/overflow/discovery/model/Port.java
Normal file
|
@ -0,0 +1,123 @@
|
|||
package com.loafle.overflow.discovery.model;
|
||||
|
||||
import com.loafle.overflow.discovery.type.PortType;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Entity
|
||||
public class Port {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
@JsonIgnore
|
||||
private Host host;
|
||||
public Host getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(Host host) {
|
||||
this.host = host;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private PortType portType;
|
||||
|
||||
@Column(nullable = false)
|
||||
private int portNumber;
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "port" ,cascade = CascadeType.ALL)
|
||||
private List<Service> services;
|
||||
|
||||
public List<Service> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||
private Date createDate;
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false)
|
||||
private Date updateDate;
|
||||
|
||||
public Port() {}
|
||||
|
||||
public Port(PortType type, int portNumber) {
|
||||
this.portType = type;
|
||||
this.portNumber = portNumber;
|
||||
}
|
||||
|
||||
public Port(Host host, PortType type, int portNumber) {
|
||||
this.host = host;
|
||||
this.portType = type;
|
||||
this.portNumber = portNumber;
|
||||
}
|
||||
|
||||
|
||||
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 getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public void mappingChildren(Host discoveryHost) {
|
||||
this.setHost(discoveryHost);
|
||||
|
||||
|
||||
List<Service> discoveryServices = this.getServices();
|
||||
if (discoveryServices != null) {
|
||||
for (int z = 0 ; z < discoveryServices.size() ; ++z) {
|
||||
discoveryServices.get(z).setPort(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.loafle.overflow.discovery.model;
|
||||
|
||||
import com.loafle.overflow.discovery.type.PortType;
|
||||
import org.codehaus.jackson.annotate.JsonIgnore;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Entity
|
||||
public class Service {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(nullable = false)
|
||||
@JsonIgnore
|
||||
private Port port;
|
||||
public Port getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Port port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
@Column(nullable = false)
|
||||
@Enumerated(EnumType.STRING)
|
||||
private PortType portType;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String serviceName;
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||
private Date createDate;
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false ,insertable = false)
|
||||
private Date updateDate;
|
||||
|
||||
public Service() {}
|
||||
|
||||
public Service(Port port,PortType t, String serviceName) {
|
||||
this.port = port;
|
||||
this.portType = t;
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public PortType getPortType() {
|
||||
return portType;
|
||||
}
|
||||
|
||||
public void setPortType(PortType portType) {
|
||||
this.portType = portType;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
public void setServiceName(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
}
|
111
src/main/java/com/loafle/overflow/discovery/model/Zone.java
Normal file
111
src/main/java/com/loafle/overflow/discovery/model/Zone.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
package com.loafle.overflow.discovery.model;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
@Entity
|
||||
public class Zone {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private long id;
|
||||
|
||||
@Column(nullable=false)
|
||||
private long ip;
|
||||
|
||||
@Column(nullable=false)
|
||||
private long cidr;
|
||||
|
||||
// @JoinColumn(nullable=false)
|
||||
// @OneToOne
|
||||
// @JsonIgnore
|
||||
// private DiscoveryHistory discovery;
|
||||
|
||||
// @OneToMany(mappedBy = "zone", cascade = CascadeType.ALL)
|
||||
// private List<HostScanHistory> histories;
|
||||
|
||||
@OneToMany(mappedBy = "zone", cascade = CascadeType.ALL)
|
||||
private List<Host> hosts;
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false)
|
||||
private Date createDate;
|
||||
|
||||
@Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false)
|
||||
private Date updateDate;
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(long ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public long getCidr() {
|
||||
return cidr;
|
||||
}
|
||||
|
||||
public void setCidr(long cidr) {
|
||||
this.cidr = cidr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Host> getHosts() {
|
||||
return hosts;
|
||||
}
|
||||
|
||||
public void setHosts(List<Host> hosts) {
|
||||
this.hosts = hosts;
|
||||
}
|
||||
|
||||
// public void mappingChildren(DiscoveryHistory history) {
|
||||
// this.setDiscovery(history);
|
||||
// List<HostScanHistory> hostScanHistories = this.getHistories();
|
||||
// if (hostScanHistories != null) {
|
||||
// for (int i =0 ; i < hostScanHistories.size() ; ++i) {
|
||||
// hostScanHistories.get(i).setZone(this);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<Host> hosts = this.getHosts();
|
||||
// if (hosts != null) {
|
||||
// for (int i =0 ; i < hosts.size() ; ++i) {
|
||||
// hosts.get(i).mappingChildren(this);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.loafle.overflow.discovery.type;
|
||||
|
||||
/**
|
||||
* Created by root on 16. 11. 15.
|
||||
*/
|
||||
public enum DirectionType {
|
||||
Send("S"),
|
||||
Recv("R"),
|
||||
Timeout("T"),
|
||||
Closed("C");
|
||||
|
||||
private String stringValue;
|
||||
DirectionType(String string) {stringValue = string;}
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringValue;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.loafle.overflow.discovery.type;
|
||||
|
||||
/**
|
||||
* Created by root on 16. 11. 15.
|
||||
*/
|
||||
|
||||
public enum PortType {
|
||||
TCP("TCP"),
|
||||
UDP("UDP"),
|
||||
TLS("TLS");
|
||||
|
||||
private String stringValue;
|
||||
PortType(String string) {stringValue = string;}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return stringValue;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user