Tabnine Logo
org.eclipse.jgit.internal.transport.ssh
Code IndexAdd Tabnine to your IDE (free)

How to use org.eclipse.jgit.internal.transport.ssh

Best Java code snippets using org.eclipse.jgit.internal.transport.ssh (Showing top 20 results out of 315)

origin: org.eclipse.jgit/org.eclipse.jgit

@Override
public String getValue(String key) {
  // See com.jcraft.jsch.OpenSSHConfig.MyConfig.getValue()
  // for this special case.
  if (key.equals("compression.s2c") //$NON-NLS-1$
      || key.equals("compression.c2s")) { //$NON-NLS-1$
    if (!OpenSshConfigFile.flag(
        Host.this.entry.getValue(mapKey(key)))) {
      return "none,zlib@openssh.com,zlib"; //$NON-NLS-1$
    }
    return "zlib@openssh.com,zlib,none"; //$NON-NLS-1$
  }
  return Host.this.entry.getValue(mapKey(key));
}
origin: org.eclipse.jgit/org.eclipse.jgit

  @Override
  public String[] getValues(String key) {
    List<String> values = Host.this.entry
        .getValues(mapKey(key));
    if (values == null) {
      return new String[0];
    }
    return values.toArray(new String[0]);
  }
};
origin: org.eclipse.jgit/org.eclipse.jgit

private static boolean isHostMatch(String pattern, String name) {
  if (pattern.startsWith("!")) { //$NON-NLS-1$
    return !patternMatchesHost(pattern.substring(1), name);
  } else {
    return patternMatchesHost(pattern, name);
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit

void substitute(String originalHostName, int port, String userName,
    String localUserName, File home) {
  int p = port >= 0 ? port : positive(getValue(SshConstants.PORT));
  if (p < 0) {
    p = SshConstants.SSH_DEFAULT_PORT;
      : getValue(SshConstants.USER);
  if (u == null || u.isEmpty()) {
    u = localUserName;
  Replacer r = new Replacer(originalHostName, p, u, localUserName,
      home);
  if (options != null) {
      options.put(SshConstants.HOST_NAME, originalHostName);
    } else {
      hostName = r.substitute(hostName, "h"); //$NON-NLS-1$
      options.put(SshConstants.HOST_NAME, hostName);
      r.update('h', hostName);
        .get(SshConstants.IDENTITY_FILE);
    if (values != null) {
      values = substitute(values, "dhlru", r); //$NON-NLS-1$
      values = replaceTilde(values, home);
      multiOptions.put(SshConstants.IDENTITY_FILE, values);
      values = substitute(values, "dhlru", r); //$NON-NLS-1$
      values = replaceTilde(values, home);
      multiOptions.put(SshConstants.CERTIFICATE_FILE, values);
origin: org.eclipse.jgit/org.eclipse.jgit

private void complete(String initialHostName, String localUserName) {
  hostName = entry.getValue(SshConstants.HOST_NAME);
  user = entry.getValue(SshConstants.USER);
  port = positive(entry.getValue(SshConstants.PORT));
  connectionAttempts = positive(
      entry.getValue(SshConstants.CONNECTION_ATTEMPTS));
  strictHostKeyChecking = entry
      .getValue(SshConstants.STRICT_HOST_KEY_CHECKING);
  batchMode = Boolean.valueOf(OpenSshConfigFile
      .flag(entry.getValue(SshConstants.BATCH_MODE)));
  preferredAuthentications = entry
      .getValue(SshConstants.PREFERRED_AUTHENTICATIONS);
      .getValues(SshConstants.IDENTITY_FILE);
  if (identityFiles != null && !identityFiles.isEmpty()) {
    identityFile = new File(identityFiles.get(0));
origin: org.eclipse.jgit/org.eclipse.jgit

public HostEntry lookup(@NonNull String hostName, int port,
    String userName) {
  final State cache = refresh();
  String cacheKey = toCacheKey(hostName, port, userName);
  HostEntry h = cache.hosts.get(cacheKey);
  if (h != null) {
    return h;
  HostEntry fullConfig = new HostEntry();
  fullConfig.merge(cache.entries.get(DEFAULT_NAME));
  for (Map.Entry<String, HostEntry> e : cache.entries.entrySet()) {
    String pattern = e.getKey();
    if (isHostMatch(pattern, hostName)) {
      fullConfig.merge(e.getValue());
  fullConfig.substitute(hostName, port, userName, localUserName, home);
  cache.hosts.put(cacheKey, fullConfig);
  return fullConfig;
origin: org.eclipse.jgit/org.eclipse.jgit

HostEntry defaults = new HostEntry();
current.add(defaults);
entries.put(DEFAULT_NAME, defaults);
  String keyword = dequote(parts[0].trim());
    for (String name : parseList(argValue)) {
      if (name == null || name.isEmpty()) {
        c = new HostEntry();
        entries.put(name, c);
  if (HostEntry.isListKey(keyword)) {
    List<String> args = validate(keyword, parseList(argValue));
    for (HostEntry entry : current) {
      entry.setValue(keyword, args);
    argValue = validate(keyword, dequote(argValue));
    for (HostEntry entry : current) {
      entry.setValue(keyword, argValue);
origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Locate the configuration for a specific host request.
 *
 * @param hostName
 *            the name the user has supplied to the SSH tool. This may be a
 *            real host name, or it may just be a "Host" block in the
 *            configuration file.
 * @return r configuration for the requested name. Never null.
 */
public Host lookup(String hostName) {
  HostEntry entry = configFile.lookup(hostName, -1, null);
  return new Host(entry, hostName, configFile.getLocalUserName());
}
origin: org.eclipse.jgit/org.eclipse.jgit

private synchronized State refresh() {
  final long mtime = configFile.lastModified();
  if (mtime != lastModified) {
    State newState = new State();
    try (BufferedReader br = Files
        .newBufferedReader(configFile.toPath(), UTF_8)) {
      newState.entries = parse(br);
    } catch (IOException | RuntimeException none) {
      // Ignore -- we'll set and return an empty state
    }
    lastModified = mtime;
    state = newState;
  }
  return state;
}
origin: org.eclipse.jgit/org.eclipse.jgit

OpenSshConfig(File h, File cfg) {
  configFile = new OpenSshConfigFile(h, cfg,
      SshSessionFactory.getLocalUserName());
}
origin: org.eclipse.jgit/org.eclipse.jgit

private List<String> substitute(List<String> values, String allowed,
    Replacer r) {
  List<String> result = new ArrayList<>(values.size());
  for (String value : values) {
    result.add(r.substitute(value, allowed));
  }
  return result;
}
origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Hook to perform validation on a single value, or to sanitize it. If this
 * throws an (unchecked) exception, parsing of the file is abandoned.
 *
 * @param key
 *            of the entry
 * @param value
 *            as read from the config file
 * @return the validated and possibly sanitized value
 */
protected String validate(String key, String value) {
  if (String.CASE_INSENSITIVE_ORDER.compare(key,
      SshConstants.PREFERRED_AUTHENTICATIONS) == 0) {
    return stripWhitespace(value);
  }
  return value;
}
origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Creates a new {@link OpenSshConfigFile} that will read the config from
 * file {@code config} use the given file {@code home} as "home" directory.
 *
 * @param home
 *            user's home directory for the purpose of ~ replacement
 * @param config
 *            file to load.
 * @param localUserName
 *            user name of the current user on the local host OS
 */
public OpenSshConfigFile(@NonNull File home, @NonNull File config,
    @NonNull String localUserName) {
  this.home = home;
  this.configFile = config;
  this.localUserName = localUserName;
  state = new State();
}
origin: berlam/github-bucket

@Override
public String getValue(String key) {
  // See com.jcraft.jsch.OpenSSHConfig.MyConfig.getValue()
  // for this special case.
  if (key.equals("compression.s2c") //$NON-NLS-1$
      || key.equals("compression.c2s")) { //$NON-NLS-1$
    if (!OpenSshConfigFile.flag(
        Host.this.entry.getValue(mapKey(key)))) {
      return "none,zlib@openssh.com,zlib"; //$NON-NLS-1$
    }
    return "zlib@openssh.com,zlib,none"; //$NON-NLS-1$
  }
  return Host.this.entry.getValue(mapKey(key));
}
origin: berlam/github-bucket

/**
 * Locate the configuration for a specific host request.
 *
 * @param hostName
 *            the name the user has supplied to the SSH tool. This may be a
 *            real host name, or it may just be a "Host" block in the
 *            configuration file.
 * @return r configuration for the requested name. Never null.
 */
public Host lookup(String hostName) {
  HostEntry entry = configFile.lookup(hostName, -1, null);
  return new Host(entry, hostName, configFile.getLocalUserName());
}
origin: berlam/github-bucket

private synchronized State refresh() {
  final long mtime = configFile.lastModified();
  if (mtime != lastModified) {
    State newState = new State();
    try (BufferedReader br = Files
        .newBufferedReader(configFile.toPath(), UTF_8)) {
      newState.entries = parse(br);
    } catch (IOException | RuntimeException none) {
      // Ignore -- we'll set and return an empty state
    }
    lastModified = mtime;
    state = newState;
  }
  return state;
}
origin: berlam/github-bucket

  @Override
  public String[] getValues(String key) {
    List<String> values = Host.this.entry
        .getValues(mapKey(key));
    if (values == null) {
      return new String[0];
    }
    return values.toArray(new String[0]);
  }
};
origin: org.eclipse.jgit/org.eclipse.jgit

public void update(char key, String value) {
  replacements.put(Character.valueOf(key), value);
  if ("lhpr".indexOf(key) >= 0) { //$NON-NLS-1$
    replacements.put(Character.valueOf('C'),
        substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$
  }
}
origin: berlam/github-bucket

private static boolean isHostMatch(String pattern, String name) {
  if (pattern.startsWith("!")) { //$NON-NLS-1$
    return !patternMatchesHost(pattern.substring(1), name);
  } else {
    return patternMatchesHost(pattern, name);
  }
}
origin: org.eclipse.jgit/org.eclipse.jgit

public Replacer(String host, int port, String user,
    String localUserName, File home) {
  replacements.put(Character.valueOf('%'), "%"); //$NON-NLS-1$
  replacements.put(Character.valueOf('d'), home.getPath());
  replacements.put(Character.valueOf('h'), host);
  String localhost = SystemReader.getInstance().getHostname();
  replacements.put(Character.valueOf('l'), localhost);
  int period = localhost.indexOf('.');
  if (period > 0) {
    localhost = localhost.substring(0, period);
  }
  replacements.put(Character.valueOf('L'), localhost);
  replacements.put(Character.valueOf('n'), host);
  replacements.put(Character.valueOf('p'), Integer.toString(port));
  replacements.put(Character.valueOf('r'), user == null ? "" : user); //$NON-NLS-1$
  replacements.put(Character.valueOf('u'), localUserName);
  replacements.put(Character.valueOf('C'),
      substitute("%l%h%p%r", "hlpr")); //$NON-NLS-1$ //$NON-NLS-2$
  replacements.put(Character.valueOf('T'), "NONE"); //$NON-NLS-1$
}
org.eclipse.jgit.internal.transport.ssh

Most used classes

  • OpenSshConfigFile$HostEntry
    A host entry from the ssh config file. Any merging of global values and of several matching host ent
  • OpenSshConfigFile
    Fairly complete configuration parser for the openssh ~/.ssh/config file. Both JSch 0.1.54 and Apache
  • OpenSshConfigFile$Replacer
  • OpenSshConfigFile$State
    Encapsulates entries read out of the configuration file, and a cache of fully resolved entries creat
  • CachingKeyPairProvider$CancellingKeyPairIterator
  • GssApiMechanisms,
  • GssApiWithMicAuthentication,
  • JGitClientSession,
  • JGitHostConfigEntry,
  • JGitPasswordAuthentication,
  • JGitPublicKeyAuthFactory,
  • JGitPublicKeyAuthentication,
  • JGitPublicKeyIterator$AgentIdentityIterator,
  • JGitPublicKeyIterator$KeyPairIdentityIterator,
  • JGitPublicKeyIterator,
  • JGitSshClient$CombinedKeyPairProvider,
  • JGitSshClient$JGitSessionFactory,
  • JGitSshClient,
  • JGitSshConfig
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now