use of org.apache.maven.settings.building.DefaultSettingsProblem in project fabric8 by jboss-fuse.
the class MavenSettingsDecrypter method decrypt.
public SettingsDecryptionResult decrypt(SettingsDecryptionRequest request) {
List<SettingsProblem> problems = new ArrayList<SettingsProblem>();
List<Server> servers = new ArrayList<Server>();
for (Server server : request.getServers()) {
server = server.clone();
servers.add(server);
try {
server.setPassword(decrypt(server.getPassword()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt password for server " + server.getId() + ": " + e.getMessage(), Severity.ERROR, "server: " + server.getId(), -1, -1, e));
}
try {
server.setPassphrase(decrypt(server.getPassphrase()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt passphrase for server " + server.getId() + ": " + e.getMessage(), Severity.ERROR, "server: " + server.getId(), -1, -1, e));
}
}
List<Proxy> proxies = new ArrayList<Proxy>();
for (Proxy proxy : request.getProxies()) {
proxy = proxy.clone();
proxies.add(proxy);
try {
proxy.setPassword(decrypt(proxy.getPassword()));
} catch (SecDispatcherException e) {
problems.add(new DefaultSettingsProblem("Failed to decrypt password for proxy " + proxy.getId() + ": " + e.getMessage(), Severity.ERROR, "proxy: " + proxy.getId(), -1, -1, e));
}
}
return new MavenSettingsDecryptionResult(servers, proxies, problems);
}
use of org.apache.maven.settings.building.DefaultSettingsProblem in project maven-plugins by apache.
the class GitHubDownloaderTestCase method testConfigureAuthenticationWithProblems.
public void testConfigureAuthenticationWithProblems() throws Exception {
IssueManagement issueManagement = newGitHubIssueManagement();
GitHubDownloader gitHubDownloader = newGitHubDownloader(issueManagement);
Settings settings = new Settings();
Server server = newServer("github-server");
settings.addServer(server);
SettingsDecrypter decrypter = mock(SettingsDecrypter.class);
SettingsDecryptionResult result = mock(SettingsDecryptionResult.class);
Log log = mock(Log.class);
when(result.getProblems()).thenReturn(Arrays.<SettingsProblem>asList(new DefaultSettingsProblem("Ups " + server.getId(), Severity.ERROR, null, -1, -1, null)));
when(result.getServer()).thenReturn(server);
when(decrypter.decrypt(any(SettingsDecryptionRequest.class))).thenReturn(result);
gitHubDownloader.configureAuthentication(decrypter, "github-server", settings, log);
verify(log).error("Ups github-server", null);
ArgumentCaptor<SettingsDecryptionRequest> argument = ArgumentCaptor.forClass(SettingsDecryptionRequest.class);
verify(decrypter).decrypt(argument.capture());
List<Server> servers = ((DefaultSettingsDecryptionRequest) argument.getValue()).getServers();
assertEquals(1, servers.size());
assertSame(server, servers.get(0));
}
Aggregations