/** * Configure transport with credentials provider, timeout, and config * callback * * @param transport * a {@link org.eclipse.jgit.transport.Transport} object. * @return {@code this} */ protected C configure(Transport transport) { if (credentialsProvider != null) transport.setCredentialsProvider(credentialsProvider); transport.setTimeout(timeout); if (transportConfigCallback != null) transportConfigCallback.configure(transport); return self(); }
private void configure(final Transport transport) { String username = getProperty("fs.jgit.auth.user", "").toString(); if (!username.isEmpty()) { String password = getProperty("fs.jgit.auth.pass").toString(); logger.debug(String.format("Login: %s %s", username, password.replaceAll(".", "*"))); transport.setCredentialsProvider(new UsernamePasswordCredentialsProvider(username, password)); } }
private static void configure(Transport transport, String username, String password) { if (username != null && password != null) transport .setCredentialsProvider(new UsernamePasswordCredentialsProvider( username, password)); // wait 30 seconds transport.setTimeout(30); }
/** * Configure transport with credentials provider, timeout, and config * callback * * @param transport * @return {@code this} */ protected C configure(final Transport transport) { if (credentialsProvider != null) transport.setCredentialsProvider(credentialsProvider); transport.setTimeout(timeout); if (transportConfigCallback != null) transportConfigCallback.configure(transport); return self(); }
/** * Configure transport with credentials provider, timeout, and config * callback * * @param transport * a {@link org.eclipse.jgit.transport.Transport} object. * @return {@code this} */ protected C configure(Transport transport) { if (credentialsProvider != null) transport.setCredentialsProvider(credentialsProvider); transport.setTimeout(timeout); if (transportConfigCallback != null) transportConfigCallback.configure(transport); return self(); }
remoteCapablities.setAccessible(true); try (Transport transport = Transport.open(repo, url)) { transport.setCredentialsProvider(getProvider()); try (FetchConnection fc = transport.openFetch()) { fc.getRefs();
private Set<String> listRemoteBranches(String remote) throws NotSupportedException, TransportException, URISyntaxException { Set<String> branches = new HashSet<>(); try (final Repository repo = getRepository()) { StoredConfig config = repo.getConfig(); try (final Transport tn = Transport.open(repo, new URIish(config.getString("remote",remote,"url")))) { tn.setCredentialsProvider(getProvider()); try (final FetchConnection c = tn.openFetch()) { for (final Ref r : c.getRefs()) { if (r.getName().startsWith(R_HEADS)) branches.add("refs/remotes/"+remote+"/"+r.getName().substring(R_HEADS.length())); } } } } return branches; }
tn.setCredentialsProvider(credentialsProvider);
/** {@inheritDoc} */ @Override public ObjectId getHeadRev(String remoteRepoUrl, String branchSpec) throws GitException { try (Repository repo = openDummyRepository(); final Transport tn = Transport.open(repo, new URIish(remoteRepoUrl))) { final String branchName = extractBranchNameFromBranchSpec(branchSpec); String regexBranch = createRefRegexFromGlob(branchName); tn.setCredentialsProvider(getProvider()); try (FetchConnection c = tn.openFetch()) { for (final Ref r : c.getRefs()) { if (r.getName().matches(regexBranch)) { return r.getPeeledObjectId() != null ? r.getPeeledObjectId() : r.getObjectId(); } } } } catch (IOException | URISyntaxException | IllegalStateException e) { throw new GitException(e); } return null; }
transport.setCredentialsProvider(credentialsProvider);