@Override public Pair<Byte, Byte> getCode(Class serializedClass) throws MissingException { rwLock.readLock().lock(); try { Triplet<Class, Byte, Byte> multiplexInfo = classToBCode.get(serializedClass); if (multiplexInfo == null) { throw new MissingException(); } return multiplexInfo.removeFrom0(); } finally { rwLock.readLock().unlock(); } }
/** Register custom classes to serializes with gryo using default serialization. */ public Builder addCustom(final Class... custom) { if (custom != null && custom.length > 0) serializationList.addAll( Arrays.asList(custom) .stream() .map( c -> Triplet.<Class, Function<Kryo, Serializer>, Integer>with( c, null, currentSerializationId.getAndIncrement())) .collect(Collectors.<Triplet<Class, Function<Kryo, Serializer>, Integer>>toList())); return this; }
/** * 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); }
@Override public Serializer getSerializer(Class aliasedClass, byte aliasCode, byte multiplexCode) throws MissingException { rwLock.readLock().lock(); try { Class multiplexClass = bcodeToClass.get(Triplet.with(aliasedClass, aliasCode, multiplexCode)); if (multiplexClass == null) { throw new MissingException(); } Serializer serializer = serializers.get(multiplexClass); if (serializer == null) { throw new MissingException(); } return serializer; } finally { rwLock.readLock().unlock(); } }
@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); }
/** * Register a custom class to serialize with a custom serializer as returned from a {@link * Function}. */ public Builder addCustom(final Class clazz, final Function<Kryo, Serializer> serializer) { serializationList.add( Triplet.with(clazz, serializer, currentSerializationId.getAndIncrement())); return this; }
{ add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(byte[].class, null, 25)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(char[].class, null, 26)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(short[].class, null, 27)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(int[].class, null, 28)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(long[].class, null, 29)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(float[].class, null, 30)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(double[].class, null, 31)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(String[].class, null, 32)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Object[].class, null, 33)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ArrayList.class, null, 10)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( BigInteger.class, null, 34)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( BigDecimal.class, null, 35)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Calendar.class, null, 39)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Class.class, null, 41)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collection.class, null, 37)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.EMPTY_LIST.getClass(), null, 51)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.EMPTY_MAP.getClass(), null, 52)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.EMPTY_SET.getClass(), null, 53)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.singleton(null).getClass(), null, 54)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.singletonList(null).getClass(), null, 24)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Collections.singletonMap(null, null).getClass(), null, 23)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Contains.class, null, 49)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Currency.class, null, 40)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Date.class, null, 38)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Direction.class, null, 12)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DetachedEdge.class, null, 21)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DetachedVertexProperty.class, null, 20)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DetachedProperty.class, null, 18)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DetachedVertex.class, null, 19)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DetachedPath.class, null, 60)); // skip 14 add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(EnumSet.class, null, 46)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(HashMap.class, null, 11)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( HashMap.Entry.class, null, 16)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( KryoSerializable.class, null, 36)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( LinkedHashMap.class, null, 47)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( LinkedHashSet.class, null, 71)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( LINKED_HASH_MAP_ENTRY_CLASS, null, 15)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Locale.class, null, 22)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( StringBuffer.class, null, 43)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( StringBuilder.class, null, 44)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(T.class, null, 48)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TimeZone.class, null, 42)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TreeMap.class, null, 45)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(TreeSet.class, null, 50)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( UUID.class, kryo -> new UUIDSerializer(), 17)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( URI.class, kryo -> new URISerializer(), 72)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( VertexTerminator.class, null, 13)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ReferenceEdge.class, null, 81)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ReferenceVertexProperty.class, null, 82)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ReferenceProperty.class, null, 83)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ReferenceVertex.class, null, 84)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( ReferencePath.class, null, 85)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( StarGraph.class, kryo -> StarGraphGryoSerializer.with(Direction.BOTH), 86)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Edge.class, kryo -> new GryoSerializers.EdgeSerializer(), 65)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Vertex.class, kryo -> new GryoSerializers.VertexSerializer(), 66)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Property.class, kryo -> new GryoSerializers.PropertySerializer(), 67)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( VertexProperty.class, kryo -> new GryoSerializers.VertexPropertySerializer(), 68)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Path.class, kryo -> new GryoSerializers.PathSerializer(), 59)); // skip 55 add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( B_O_Traverser.class, null, 75)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( O_Traverser.class, null, 76)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( B_LP_O_P_S_SE_SL_Traverser.class, null, 77)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( B_O_S_SE_SL_Traverser.class, null, 78)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( B_LP_O_S_SE_SL_Traverser.class, null, 87)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( TraverserSet.class, null, 58)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(Tree.class, null, 61)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(HashSet.class, null, 62)); add(Triplet.<Class, Function<Kryo, Serializer>, Integer>with(BulkSet.class, null, 64)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( MutableMetrics.class, null, 69)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( StandardTraversalMetrics.class, null, 70)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( MapMemory.class, null, 73)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( MapReduce.NullObject.class, null, 74)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( AtomicLong.class, null, 79)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( DependantMutableMetrics.class, null, 80)); add( Triplet.<Class, Function<Kryo, Serializer>, Integer>with( Pair.class, kryo -> new PairSerializer(), 88)); // ***LAST ID** }