summaryrefslogtreecommitdiffstats
path: root/verigraph/src/it/polito/verigraph/model
diff options
context:
space:
mode:
Diffstat (limited to 'verigraph/src/it/polito/verigraph/model')
-rw-r--r--verigraph/src/it/polito/verigraph/model/Configuration.java72
-rw-r--r--verigraph/src/it/polito/verigraph/model/Entry.java36
-rw-r--r--verigraph/src/it/polito/verigraph/model/ErrorMessage.java60
-rw-r--r--verigraph/src/it/polito/verigraph/model/Graph.java101
-rw-r--r--verigraph/src/it/polito/verigraph/model/Link.java70
-rw-r--r--verigraph/src/it/polito/verigraph/model/Neighbour.java69
-rw-r--r--verigraph/src/it/polito/verigraph/model/Node.java151
-rw-r--r--verigraph/src/it/polito/verigraph/model/Test.java61
-rw-r--r--verigraph/src/it/polito/verigraph/model/Verification.java67
9 files changed, 687 insertions, 0 deletions
diff --git a/verigraph/src/it/polito/verigraph/model/Configuration.java b/verigraph/src/it/polito/verigraph/model/Configuration.java
new file mode 100644
index 0000000..ecd0e7e
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Configuration.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import it.polito.verigraph.deserializer.ConfigurationCustomDeserializer;
+import it.polito.verigraph.serializer.CustomConfigurationSerializer;
+
+@XmlRootElement
+@ApiModel("Configuration")
+@JsonSerialize(using = CustomConfigurationSerializer.class)
+@JsonDeserialize(using = ConfigurationCustomDeserializer.class)
+public class Configuration {
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private String id;
+
+ @ApiModelProperty(required = false)
+ @XmlTransient
+ private String description= "";
+
+ @ApiModelProperty(required = true)
+ private JsonNode configuration;
+
+ public Configuration() {
+
+ }
+
+ public Configuration(String id, String description, JsonNode configuration) {
+ this.id = id;
+ this.description = description;
+ this.configuration = configuration;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public JsonNode getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(JsonNode configuration) {
+ this.configuration = configuration;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Entry.java b/verigraph/src/it/polito/verigraph/model/Entry.java
new file mode 100644
index 0000000..5f46945
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Entry.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+public class Entry {
+ private String direction;
+ private String destination;
+
+ public Entry(String direction, String destination) {
+ this.direction = direction;
+ this.destination = destination;
+ }
+
+ public String getDirection() {
+ return direction;
+ }
+
+ public void setDirection(String direction) {
+ this.direction = direction;
+ }
+
+ public String getDestination() {
+ return destination;
+ }
+
+ public void setDestination(String destination) {
+ this.destination = destination;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/ErrorMessage.java b/verigraph/src/it/polito/verigraph/model/ErrorMessage.java
new file mode 100644
index 0000000..e4aef4d
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/ErrorMessage.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Error")
+@XmlRootElement
+public class ErrorMessage {
+
+ @ApiModelProperty(example = "Error message")
+ private String errorMessage;
+ @ApiModelProperty(allowableValues = "400,403,404,500", value = "HTTP error code", example = "[400,403,404,500]")
+ private int errorCode;
+ @ApiModelProperty(example = "http://localhost:8080/verigraph/api-docs/")
+ private String documentation;
+
+ public ErrorMessage() {
+
+ }
+
+ public ErrorMessage(String errorMessage, int errorCode, String documentation) {
+ this.errorMessage = errorMessage;
+ this.errorCode = errorCode;
+ this.documentation = documentation;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getDocumentation() {
+ return documentation;
+ }
+
+ public void setDocumentation(String documentation) {
+ this.documentation = documentation;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Graph.java b/verigraph/src/it/polito/verigraph/model/Graph.java
new file mode 100644
index 0000000..22b4907
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Graph.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import it.polito.verigraph.deserializer.GraphCustomDeserializer;
+import it.polito.verigraph.serializer.CustomMapSerializer;
+
+@ApiModel(value = "Graph")
+@XmlRootElement
+@JsonDeserialize(using = GraphCustomDeserializer.class)
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class Graph {
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private long id;
+
+ @ApiModelProperty(name = "nodes", notes = "Nodes", dataType = "List[it.polito.verigraph.model.Node]")
+ private Map<Long, Node>nodes= new HashMap<Long, Node>();
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private Set<Link>links= new HashSet<Link>();
+
+ public Graph() {
+
+ }
+
+ public Graph(long id) {
+ this.id = id;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ @JsonSerialize(using = CustomMapSerializer.class)
+ public Map<Long, Node> getNodes() {
+ return nodes;
+ }
+
+ public void setNodes(Map<Long, Node> nodes) {
+ this.nodes = nodes;
+ }
+
+ @XmlTransient
+ public Set<Link> getLinks() {
+ return links;
+ }
+
+ public void setLinks(Set<Link> links) {
+ this.links = links;
+ }
+
+ public void addLink(String url, String rel) {
+ Link link = new Link();
+ link.setLink(url);
+ link.setRel(rel);
+ links.add(link);
+ }
+
+ public Node searchNodeByName(String name) {
+ for (Node node : this.nodes.values()) {
+ if (node.getName().equals(name))
+ return node;
+ }
+ return null;
+ }
+
+ public int nodesWithName(String name) {
+ int occurrences = 0;
+ for (Node node : this.nodes.values()) {
+ if (node.getName().equals(name))
+ occurrences++;
+
+ }
+ return occurrences;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Link.java b/verigraph/src/it/polito/verigraph/model/Link.java
new file mode 100644
index 0000000..d17880b
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Link.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Link")
+public class Link {
+ @ApiModelProperty(required = false, hidden = true)
+ private String link;
+ @ApiModelProperty(required = false, hidden = true)
+ private String rel;
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getRel() {
+ return rel;
+ }
+
+ public void setRel(String rel) {
+ this.rel = rel;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((link == null) ? 0 : link.hashCode());
+ result = prime * result + ((rel == null) ? 0 : rel.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Link other = (Link) obj;
+ if (link == null) {
+ if (other.link != null)
+ return false;
+ }
+ else if (!link.equals(other.link))
+ return false;
+ if (rel == null) {
+ if (other.rel != null)
+ return false;
+ }
+ else if (!rel.equals(other.rel))
+ return false;
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Neighbour.java b/verigraph/src/it/polito/verigraph/model/Neighbour.java
new file mode 100644
index 0000000..2c0a406
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Neighbour.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import javax.xml.bind.annotation.XmlTransient;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Neighbour")
+public class Neighbour {
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private long id;
+
+ @ApiModelProperty(required = true,
+ example = "nat",
+ value = "The neighbour name must refer to an existing node of the same graph")
+ private String name;
+
+ public Neighbour() {
+
+ }
+
+ public Neighbour(long id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ else
+ return false;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Node.java b/verigraph/src/it/polito/verigraph/model/Node.java
new file mode 100644
index 0000000..4d54ffd
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Node.java
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import it.polito.verigraph.deserializer.NodeCustomDeserializer;
+import it.polito.verigraph.serializer.CustomMapSerializer;
+
+@ApiModel(value = "Node")
+@XmlRootElement
+@JsonDeserialize(using = NodeCustomDeserializer.class)
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+public class Node {
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private long id;
+
+ @ApiModelProperty(required = true, example = "ep", value = "The name of the node can be any string")
+ private String name;
+
+ @ApiModelProperty(required = true,
+ example = "endpoint",
+ value = "The functional types that are currently supported are: endpoint, firewall, nat, antispam, webclient, webserver, mailclient, mailserver")
+ private String functional_type;
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private Configuration configuration= new Configuration();
+
+ @ApiModelProperty(name = "neighbours",
+ notes = "Neighbours",
+ dataType = "List[it.polito.verigraph.model.Neighbour]")
+ private Map<Long, Neighbour>neighbours= new HashMap<Long, Neighbour>();
+
+ @ApiModelProperty(required = false, hidden = true)
+ @XmlTransient
+ private Set<Link>links= new HashSet<>();
+
+ public Node() {
+
+ }
+
+ public Node(long id, String name, String functional_type, Configuration configuration) {
+ this.id = id;
+ this.name = name;
+ this.functional_type = functional_type;
+ this.configuration = configuration;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getFunctional_type() {
+ return functional_type;
+ }
+
+ public void setFunctional_type(String functional_type) {
+ this.functional_type = functional_type;
+ }
+
+ // @XmlTransient
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ @JsonSerialize(using = CustomMapSerializer.class)
+ public Map<Long, Neighbour> getNeighbours() {
+ return neighbours;
+ }
+
+ public void setNeighbours(Map<Long, Neighbour> neighbours) {
+ this.neighbours = neighbours;
+ }
+
+ public long getId() {
+ return this.id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Set<Link> getLinks() {
+ return links;
+ }
+
+ public void setLinks(Set<Link> links) {
+ this.links = links;
+ }
+
+ public void addLink(String url, String rel) {
+ Link link = new Link();
+ link.setLink(url);
+ link.setRel(rel);
+ links.add(link);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ else
+ return false;
+ }
+
+ public Neighbour searchNeighbourByName(String name) {
+ for (Neighbour neighbour : this.neighbours.values()) {
+ if (neighbour.getName().equals(name))
+ return neighbour;
+ }
+ return null;
+ }
+
+} \ No newline at end of file
diff --git a/verigraph/src/it/polito/verigraph/model/Test.java b/verigraph/src/it/polito/verigraph/model/Test.java
new file mode 100644
index 0000000..4dc44f0
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Test.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Test {
+ private List<Node> nodes= new ArrayList<Node>();
+ private String result;
+
+ public Test() {
+
+ }
+
+ public Test(List<Node> paths, int result) {
+ switch (result) {
+ case 0:
+ this.result = "SAT";
+ break;
+ case -1:
+ this.result = "UNSAT";
+ break;
+ case -2:
+ this.result = "UNKNOWN";
+ break;
+ default:
+ this.result = "UNKNWON";
+ break;
+ }
+ this.nodes = paths;
+ }
+
+ public Test(List<Node> paths, String result) {
+ this.nodes = paths;
+ this.result = result;
+ }
+
+ public List<Node> getPath() {
+ return nodes;
+ }
+
+ public void setPath(List<Node> paths) {
+ this.nodes = paths;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+}
diff --git a/verigraph/src/it/polito/verigraph/model/Verification.java b/verigraph/src/it/polito/verigraph/model/Verification.java
new file mode 100644
index 0000000..1dad96e
--- /dev/null
+++ b/verigraph/src/it/polito/verigraph/model/Verification.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Politecnico di Torino and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+package it.polito.verigraph.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+@ApiModel(value = "Policy verification")
+public class Verification {
+
+ @ApiModelProperty(example = "SAT | UNSAT | UNKNOWN")
+ private String result;
+ private String comment;
+ private List<Test> tests= new ArrayList<Test>();
+
+ public Verification() {
+
+ }
+
+ public Verification(String result) {
+ this.result = result;
+ }
+
+ public Verification(String result, List<Test> tests, String comment){
+ this.result = result;
+ this.tests = tests;
+ this.comment = comment;
+ }
+
+ public Verification(String result, String comment){
+ this.result = result;
+ this.comment = comment;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public void setResult(String result) {
+ this.result = result;
+ }
+
+ public List<Test> getTests() {
+ return tests;
+ }
+
+ public void setTests(List<Test> tests) {
+ this.tests = tests;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+} \ No newline at end of file