/** * Install default provider for the .netrc parser. */ public static void install() { CredentialsProvider.setDefault(new NetRCCredentialsProvider()); }
credentialsProvider = new UsernamePasswordCredentialsProvider(username, password); } else { credentialsProvider = CredentialsProvider.getDefault();
/** * {@inheritDoc} * <p> * Populates the credential items with the credentials provided by the first * credential provider in the list which populates them with non-null values * * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[]) */ @Override public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { for (CredentialsProvider p : credentialProviders) { if (p.supports(items)) { if (!p.get(uri, items)) { if (p.isInteractive()) { return false; // user cancelled the request } continue; } if (isAnyNull(items)) { continue; } return true; } } return false; } }
return delegate.get(uri, unprocessedItems.toArray(new CredentialItem[0]));
@Override public void reset(URIish uri) { if (delegate != null) { delegate.reset(uri); } }
@Override public boolean isInteractive() { return (delegate != null) && delegate.isInteractive(); }
@Override public boolean supports(CredentialItem... items) { List<CredentialItem> unprocessedItems = new ArrayList<>(); for (CredentialItem item : items) { if (item instanceof CredentialItem.InformationalMessage && item.getPromptText() != null && item.getPromptText() .contains(JGitText.get().sslFailureTrustExplanation)) continue; if (item instanceof CredentialItem.YesNoType && item.getPromptText() != null && (item.getPromptText().equals(JGitText.get().sslTrustNow) || item.getPromptText() .startsWith(stripFormattingPlaceholders( JGitText.get().sslTrustForRepo)) || item.getPromptText() .equals(JGitText.get().sslTrustAlways))) continue; unprocessedItems.add(item); } return unprocessedItems.isEmpty() || (delegate != null && delegate.supports(unprocessedItems.toArray(new CredentialItem[0]))); }
/** * Ask for the credential items to be populated. * * @param uri * the URI of the remote resource that needs authentication. * @param items * the items the application requires to complete authentication. * @return {@code true} if the request was successful and values were * supplied; {@code false} if the user canceled the request and did * not supply all requested values. * @throws org.eclipse.jgit.errors.UnsupportedCredentialItem * if one of the items supplied is not supported. */ public boolean get(URIish uri, List<CredentialItem> items) throws UnsupportedCredentialItem { return get(uri, items.toArray(new CredentialItem[0])); }
credentialsProvider.reset(currentUri);
/** {@inheritDoc} */ @Override public boolean isInteractive() { for (CredentialsProvider p : credentialProviders) if (p.isInteractive()) return true; return false; }
/** {@inheritDoc} */ @Override public boolean supports(CredentialItem... items) { for (CredentialsProvider p : credentialProviders) if (p.supports(items)) return true; return false; }
/** * <p>Constructor for TransportCommand.</p> * * @param repo a {@link org.eclipse.jgit.lib.Repository} object. */ protected TransportCommand(Repository repo) { super(repo); setCredentialsProvider(CredentialsProvider.getDefault()); }
/** * Install default provider for the .netrc parser. */ public static void install() { CredentialsProvider.setDefault(new NetRCCredentialsProvider()); }
/** * Populates the credential items with the credentials provided by the first * credential provider in the list which populates them with non-null values * * @return {@code true} if any of the credential providers in the list * supports the requested items, otherwise {@code false} * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[]) */ @Override public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { for (CredentialsProvider p : credentialProviders) { if (p.supports(items)) { if (!p.get(uri, items)) { if (p.isInteractive()) { return false; // user cancelled the request } continue; } if (isAnyNull(items)) { continue; } return true; } } return false; } }
/** {@inheritDoc} */ @Override public void showMessage(String msg) { provider.get(uri, new CredentialItem.InformationalMessage(msg)); }
credentialsProvider.reset(uri); session = createSession(credentialsProvider, fs, user, pass, host, port, hc);