Refine search
private RegistryAuth createRegistryAuth(Server server) throws DockerException { SettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server); SettingsDecryptionResult decryptionResult = settingsDecrypter.decrypt(decryptionRequest); if (decryptionResult.getProblems().isEmpty()) { log.debug("Successfully decrypted Maven server password"); } else { for (SettingsProblem problem : decryptionResult.getProblems()) { log.error("Settings problem for server {}: {}", server.getId(), problem); } throw new DockerException("Failed to decrypt Maven server password"); } return RegistryAuth.builder() .username(server.getUsername()) .password(decryptionResult.getServer().getPassword()) .build(); } }
private static Proxy decryptProxy(Proxy proxy, SettingsDecrypter decrypter) { final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(proxy); SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest); return decryptedResult.getProxy(); }
SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( proxy ); SettingsDecryptionResult result = settingsDecrypter.decrypt( request ); proxy = result.getProxy(); for ( SettingsProblem problem : result.getProblems() )
private void decryptSettings() { SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest( m_settings ); SettingsDecryptionResult result = decrypter.decrypt( request ); m_settings.setProxies(result.getProxies()); m_settings.setServers( result.getServers() ); }
static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) { if (StringUtils.isEmpty(serverId)) { return null; } Server server = mavenSession.getSettings().getServer(serverId); if (server != null) { 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; } }
DefaultSettingsDecryptionRequest decrypt = new DefaultSettingsDecryptionRequest(); decrypt.setProxies( request.getProxies() ); decrypt.setServers( request.getServers() ); SettingsDecryptionResult decrypted = settingsDecrypter.decrypt( decrypt ); for ( SettingsProblem problem : decrypted.getProblems() ) for ( Proxy proxy : decrypted.getProxies() ) for ( Server server : decrypted.getServers() )
/** * Returns the list of servers with decrypted passwords. * * @return list of servers with decrypted passwords. */ List<Server> getDecryptedServers() { final SettingsDecryptionRequest settingsDecryptionRequest = new DefaultSettingsDecryptionRequest(); settingsDecryptionRequest.setServers(settings.getServers()); final SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(settingsDecryptionRequest); return decrypt.getServers(); }
private String decrypt(final Server server) { SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server)); return decrypt.getServer().getPassword(); }
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); }
private AuthenticationSelector createAuthenticationSelector( SettingsDecryptionResult decryptedSettings) { DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector(); for (Server server : decryptedSettings.getServers()) { AuthenticationBuilder auth = new AuthenticationBuilder(); auth.addUsername(server.getUsername()).addPassword(server.getPassword()); auth.addPrivateKey(server.getPrivateKey(), server.getPassphrase()); selector.add(server.getId(), auth.build()); } return new ConservativeAuthenticationSelector(selector); }
private ProxySelector createProxySelector( SettingsDecryptionResult decryptedSettings) { DefaultProxySelector selector = new DefaultProxySelector(); for (Proxy proxy : decryptedSettings.getProxies()) { Authentication authentication = new AuthenticationBuilder() .addUsername(proxy.getUsername()).addPassword(proxy.getPassword()) .build(); selector.add( new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts()); } return selector; }
@Override public MavenRepositorySettings.Credentials getCredentials(MavenRepositoryLocation location) { if (location.getId() == null) { return null; } Server serverSettings = context.getSession().getSettings().getServer(location.getId()); if (serverSettings != null) { SettingsDecryptionResult result = decrypter.decryptAndLogProblems(serverSettings); Server decryptedServer = result.getServer(); return new MavenRepositorySettings.Credentials(decryptedServer.getUsername(), decryptedServer.getPassword()); } return null; }
private void setProxy(ProxyServiceFacade proxyService, Proxy proxy) { String protocol = proxy.getProtocol(); if (isSupportedProtocol(protocol)) { SettingsDecryptionResult result = decrypter.decryptAndLogProblems(proxy); proxy = result.getProxy(); logger.debug("Configuring proxy for protocol " + protocol + ": host=" + proxy.getHost() + ", port=" + proxy.getPort() + ", nonProxyHosts=" + proxy.getNonProxyHosts()); proxyService.configureProxy(protocol, proxy.getHost(), proxy.getPort(), proxy.getUsername(), proxy.getPassword(), proxy.getNonProxyHosts()); } else { logger.debug("Ignoring proxy configuration for unsupported protocol: '" + protocol + "'"); } }
private Settings decryptPasswords(Settings settings) { File securitySettings = new File(DEFAULT_SETTINGS_SECURITY_PATH); String altSecuritySettings = SecurityActions.getProperty(ALT_SECURITY_SETTINGS_XML_LOCATION); // set alternate file if (altSecuritySettings != null && altSecuritySettings.length() > 0) { securitySettings = new File(altSecuritySettings); } SettingsDecrypter decrypter = new MavenSettingsDecrypter(securitySettings); SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(settings); SettingsDecryptionResult result = decrypter.decrypt(request); if (result.getProblems().size() > 0) { StringBuilder sb = new StringBuilder("Found ").append(result.getProblems().size()) .append(" problems while trying to decrypt settings configuration."); int counter = 1; for (SettingsProblem problem : result.getProblems()) { sb.append(counter++).append("/ ").append(problem).append("\n"); } throw new InvalidConfigurationFileException(sb.toString()); } settings.setProxies(result.getProxies()); settings.setServers(result.getServers()); return settings; }
settingsDecrypter.decrypt( new DefaultSettingsDecryptionRequest( server ) ); server = result.getServer();
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); }
private AuthenticationSelector createAuthenticationSelector( SettingsDecryptionResult decryptedSettings) { DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector(); for (Server server : decryptedSettings.getServers()) { AuthenticationBuilder auth = new AuthenticationBuilder(); auth.addUsername(server.getUsername()).addPassword(server.getPassword()); auth.addPrivateKey(server.getPrivateKey(), server.getPassphrase()); selector.add(server.getId(), auth.build()); } return new ConservativeAuthenticationSelector(selector); }
private ProxySelector createProxySelector( SettingsDecryptionResult decryptedSettings) { DefaultProxySelector selector = new DefaultProxySelector(); for (Proxy proxy : decryptedSettings.getProxies()) { Authentication authentication = new AuthenticationBuilder() .addUsername(proxy.getUsername()).addPassword(proxy.getPassword()) .build(); selector.add( new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), authentication), proxy.getNonProxyHosts()); } return selector; }
private Settings decryptPasswords(Settings settings) { File securitySettings = new File(DEFAULT_SETTINGS_SECURITY_PATH); String altSecuritySettings = SecurityActions.getProperty(ALT_SECURITY_SETTINGS_XML_LOCATION); // set alternate file if (altSecuritySettings != null && altSecuritySettings.length() > 0) { securitySettings = new File(altSecuritySettings); } SettingsDecrypter decrypter = new MavenSettingsDecrypter(securitySettings); SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(settings); SettingsDecryptionResult result = decrypter.decrypt(request); if (result.getProblems().size() > 0) { StringBuilder sb = new StringBuilder("Found ").append(result.getProblems().size()) .append(" problems while trying to decrypt settings configuration."); int counter = 1; for (SettingsProblem problem : result.getProblems()) { sb.append(counter++).append("/ ").append(problem).append("\n"); } throw new InvalidConfigurationFileException(sb.toString()); } settings.setProxies(result.getProxies()); settings.setServers(result.getServers()); return settings; }
private String decrypt(final Server server) { SettingsDecryptionResult decrypt = settingsDecrypter.decrypt(new DefaultSettingsDecryptionRequest(server)); return decrypt.getServer().getPassword(); } }