Authenticate command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - it must appear in .capabilities in the form AUTH= . 'authobject' must be a callable object: data =
(self, mechanism, authobject)
| 418 | |
| 419 | |
| 420 | def authenticate(self, mechanism, authobject): |
| 421 | """Authenticate command - requires response processing. |
| 422 | |
| 423 | 'mechanism' specifies which authentication mechanism is to |
| 424 | be used - it must appear in <instance>.capabilities in the |
| 425 | form AUTH=<mechanism>. |
| 426 | |
| 427 | 'authobject' must be a callable object: |
| 428 | |
| 429 | data = authobject(response) |
| 430 | |
| 431 | It will be called to process server continuation responses; the |
| 432 | response argument it is passed will be a bytes. It should return bytes |
| 433 | data that will be base64 encoded and sent to the server. It should |
| 434 | return None if the client abort response '*' should be sent instead. |
| 435 | """ |
| 436 | mech = mechanism.upper() |
| 437 | # XXX: shouldn't this code be removed, not commented out? |
| 438 | #cap = 'AUTH=%s' % mech |
| 439 | #if not cap in self.capabilities: # Let the server decide! |
| 440 | # raise self.error("Server doesn't allow %s authentication." % mech) |
| 441 | self.literal = _Authenticator(authobject).process |
| 442 | typ, dat = self._simple_command('AUTHENTICATE', mech) |
| 443 | if typ != 'OK': |
| 444 | raise self.error(dat[-1].decode('utf-8', 'replace')) |
| 445 | self.state = 'AUTH' |
| 446 | return typ, dat |
| 447 | |
| 448 | |
| 449 | def capability(self): |
no test coverage detected