error.py 2.6 KB

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