An example implementation of authentication via handshake.
| 598 | |
| 599 | |
| 600 | class TokenClientAuthHandler(ClientAuthHandler): |
| 601 | """An example implementation of authentication via handshake.""" |
| 602 | |
| 603 | def __init__(self, username, password): |
| 604 | super().__init__() |
| 605 | self.username = username |
| 606 | self.password = password |
| 607 | self.token = b'' |
| 608 | |
| 609 | def authenticate(self, outgoing, incoming): |
| 610 | outgoing.write(self.username) |
| 611 | outgoing.write(self.password) |
| 612 | self.token = incoming.read() |
| 613 | |
| 614 | def get_token(self): |
| 615 | return self.token |
| 616 | |
| 617 | |
| 618 | class NoopAuthHandler(ServerAuthHandler): |
no outgoing calls