+def cmd_info(argv):
+ try:
+ opts, argv = getopt(argv, '', [])
+ except GetoptError:
+ return 1
+ if len(argv) != 1:
+ return 1
+ local = argv[0]
+ db = CMDB(dbfile)
+ try:
+ id = getid(local)
+ a = AttrMultiMap(db, id)
+ if user is not None and user != a.get('user', [None])[0]:
+ raise Reject, 'not your token'
+ if 'addr' not in a:
+ die('unknown token (expired?)')
+ keys = a.keys()
+ keys.sort()
+ for k in keys:
+ for v in a[k]:
+ print '%s: %s' % (k, v)
+ expwhen = db.expiry(id)
+ if expwhen:
+ print 'expires: %s'
+ else:
+ print 'no-expiry'
+ except Reject, msg:
+ die('invalid token')
+commands['info'] = \
+ (cmd_info, 'LOCAL', """
+Exaimne the address token LOCAL, and print information about it to standard
+output.""")
+
+def cmd_revoke(argv):
+ try:
+ opts, argv = getopt(argv, '', [])
+ except GetoptError:
+ return 1
+ if len(argv) != 1:
+ return 1
+ local = argv[0]
+ db = CMDB(dbfile)
+ try:
+ id = getid(local)
+ a = AttrMultiMap(db, id)
+ if user is not None and user != a.get('user', [None])[0]:
+ raise Reject, 'not your token'
+ if 'addr' not in a:
+ die('unknown token (expired?)')
+ a.clear()
+ db.cleanup()
+ db.commit()
+ except Reject, msg:
+ die('invalid token')
+commands['revoke'] = \
+ (cmd_revoke, 'LOCAL', """
+Revoke the token LOCAL.""")
+