error.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. An error to represent bad things happening in Conch.
  5. Maintainer: Paul Swartz
  6. """
  7. from __future__ import absolute_import, division
  8. from twisted.cred.error import UnauthorizedLogin
  9. class ConchError(Exception):
  10. def __init__(self, value, data = None):
  11. Exception.__init__(self, value, data)
  12. self.value = value
  13. self.data = data
  14. class NotEnoughAuthentication(Exception):
  15. """
  16. This is thrown if the authentication is valid, but is not enough to
  17. successfully verify the user. i.e. don't retry this type of
  18. authentication, try another one.
  19. """
  20. class ValidPublicKey(UnauthorizedLogin):
  21. """
  22. Raised by public key checkers when they receive public key credentials
  23. that don't contain a signature at all, but are valid in every other way.
  24. (e.g. the public key matches one in the user's authorized_keys file).
  25. Protocol code (eg
  26. L{SSHUserAuthServer<twisted.conch.ssh.userauth.SSHUserAuthServer>}) which
  27. attempts to log in using
  28. L{ISSHPrivateKey<twisted.cred.credentials.ISSHPrivateKey>} credentials
  29. should be prepared to handle a failure of this type by telling the user to
  30. re-authenticate using the same key and to include a signature with the new
  31. attempt.
  32. See U{http://www.ietf.org/rfc/rfc4252.txt} section 7 for more details.
  33. """
  34. class IgnoreAuthentication(Exception):
  35. """
  36. This is thrown to let the UserAuthServer know it doesn't need to handle the
  37. authentication anymore.
  38. """
  39. class MissingKeyStoreError(Exception):
  40. """
  41. Raised if an SSHAgentServer starts receiving data without its factory
  42. providing a keys dict on which to read/write key data.
  43. """
  44. class UserRejectedKey(Exception):
  45. """
  46. The user interactively rejected a key.
  47. """
  48. class InvalidEntry(Exception):
  49. """
  50. An entry in a known_hosts file could not be interpreted as a valid entry.
  51. """
  52. class HostKeyChanged(Exception):
  53. """
  54. The host key of a remote host has changed.
  55. @ivar offendingEntry: The entry which contains the persistent host key that
  56. disagrees with the given host key.
  57. @type offendingEntry: L{twisted.conch.interfaces.IKnownHostEntry}
  58. @ivar path: a reference to the known_hosts file that the offending entry
  59. was loaded from
  60. @type path: L{twisted.python.filepath.FilePath}
  61. @ivar lineno: The line number of the offending entry in the given path.
  62. @type lineno: L{int}
  63. """
  64. def __init__(self, offendingEntry, path, lineno):
  65. Exception.__init__(self)
  66. self.offendingEntry = offendingEntry
  67. self.path = path
  68. self.lineno = lineno