use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project m2e-core by eclipse-m2e.
the class MavenImpl method decryptPassword.
@Override
public Server decryptPassword(Server server) throws CoreException {
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
SettingsDecryptionResult result = lookup(SettingsDecrypter.class).decrypt(request);
for (SettingsProblem problem : result.getProblems()) {
log.warn(problem.getMessage(), problem.getException());
}
return result.getServer();
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project spring-boot by spring-projects.
the class MavenSettingsReader method readSettings.
public MavenSettings readSettings() {
Settings settings = loadSettings();
SettingsDecryptionResult decrypted = decryptSettings(settings);
if (!decrypted.getProblems().isEmpty()) {
Log.error("Maven settings decryption failed. Some Maven repositories may be inaccessible");
// Continue - the encrypted credentials may not be used
}
return new MavenSettings(settings, decrypted);
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult 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));
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project maven-plugins by apache.
the class GitHubDownloader method configureAuthentication.
public void configureAuthentication(SettingsDecrypter decrypter, String githubAPIServerId, Settings settings, Log log) {
boolean configured = false;
List<Server> servers = settings.getServers();
for (Server server : servers) {
if (server.getId().equals(githubAPIServerId)) {
SettingsDecryptionResult result = decrypter.decrypt(new DefaultSettingsDecryptionRequest(server));
for (SettingsProblem problem : result.getProblems()) {
log.error(problem.getMessage(), problem.getException());
}
server = result.getServer();
String user = server.getUsername();
String password = server.getPassword();
this.client.setCredentials(user, password);
configured = true;
break;
}
}
if (!configured) {
log.warn("Can't find server id [" + githubAPIServerId + "] configured in githubAPIServerId.");
}
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project maven-plugins by apache.
the class AbstractDeployMojo method getProxy.
/**
* Get proxy information for Maven 3.
*
* @param repository
* @param settingsDecrypter
* @return
*/
private ProxyInfo getProxy(Repository repository, SettingsDecrypter settingsDecrypter) {
String protocol = repository.getProtocol();
String url = repository.getUrl();
getLog().debug("repository protocol " + protocol);
String originalProtocol = protocol;
// so we will check both
if (StringUtils.equalsIgnoreCase("dav", protocol) && url.startsWith("dav:")) {
url = url.substring(4);
if (url.startsWith("http")) {
try {
URL urlSite = new URL(url);
protocol = urlSite.getProtocol();
getLog().debug("found dav protocol so transform to real transport protocol " + protocol);
} catch (MalformedURLException e) {
getLog().warn("fail to build URL with " + url);
}
}
} else {
getLog().debug("getProxy 'protocol': " + protocol);
}
if (mavenSession != null && protocol != null) {
MavenExecutionRequest request = mavenSession.getRequest();
if (request != null) {
List<Proxy> proxies = request.getProxies();
if (proxies != null) {
for (Proxy proxy : proxies) {
if (proxy.isActive() && (protocol.equalsIgnoreCase(proxy.getProtocol()) || originalProtocol.equalsIgnoreCase(proxy.getProtocol()))) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
proxy = result.getProxy();
ProxyInfo proxyInfo = new ProxyInfo();
proxyInfo.setHost(proxy.getHost());
// so hackish for wagon the protocol is https for site dav:
// dav:https://dav.codehaus.org/mojo/
// proxy.getProtocol() );
proxyInfo.setType(protocol);
proxyInfo.setPort(proxy.getPort());
proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
proxyInfo.setUserName(proxy.getUsername());
proxyInfo.setPassword(proxy.getPassword());
getLog().debug("found proxyInfo " + ("host:port " + proxyInfo.getHost() + ":" + proxyInfo.getPort() + ", " + proxyInfo.getUserName()));
return proxyInfo;
}
}
}
}
}
getLog().debug("getProxy 'protocol': " + protocol + " no ProxyInfo found");
return null;
}
Aggregations