Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
C
CUREX
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alberto Blázquez Herranz
CUREX
Commits
70c7b558
Commit
70c7b558
authored
Oct 22, 2020
by
David Fernandez Lobon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit parcial
parent
d77177bc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
2 deletions
+117
-2
src/main/java/adt/mainnode/controller/InitializeController.java
...in/java/adt/mainnode/controller/InitializeController.java
+0
-2
src/main/java/adt/mainnode/controller/NewPortController.java
src/main/java/adt/mainnode/controller/NewPortController.java
+63
-0
src/main/java/adt/mainnode/entity/PortDetection.java
src/main/java/adt/mainnode/entity/PortDetection.java
+50
-0
src/main/java/adt/mainnode/service/NewPortServices.java
src/main/java/adt/mainnode/service/NewPortServices.java
+4
-0
No files found.
src/main/java/adt/mainnode/controller/InitializeController.java
View file @
70c7b558
...
@@ -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
)
{
...
...
src/main/java/adt/mainnode/controller/NewPortController.java
0 → 100644
View file @
70c7b558
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
;
}
}
src/main/java/adt/mainnode/entity/PortDetection.java
0 → 100644
View file @
70c7b558
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
+
'}'
;
}
}
src/main/java/adt/mainnode/service/NewPortServices.java
0 → 100644
View file @
70c7b558
package
adt
.
mainnode
.
service
;
public
class
NewPortServices
{
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment