@Test void filterNoEntities() { PrivateKeyFilter filter = new PrivateKeyFilter(); Bundle filteredBundle = new Bundle(); Bundle bundle = FilterTestUtils.getBundle(); bundle.setDependencyMap(Collections.emptyMap()); List<PrivateKey> filteredEntities = filter.filter("/my/folder/path", new FilterConfiguration(), bundle, filteredBundle); assertEquals(0, filteredEntities.size()); }
@Override @SuppressWarnings("squid:S1157") public List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Stream<PrivateKey> stream = DependencyUtils.filterDependencies(PrivateKey.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())).stream(); if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())); } if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())); } List<PrivateKey> privateKeys = stream.collect(Collectors.toList()); DependencyUtils.validateEntitiesInList(privateKeys, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Private Key(s)"); return privateKeys; }
PrivateKeyFilter implements EntityFilter<PrivateKey> { @Override @SuppressWarnings("squid:S1157") public List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Stream<PrivateKey> stream = DependencyUtils.filterDependencies(PrivateKey.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())).stream(); if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())); } if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())); } List<PrivateKey> privateKeys = stream.collect(Collectors.toList()); DependencyUtils.validateEntitiesInList(privateKeys, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Private Key(s)"); return privateKeys; } }
PrivateKeyFilter implements EntityFilter<PrivateKey> { @Override @SuppressWarnings("squid:S1157") public List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Stream<PrivateKey> stream = DependencyUtils.filterDependencies(PrivateKey.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())).stream(); if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())); } if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())); } List<PrivateKey> privateKeys = stream.collect(Collectors.toList()); DependencyUtils.validateEntitiesInList(privateKeys, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Private Key(s)"); return privateKeys; }  }
PrivateKeyFilter implements EntityFilter<PrivateKey> { @Override @SuppressWarnings("squid:S1157") public List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Stream<PrivateKey> stream = DependencyUtils.filterDependencies(PrivateKey.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())).stream(); if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())); } if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())); } List<PrivateKey> privateKeys = stream.collect(Collectors.toList()); DependencyUtils.validateEntitiesInList(privateKeys, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Private Key(s)"); return privateKeys; }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override @SuppressWarnings("squid:S1157") List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle); @Override String getFilterableEntityName(); }
PrivateKeyFilter implements EntityFilter<PrivateKey> { @Override @SuppressWarnings("squid:S1157") public List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle) { Stream<PrivateKey> stream = DependencyUtils.filterDependencies(PrivateKey.class, bundle, filteredBundle, e -> filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(e.getName())).stream(); if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toUpperCase())); } if (!filterConfiguration.getRequiredEntityNames(ENTITY_NAME).contains(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())) { stream = stream .filter(p -> !p.getName().equals(SSL_DEFAULT_PRIVATE_KEY.toLowerCase())); } List<PrivateKey> privateKeys = stream.collect(Collectors.toList()); DependencyUtils.validateEntitiesInList(privateKeys, filterConfiguration.getRequiredEntityNames(ENTITY_NAME), "Private Key(s)"); return privateKeys; }  @Override @NotNull Collection<Class<? extends EntityFilter>> getDependencyEntityFilters(); @Override @SuppressWarnings("squid:S1157") List<PrivateKey> filter(String folderPath, FilterConfiguration filterConfiguration, Bundle bundle, Bundle filteredBundle); @Override String getFilterableEntityName();  }