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