use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project fabric8 by jboss-fuse.
the class AetherBasedResolver method decryptSettings.
private void decryptSettings() {
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(m_settings);
SettingsDecryptionResult result = decrypter.decrypt(request);
m_settings.setProxies(result.getProxies());
m_settings.setServers(result.getServers());
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project spring-cloud-function by spring-cloud.
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-archetype by apache.
the class RemoteCatalogArchetypeDataSource method getAuthenticationInfo.
private AuthenticationInfo getAuthenticationInfo(String id) {
MavenSession session = legacySupport.getSession();
if (session != null && id != null) {
MavenExecutionRequest request = session.getRequest();
if (request != null) {
List<Server> servers = request.getServers();
if (servers != null) {
for (Server server : servers) {
if (id.equalsIgnoreCase(server.getId())) {
SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server));
server = result.getServer();
AuthenticationInfo authInfo = new AuthenticationInfo();
authInfo.setUserName(server.getUsername());
authInfo.setPassword(server.getPassword());
authInfo.setPrivateKey(server.getPrivateKey());
authInfo.setPassphrase(server.getPassphrase());
return authInfo;
}
}
}
}
}
// empty one to prevent NPE
return new AuthenticationInfo();
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project maven-plugins by apache.
the class GitHubDownloaderTestCase method testConfigureAuthenticationWithNoServer.
public void testConfigureAuthenticationWithNoServer() throws Exception {
IssueManagement issueManagement = newGitHubIssueManagement();
GitHubDownloader gitHubDownloader = newGitHubDownloader(issueManagement);
Settings settings = new Settings();
Server server = newServer("not-the-right-one");
settings.addServer(server);
SettingsDecrypter decrypter = mock(SettingsDecrypter.class);
SettingsDecryptionResult result = mock(SettingsDecryptionResult.class);
Log log = mock(Log.class);
when(result.getProblems()).thenReturn(Collections.<SettingsProblem>emptyList());
when(result.getServer()).thenReturn(server);
when(decrypter.decrypt(new DefaultSettingsDecryptionRequest(server))).thenReturn(result);
gitHubDownloader.configureAuthentication(decrypter, "github-server", settings, log);
verify(log).warn("Can't find server id [github-server] configured in githubAPIServerId.");
}
use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project maven-plugins by apache.
the class AbstractScmPublishMojo method setupScm.
private ReleaseDescriptor setupScm() throws ScmRepositoryException, NoSuchScmProviderException {
String scmUrl;
if (localCheckout) {
// in the release phase we have to change the checkout URL
// to do a local checkout instead of going over the network.
String provider = ScmUrlUtils.getProvider(pubScmUrl);
String delimiter = ScmUrlUtils.getDelimiter(pubScmUrl);
String providerPart = "scm:" + provider + delimiter;
// X TODO: also check the information from releaseDescriptor.getScmRelativePathProjectDirectory()
// X TODO: in case our toplevel git directory has no pom.
// X TODO: fix pathname once I understand this.
scmUrl = providerPart + "file://" + "target/localCheckout";
logInfo("Performing a LOCAL checkout from " + scmUrl);
}
ReleaseDescriptor releaseDescriptor = new ReleaseDescriptor();
releaseDescriptor.setInteractive(settings.isInteractiveMode());
if (username == null || password == null) {
for (Server server : settings.getServers()) {
if (server.getId().equals(serverId)) {
SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt(decryptionRequest);
if (!decryptionResult.getProblems().isEmpty()) {
// todo throw exception?
}
if (username == null) {
username = decryptionResult.getServer().getUsername();
}
if (password == null) {
password = decryptionResult.getServer().getPassword();
}
break;
}
}
}
releaseDescriptor.setScmPassword(password);
releaseDescriptor.setScmUsername(username);
releaseDescriptor.setWorkingDirectory(basedir.getAbsolutePath());
releaseDescriptor.setLocalCheckout(localCheckout);
releaseDescriptor.setScmSourceUrl(pubScmUrl);
if (providerImplementations != null) {
for (Map.Entry<String, String> providerEntry : providerImplementations.entrySet()) {
logInfo("Changing the default '%s' provider implementation to '%s'.", providerEntry.getKey(), providerEntry.getValue());
scmManager.setScmProviderImplementation(providerEntry.getKey(), providerEntry.getValue());
}
}
scmRepository = scmRepositoryConfigurator.getConfiguredRepository(releaseDescriptor, settings);
scmProvider = scmRepositoryConfigurator.getRepositoryProvider(scmRepository);
return releaseDescriptor;
}
Aggregations