コード例 #1
0
 /**
  * Method for save a site's reputation result into external file
  *
  * @param listHistoryReputation
  */
 public static void saveHistoryReputation(
     List<Pair<String, historySitesReputation>> listHistoryReputation) {
   // Write again into external file
   StringBuffer rawContent = new StringBuffer();
   for (int i = 0; i < listHistoryReputation.size(); i++) {
     Pair<String, historySitesReputation> thisHistoryReputation = listHistoryReputation.get(i);
     String sitesName = thisHistoryReputation.getValue0();
     historySitesReputation historyReputation = thisHistoryReputation.getValue1();
     String sitesLabel = historyReputation.getLabelNormality();
     String sitesResponseTime = String.valueOf(historyReputation.getResponseTime());
     String sitesDateMeasure = String.valueOf(historyReputation.getMeasureDate());
     Triplet<Double, Double, Double> sitesComposition =
         historyReputation.getCompositionDangerousity();
     Double malwareComposition = sitesComposition.getValue0();
     Double phishingComposition = sitesComposition.getValue1();
     Double spammingComposition = sitesComposition.getValue2();
     String methodType = historyReputation.getMethodType();
     String reputationType = historyReputation.getReputationType();
     rawContent.append(
         sitesName
             + "*"
             + sitesLabel
             + "*"
             + sitesResponseTime
             + "*"
             + sitesDateMeasure
             + "*"
             + malwareComposition
             + "*"
             + phishingComposition
             + "*"
             + spammingComposition
             + "*"
             + methodType
             + "*"
             + reputationType
             + "\n");
   }
   EksternalFile.saveRawContentToEksternalFile(rawContent.toString(), pathHistoryReputation);
 }
コード例 #2
0
 @Override
 public void initialize(URL location, ResourceBundle resources) {
   // Set measurement result into scene
   domainName.setText(StaticVars.currentDomainName);
   domainNameLabel.setText(StaticVars.currentLabel);
   domainNameResponseTime.setText(StaticVars.currentResponseTime + " second(s)");
   domainNameDateMeasured.setText(String.valueOf(StaticVars.currentDate));
   if (StaticVars.methodType == 1) {
     labelSiteComposition.setVisible(false);
     chartCompositionDangerousity.setVisible(false);
   } else {
     if (StaticVars.currentLabel.equals("normal")) {
       labelSiteComposition.setVisible(false);
       chartCompositionDangerousity.setVisible(false);
     } else {
       if (!StaticVars.currentLabel.equals("malicious (unknown type)")
           && !StaticVars.currentLabel.equals("unknown")) {
         Triplet<Double, Double, Double> compositionDangerousity = StaticVars.currentComposition;
         ObservableList<PieChart.Data> pieChartElements = FXCollections.observableArrayList();
         pieChartElements.addAll(
             new PieChart.Data("Malware", compositionDangerousity.getValue0()),
             new PieChart.Data("Phishing", compositionDangerousity.getValue1()),
             new PieChart.Data("Spamming", compositionDangerousity.getValue2()));
         chartCompositionDangerousity.setData(pieChartElements);
         chartCompositionDangerousity.setLegendSide(Side.RIGHT);
         chartCompositionDangerousity.setLabelLineLength(10);
       } else {
         labelSiteComposition.setVisible(false);
         chartCompositionDangerousity.setVisible(false);
       }
     }
   }
   // Save this reputation result into eksternal file
   historySitesReputation thisResultReputation = new historySitesReputation();
   thisResultReputation.setCompositionDangerousity(StaticVars.currentComposition);
   thisResultReputation.setLabelNormality(StaticVars.currentLabel);
   thisResultReputation.setResponseTime(Long.parseLong(StaticVars.currentResponseTime));
   thisResultReputation.setMeasureDate(StaticVars.currentDate);
   switch (StaticVars.reputationType) {
     case 1:
       thisResultReputation.setReputationType("DNS");
       break;
     case 2:
       thisResultReputation.setReputationType("Spesific");
       break;
     case 3:
       thisResultReputation.setReputationType("Trust");
       break;
     case 4:
       thisResultReputation.setReputationType("DNS+Spesific");
       break;
     case 5:
       thisResultReputation.setReputationType("DNS+Trust");
       break;
     case 6:
       thisResultReputation.setReputationType("Spesific+Trust");
       break;
     case 7:
       thisResultReputation.setReputationType("DNS+Spesific+Trust");
       break;
   }
   switch (StaticVars.methodType) {
     case 1:
       thisResultReputation.setMethodType("supervised");
       break;
     case 2:
       thisResultReputation.setMethodType("unsupervised");
       break;
     case 3:
       thisResultReputation.setMethodType("hybrid");
       break;
   }
   List<Pair<String, historySitesReputation>> oldHistoryReputation =
       reputationResultController.loadHistoryReputation();
   Pair<String, historySitesReputation> addedHistoryReputation =
       new Pair<String, historySitesReputation>(
           StaticVars.currentDomainName, thisResultReputation);
   oldHistoryReputation.add(addedHistoryReputation);
   reputationResultController.saveHistoryReputation(oldHistoryReputation);
 }