Commit 70c7b558 authored by David Fernandez Lobon's avatar David Fernandez Lobon

Commit parcial

parent d77177bc
...@@ -163,8 +163,6 @@ public class InitializeController { ...@@ -163,8 +163,6 @@ public class InitializeController {
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
Node saveNode(HttpServletResponse response, HttpServletRequest httpServletRequest, @RequestParam(value = "token"/*, required = false*/) String token) { Node saveNode(HttpServletResponse response, HttpServletRequest httpServletRequest, @RequestParam(value = "token"/*, required = false*/) String token) {
//TODO: Si está detrás de un Proxy (PE: NGINX) habria que obtener la IP de la cabecera si es que se envia
// 'X-Forwarded-For'.
Credentials credential = credentialsRepository.findByToken(token); Credentials credential = credentialsRepository.findByToken(token);
if(credential != null) { if(credential != null) {
......
package adt.mainnode.controller;
import adt.mainnode.dto.Asset;
import adt.mainnode.entity.Credentials;
import adt.mainnode.entity.PortDetection;
import adt.mainnode.repository.CredentialsRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@RestController
@RequestMapping("sniffing")
@Api(
value = "/sniffing",
tags = {"Add data to sniffing snapshots"}
)
@Slf4j
public class NewPortController {
private final CredentialsRepository credentialsRepository;
@Autowired
public NewPortController(CredentialsRepository credentialsRepository) {
this.credentialsRepository = credentialsRepository;
}
@CrossOrigin
@ApiOperation(value = "Save a new set of a list of new ports", response = Long.class)
@ResponseStatus(HttpStatus.CREATED)
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
Long saveAssets(HttpServletResponse response, @RequestBody Asset asset, @RequestParam String token) {
Credentials credential = credentialsRepository.findByToken(token);
if(credential != null && credential.getStatus().equals("OPERATIVE")) {
if(credential.getAvailableEndpoint().contains("(POST) sniffing/")) {
log.info("New assets received");
//Guardar la lista
return null;
}
}
try {
response.sendError(400, "Unrecognized token. Access denied.");
}catch(IOException ioe){
//
}
return null;
}
}
package adt.mainnode.entity;
public class PortDetection {
private String time;
private String ip;
private int port;
private int length;
public PortDetection(String time, String ip, int port, int length) {
this.time = time;
this.ip = ip;
this.port = port;
this.length = length;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
@Override
public String toString() {
return "PortDetection{" +
"time='" + time + '\'' +
", ip='" + ip + '\'' +
", port=" + port +
", length=" + length +
'}';
}
}
package adt.mainnode.service;
public class NewPortServices {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment