Search in sources :

Example 1 with SettingsDecrypter

use of org.apache.maven.settings.crypto.SettingsDecrypter in project spring-boot by spring-projects.

the class MavenSettingsReader method createSettingsDecrypter.

private SettingsDecrypter createSettingsDecrypter() {
    SettingsDecrypter settingsDecrypter = new DefaultSettingsDecrypter();
    setField(DefaultSettingsDecrypter.class, "securityDispatcher", settingsDecrypter, new SpringBootSecDispatcher());
    return settingsDecrypter;
}
Also used : SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter)

Example 2 with SettingsDecrypter

use of org.apache.maven.settings.crypto.SettingsDecrypter 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.");
}
Also used : 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) IssueManagement(org.apache.maven.model.IssueManagement) Settings(org.apache.maven.settings.Settings)

Example 3 with SettingsDecrypter

use of org.apache.maven.settings.crypto.SettingsDecrypter in project maven-plugins by apache.

the class AbstractDeployMojo method deploy.

private void deploy(final File directory, final Repository repository) throws MojoExecutionException {
    // TODO: work on moving this into the deployer like the other deploy methods
    final Wagon wagon = getWagon(repository, wagonManager);
    try {
        configureWagon(wagon, repository.getId(), settings, container, getLog());
    } catch (TransferFailedException e) {
        throw new MojoExecutionException("Unable to configure Wagon: '" + repository.getProtocol() + "'", e);
    }
    try {
        final ProxyInfo proxyInfo;
        if (!isMaven3OrMore()) {
            proxyInfo = getProxyInfo(repository, wagonManager);
        } else {
            try {
                SettingsDecrypter settingsDecrypter = container.lookup(SettingsDecrypter.class);
                proxyInfo = getProxy(repository, settingsDecrypter);
            } catch (ComponentLookupException cle) {
                throw new MojoExecutionException("Unable to lookup SettingsDecrypter: " + cle.getMessage(), cle);
            }
        }
        push(directory, repository, wagon, proxyInfo, getLocales(), getDeployModuleDirectory());
        if (chmod) {
            chmod(wagon, repository, chmodOptions, chmodMode);
        }
    } finally {
        try {
            wagon.disconnect();
        } catch (ConnectionException e) {
            getLog().error("Error disconnecting wagon - ignored", e);
        }
    }
}
Also used : ProxyInfo(org.apache.maven.wagon.proxy.ProxyInfo) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) Wagon(org.apache.maven.wagon.Wagon) TransferFailedException(org.apache.maven.wagon.TransferFailedException) ConnectionException(org.apache.maven.wagon.ConnectionException)

Example 4 with SettingsDecrypter

use of org.apache.maven.settings.crypto.SettingsDecrypter in project spring-cloud-function by spring-cloud.

the class MavenSettingsReader method createSettingsDecrypter.

private SettingsDecrypter createSettingsDecrypter() {
    SettingsDecrypter settingsDecrypter = new DefaultSettingsDecrypter();
    setField(DefaultSettingsDecrypter.class, "securityDispatcher", settingsDecrypter, new SpringBootSecDispatcher());
    return settingsDecrypter;
}
Also used : SettingsDecrypter(org.apache.maven.settings.crypto.SettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter) DefaultSettingsDecrypter(org.apache.maven.settings.crypto.DefaultSettingsDecrypter)

Example 5 with SettingsDecrypter

use of org.apache.maven.settings.crypto.SettingsDecrypter 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

SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)5 IssueManagement (org.apache.maven.model.IssueManagement)2 Log (org.apache.maven.plugin.logging.Log)2 Server (org.apache.maven.settings.Server)2 Settings (org.apache.maven.settings.Settings)2 DefaultSettingsDecrypter (org.apache.maven.settings.crypto.DefaultSettingsDecrypter)2 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)2 SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 DefaultSettingsProblem (org.apache.maven.settings.building.DefaultSettingsProblem)1 SettingsDecryptionRequest (org.apache.maven.settings.crypto.SettingsDecryptionRequest)1 ConnectionException (org.apache.maven.wagon.ConnectionException)1 TransferFailedException (org.apache.maven.wagon.TransferFailedException)1 Wagon (org.apache.maven.wagon.Wagon)1 ProxyInfo (org.apache.maven.wagon.proxy.ProxyInfo)1 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)1