import re
from collections import defaultdict
-from gkeys.config import GKEY, KEYLEN_MAP
+from gkeys.config import GKEY
from gkeys.seed import Seeds
from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH)
'''
result = []
for keyid in keyids:
- target_len = KEYLEN_MAP[key_len]
+ target_len = 16
if keyid.startswith('0x'):
- target_len = KEYLEN_MAP[key_len] + 2
+ target_len = target_len + 2
if len(keyid) == target_len:
result.append(keyid)
return result
# assume it's good until an error is found
is_good = True
#self.logger.debug("Actions: build_gkeylist; info = %s" % str(info))
- for attr in GKEY._fields:
+ for attr in gkey2ldap_map:
field = gkey2ldap_map[attr]
if not field:
keyinfo[attr] = None
values = [v.replace(' ', '') for v in values]
# assign it to gpgkey to prevent a possible
# "gpgkey" undefined error
- gpgkey = ['0x' + x[-KEYLEN_MAP['longkeyid']:] for x in values]
+ gpgkey = ['0x' + x[-16:] for x in values]
keyinfo['longkeyid'] = gpgkey
self.logger.debug(' Generate gpgkey, NEW keyinfo[\'fingerprint\'] = %s'
% str(keyinfo['longkeyid']))
'keydir': 'uid',
'fingerprint': 'gpgfingerprint'
}
-# Sanity check they are in sync
-if not sorted(gkey2ldap_map) == sorted(GKEY._fields):
- raise "Search.py out of sync with GKEY class"
# Now for some search field defaults
return super(GKeysConfig, self)._get_(key, subkey)
-# set some defaults
-KEYLEN_MAP = {
- 'keyid': 8,
- 'longkeyid': 16,
-}
-
-class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
- 'keydir', 'fingerprint'])):
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
'''Class to hold the relavent info about a key'''
- # subclass __new__ to make both gkeys and gkeyldap work properly
- # delete it when keyid and longkeyid are removed from LDAP
- def __new__(cls, nick=None, name=None, keydir=None, fingerprint=None,
- keyid=None, longkeyid=None):
- return super(GKEY, cls).__new__(cls, nick, name, keydir, fingerprint,
- keyid, longkeyid)
field_types = {'nick': str, 'name': str, 'keyid': list,
'longkeyid': list, 'keydir': str, 'fingerprint': list}