use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class ProxyManager method createProxyInfoForHost.
public ProxyInfo createProxyInfoForHost(String proxyHostCandidate) throws IllegalArgumentException {
Optional<SettingsProxyModel> optionalSettingsConfiguration = settingsUtility.getConfiguration();
if (optionalSettingsConfiguration.isPresent()) {
SettingsProxyModel settingsProxyModel = optionalSettingsConfiguration.get();
List<String> nonProxyHosts = settingsProxyModel.getNonProxyHosts().orElse(List.of());
NonProxyHostChecker nonProxyHostChecker = new NonProxyHostChecker(nonProxyHosts);
if (StringUtils.isNotBlank(proxyHostCandidate) && nonProxyHostChecker.isNonProxyHost(proxyHostCandidate)) {
return ProxyInfo.NO_PROXY_INFO;
}
return createProxyInfo(settingsProxyModel);
}
return ProxyInfo.NO_PROXY_INFO;
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyConfigAccessor method createConfigModel.
private SettingsProxyModel createConfigModel(SettingsProxyConfigurationEntity proxyConfiguration) {
SettingsProxyModel newModel = new SettingsProxyModel();
String createdAtFormatted = null;
String lastUpdatedFormatted = null;
if (null != proxyConfiguration) {
createdAtFormatted = DateUtils.formatDate(proxyConfiguration.getCreatedAt(), DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
if (null != proxyConfiguration.getLastUpdated()) {
lastUpdatedFormatted = DateUtils.formatDate(proxyConfiguration.getLastUpdated(), DateUtils.UTC_DATE_FORMAT_TO_MINUTE);
}
newModel.setId(String.valueOf(proxyConfiguration.getConfigurationId()));
newModel.setName(proxyConfiguration.getName());
newModel.setProxyHost(proxyConfiguration.getHost());
newModel.setProxyPort(proxyConfiguration.getPort());
newModel.setProxyUsername(proxyConfiguration.getUsername());
String proxyPassword = proxyConfiguration.getPassword();
boolean doesPasswordExist = StringUtils.isNotBlank(proxyPassword);
newModel.setIsProxyPasswordSet(doesPasswordExist);
if (doesPasswordExist) {
newModel.setProxyPassword(encryptionUtility.decrypt(proxyPassword));
}
newModel.setNonProxyHosts(getNonProxyHosts(proxyConfiguration.getNonProxyHosts()));
}
newModel.setCreatedAt(createdAtFormatted);
newModel.setLastUpdated(lastUpdatedFormatted);
return newModel;
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class ProxyConfigurationModelSaveActions method convertModelAndPerformAction.
private void convertModelAndPerformAction(ConfigurationModel configurationModel, Function<SettingsProxyModel, ActionResponse<SettingsProxyModel>> configAction) {
Optional<SettingsProxyModel> settingsProxyModel = proxyFieldModelConverter.convert(configurationModel);
if (settingsProxyModel.isPresent()) {
SettingsProxyModel model = settingsProxyModel.get();
model.setName(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
configAction.apply(model);
}
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyControllerTestIT method testValidate.
@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
public void testValidate() throws Exception {
SettingsProxyModel settingsProxyModel = createSettingsProxyModel(AlertRestConstants.DEFAULT_CONFIGURATION_NAME);
String url = AlertRestConstants.SETTINGS_PROXY_PATH + "/validate";
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf()).content(gson.toJson(settingsProxyModel)).contentType(contentType);
mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk());
}
use of com.synopsys.integration.alert.common.rest.model.SettingsProxyModel in project hub-alert by blackducksoftware.
the class SettingsProxyControllerTestIT method createSettingsProxyModel.
private SettingsProxyModel createSettingsProxyModel(String configurationName) {
SettingsProxyModel settingsProxyModel = new SettingsProxyModel();
settingsProxyModel.setName(configurationName);
settingsProxyModel.setProxyHost(HOST);
settingsProxyModel.setProxyPort(PORT);
settingsProxyModel.setProxyUsername(USERNAME);
settingsProxyModel.setProxyPassword(PASSWORD);
settingsProxyModel.setNonProxyHosts(List.of("hosts"));
return settingsProxyModel;
}
Aggregations