use of org.mitre.cybox.objects.CategoryTypeEnum in project metron by apache.
the class AddressHandler method extract.
@Override
public Iterable<LookupKV> extract(final Address type, Map<String, Object> config) throws IOException {
List<LookupKV> ret = new ArrayList<>();
final CategoryTypeEnum category = type.getCategory();
if (!SUPPORTED_CATEGORIES.contains(category)) {
return ret;
}
String typeStr = getType();
if (config != null) {
if (config.containsKey(SPECIFIC_CATEGORY_CONFIG)) {
List<CategoryTypeEnum> categories = new ArrayList<>();
for (String c : Splitter.on(",").split(config.get(SPECIFIC_CATEGORY_CONFIG).toString())) {
categories.add(CategoryTypeEnum.valueOf(c));
}
EnumSet<CategoryTypeEnum> specificCategories = EnumSet.copyOf(categories);
if (!specificCategories.contains(category)) {
return ret;
}
}
if (config.containsKey(TYPE_CONFIG)) {
typeStr = config.get(TYPE_CONFIG).toString();
}
}
StringObjectPropertyType value = type.getAddressValue();
for (String token : StixExtractor.split(value)) {
final String indicatorType = typeStr + ":" + category;
LookupKV results = new LookupKV(new EnrichmentKey(indicatorType, token), new EnrichmentValue(new HashMap<String, Object>() {
{
put("source-type", "STIX");
put("indicator-type", indicatorType);
put("source", type.toXMLString());
}
}));
ret.add(results);
}
return ret;
}
use of org.mitre.cybox.objects.CategoryTypeEnum in project metron by apache.
the class AddressHandler method getPossibleTypes.
@Override
public List<String> getPossibleTypes() {
String typeStr = getType();
List<String> ret = new ArrayList<>();
for (CategoryTypeEnum e : SUPPORTED_CATEGORIES) {
ret.add(typeStr + ":" + e);
}
return ret;
}
Aggregations