private void writeDumpData(OutputStream out, String data) throws SVNException { try { out.write(data.getBytes("UTF-8")); } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } }
public SVNAuthentication getFirstAuthentication(String kind, String realm, SVNURL url) throws SVNException { myPreviousAuthentication = null; myPreviousErrorMessage = null; myLastProviderIndex = 0; // iterate over providers and ask for auth till it is found. for (int i = 0; i < myProviders.length; i++) { if (myProviders[i] == null) { continue; } SVNAuthentication auth = myProviders[i].requestClientAuthentication(kind, url, realm, null, null, myIsStoreAuth); if (auth != null) { myPreviousAuthentication = auth; myLastProviderIndex = i; return auth; } if (i == 3) { SVNErrorManager.cancel("authentication cancelled"); } } SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", realm); return null; }
public SVNSqlJetStatement getJoinedStatement(String joinedTable) throws SVNException { SVNErrorManager.assertionFailure(false, "unsupported", SVNLogType.WC); return null; }
public void open(SVNRepositoryImpl repository) throws SVNException { ISVNAuthenticationManager authManager = repository.getAuthenticationManager(); if (authManager == null) { SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", repository.getLocation()); return; if (connection == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Cannot connect to ''{0}''", repository.getLocation().setPath("", false)); SVNErrorManager.error(err, SVNLogType.NETWORK); SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } else if (connection == null || connection.isDisposed()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Can not establish connection to ''{0}''", realm), SVNLogType.NETWORK); SVNAuthentication author = authManager.getFirstAuthentication(ISVNAuthenticationManager.USERNAME, realm, repository.getLocation()); if (author == null) { SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } 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) { reconnect--;
private SVNSqlJetStatement prepareStatement(SVNWCDbStatements statementIndex) throws SVNException { final Class<? extends SVNSqlJetStatement> statementClass = statementIndex.getStatementClass(); SVNErrorManager.assertionFailure(statementClass != null, String.format("Statement '%s' not defined", statementIndex.toString()), SVNLogType.WC); if (statementClass == null) { return null; } try { final Constructor<? extends SVNSqlJetStatement> constructor = statementClass.getConstructor(SVNSqlJetDb.class); final SVNSqlJetStatement stmt = constructor.newInstance(this); return stmt; } catch (Exception e) { SVNErrorCode errorCode = SVNErrorCode.UNSUPPORTED_FEATURE; String message = e.getMessage() != null ? e.getMessage() : errorCode.getDescription(); SVNErrorMessage err = SVNErrorMessage.create(errorCode, message, new Object[0], SVNErrorMessage.TYPE_ERROR, e); SVNErrorManager.error(err, SVNLogType.WC); return null; } }
private void checkCancelled() throws SVNCancelException { if (cancelOperation) { cancelOperation = false; SVNErrorManager.cancel("operation cancelled", SVNLogType.DEFAULT); } }
/** * Getting here means the authentication tried in {@link #getFirstAuthentication(String, String, SVNURL)} * didn't work. */ @Override public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { SVNErrorManager.authenticationFailed("Authentication failed for " + url, null); return null; }
private void checkAccess(String repository, String path, boolean checkDestinationPath, String destinationPath, String user, int access) throws SVNException { if (getDAVConfig().getSVNAccess() == null) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_DAV_INVALID_CONFIG_VALUE, "An error occured while loading configuration file."), SVNLogType.NETWORK); } if (!getDAVConfig().isAnonymousAllowed() && user == null) { SVNErrorManager.authenticationFailed("Anonymous user is not allowed on resource", null); } if (path != null || (path == null && (access & SVNPathBasedAccess.SVN_ACCESS_WRITE) != SVNPathBasedAccess.SVN_ACCESS_NONE)) { if (!getDAVConfig().getSVNAccess().checkAccess(repository, path, user, access)) { if (user == null) { SVNErrorManager.authenticationFailed("Forbidden for anonymous", null); } else { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.NO_AUTH_FILE_PATH), SVNLogType.NETWORK); } } } if (checkDestinationPath) { if (path != null) { if (!getDAVConfig().getSVNAccess().checkAccess(repository, destinationPath, user, access)) { if (user == null) { SVNErrorManager.authenticationFailed("Forbidden for anonymous", null); } else { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.NO_AUTH_FILE_PATH), SVNLogType.NETWORK); } } } } }
public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { int index = Math.min(myLastProviderIndex + 1, 3); for(int i = index; i < myProviders.length; i++) { if (myProviders[i] == null) { continue; } if ((i == 1 || i == 2) && hasExplicitCredentials(kind)) { continue; } SVNAuthentication auth = myProviders[i].requestClientAuthentication(kind, url, realm, myPreviousErrorMessage, myPreviousAuthentication, myIsStoreAuth); if (auth != null) { if (i == 2) { myLastLoadedAuth = auth; } myPreviousAuthentication = auth; myLastProviderIndex = i; if (auth.isPartial()) { continue; } return auth; } if (i == 3) { SVNErrorManager.cancelAuthentication(myPreviousErrorMessage, myPreviousAuthentication); } } SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", realm); return null; }
public void open(SVNRepositoryImpl repository) throws SVNException { ISVNAuthenticationManager authManager = repository.getAuthenticationManager(); if (authManager == null) { SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", repository.getLocation()); return; if (connection == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Cannot connect to ''{0}''", repository.getLocation().setPath("", false)); SVNErrorManager.error(err, SVNLogType.NETWORK); SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } else if (connection == null || connection.isDisposed()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Can not establish connection to ''{0}''", realm), SVNLogType.NETWORK); SVNAuthentication author = authManager.getFirstAuthentication(ISVNAuthenticationManager.USERNAME, realm, repository.getLocation()); if (author == null) { SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } 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) { reconnect--;
protected long getPackedOffset(long revision) throws SVNException { //TODO: later on introduce invoking memcache here to fetch\store the requested data //long shard = revision / myMaxFilesPerDirectory; File manifestFile = getPackedRevPath(revision, PACK_KIND_MANIFEST); BufferedReader reader = null; LinkedList manifest = new LinkedList(); try { reader = new BufferedReader(new InputStreamReader(SVNFileUtil.openFileForReading(manifestFile))); String line = null; while ((line = reader.readLine()) != null) { Long offset = null; try { offset = Long.valueOf(line); } catch (NumberFormatException nfe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_CORRUPT); SVNErrorManager.error(err, SVNLogType.FSFS); } manifest.add(offset); } } catch (IOException ioe) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getMessage()); SVNErrorManager.error(err, ioe, SVNLogType.FSFS); } finally { SVNFileUtil.closeFile(reader); } Long revOffsetLong = (Long) manifest.get((int) (revision % myMaxFilesPerDirectory)); SVNErrorManager.assertionFailure(revOffsetLong != null, "offset for revision " + String.valueOf(revision) + " is null", SVNLogType.FSFS); return revOffsetLong.longValue(); }
public void checkCancelled() throws SVNCancelException { if (cancelOperation) { cancelOperation = false; SVNErrorManager.cancel("operation cancelled", SVNLogType.DEFAULT); } } }
/** * Getting here means the authentication tried in {@link #getFirstAuthentication(String, String, SVNURL)} * didn't work. */ @Override public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { SVNErrorManager.authenticationFailed("Authentication failed for " + url, null); return null; }
SVNErrorManager.cancelAuthentication(myPreviousErrorMessage, myPreviousAuthentication); SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", realm); return null;
private void lookupToken(String token, boolean isFile) throws SVNException { Boolean tokenType = (Boolean) myTokens.get(token); if (tokenType == null || tokenType != Boolean.valueOf(isFile)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Invalid file or dir token during edit"); SVNErrorManager.error(err, SVNLogType.NETWORK); } }
public void open(SVNRepositoryImpl repository) throws SVNException { ISVNAuthenticationManager authManager = repository.getAuthenticationManager(); if (authManager == null) { SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", repository.getLocation()); return; if (password == null) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.RA_NOT_AUTHORIZED, "File ''{0}'' is not valid OpenSSH DSA or RSA private key file", authentication.getPrivateKeyFile()); SVNErrorManager.error(error, SVNLogType.NETWORK); SVNErrorManager.error(err, SVNLogType.NETWORK); connection = null; SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, e); SVNErrorManager.error(error, SVNLogType.NETWORK); SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } else if (connection == null) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_SVN_CONNECTION_CLOSED, "Can not establish connection to ''{0}''", realm), SVNLogType.NETWORK); SVNAuthentication author = authManager.getFirstAuthentication(ISVNAuthenticationManager.USERNAME, realm, repository.getLocation()); if (author == null) { SVNErrorManager.cancel("authentication cancelled", SVNLogType.NETWORK); } 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);
public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { int index = Math.min(myLastProviderIndex + 1, 3); for(int i = index; i < myProviders.length; i++) { if (myProviders[i] == null) { continue; } SVNAuthentication auth = myProviders[i].requestClientAuthentication(kind, url, realm, myPreviousErrorMessage, myPreviousAuthentication, myIsStoreAuth); if (auth != null) { myPreviousAuthentication = auth; myLastProviderIndex = i; return auth; } if (i == 3) { SVNErrorManager.cancel("authentication cancelled"); } } SVNErrorManager.authenticationFailed("Authentication required for ''{0}''", realm); return null; }
public static InputStream readSpecialFile(File localAbsPath) throws SVNException { if (!SVNFileUtil.symlinksSupported()) { return SVNFileUtil.openFileForReading(localAbsPath, SVNLogType.WC); } /* * First determine what type of special file we are detranslating. */ final SVNFileType filetype = SVNFileType.getType(localAbsPath); if (SVNFileType.FILE == filetype) { /* * Nothing special to do here, just create stream from the original * file's contents. */ return SVNFileUtil.openFileForReading(localAbsPath, SVNLogType.WC); } else if (SVNFileType.SYMLINK == filetype) { /* Determine the destination of the link. */ String linkPath = SVNFileUtil.getSymlinkName(localAbsPath); if (linkPath == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot detranslate symbolic link ''{0}''; file does not exist or not a symbolic link", localAbsPath); SVNErrorManager.error(err, SVNLogType.DEFAULT); } String symlinkContents = "link " + linkPath; return new ByteArrayInputStream(symlinkContents.getBytes()); } else { SVNErrorManager.assertionFailure(false, "ERR_MALFUNCTION", SVNLogType.WC); } return null; }
public void checkCancelled() throws SVNCancelException { if (myCancelOperation) { myCancelOperation = false; SVNErrorManager.cancel("operation cancelled", SVNLogType.DEFAULT); } } };
/** * Getting here means the authentication tried in {@link #getFirstAuthentication(String, String, SVNURL)} * didn't work. */ @Override public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { SVNErrorManager.authenticationFailed("Authentication failed for " + url, null); return null; }