private static File getDefaultFile() { File home = FS.DETECTED.userHome(); File netrc = new File(home, ".netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; netrc = new File(home, "_netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; return null; }
@Override public FileBasedConfig openUserConfig(Config parent, FS fs) { final File home = fs.userHome(); return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$ }
private static void knownHosts(JSch sch, FS fs) throws JSchException { final File home = fs.userHome(); if (home == null) return; final File known_hosts = new File(new File(home, ".ssh"), "known_hosts"); //$NON-NLS-1$ //$NON-NLS-2$ try (FileInputStream in = new FileInputStream(known_hosts)) { sch.setKnownHosts(in); } catch (FileNotFoundException none) { // Oh well. They don't have a known hosts in home. } catch (IOException err) { // Oh well. They don't have a known hosts in home. } }
/** * Obtain the user's configuration data. * <p> * The configuration file is always returned to the caller, even if no file * exists in the user's home directory at the time the call was made. Lookup * requests are cached and are automatically updated if the user modifies * the configuration file since the last time it was cached. * * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return a caching reader of the user's configuration file. */ public static OpenSshConfig get(FS fs) { File home = fs.userHome(); if (home == null) home = new File(".").getAbsoluteFile(); //$NON-NLS-1$ final File config = new File(new File(home, SshConstants.SSH_DIR), SshConstants.CONFIG); return new OpenSshConfig(home, config); }
private static void identities(JSch sch, FS fs) { final File home = fs.userHome(); if (home == null) return; final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$ if (sshdir.isDirectory()) { loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$ } }
/** * {@inheritDoc} * * @since 4.10 */ @Override protected byte[] readIncludedConfig(String relPath) throws ConfigInvalidException { final File file; if (relPath.startsWith("~/")) { //$NON-NLS-1$ file = fs.resolve(fs.userHome(), relPath.substring(2)); } else { file = fs.resolve(configFile.getParentFile(), relPath); } if (!file.exists()) { return null; } try { return IO.readFully(file); } catch (IOException ioe) { throw new ConfigInvalidException(MessageFormat .format(JGitText.get().cannotReadFile, relPath), ioe); } } }
private Properties loadProperties() throws NotSupportedException { if (local.getDirectory() != null) { File propsFile = new File(local.getDirectory(), uri.getUser()); if (propsFile.isFile()) return loadPropertiesFile(propsFile); } File propsFile = new File(local.getFS().userHome(), uri.getUser()); if (propsFile.isFile()) return loadPropertiesFile(propsFile); Properties props = new Properties(); String user = uri.getUser(); String pass = uri.getPass(); if (user != null && pass != null) { props.setProperty("accesskey", user); //$NON-NLS-1$ props.setProperty("secretkey", pass); //$NON-NLS-1$ } else throw new NotSupportedException(MessageFormat.format( JGitText.get().cannotReadFile, propsFile)); return props; }
/** * Load the attributes node * * @return the attributes node * @throws java.io.IOException */ public AttributesNode load() throws IOException { AttributesNode r = new AttributesNode(); FS fs = repository.getFS(); String path = repository.getConfig().get(CoreConfig.KEY) .getAttributesFile(); if (path != null) { File attributesFile; if (path.startsWith("~/")) { //$NON-NLS-1$ attributesFile = fs.resolve(fs.userHome(), path.substring(2)); } else { attributesFile = fs.resolve(null, path); } FileRepository.AttributesNodeProviderImpl.loadRulesFromFile(r, attributesFile); } return r.getRules().isEmpty() ? null : r; } }
FS fs = FS.detect(); if (globalAttributesPath.startsWith("~/")) { //$NON-NLS-1$ globalAttributesFile = fs.resolve(fs.userHome(), globalAttributesPath.substring(2)); } else { globalAttributesFile = fs.resolve(null, globalAttributesPath);
@Override IgnoreNode load() throws IOException { IgnoreNode r; if (entry != null) { r = super.load(); if (r == null) r = new IgnoreNode(); } else { r = new IgnoreNode(); } FS fs = repository.getFS(); String path = repository.getConfig().get(CoreConfig.KEY) .getExcludesFile(); if (path != null) { File excludesfile; if (path.startsWith("~/")) //$NON-NLS-1$ excludesfile = fs.resolve(fs.userHome(), path.substring(2)); else excludesfile = fs.resolve(null, path); loadRulesFromFile(r, excludesfile); } File exclude = fs.resolve(repository.getDirectory(), Constants.INFO_EXCLUDE); loadRulesFromFile(r, exclude); return r.getRules().isEmpty() ? null : r; }
private static String getDefaultDefaultRepositoryDir() { return new File(FS.DETECTED.userHome(), "git").getPath(); //$NON-NLS-1$ }
private static File getDefaultFile() { File home = FS.DETECTED.userHome(); File netrc = new File(home, ".netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; netrc = new File(home, "_netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; return null; }
private static File getDefaultFile() { File home = FS.DETECTED.userHome(); File netrc = new File(home, ".netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; netrc = new File(home, "_netrc"); //$NON-NLS-1$ if (netrc.exists()) return netrc; return null; }
@Override public FileBasedConfig openUserConfig(Config parent, FS fs) { final File home = fs.userHome(); return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$ }
public FileBasedConfig openUserConfig(Config parent, FS fs) { final File home = fs.userHome(); return new FileBasedConfig(parent, new File(home, ".gitconfig"), fs); //$NON-NLS-1$ }
protected static void knownHosts(final JSch jsch, FS fs) throws JSchException { final File home = fs.userHome(); if (home == null) return; final Path knownHosts = home.toPath().resolve(HSSH.SSHDIR).resolve(HSSH.KNOWN_HOSTS); try { try (final InputStream in = Files.newInputStream(knownHosts)) { jsch.setKnownHosts(in); } } catch (IOException exception) { // No known hosts file, no real problem } }
private static void identities(JSch sch, FS fs) { final File home = fs.userHome(); if (home == null) return; final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$ if (sshdir.isDirectory()) { loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$ } }
private void identities(final JSch sch, FS fs) { final File home = fs.userHome(); if (home == null) { return; } final File sshdir = new File(home, ".ssh"); if (sshdir.isDirectory()) { loadIdentity(sch, new File(sshdir, "identity")); loadIdentity(sch, new File(sshdir, "id_rsa")); loadIdentity(sch, new File(sshdir, "id_dsa")); } }
private static void identities(final JSch sch, FS fs) { final File home = fs.userHome(); if (home == null) return; final File sshdir = new File(home, ".ssh"); //$NON-NLS-1$ if (sshdir.isDirectory()) { loadIdentity(sch, new File(sshdir, "identity")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_rsa")); //$NON-NLS-1$ loadIdentity(sch, new File(sshdir, "id_dsa")); //$NON-NLS-1$ } }
@Override protected JSch getJSch(OpenSshConfig.Host hc, FS fs) throws JSchException { JSch jsch = super.getJSch(hc, fs); if (StringUtils.hasValue(passphrase)) { // If passphrase is set, add it to identity File sshDir = new File(fs.userHome(), ".ssh"); if (sshDir.isDirectory()) { updateIdentity(jsch, new File(sshDir, "identity")); updateIdentity(jsch, new File(sshDir, "id_rsa")); updateIdentity(jsch, new File(sshDir, "id_dsa")); } } return jsch; }