Show the content of a CCache
(self, utc=False)
| 501 | return fd.write(bytes(self.keytab)) |
| 502 | |
| 503 | def show(self, utc=False): |
| 504 | """ |
| 505 | Show the content of a CCache |
| 506 | """ |
| 507 | |
| 508 | def _to_str(x): |
| 509 | if x is None: |
| 510 | return "None" |
| 511 | else: |
| 512 | x = datetime.fromtimestamp(x, tz=timezone.utc if utc else None) |
| 513 | return x.strftime("%d/%m/%y %H:%M:%S") |
| 514 | |
| 515 | # Show Keytab |
| 516 | if self.keytab.entries: |
| 517 | print("Keytab name: %s" % (self.keytab_fname or "UNSAVED")) |
| 518 | print( |
| 519 | pretty_list( |
| 520 | [ |
| 521 | ( |
| 522 | entry.getPrincipal(), |
| 523 | _to_str(entry.timestamp), |
| 524 | str(entry.versionNumber), |
| 525 | entry.key.sprintf("%keytype%"), |
| 526 | ) |
| 527 | for entry in self.keytab.entries |
| 528 | ], |
| 529 | [("Principal", "Timestamp", "KVNO", "Keytype")], |
| 530 | ) |
| 531 | ) |
| 532 | print() |
| 533 | |
| 534 | # Show CCache |
| 535 | if not self.ccache.credentials: |
| 536 | print("No tickets in CCache.") |
| 537 | return |
| 538 | else: |
| 539 | print("CCache tickets:") |
| 540 | |
| 541 | for i, cred in enumerate(self.ccache.credentials): |
| 542 | if cred.keyblock.keytype == 0: |
| 543 | continue |
| 544 | print( |
| 545 | "%s. %s -> %s" |
| 546 | % ( |
| 547 | i, |
| 548 | cred.client.toPN(), |
| 549 | cred.server.toPN(), |
| 550 | ) |
| 551 | ) |
| 552 | print(cred.sprintf(" %ticket_flags%")) |
| 553 | print( |
| 554 | pretty_list( |
| 555 | [ |
| 556 | ( |
| 557 | _to_str(cred.starttime), |
| 558 | _to_str(cred.endtime), |
| 559 | _to_str(cred.renew_till), |
| 560 | _to_str(cred.authtime), |
no test coverage detected