ing
This commit is contained in:
parent
963ac0c068
commit
3f9d6c05c2
|
@ -6,10 +6,10 @@ import io.grpc.Metadata;
|
|||
import static io.grpc.Metadata.ASCII_STRING_MARSHALLER;
|
||||
|
||||
public class SessionMetadata {
|
||||
public static final Context.Key<String> CTX_EMAIL_KEY = Context.key("email");
|
||||
public static final Metadata.Key<String> METADATA_EMAIL_KEY = Metadata.Key.of("email", ASCII_STRING_MARSHALLER);
|
||||
public static final Context.Key<String> CTX_SESSION_ID_KEY = Context.key("SESSION_ID");
|
||||
public static final Metadata.Key<String> METADATA_SESSION_ID_KEY = Metadata.Key.of("SESSION_ID", ASCII_STRING_MARSHALLER);
|
||||
|
||||
public static String getEmail() {
|
||||
return CTX_EMAIL_KEY.get();
|
||||
public static String getSessionID() {
|
||||
return CTX_SESSION_ID_KEY.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.commons.stereotype;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ProbeAPI {
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.loafle.overflow.commons.stereotype;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface WebappAPI {
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryHost {
|
||||
private String firstScanRange;
|
||||
private String lastScanRange;
|
||||
private List<String> excludeHosts;
|
||||
private List<String> includeHosts;
|
||||
|
||||
private DiscoveryPort discoveryPort;
|
||||
|
||||
public String getFirstScanRange() {
|
||||
return firstScanRange;
|
||||
}
|
||||
|
||||
public void setFirstScanRange(String firstScanRange) {
|
||||
this.firstScanRange = firstScanRange;
|
||||
}
|
||||
|
||||
public String getLastScanRange() {
|
||||
return lastScanRange;
|
||||
}
|
||||
|
||||
public void setLastScanRange(String lastScanRange) {
|
||||
this.lastScanRange = lastScanRange;
|
||||
}
|
||||
|
||||
public List<String> getExcludeHosts() {
|
||||
return excludeHosts;
|
||||
}
|
||||
|
||||
public void setExcludeHosts(List<String> excludeHosts) {
|
||||
this.excludeHosts = excludeHosts;
|
||||
}
|
||||
|
||||
public List<String> getIncludeHosts() {
|
||||
return includeHosts;
|
||||
}
|
||||
|
||||
public void setIncludeHosts(List<String> includeHosts) {
|
||||
this.includeHosts = includeHosts;
|
||||
}
|
||||
|
||||
public DiscoveryPort getDiscoveryPort() {
|
||||
return discoveryPort;
|
||||
}
|
||||
|
||||
public void setDiscoveryPort(DiscoveryPort discoveryPort) {
|
||||
this.discoveryPort = discoveryPort;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryPort {
|
||||
private int firstScanRange;
|
||||
private int lastScanRange;
|
||||
private List<Integer> excludePorts;
|
||||
private boolean includeTCP;
|
||||
private boolean includeUDP;
|
||||
|
||||
private DiscoveryService discoveryService;
|
||||
|
||||
public int getFirstScanRange() {
|
||||
return firstScanRange;
|
||||
}
|
||||
|
||||
public void setFirstScanRange(int firstScanRange) {
|
||||
this.firstScanRange = firstScanRange;
|
||||
}
|
||||
|
||||
public int getLastScanRange() {
|
||||
return lastScanRange;
|
||||
}
|
||||
|
||||
public void setLastScanRange(int lastScanRange) {
|
||||
this.lastScanRange = lastScanRange;
|
||||
}
|
||||
|
||||
public List<Integer> getExcludePorts() {
|
||||
return excludePorts;
|
||||
}
|
||||
|
||||
public void setExcludePorts(List<Integer> excludePorts) {
|
||||
this.excludePorts = excludePorts;
|
||||
}
|
||||
|
||||
public boolean isIncludeTCP() {
|
||||
return includeTCP;
|
||||
}
|
||||
|
||||
public void setIncludeTCP(boolean includeTCP) {
|
||||
this.includeTCP = includeTCP;
|
||||
}
|
||||
|
||||
public boolean isIncludeUDP() {
|
||||
return includeUDP;
|
||||
}
|
||||
|
||||
public void setIncludeUDP(boolean includeUDP) {
|
||||
this.includeUDP = includeUDP;
|
||||
}
|
||||
|
||||
public DiscoveryService getDiscoveryService() {
|
||||
return discoveryService;
|
||||
}
|
||||
|
||||
public void setDiscoveryService(DiscoveryService discoveryService) {
|
||||
this.discoveryService = discoveryService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryService {
|
||||
private List<String> includeServices;
|
||||
|
||||
public List<String> getIncludeServices() {
|
||||
return includeServices;
|
||||
}
|
||||
|
||||
public void setIncludeServices(List<String> includeServices) {
|
||||
this.includeServices = includeServices;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscoveryZone {
|
||||
private List<String> excludePatterns;
|
||||
|
||||
private DiscoveryHost discoveryHost;
|
||||
|
||||
public List<String> getExcludePatterns() {
|
||||
return excludePatterns;
|
||||
}
|
||||
|
||||
public void setExcludePatterns(List<String> excludePatterns) {
|
||||
this.excludePatterns = excludePatterns;
|
||||
}
|
||||
|
||||
public DiscoveryHost getDiscoveryHost() {
|
||||
return discoveryHost;
|
||||
}
|
||||
|
||||
public void setDiscoveryHost(DiscoveryHost discoveryHost) {
|
||||
this.discoveryHost = discoveryHost;
|
||||
}
|
||||
}
|
|
@ -1,39 +1,19 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
*/
|
||||
|
||||
public class Host {
|
||||
|
||||
|
||||
private long id;
|
||||
private long ip;
|
||||
private long mac;
|
||||
|
||||
private Date createDate;
|
||||
private Date updateDate;
|
||||
|
||||
private String os;
|
||||
private boolean target;
|
||||
|
||||
|
||||
private List<Port> ports;
|
||||
|
||||
public List<Port> getPorts() {
|
||||
return ports;
|
||||
}
|
||||
|
||||
public void setPorts(List<Port> ports) {
|
||||
this.ports = ports;
|
||||
}
|
||||
|
||||
|
||||
private Date discoveredDate;
|
||||
|
||||
private Zone zone;
|
||||
|
||||
public Host(){}
|
||||
|
||||
|
@ -66,22 +46,6 @@ public class Host {
|
|||
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 String getOs() {
|
||||
return os;
|
||||
}
|
||||
|
@ -90,11 +54,19 @@ public class Host {
|
|||
this.os = os;
|
||||
}
|
||||
|
||||
public boolean isTarget() {
|
||||
return target;
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setTarget(boolean target) {
|
||||
this.target = target;
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Zone getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(Zone zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ package com.loafle.overflow.module.discovery.model;
|
|||
import com.loafle.overflow.module.discovery.type.PortType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by root on 17. 6. 4.
|
||||
|
@ -18,54 +17,14 @@ public class Port {
|
|||
|
||||
|
||||
private long id;
|
||||
|
||||
private PortType portType;
|
||||
private int portNumber;
|
||||
private Date discoveredDate;
|
||||
|
||||
private Host host;
|
||||
public Host getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(Host host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
private PortType portType;
|
||||
|
||||
|
||||
private int portNumber;
|
||||
|
||||
|
||||
|
||||
private List<Service> services;
|
||||
|
||||
public List<Service> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
|
||||
private Date createDate;
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -90,33 +49,20 @@ public class Port {
|
|||
this.portNumber = portNumber;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
public Host getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
public void setHost(Host host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
|
||||
import com.loafle.overflow.module.discovery.type.PortType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -10,48 +7,29 @@ import java.util.Date;
|
|||
*/
|
||||
|
||||
public class Service {
|
||||
|
||||
|
||||
private long id;
|
||||
|
||||
private String cryptoType;
|
||||
private String serviceName;
|
||||
private Date discoveredDate;
|
||||
|
||||
private Port port;
|
||||
public Port getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Port port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
private PortType portType;
|
||||
|
||||
|
||||
private String serviceName;
|
||||
|
||||
|
||||
private Date createDate;
|
||||
|
||||
|
||||
private Date updateDate;
|
||||
|
||||
private boolean target;
|
||||
|
||||
public Service() {}
|
||||
|
||||
public Service(Port port, PortType t, String serviceName) {
|
||||
this.port = port;
|
||||
this.portType = t;
|
||||
this.serviceName = serviceName;
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public PortType getPortType() {
|
||||
return portType;
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setPortType(PortType portType) {
|
||||
this.portType = portType;
|
||||
public String getCryptoType() {
|
||||
return cryptoType;
|
||||
}
|
||||
|
||||
public void setCryptoType(String cryptoType) {
|
||||
this.cryptoType = cryptoType;
|
||||
}
|
||||
|
||||
public String getServiceName() {
|
||||
|
@ -62,36 +40,21 @@ public class Service {
|
|||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
|
||||
public Port getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Port port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
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 boolean isTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(boolean target) {
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.loafle.overflow.module.discovery.model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 10. 31.
|
||||
*/
|
||||
|
@ -9,8 +11,7 @@ public class Zone {
|
|||
private String ip;
|
||||
private String iface;
|
||||
private String mac;
|
||||
private long firstScanRange;
|
||||
private long lastScanRange;
|
||||
private Date discoveredDate;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
|
@ -52,19 +53,11 @@ public class Zone {
|
|||
this.mac = mac;
|
||||
}
|
||||
|
||||
public long getFirstScanRange() {
|
||||
return firstScanRange;
|
||||
public Date getDiscoveredDate() {
|
||||
return discoveredDate;
|
||||
}
|
||||
|
||||
public void setFirstScanRange(long firstScanRange) {
|
||||
this.firstScanRange = firstScanRange;
|
||||
}
|
||||
|
||||
public long getLastScanRange() {
|
||||
return lastScanRange;
|
||||
}
|
||||
|
||||
public void setLastScanRange(long lastScanRange) {
|
||||
this.lastScanRange = lastScanRange;
|
||||
public void setDiscoveredDate(Date discoveredDate) {
|
||||
this.discoveredDate = discoveredDate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package com.loafle.overflow.module.discovery.service;
|
||||
|
||||
import com.loafle.overflow.commons.model.SessionMetadata;
|
||||
import com.loafle.overflow.commons.service.MessagePublisher;
|
||||
import com.loafle.overflow.commons.stereotype.ProbeAPI;
|
||||
import com.loafle.overflow.commons.stereotype.WebappAPI;
|
||||
import com.loafle.overflow.module.discovery.model.DiscoveryHost;
|
||||
import com.loafle.overflow.module.discovery.model.DiscoveryPort;
|
||||
import com.loafle.overflow.module.discovery.model.DiscoveryStartInfo;
|
||||
import com.loafle.overflow.module.discovery.model.DiscoveryZone;
|
||||
import com.loafle.overflow.module.discovery.model.Host;
|
||||
import com.loafle.overflow.module.discovery.model.Port;
|
||||
import com.loafle.overflow.module.discovery.model.Zone;
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -49,5 +58,55 @@ public class DiscoveryService {
|
|||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverZone(String probeID, DiscoveryZone discoveryZone) {
|
||||
String requestMemberEmail = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe("/probe", probeID, "DiscoveryService.DiscoverZone", requestMemberEmail, discoveryZone);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverHost(String probeID, Zone zone, DiscoveryHost discoveryHost) {
|
||||
String requestMemberEmail = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe("/probe", probeID, "DiscoveryService.DiscoverHost", requestMemberEmail, zone, discoveryHost);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverPort(String probeID, Host host, DiscoveryPort discoveryPort) {
|
||||
String requestMemberEmail = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe("/probe", probeID, "DiscoveryService.DiscoverPort", requestMemberEmail, host, discoveryPort);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void discoverService(String probeID, Port port, com.loafle.overflow.module.discovery.model.DiscoveryService discoveryService) {
|
||||
String requestMemberEmail = SessionMetadata.getSessionID();
|
||||
|
||||
messagePublisher.publishToProbe("/probe", probeID, "DiscoveryService.DiscoverService", requestMemberEmail, port, discoveryService);
|
||||
}
|
||||
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredZone(String requestMemberEmail, Zone zone) {
|
||||
messagePublisher.publishToMember("/webapp", requestMemberEmail, "DiscoveryService.discoveredZone", zone);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredHost(String requestMemberEmail, Host host) {
|
||||
messagePublisher.publishToMember("/webapp", requestMemberEmail, "DiscoveryService.discoveredHost", host);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredPort(String requestMemberEmail, Port port) {
|
||||
messagePublisher.publishToMember("/webapp", requestMemberEmail, "DiscoveryService.discoveredPort", port);
|
||||
}
|
||||
|
||||
@ProbeAPI
|
||||
public void discoveredService(String requestMemberEmail, com.loafle.overflow.module.discovery.model.Service service) {
|
||||
messagePublisher.publishToMember("/webapp", requestMemberEmail, "DiscoveryService.discoveredService", service);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.loafle.overflow.module.member.service;
|
||||
|
||||
import com.loafle.overflow.commons.model.SessionMetadata;
|
||||
import com.loafle.overflow.commons.stereotype.WebappAPI;
|
||||
import com.loafle.overflow.commons.utils.EmailSender;
|
||||
import com.loafle.overflow.module.apikey.model.ApiKey;
|
||||
import com.loafle.overflow.module.apikey.service.ApiKeyService;
|
||||
|
@ -21,7 +22,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -113,7 +113,6 @@ public class MemberService {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return resMember;
|
||||
}
|
||||
|
||||
|
@ -161,8 +160,9 @@ public class MemberService {
|
|||
// Todo websocket session remove
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public Member modify(Member member, String pw) {
|
||||
String email = SessionMetadata.getEmail();
|
||||
String email = SessionMetadata.getSessionID();
|
||||
Member preMember = this.memberDAO.findByEmail(member.getEmail());
|
||||
|
||||
if (null != pw && !pw.equals("")) {
|
||||
|
@ -227,8 +227,9 @@ public class MemberService {
|
|||
return resMember;
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public void withdrawal(Member member) {
|
||||
String email = SessionMetadata.getEmail();
|
||||
String email = SessionMetadata.getSessionID();
|
||||
|
||||
// Todo DB delete?
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.loafle.overflow.module.noauthprobe.service;
|
||||
|
||||
import com.loafle.overflow.commons.service.MessagePublisher;
|
||||
import com.loafle.overflow.commons.stereotype.ProbeAPI;
|
||||
import com.loafle.overflow.commons.stereotype.WebappAPI;
|
||||
import com.loafle.overflow.module.apikey.model.ApiKey;
|
||||
import com.loafle.overflow.module.apikey.service.ApiKeyService;
|
||||
import com.loafle.overflow.module.domain.model.Domain;
|
||||
|
@ -44,6 +46,7 @@ public class NoAuthProbeService {
|
|||
@Autowired
|
||||
private MessagePublisher messagePublisher;
|
||||
|
||||
@ProbeAPI
|
||||
public NoAuthProbe regist(NoAuthProbe noAuthProbe) {
|
||||
|
||||
noAuthProbe.setTempProbeKey(UUID.randomUUID().toString());
|
||||
|
@ -67,6 +70,7 @@ public class NoAuthProbeService {
|
|||
return this.noAuthProbeDAO.findOne(id);
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public List<NoAuthProbe> acceptNoAuthProbe(NoAuthProbe noAuthProbe) throws IOException {
|
||||
|
||||
// Todo domain injection & member injection
|
||||
|
@ -108,6 +112,7 @@ public class NoAuthProbeService {
|
|||
return this.readAllByDomain(noAuthProbe.getDomain());
|
||||
}
|
||||
|
||||
@WebappAPI
|
||||
public List<NoAuthProbe> denyNoauthProbe(NoAuthProbe noAuthProbe) {
|
||||
this.noAuthProbeDAO.save(noAuthProbe);
|
||||
|
||||
|
|
|
@ -44,177 +44,177 @@ public class TargetDiscoveryService {
|
|||
@Autowired
|
||||
private InfraServiceService infraServiceService;
|
||||
|
||||
@Transactional
|
||||
public boolean saveAllTarget(List<Host> hosts, Probe probe) {
|
||||
// @Transactional
|
||||
// public boolean saveAllTarget(List<Host> hosts, Probe probe) {
|
||||
|
||||
InfraHost infraHost = null;
|
||||
// InfraHost infraHost = null;
|
||||
|
||||
for(Host host : hosts) {
|
||||
// for(Host host : hosts) {
|
||||
|
||||
infraHost = this.createAndReadHost(host, probe);
|
||||
// infraHost = this.createAndReadHost(host, probe);
|
||||
|
||||
this.createPort(infraHost, host, probe);
|
||||
// this.createPort(infraHost, host, probe);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private void createService(InfraHost infraHost, Port port, Probe probe) {
|
||||
// private void createService(InfraHost infraHost, Port port, Probe probe) {
|
||||
|
||||
if(port.getServices() == null) {
|
||||
return;
|
||||
}
|
||||
// if(port.getServices() == null) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
MetaInfraType typeService = new MetaInfraType();
|
||||
typeService.setId(7);
|
||||
// MetaInfraType typeService = new MetaInfraType();
|
||||
// typeService.setId(7);
|
||||
|
||||
String portType = "UDP";
|
||||
// String portType = "UDP";
|
||||
|
||||
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||
portType = "TCP";
|
||||
}
|
||||
// if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||
// portType = "TCP";
|
||||
// }
|
||||
|
||||
for(com.loafle.overflow.module.discovery.model.Service service : port.getServices()) {
|
||||
// for(com.loafle.overflow.module.discovery.model.Service service : port.getServices()) {
|
||||
|
||||
InfraService dbInfraService = this.infraServiceService.readByService(infraHost.getId(), port.getPortNumber(), portType);
|
||||
// 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;
|
||||
}
|
||||
// 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);
|
||||
// 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 (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);
|
||||
}
|
||||
// if(service.isTarget()) {
|
||||
// Target targetService = new Target();
|
||||
// targetService.setDisplayName(service.getServiceName() + "-Service");
|
||||
// this.targetService.regist(targetService);
|
||||
// infraService.setTarget(targetService);
|
||||
// }
|
||||
|
||||
this.infraServiceService.regist(infraService);
|
||||
// this.infraServiceService.regist(infraService);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
private void createPort(InfraHost infraHost, Host host, Probe probe) {
|
||||
// private void createPort(InfraHost infraHost, Host host, Probe probe) {
|
||||
|
||||
if(host.getPorts() == null) {
|
||||
return;
|
||||
}
|
||||
// if(host.getPorts() == null) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
String portType = "UDP";
|
||||
// String portType = "UDP";
|
||||
|
||||
MetaInfraType typePort = new MetaInfraType();
|
||||
typePort.setId(6);
|
||||
// MetaInfraType typePort = new MetaInfraType();
|
||||
// typePort.setId(6);
|
||||
|
||||
InfraOS infraOS = infraHost.getOs();
|
||||
// InfraOS infraOS = infraHost.getOs();
|
||||
|
||||
for(Port port : host.getPorts()) {
|
||||
// for(Port port : host.getPorts()) {
|
||||
|
||||
if(port.getPortType() == PortType.TLS || port.getPortType() == PortType.TCP) {
|
||||
portType = "TCP";
|
||||
}
|
||||
// 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);
|
||||
// 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);
|
||||
}
|
||||
// if (port.getPortType() == PortType.TLS) {
|
||||
// infraOSPort.setTlsType(true);
|
||||
// }
|
||||
// infraOSPort.setVendor(MetaInfraVendor.CreateInfraVendorByPort(port.getPortNumber()));
|
||||
// this.infraOSPortService.regist(infraOSPort);
|
||||
// }
|
||||
|
||||
this.createService(infraHost, port, probe);
|
||||
}
|
||||
}
|
||||
// this.createService(infraHost, port, probe);
|
||||
// }
|
||||
// }
|
||||
|
||||
private InfraHost createAndReadHost(Host host, Probe probe) {
|
||||
// private InfraHost createAndReadHost(Host host, Probe probe) {
|
||||
|
||||
InfraHost infraHost = this.infraHostService.readByIp(host.getIp());
|
||||
if(infraHost != null) {
|
||||
// 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");
|
||||
// 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);
|
||||
}
|
||||
// this.targetService.regist(target);
|
||||
// infraHost.setTarget(target);
|
||||
// this.infraHostService.regist(infraHost);
|
||||
// }
|
||||
|
||||
return infraHost;
|
||||
} else {
|
||||
MetaInfraType typeMachine = new MetaInfraType();
|
||||
typeMachine.setId(1); // 1 = Machine;
|
||||
// return infraHost;
|
||||
// } else {
|
||||
// MetaInfraType typeMachine = new MetaInfraType();
|
||||
// typeMachine.setId(1); // 1 = Machine;
|
||||
|
||||
MetaInfraType typeOS = new MetaInfraType();
|
||||
typeOS.setId(3); // 3 = Os
|
||||
// MetaInfraType typeOS = new MetaInfraType();
|
||||
// typeOS.setId(3); // 3 = Os
|
||||
|
||||
MetaInfraType typeHost = new MetaInfraType();
|
||||
typeHost.setId(2); // 2 = Host
|
||||
// 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);
|
||||
// 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);
|
||||
// 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);
|
||||
// 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");
|
||||
// if(host.isTarget()) {
|
||||
// Target target = new Target();
|
||||
// target.setDisplayName(StringConvertor.intToIp(host.getIp()) + "-Host");
|
||||
|
||||
this.targetService.regist(target);
|
||||
newInfraHost.setTarget(target);
|
||||
}
|
||||
// this.targetService.regist(target);
|
||||
// newInfraHost.setTarget(target);
|
||||
// }
|
||||
|
||||
this.infraHostService.regist(newInfraHost);
|
||||
infraHost = newInfraHost;
|
||||
}
|
||||
// this.infraHostService.regist(newInfraHost);
|
||||
// infraHost = newInfraHost;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return infraHost;
|
||||
}
|
||||
// return infraHost;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ public class ProxyServerInterceptor implements ServerInterceptor {
|
|||
|
||||
@Override
|
||||
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
|
||||
String email = headers.get(SessionMetadata.METADATA_EMAIL_KEY);
|
||||
Context ctx = Context.current().withValue(SessionMetadata.CTX_EMAIL_KEY, email);
|
||||
String sessionID = headers.get(SessionMetadata.METADATA_SESSION_ID_KEY);
|
||||
Context ctx = Context.current().withValue(SessionMetadata.CTX_SESSION_ID_KEY, sessionID);
|
||||
|
||||
return Contexts.interceptCall(ctx, call, headers, next);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user