protected static boolean isSshUri(Object uri) { if(uri != null) { try { URIish urIish = new URIish(uri.toString()); String scheme = urIish.getScheme(); if(scheme == null && hasText(urIish.getHost()) && hasText(urIish.getUser())) { //JGit returns null if using SCP URI but user and host will be populated return true; } return scheme != null && !scheme.matches("^(http|https)$"); } catch (URISyntaxException e) { return false; } } return false; }
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; }
@Override public Process exec(String command, int timeout) throws TransportException { String ssh = SystemReader.getInstance().getenv("GIT_SSH"); //$NON-NLS-1$ boolean putty = ssh.toLowerCase(Locale.ROOT).contains("plink"); //$NON-NLS-1$ List<String> args = new ArrayList<>(); args.add(ssh); if (putty && !ssh.toLowerCase(Locale.ROOT).contains("tortoiseplink")) //$NON-NLS-1$ args.add("-batch"); //$NON-NLS-1$ if (0 < getURI().getPort()) { args.add(putty ? "-P" : "-p"); //$NON-NLS-1$ //$NON-NLS-2$ args.add(String.valueOf(getURI().getPort())); } if (getURI().getUser() != null) args.add(getURI().getUser() + "@" + getURI().getHost()); //$NON-NLS-1$ else args.add(getURI().getHost()); args.add(command); ProcessBuilder pb = createProcess(args); try { return pb.start(); } catch (IOException err) { throw new TransportException(err.getMessage(), err); } }
/** {@inheritDoc} */ @Override public int hashCode() { int hc = 0; if (getScheme() != null) hc = hc * 31 + getScheme().hashCode(); if (getUser() != null) hc = hc * 31 + getUser().hashCode(); if (getPass() != null) hc = hc * 31 + getPass().hashCode(); if (getHost() != null) hc = hc * 31 + getHost().hashCode(); if (getPort() > 0) hc = hc * 31 + getPort(); if (getPath() != null) hc = hc * 31 + getPath().hashCode(); return hc; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { if (!(obj instanceof URIish)) return false; final URIish b = (URIish) obj; if (!eq(getScheme(), b.getScheme())) return false; if (!eq(getUser(), b.getUser())) return false; if (!eq(getPass(), b.getPass())) return false; if (!eq(getHost(), b.getHost())) return false; if (getPort() != b.getPort()) return false; if (!eq(getPath(), b.getPath())) return false; return true; }
return false; } else { username = uri.getUser(); password = uri.getPass();
throws TransportException { String user = uri.getUser(); final String pass = uri.getPass(); String host = uri.getHost();
public void modifyText(final ModifyEvent e) { eventDepth++; try { if (eventDepth == 1) { URIish u = new URIish(uriText.getText()); String newUser = u.getUser(); user.setText(newUser != null ? newUser : ""); //$NON-NLS-1$ } } catch (URISyntaxException e1) { // empty } finally { eventDepth--; } checkPage(); } });
public int hashCode() { int hc = 0; if (getScheme() != null) hc = hc * 31 + getScheme().hashCode(); if (getUser() != null) hc = hc * 31 + getUser().hashCode(); if (getPass() != null) hc = hc * 31 + getPass().hashCode(); if (getHost() != null) hc = hc * 31 + getHost().hashCode(); if (getPort() > 0) hc = hc * 31 + getPort(); if (getPath() != null) hc = hc * 31 + getPath().hashCode(); return hc; }
@Override public boolean handles(URIish uri) { if (getDefaultScheme().equals(uri.getScheme())) return true; if (uri.getHost() != null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getPath() == null) return false; if (uri.getScheme() == null) return FS.DETECTED .resolve(new File("."), uri.getPath()).isDirectory(); //$NON-NLS-1$ return false; } };
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }
@Override public boolean canHandle(URIish uri, Repository local, String remoteName) { if (uri.getPath() == null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getHost() != null || (uri.getScheme() != null && !getSchemes().contains(uri.getScheme()))) return false; return true; }