Search in sources :

Example 1 with SettingsDecryptionRequest

use of org.apache.maven.settings.crypto.SettingsDecryptionRequest 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());
}
Also used : DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult)

Example 2 with SettingsDecryptionRequest

use of org.apache.maven.settings.crypto.SettingsDecryptionRequest 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;
}
Also used : Server(org.apache.maven.settings.Server) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) ReleaseDescriptor(org.apache.maven.shared.release.config.ReleaseDescriptor) Map(java.util.Map)

Example 3 with SettingsDecryptionRequest

use of org.apache.maven.settings.crypto.SettingsDecryptionRequest in project sts4 by spring-projects.

the class MavenBridge method decryptPassword.

public Server decryptPassword(Server server) throws MavenException {
    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();
}
Also used : SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) SettingsProblem(org.apache.maven.settings.building.SettingsProblem)

Example 4 with SettingsDecryptionRequest

use of org.apache.maven.settings.crypto.SettingsDecryptionRequest 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));
}
Also used : DefaultSettingsProblem(org.apache.maven.settings.building.DefaultSettingsProblem) Server(org.apache.maven.settings.Server) SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) Log(org.apache.maven.plugin.logging.Log) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionRequest(org.apache.maven.settings.crypto.SettingsDecryptionRequest) IssueManagement(org.apache.maven.model.IssueManagement) Settings(org.apache.maven.settings.Settings)

Aggregations

DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)4 SettingsDecryptionRequest (org.apache.maven.settings.crypto.SettingsDecryptionRequest)4 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)4 Server (org.apache.maven.settings.Server)2 SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)2 Map (java.util.Map)1 IssueManagement (org.apache.maven.model.IssueManagement)1 Log (org.apache.maven.plugin.logging.Log)1 Settings (org.apache.maven.settings.Settings)1 DefaultSettingsProblem (org.apache.maven.settings.building.DefaultSettingsProblem)1 SettingsProblem (org.apache.maven.settings.building.SettingsProblem)1 ReleaseDescriptor (org.apache.maven.shared.release.config.ReleaseDescriptor)1