private AuthenticationSelector getAuthSelector() { DefaultAuthenticationSelector selector = new DefaultAuthenticationSelector(); Collection<String> ids = new HashSet<String>(); for (Authentication auth : authentications) { List<String> servers = auth.getServers(); if (!servers.isEmpty()) { org.sonatype.aether.repository.Authentication a = ConverterUtils.toAuthentication(auth); for (String server : servers) { if (ids.add(server)) { selector.add(server, a); } } } } Settings settings = getSettings(); for (Server server : settings.getServers()) { org.sonatype.aether.repository.Authentication auth = new org.sonatype.aether.repository.Authentication( server.getUsername(), server.getPassword(), server.getPrivateKey(), server.getPassphrase()); selector.add(server.getId(), auth); } return new ConservativeAuthenticationSelector(selector); }
/** * Get server with given id * * @param settings * @param serverId must be non-null and non-empty * @return server or null if none matching */ protected Server getServer(final Settings settings, final String serverId) { if (settings == null) return null; List<Server> servers = settings.getServers(); if (servers == null || servers.isEmpty()) return null; for (Server server : servers) if (serverId.equals(server.getId())) return server; return null; }
public void configureAuthentication(String githubAPIServerId, Settings settings, Log log) { boolean configured = false; List<Server> servers = settings.getServers(); for (Server server : servers) { if (server.getId().equals(githubAPIServerId)) { String user = server.getUsername(); String password = server.getPassword(); this.client.setCredentials(user, password); configured = true; break; } } if (!configured) { log.warn("Can't find server id [" + githubAPIServerId + "] configured in githubAPIServerId."); } }
/** * Retrieves the credentials for the given server or null if none could be found * * @param serverID * @return */ public Credentials findCredentials(String serverID) { List<Server> decryptedServers = getDecryptedServers(); for (Server ds : decryptedServers) { if (ds.getId().equals(serverID)) { getLog() .debug( "credentials have been found for server: " + serverID + ", login:"******", password:"******"no credentials found for server: " + serverID); return null; }