use of com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider in project sechub by mercedes-benz.
the class DefaultExecutorConfigSupport method getNamePatternIdProvider.
/**
* Resolves a name pattern provider for given id
*
* @param id
* @param failWhenNotConfigured when <code>false</code> missing name provider
* will be replaced by fallback implementation
* returning always null (nothing configured)
* @return provider never <code>null</code>
* @throws SecHubRuntimeException when name pattern provider cannot be resolved
*/
public NamePatternIdProvider getNamePatternIdProvider(String id, boolean failWhenNotConfigured) {
NamePatternIdProvider provider = namePatternIdProviders.get(id);
if (provider != null) {
return provider;
}
String parameterValue = getParameter(id);
if (parameterValue == null) {
if (failWhenNotConfigured) {
throw new SecHubRuntimeException("No parameter found for necessary mapping key:" + id);
} else {
return FALLBACK_NOT_FOUND_PROVIDER;
}
}
NamePatternIdProvider newProvider = providerFactory.createProvider(id, parameterValue);
namePatternIdProviders.put(id, newProvider);
LOG.debug("Created NamePatternIdProvider:{}", newProvider.getProviderId());
return newProvider;
}
use of com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider in project sechub by mercedes-benz.
the class NamePatternIdProviderFactory method createProvider.
public NamePatternIdProvider createProvider(String id, String parameterValue) {
NamePatternIdProvider provider;
MappingData mappingData = MappingData.fromString(parameterValue);
List<NamePatternToIdEntry> entries = converter.convert(mappingData);
provider = new NamePatternIdProvider(id);
for (NamePatternToIdEntry entry : entries) {
provider.add(entry);
}
return provider;
}
use of com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider in project sechub by mercedes-benz.
the class ScanMappingConfigurationTestJSONasNamePatternDialogAction method execute.
@Override
protected void execute(ActionEvent e) throws Exception {
/* convert to rows */
String json = getMappingUI().getJSON();
MappingIdentifier identifier = resolveMappingIdentifier();
ScanMappingConfiguration config = createScanConfig(json, identifier);
DeveloperToolsScanMappingConfigurationService scanMappingConfigurationService = new DeveloperToolsScanMappingConfigurationService();
scanMappingConfigurationService.switchConfigurationIfChanged(config);
NamePatternIdProvider provider = scanMappingConfigurationService.getNamePatternIdProvider(identifier);
boolean ongoing = true;
while (ongoing) {
/* ui */
Optional<String> value = getDialogUI().getContext().getDialogUI().getUserInput("Enter a name to check", "pattern");
if (!value.isPresent()) {
return;
}
String pattern = value.get();
String id = provider.getIdForName(pattern);
ongoing = getDialogUI().getContext().getDialogUI().confirm("Pattern '" + pattern + "' results in '" + id + "'\n\nDo you want to test another value?");
}
}
use of com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider in project sechub by mercedes-benz.
the class IntegrationTestScanRestController method getIdForNameByProvider.
@SuppressWarnings("deprecation")
@RequestMapping(path = APIConstants.API_ANONYMOUS + "integrationtest/config/namepattern/{namePatternProviderId}/{name}", method = RequestMethod.GET)
public String getIdForNameByProvider(@PathVariable("namePatternProviderId") String namePatternProviderId, @PathVariable("name") String name) {
NamePatternIdProvider provider = scanMappingConfigurationService.getNamePatternIdProvider(namePatternProviderId);
if (provider == null) {
return null;
}
String id = provider.getIdForName(name);
return id;
}
use of com.mercedesbenz.sechub.domain.scan.config.NamePatternIdProvider in project sechub by mercedes-benz.
the class ScanConfigTestJSONasNamePatternDialogAction method execute.
@Override
protected void execute(ActionEvent e) throws Exception {
/* convert to rows */
String json = getMappingUI().getJSON();
MappingIdentifier identifier = resolveMappingIdentifier();
ScanConfig config = createScanConfig(json, identifier);
DeveloperToolsScanConfigService scanConfigService = new DeveloperToolsScanConfigService();
scanConfigService.switchConfigurationIfChanged(config);
NamePatternIdprovider provider = scanConfigService.getNamePatternIdProvider(identifier);
boolean ongoing = true;
while (ongoing) {
/* ui */
Optional<String> value = getDialogUI().getContext().getDialogUI().getUserInput("Enter a name to check", "pattern");
if (!value.isPresent()) {
return;
}
String pattern = value.get();
String id = provider.getIdForName(pattern);
ongoing = getDialogUI().getContext().getDialogUI().confirm("Pattern '" + pattern + "' results in '" + id + "'\n\nDo you want to test another value?");
}
}
Aggregations