List of usage examples for org.jdom2 Element setText
public Element setText(final String text)
From source file:org.fiware.cybercaptor.server.remediation.cost.GlobalParameters.java
License:Open Source License
/** * Get the dom element related to the global parameters * @return the related XML DOM element//ww w.j a v a 2 s.c om */ public Element toDomElement() { Element root = new Element("global_parameters"); //expensesForIT Element expensesForITElement = new Element("expensesForIT"); expensesForITElement.setText(expensesForIT + ""); root.addContent(expensesForITElement); return root; }
From source file:org.fiware.cybercaptor.server.remediation.cost.OperationalCostParameters.java
License:Open Source License
/** * Function used to save the parameters in DOM Element * * @return the related DOM element/*from ww w . jav a2 s. c om*/ */ public Element toDomElement() { Element root = new Element("operational_cost_parameters"); //businessApplicationsTestsDuration Element businessApplicationsTestsDurationElement = new Element("businessApplicationsTestsDuration"); businessApplicationsTestsDurationElement.setText(getBusinessApplicationsTestsDuration() + ""); root.addContent(businessApplicationsTestsDurationElement); //workCost Element workCostElement = new Element("workCost"); workCostElement.setText(getWorkCost() + ""); root.addContent(workCostElement); //remediationCost Element remediationCostElement = new Element("remediationCost"); remediationCostElement.setText(getRemediationCost() + ""); root.addContent(remediationCostElement); //computationPowerCost Element computationPowerCostElement = new Element("computationPowerCost"); computationPowerCostElement.setText(getComputationPowerCost() + ""); root.addContent(computationPowerCostElement); //storageCost Element storageCostElement = new Element("storageCost"); storageCostElement.setText(getStorageCost() + ""); root.addContent(storageCostElement); //deploymentDuration Element deploymentDurationElement = new Element("deploymentDuration"); deploymentDurationElement.setText(getDeploymentDuration() + ""); root.addContent(deploymentDurationElement); //remediationUninstallDuration Element remediationUninstallDurationElement = new Element("remediationUninstallDuration"); remediationUninstallDurationElement.setText(getRemediationUninstallDuration() + ""); root.addContent(remediationUninstallDurationElement); //serviceUnavailabilityDeploymentDuration Element serviceUnavailabilityDeploymentDurationElement = new Element( "serviceUnavailabilityDeploymentDuration"); serviceUnavailabilityDeploymentDurationElement.setText(getServiceUnavailabilityDeploymentDuration() + ""); root.addContent(serviceUnavailabilityDeploymentDurationElement); //restartCost Element restartCostElement = new Element("restartCost"); restartCostElement.setText(getRestartCost() + ""); root.addContent(restartCostElement); //restartDuration Element restartDurationElement = new Element("restartDuration"); restartDurationElement.setText(getRestartDuration() + ""); root.addContent(restartDurationElement); //usedPower Element usedPowerElement = new Element("usedPower"); usedPowerElement.setText(getUsedPower() + ""); root.addContent(usedPowerElement); //usedStorage Element usedStorageElement = new Element("usedStorage"); usedStorageElement.setText(getUsedStorage() + ""); root.addContent(usedStorageElement); //maintenanceDuration Element maintenanceDurationElement = new Element("maintenanceDuration"); maintenanceDurationElement.setText(getMaintenanceDuration() + ""); root.addContent(maintenanceDurationElement); //skillRateTests Element skillRateTestsElement = new Element("skillRateTests"); skillRateTestsElement.setText(getSkillRateTests() + ""); root.addContent(skillRateTestsElement); //skillRateDeployment Element skillRateDeploymentElement = new Element("skillRateDeployment"); skillRateDeploymentElement.setText(getSkillRateDeployment() + ""); root.addContent(skillRateDeploymentElement); //skillRateMaintenance Element skillRateMaintenanceElement = new Element("skillRateMaintenance"); skillRateMaintenanceElement.setText(getSkillRateMaintenance() + ""); root.addContent(skillRateMaintenanceElement); return root; }
From source file:org.fiware.cybercaptor.server.remediation.DeployableRemediation.java
License:Open Source License
/** * To XML element.// w ww . java2 s. c o m * * @return the dom element corresponding to this deployable remediation */ public Element toXMLElement() { Element root = new Element("remediation"); Element costElement = new Element("cost"); costElement.setText(this.getCost() + ""); root.addContent(costElement); Element habitIndexElement = new Element("habit_index"); habitIndexElement.setText(this.getHabitIndex() + ""); root.addContent(habitIndexElement); //actions Element actionsElement = new Element("remediation_actions"); root.addContent(actionsElement); for (int i = 0; i < getActions().size(); i++) { DeployableRemediationAction action = getActions().get(i); actionsElement.addContent(action.toXMLElement()); } return root; }
From source file:org.fiware.cybercaptor.server.remediation.DeployableRemediationAction.java
License:Open Source License
/** * To xML element./* w ww .j a va2 s .c o m*/ * * @return the dom element corresponding to this deployable remediation action */ public Element toXMLElement() { Element root = new Element("deployable_remediation"); Element machineElement = new Element("machine"); machineElement.setText(this.getHost().getName() + ""); root.addContent(machineElement); //actions Element actionElement = new Element("action"); root.addContent(actionElement); Element typeElement = new Element("type"); actionElement.addContent(typeElement); switch (getRemediationAction().getActionType()) { case APPLY_PATCH: typeElement.setText("patch"); Element patchsElement = new Element("patchs"); actionElement.addContent(patchsElement); for (int i = 0; i < getRemediationAction().getRemediationParameters().size(); i++) { Patch patch = (Patch) getRemediationAction().getRemediationParameters().get(i); Element patchElement = new Element("patch"); patchElement.setText(patch.getLink()); patchsElement.addContent(patchElement); } break; case DEPLOY_FIREWALL_RULE: typeElement.setText("firewall-rule"); Element fwRuleElement = new Element("rule"); actionElement.addContent(fwRuleElement); fwRuleElement.setText( ((FirewallRule) getRemediationAction().getRemediationParameters().get(0)).toIptablesAddRule()); break; case DEPLOY_SNORT_RULE: typeElement.setText("snort-rules"); Element snortRulesElement = new Element("rules"); actionElement.addContent(snortRulesElement); for (int i = 0; i < getRemediationAction().getRemediationParameters().size(); i++) { Rule rule = (Rule) getRemediationAction().getRemediationParameters().get(i); Element snortRuleElement = new Element("rule"); snortRulesElement.addContent(snortRuleElement); snortRuleElement.setText(rule.getRule()); } break; default: typeElement.setText("no-remediation"); break; } return root; }
From source file:org.fiware.cybercaptor.server.scoring.gui.Launch.java
License:Open Source License
/** * Save the list of attack paths into a XML file * * @param filePath the paths where the list XML of attack paths can be written * @param AttackPaths list of attack paths * @throws Exception//ww w . j a v a2s.c o m */ protected static void saveToXmlFile(String filePath, Graph[] AttackPaths) throws Exception { XMLOutputter output = new XMLOutputter(Format.getPrettyFormat()); Element MainRoot = new Element("attack_paths"); Element root; if (AttackPaths != null) { for (Graph AttackPathBuffer : AttackPaths) { Arc[] AttackPathArcs = AttackPathBuffer.getArcs(); root = new Element("attack_path"); Element scoringElement = new Element("scoring"); scoringElement.setText(String.valueOf(formulas.MinMax(formulas.globalScore(AttackPathBuffer), AttackPathBuffer.getVertices().length))); root.addContent(scoringElement); if (AttackPathArcs != null) { Element arcsElement = new Element("arcs"); for (Arc AttackPathArc : AttackPathArcs) { Element arcElement = new Element("arc"); arcsElement.addContent(arcElement); Element srcElement = new Element("src"); srcElement.setText(String.valueOf(AttackPathArc.getSource())); arcElement.addContent(srcElement); Element dstElement = new Element("dst"); dstElement.setText(String.valueOf(AttackPathArc.getDestination())); arcElement.addContent(dstElement); } root.addContent(arcsElement); MainRoot.addContent(root); } } } output.output(MainRoot, new FileOutputStream(filePath)); }
From source file:org.fiware.cybercaptor.server.topology.asset.component.FirewallRule.java
License:Open Source License
/** * @return the dom element corresponding to this firewall rule in XML *//*from www . j av a 2s . c o m*/ public Element toDomXMLElement() { Element root = new Element("firewall-rule"); Element protocolElement = new Element("protocol"); root.addContent(protocolElement); protocolElement.setText(this.getProtocol().toString().toUpperCase()); Element sourceIPElement = new Element("source-ip"); root.addContent(sourceIPElement); sourceIPElement.setText(this.getSource().getAddress()); Element sourceMaskElement = new Element("source-mask"); root.addContent(sourceMaskElement); sourceMaskElement.setText(this.getSourceMask().getAddress()); Element sourcePortElement = new Element("source-port"); root.addContent(sourcePortElement); sourcePortElement.setText(this.getSourcePortRange().toString()); Element destinationIPElement = new Element("destination-ip"); root.addContent(destinationIPElement); destinationIPElement.setText(this.getDestination().getAddress()); Element destinationMaskElement = new Element("destination-mask"); root.addContent(destinationMaskElement); destinationMaskElement.setText(this.getDestinationMask().getAddress()); Element destinationPortElement = new Element("destination-port"); root.addContent(destinationPortElement); destinationPortElement.setText(this.getDestinationPortRange().toString()); Element actionElement = new Element("action"); root.addContent(actionElement); actionElement.setText(this.getAction().toString().toUpperCase()); return root; }
From source file:org.fiware.cybercaptor.server.topology.asset.component.FirewallRulesTable.java
License:Open Source License
/** * @return the dom element corresponding to this firewall rules tables in XML *///from w w w. j a v a 2s . co m public Element toDomXMLElement() { Element root; if (isInput) root = new Element("input-firewall"); else root = new Element("output-firewall"); Element defaultElement = new Element("default-policy"); root.addContent(defaultElement); defaultElement.setText(this.getDefaultAction().toString().toUpperCase()); //Firwall rules for (int i = 0; i < this.getRuleList().size(); i++) { FirewallRule rule = this.getRuleList().get(i); root.addContent(rule.toDomXMLElement()); } return root; }
From source file:org.fiware.cybercaptor.server.topology.asset.component.Interface.java
License:Open Source License
/** * @return the dom element corresponding to this interface in XML *///from w w w . ja v a 2s .co m public Element toDomElement() { Element root = new Element("interface"); Element intfaceNameElement = new Element("name"); intfaceNameElement.setText(this.getName()); root.addContent(intfaceNameElement); root.addContent(this.vlan.toDOMElement()); Element intfaceIpaddressElement = new Element("ipaddress"); intfaceIpaddressElement.setText(this.getAddress().getAddress()); root.addContent(intfaceIpaddressElement); if (getNetwork() != null) { Element networkIpaddressElement = new Element("network"); networkIpaddressElement.setText(getNetwork().getAddress().getAddress()); root.addContent(networkIpaddressElement); Element maskElement = new Element("mask"); maskElement.setText(getNetwork().getMask().getAddress()); root.addContent(maskElement); } Element intfaceDirectlyConnectedElement = new Element("directly-connected"); root.addContent(intfaceDirectlyConnectedElement); for (int i = 0; i < this.getDirectlyAccessibleInterface().size(); i++) { Element ipAddressElement = new Element("ipaddress"); ipAddressElement.setText(this.getDirectlyAccessibleInterface().get(i).getAddress().getAddress()); intfaceDirectlyConnectedElement.addContent(ipAddressElement); } if (this.isConnectedToTheInternet()) { Element internetElement = new Element("internet"); intfaceDirectlyConnectedElement.addContent(internetElement); } return root; }
From source file:org.fiware.cybercaptor.server.topology.asset.component.Route.java
License:Open Source License
/** * To dom xML element./*w ww . j a va2s . c o m*/ * * @return the dom element corresponding to this route */ public Element toDomXMLElement() { Element root = new Element("route"); Element destinationElement = new Element("destination"); destinationElement.setText(this.getDestination().getAddress()); root.addContent(destinationElement); Element maskElement = new Element("mask"); maskElement.setText(this.getMask().getAddress()); root.addContent(maskElement); Element gatewayElement = new Element("gateway"); gatewayElement.setText(this.getGateway().getAddress()); root.addContent(gatewayElement); Element interfaceElement = new Element("interface"); interfaceElement.setText(this.getIntface().getName()); root.addContent(interfaceElement); return root; }
From source file:org.fiware.cybercaptor.server.topology.asset.VLAN.java
License:Open Source License
/** * To dOM element./*from ww w.j av a 2 s . com*/ * * @return the element */ public Element toDOMElement() { Element root = new Element("vlan"); Element vlanNameElement = new Element("name"); vlanNameElement.setText(this.name); root.addContent(vlanNameElement); Element vlanLabelElement = new Element("label"); vlanLabelElement.setText(this.label); root.addContent(vlanLabelElement); return root; }