Search in sources :

Example 36 with SettingsDecryptionResult

use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project maven-archetype by apache.

the class RemoteCatalogArchetypeDataSource method getProxy.

private ProxyInfo getProxy(String protocol) {
    MavenSession session = legacySupport.getSession();
    if (session != null && protocol != null) {
        MavenExecutionRequest request = session.getRequest();
        if (request != null) {
            List<Proxy> proxies = request.getProxies();
            if (proxies != null) {
                for (Proxy proxy : proxies) {
                    if (proxy.isActive() && protocol.equalsIgnoreCase(proxy.getProtocol())) {
                        SettingsDecryptionResult result = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(proxy));
                        proxy = result.getProxy();
                        ProxyInfo proxyInfo = new ProxyInfo();
                        proxyInfo.setHost(proxy.getHost());
                        proxyInfo.setType(proxy.getProtocol());
                        proxyInfo.setPort(proxy.getPort());
                        proxyInfo.setNonProxyHosts(proxy.getNonProxyHosts());
                        proxyInfo.setUserName(proxy.getUsername());
                        proxyInfo.setPassword(proxy.getPassword());
                        return proxyInfo;
                    }
                }
            }
        }
    }
    return null;
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) ProxyInfo(org.apache.maven.wagon.proxy.ProxyInfo) Proxy(org.apache.maven.settings.Proxy) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult)

Example 37 with SettingsDecryptionResult

use of org.apache.maven.settings.crypto.SettingsDecryptionResult in project frontend-maven-plugin by eirslett.

the class MojoUtils method decryptServer.

static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) {
    if (StringUtils.isEmpty(serverId)) {
        return null;
    }
    Server server = mavenSession.getSettings().getServer(serverId);
    if (server != null) {
        synchronized (server) {
            final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
            SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest);
            return decryptedResult.getServer();
        }
    } else {
        LOGGER.warn("Could not find server '" + serverId + "' in settings.xml");
        return null;
    }
}
Also used : Server(org.apache.maven.settings.Server) DefaultSettingsDecryptionRequest(org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest) SettingsDecryptionResult(org.apache.maven.settings.crypto.SettingsDecryptionResult)

Aggregations

SettingsDecryptionResult (org.apache.maven.settings.crypto.SettingsDecryptionResult)37 DefaultSettingsDecryptionRequest (org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest)33 Server (org.apache.maven.settings.Server)17 SettingsDecryptionRequest (org.apache.maven.settings.crypto.SettingsDecryptionRequest)16 SettingsProblem (org.apache.maven.settings.building.SettingsProblem)14 Proxy (org.apache.maven.settings.Proxy)7 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)6 MavenSession (org.apache.maven.execution.MavenSession)6 SettingsDecrypter (org.apache.maven.settings.crypto.SettingsDecrypter)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 Settings (org.apache.maven.settings.Settings)5 IOException (java.io.IOException)3 Map (java.util.Map)3 ProxyInfo (org.apache.maven.wagon.proxy.ProxyInfo)3 JibContainerBuilder (com.google.cloud.tools.jib.api.JibContainerBuilder)2 LayerConfiguration (com.google.cloud.tools.jib.api.LayerConfiguration)2 AbsoluteUnixPath (com.google.cloud.tools.jib.api.buildplan.AbsoluteUnixPath)2 AuthProperty (com.google.cloud.tools.jib.plugins.common.AuthProperty)2 InferredAuthException (com.google.cloud.tools.jib.plugins.common.InferredAuthException)2 File (java.io.File)2