private boolean reparent(SVNURL url) throws SVNException { if (myConnection != null) { if (getLocation().equals(url)) { return true; } try { Object[] buffer = new Object[]{"reparent", url.toString()}; write("(w(s))", buffer); authenticate(); read("", null, false); String newLocation = url.toString(); String rootLocation = myRepositoryRoot.toString(); return newLocation.startsWith(rootLocation) && (newLocation.length() == rootLocation.length() || (newLocation.length() > rootLocation.length() && newLocation.charAt(rootLocation.length()) == '/')); } catch (SVNException e) { if (e instanceof SVNCancelException || e instanceof SVNAuthenticationException) { throw e; } } } return false; }
private boolean reparent(SVNURL url) throws SVNException { if (myConnection != null) { if (getLocation().equals(url)) { return true; } try { Object[] buffer = new Object[]{"reparent", url.toString()}; write("(w(s))", buffer); authenticate(); read("", null, false); String newLocation = url.toString(); String rootLocation = myRepositoryRoot.toString(); return newLocation.startsWith(rootLocation) && (newLocation.length() == rootLocation.length() || (newLocation.length() > rootLocation.length() && newLocation.charAt(rootLocation.length()) == '/')); } catch (SVNException e) { if (e instanceof SVNCancelException || e instanceof SVNAuthenticationException) { throw e; } } } return false; }
private boolean reparent(SVNURL url) throws SVNException { if (myConnection != null) { if (getLocation().equals(url)) { return true; } try { Object[] buffer = new Object[]{"reparent", url.toString()}; write("(w(s))", buffer); authenticate(); read("", null, false); String newLocation = url.toString(); String rootLocation = myRepositoryRoot.toString(); return newLocation.startsWith(rootLocation) && (newLocation.length() == rootLocation.length() || (newLocation.length() > rootLocation.length() && newLocation.charAt(rootLocation.length()) == '/')); } catch (SVNException e) { if (e instanceof SVNCancelException || e instanceof SVNAuthenticationException) { throw e; } } } return false; }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort()); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e); } }
public void open(SVNRepositoryImpl repository) throws SVNException { // 1. expand tunnel spec (when env. is used). String expandedTunnel = expandTunnelSpec(myName, myTunnelSpec); // 2. create tunnel command using repo URL. String host = repository.getLocation().getHost(); if (repository.getLocation().getUserInfo() != null && !"".equals(repository.getLocation().getUserInfo())) { String username = repository.getLocation().getUserInfo(); host = username + "@" + host; } expandedTunnel = MessageFormat.format(TUNNEL_COMMAND, new Object[] {expandedTunnel, host}); // 3. get and append --tunnel-user if needed. if (repository.getAuthenticationManager() != null) { SVNAuthentication auth = repository.getAuthenticationManager().getFirstAuthentication(ISVNAuthenticationManager.USERNAME, host, repository.getLocation()); if (auth == null) { SVNErrorManager.cancel("Authentication cancelled", SVNLogType.NETWORK); } String userName = auth.getUserName(); if (userName == null || "".equals(userName.trim())) { userName = System.getProperty("user.name"); } auth = new SVNUserNameAuthentication(userName, auth.isStorageAllowed(), repository.getLocation(), false); repository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.USERNAME, host, null, auth); expandedTunnel += " --tunnel-user " + userName; repository.setExternalUserName(userName); } SVNDebugLog.getDefaultLog().logFinest(SVNLogType.NETWORK, "tunnel command: " + expandedTunnel); open(repository, expandedTunnel); }
public void open(SVNRepositoryImpl repository) throws SVNException { // 1. expand tunnel spec (when env. is used). String expandedTunnel = expandTunnelSpec(myName, myTunnelSpec); // 2. create tunnel command using repo URL. String host = repository.getLocation().getHost(); if (repository.getLocation().getUserInfo() != null && !"".equals(repository.getLocation().getUserInfo())) { String username = repository.getLocation().getUserInfo(); host = username + "@" + host; } expandedTunnel = MessageFormat.format(TUNNEL_COMMAND, new Object[] {expandedTunnel, host}); // 3. get and append --tunnel-user if needed. if (repository.getAuthenticationManager() != null) { SVNAuthentication auth = repository.getAuthenticationManager().getFirstAuthentication(ISVNAuthenticationManager.USERNAME, host, repository.getLocation()); if (auth == null) { SVNErrorManager.cancel("Authentication cancelled", SVNLogType.NETWORK); } String userName = auth.getUserName(); if (userName == null || "".equals(userName.trim())) { userName = System.getProperty("user.name"); } auth = new SVNUserNameAuthentication(userName, auth.isStorageAllowed(), repository.getLocation(), false); repository.getAuthenticationManager().acknowledgeAuthentication(true, ISVNAuthenticationManager.USERNAME, host, null, auth); expandedTunnel += " --tunnel-user " + userName; repository.setExternalUserName(userName); } SVNDebugLog.getDefaultLog().logFinest(SVNLogType.NETWORK, "tunnel command: " + expandedTunnel); open(repository, expandedTunnel); }
private void receiveRepositoryCredentials(SVNRepositoryImpl repository) throws SVNException { if (myIsCredentialsReceived) { return; } List creds = read("s?s?l", null, true); myIsCredentialsReceived = true; if (creds != null && creds.size() >= 2 && creds.get(0) != null && creds.get(1) != null) { SVNURL rootURL = creds.get(1) != null ? SVNURL.parseURIEncoded(SVNReader.getString(creds, 1)) : null; if (rootURL != null && rootURL.toString().length() > repository.getLocation().toString().length()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Impossibly long repository root from server"), SVNLogType.NETWORK); } if (repository != null && repository.getRepositoryRoot(false) == null) { repository.updateCredentials(SVNReader.getString(creds, 0), rootURL); } if (myRealm == null) { myRealm = SVNReader.getString(creds, 0); } if (myRoot == null) { myRoot = SVNReader.getString(creds, 1); } if (creds.size() > 2 && creds.get(2) instanceof List) { List capabilities = (List) creds.get(2); addCapabilities(capabilities); } } }
private void receiveRepositoryCredentials(SVNRepositoryImpl repository) throws SVNException { if (myIsCredentialsReceived) { return; } List creds = read("s?s?l", null, true); myIsCredentialsReceived = true; if (creds != null && creds.size() >= 2 && creds.get(0) != null && creds.get(1) != null) { SVNURL rootURL = creds.get(1) != null ? SVNURL.parseURIEncoded(SVNReader.getString(creds, 1)) : null; if (rootURL != null && rootURL.toString().length() > repository.getLocation().toString().length()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Impossibly long repository root from server"), SVNLogType.NETWORK); } if (repository != null && repository.getRepositoryRoot(false) == null) { repository.updateCredentials(SVNReader.getString(creds, 0), rootURL); } if (myRealm == null) { myRealm = SVNReader.getString(creds, 0); } if (myRoot == null) { myRoot = SVNReader.getString(creds, 1); } if (creds.size() > 2 && creds.get(2) instanceof List) { List capabilities = (List) creds.get(2); addCapabilities(capabilities); } } }
private void receiveRepositoryCredentials(SVNRepositoryImpl repository) throws SVNException { if (myIsCredentialsReceived) { return; } List creds = read("s?s?l", null, true); myIsCredentialsReceived = true; if (creds != null && creds.size() >= 2 && creds.get(0) != null && creds.get(1) != null) { SVNURL rootURL = creds.get(1) != null ? SVNURL.parseURIEncoded(SVNReader.getString(creds, 1)) : null; if (rootURL != null && rootURL.toString().length() > repository.getLocation().toString().length()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Impossibly long repository root from server"), SVNLogType.NETWORK); } if (repository != null && repository.getRepositoryRoot(false) == null) { repository.updateCredentials(SVNReader.getString(creds, 0), rootURL); } if (myRealm == null) { myRealm = SVNReader.getString(creds, 0); } if (myRoot == null) { myRoot = SVNReader.getString(creds, 1); } if (creds.size() > 2 && creds.get(2) instanceof List) { List capabilities = (List) creds.get(2); addCapabilities(capabilities); } } }
repository.getLocation().toString()});
private void openConnection() throws SVNException { if (myConnection != null) { // attempt to reparent, close connection if reparent failed. if (reparent(getLocation())) { return; } } lock(); ISVNConnector connector = SVNRepositoryFactoryImpl.getConnectorFactory().createConnector(this); myConnection = new SVNConnection(connector, this); try { myConnection.open(this); authenticate(); } finally { myRealm = myConnection.getRealm(); } }
protected void handshake(SVNRepositoryImpl repository) throws SVNException { Object[] items = read("[(*N(*W)(*W))]", null, true); if (!SVNReader.hasValue(items, 0, 2)) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_BAD_VERSION, "Only protocol of version '2' or older is supported")); } else if (!SVNReader.hasValue(items, 2, EDIT_PIPELINE)) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_BAD_VERSION, "Only servers with 'edit-pipeline' capability is supported")); } myIsSVNDiff1 = SVNReader.hasValue(items, 2, SVNDIFF1); write("(n(www)s)", new Object[] { "2", EDIT_PIPELINE, SVNDIFF1, ABSENT_ENTRIES, repository.getLocation().toString() }); }
private boolean reparent(SVNURL url) throws SVNException { if (myConnection != null) { if (getLocation().equals(url)) { return true; } lock(); try { Object[] buffer = new Object[] {"reparent", url.toString()}; write("(w(s))", buffer); authenticate(); read("[()]", null, true); return true; } catch (SVNException e) { closeSession(); if (e instanceof SVNCancelException || e instanceof SVNAuthenticationException) { throw e; } } finally { unlock(); } } return false; }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { int connectTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getConnectTimeout(repository) : DEFAULT_SVN_TIMEOUT; int readTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getReadTimeout(repository) : DEFAULT_SVN_TIMEOUT; mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort(), connectTimeout, readTimeout, repository.getCanceller()); } catch (SocketTimeoutException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "timed out waiting for server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (UnknownHostException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "Unknown host " + e.getMessage(), null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (ConnectException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "connection refused by the server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { int connectTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getConnectTimeout(repository) : DEFAULT_SVN_TIMEOUT; int readTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getReadTimeout(repository) : DEFAULT_SVN_TIMEOUT; mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort(), connectTimeout, readTimeout, repository.getCanceller()); } catch (SocketTimeoutException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "timed out waiting for server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (UnknownHostException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "Unknown host " + e.getMessage(), null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (ConnectException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "connection refused by the server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } }
public void open(SVNRepositoryImpl repository) throws SVNException { if (mySocket != null) { return; } SVNURL location = repository.getLocation(); try { int connectTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getConnectTimeout(repository) : DEFAULT_SVN_TIMEOUT; int readTimeout = repository.getAuthenticationManager() != null ? repository.getAuthenticationManager().getReadTimeout(repository) : DEFAULT_SVN_TIMEOUT; mySocket = SVNSocketFactory.createPlainSocket(location.getHost(), location.getPort(), connectTimeout, readTimeout, repository.getCanceller()); } catch (SocketTimeoutException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "timed out waiting for server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (UnknownHostException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "Unknown host " + e.getMessage(), null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (ConnectException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, "connection refused by the server", null, SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_IO_ERROR, e.getLocalizedMessage()); SVNErrorManager.error(err, e, SVNLogType.NETWORK); } }
protected void openConnection() throws SVNException { fireConnectionOpened(); lock(); // check if connection is stale. if (myConnection != null && myConnection.isConnectionStale()) { closeSession(); } if (myConnection != null) { if (reparent(getLocation())) { return; } closeSession(); } ISVNConnector connector = SVNRepositoryFactoryImpl.getConnectorFactory().createConnector(this); myConnection = new SVNConnection(connector, this); try { myConnection.open(this); authenticate(); } finally { if (myConnection != null) { myRealm = myConnection.getRealm(); } } }
protected void openConnection() throws SVNException { lock(); fireConnectionOpened(); // check if connection is stale. if (myConnection != null && myConnection.isConnectionStale()) { closeSession(); } if (myConnection != null) { if (reparent(getLocation())) { return; } closeSession(); } ISVNConnector connector = SVNRepositoryFactoryImpl.getConnectorFactory().createConnector(this); myConnection = new SVNConnection(connector, this); try { myConnection.open(this); authenticate(); } finally { if (myConnection != null) { myRealm = myConnection.getRealm(); } } }
protected void openConnection() throws SVNException { lock(); fireConnectionOpened(); // check if connection is stale. if (myConnection != null && myConnection.isConnectionStale()) { closeSession(); } if (myConnection != null) { if (reparent(getLocation())) { return; } closeSession(); } ISVNConnector connector = SVNRepositoryFactoryImpl.getConnectorFactory().createConnector(this); myConnection = new SVNConnection(connector, this); try { myConnection.open(this); authenticate(); } finally { if (myConnection != null) { myRealm = myConnection.getRealm(); } } }
public SVNDirEntry info(String path, long revision) throws SVNException { try { openConnection(); String fullPath = getFullPath(path); SVNURL url = getLocation().setPath(fullPath, false); path = getRepositoryPath(path); Object[] buffer = new Object[] { "stat", path, getRevisionObject(revision) }; write("(w(s(n)))", buffer); authenticate(); read("[((?F))]", buffer, true); SVNDirEntry entry = (SVNDirEntry) buffer[0]; if (entry != null) { entry = new SVNDirEntry(url, SVNPathUtil.tail(path), entry.getKind(), entry.getSize(), entry.hasProperties(), entry.getRevision(), entry.getDate(), entry.getAuthor()); } return entry; } catch (SVNException e) { closeSession(); handleUnsupportedCommand(e, "'stat' not implemented"); } finally { closeConnection(); } return null; }