use of com.xebia.vulnmanager.models.nmap.objects.StateDetails in project vulnmanager by xebia-research.
the class HostsParserHelper method parseHostDataFromNodeList.
private Host parseHostDataFromNodeList(NodeList hostDataList) {
StateDetails stateDetails = null;
AddressDetails addressDetails = null;
HostNamesDetails hostNamesDetails = null;
HostPorts hostPorts = null;
TimingData timingData = null;
for (int x = 0; x < hostDataList.getLength(); x++) {
Node currentHostDetail = hostDataList.item(x);
NamedNodeMap currentChildAttributes = currentHostDetail.getAttributes();
String currentNodeName = currentHostDetail.getNodeName();
switch(currentNodeName) {
case NMapConstants.PARSER_LITERAL_STATUS:
stateDetails = getStatusDetails(currentChildAttributes);
break;
case NMapConstants.PARSER_LITERAL_ADDRESS:
addressDetails = getAddressDetails(currentChildAttributes);
break;
case NMapConstants.PARSER_LITERAL_HOST_NAMES:
hostNamesDetails = getHostNamesDetails(currentHostDetail.getChildNodes());
break;
case NMapConstants.PARSER_LITERAL_PORTS:
hostPorts = getPortDetails(currentHostDetail.getChildNodes());
break;
case NMapConstants.PARSER_LITERAL_TIMES:
timingData = getTimingData(currentChildAttributes);
break;
default:
break;
}
}
return new Host(stateDetails, addressDetails, hostNamesDetails, hostPorts, timingData);
}
use of com.xebia.vulnmanager.models.nmap.objects.StateDetails in project vulnmanager by xebia-research.
the class HostsParserHelper method getPort.
private HostPorts.Port getPort(Node currentNode) {
NamedNodeMap portAttributesNode = currentNode.getAttributes();
String protocol = portAttributesNode.getNamedItem(NMapConstants.PARSER_LITERAL_PROTOCOL).getNodeValue();
String portId = portAttributesNode.getNamedItem(NMapConstants.PARSER_LITERAL_PORTID).getNodeValue();
StateDetails stateDetails = null;
ServiceDetails serviceDetails = null;
NodeList portChildNodes = currentNode.getChildNodes();
for (int i = 0; i < portChildNodes.getLength(); i++) {
Node currentChildNode = portChildNodes.item(i);
NamedNodeMap portAttributes = currentChildNode.getAttributes();
if (currentChildNode.getNodeName().equals(NMapConstants.PARSER_LITERAL_STATE)) {
stateDetails = getStateDetails(portAttributes);
} else if (currentChildNode.getNodeName().equals(NMapConstants.PARSER_LITERAL_SERVICE)) {
serviceDetails = getServiceDetails(portAttributes);
}
}
return new HostPorts.Port(protocol, portId, stateDetails, serviceDetails);
}
Aggregations