diff options
Diffstat (limited to 'verigraph/src/main/java/it/polito/escape/verify/validation')
6 files changed, 0 insertions, 224 deletions
diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/DpiValidator.java b/verigraph/src/main/java/it/polito/escape/verify/validation/DpiValidator.java deleted file mode 100644 index 2666755..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/DpiValidator.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation; - -import com.fasterxml.jackson.databind.JsonNode; - -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.validation.exception.ValidationException; - -public class DpiValidator implements ValidationInterface { - - public DpiValidator(){ - - } - - private void validateKey(String key) throws ValidationException { - if (!key.matches("\\w+")) - throw new ValidationException("'" + key + "' is not a valid configuration string for a 'dpi'"); - } - - @Override - public void validate(Graph graph, Node node, Configuration configuration) throws ValidationException { - - JsonNode conf = configuration.getConfiguration(); - - if (!conf.isArray()) { - throw new ValidationException("Configuration of a 'dpi' must be an array"); - } - for (JsonNode key : conf) { - if (!key.isTextual()) - throw new ValidationException("Configuration of a 'dpi' must be an array of strings"); - validateKey(key.asText()); - } - } - -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/EndhostValidator.java b/verigraph/src/main/java/it/polito/escape/verify/validation/EndhostValidator.java deleted file mode 100644 index 3d9eb75..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/EndhostValidator.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation; - -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.validation.exception.ValidationException; - - -public class EndhostValidator implements ValidationInterface { - - @Override - public void validate(Graph graph, Node node, Configuration configuration) throws ValidationException { - - } - -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/ValidationInterface.java b/verigraph/src/main/java/it/polito/escape/verify/validation/ValidationInterface.java deleted file mode 100644 index 25608dd..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/ValidationInterface.java +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation; - -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.validation.exception.ValidationException; - -public interface ValidationInterface { - - void validate(Graph graph, Node node, Configuration configuration) throws ValidationException; - -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/VpnaccessValidator.java b/verigraph/src/main/java/it/polito/escape/verify/validation/VpnaccessValidator.java deleted file mode 100644 index 6abd603..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/VpnaccessValidator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation; - -import com.fasterxml.jackson.databind.JsonNode; - -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.validation.exception.ValidationException; - -public class VpnaccessValidator implements ValidationInterface { - - @Override - public void validate(Graph graph, Node node, Configuration configuration) throws ValidationException { - JsonNode configurationNode = configuration.getConfiguration(); - - if (!configurationNode.isArray()) - throw new ValidationException("configuration must be an array"); - - for (JsonNode object : configurationNode) { - JsonNode vpnexit = object.get("vpnexit"); - if (!vpnexit.isTextual()) - throw new ValidationException("value corresponding to the key 'vpnexit' must be a string"); - validateObject(graph, node, vpnexit.asText()); - } - - } - - private void validateObject(Graph g, Node node, String field) throws ValidationException { - boolean isValid = false; - for (Node n : g.getNodes().values()) { - if ((n.getFunctional_type().equals("vpnexit")) && (n.getName().equals(field))) - isValid = true; - } - - if (!isValid) - throw new ValidationException("'" + field + "' is not a valid value for the configuration of a type '" - + node.getFunctional_type() - + "'. Please use the name of an existing node of type 'vpnexit'."); - - } - -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/VpnexitValidator.java b/verigraph/src/main/java/it/polito/escape/verify/validation/VpnexitValidator.java deleted file mode 100644 index 782e124..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/VpnexitValidator.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation; - -import com.fasterxml.jackson.databind.JsonNode; - -import it.polito.escape.verify.model.Configuration; -import it.polito.escape.verify.model.Graph; -import it.polito.escape.verify.model.Node; -import it.polito.escape.verify.validation.exception.ValidationException; - -public class VpnexitValidator implements ValidationInterface { - - @Override - public void validate(Graph graph, Node node, Configuration configuration) throws ValidationException { - JsonNode configurationNode = configuration.getConfiguration(); - - if (!configurationNode.isArray()) - throw new ValidationException("configuration must be an array"); - - for (JsonNode object : configurationNode) { - JsonNode vpnexit = object.get("vpnaccess"); - if (!vpnexit.isTextual()) - throw new ValidationException("value corresponding to the key 'vpnaccess' must be a string"); - validateObject(graph, node, vpnexit.asText()); - } - - } - - private void validateObject(Graph g, Node node, String field) throws ValidationException { - boolean isValid = false; - for (Node n : g.getNodes().values()) { - if ((n.getFunctional_type().equals("vpnaccess")) && (n.getName().equals(field))) - isValid = true; - } - - if (!isValid) - throw new ValidationException("'" + field + "' is not a valid value for the configuration of a type '" - + node.getFunctional_type() - + "'. Please use the name of an existing node of type 'vpnaccess'."); - - } - -} diff --git a/verigraph/src/main/java/it/polito/escape/verify/validation/exception/ValidationException.java b/verigraph/src/main/java/it/polito/escape/verify/validation/exception/ValidationException.java deleted file mode 100644 index 8b94748..0000000 --- a/verigraph/src/main/java/it/polito/escape/verify/validation/exception/ValidationException.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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.escape.verify.validation.exception; - - -public class ValidationException extends Exception { - - /** - * - */ - private static final long serialVersionUID = -8251271078519549101L; - - private String message; - - public ValidationException(String message){ -// super(message); - this.message = message; - } - - @Override - public String getMessage() { - return this.message; - } -} |