def from_configparser(cfg):
if not cfg.has_section('janus:global'):
err = 'Config File does not have a janus:global section'
raise Exception(err)
if not cfg.has_option('janus:global', 'enabled_authorities'):
err = 'enabled_authorities not defined in janus:global section'
raise Exception(err)
authorities = {}
authorities_str = cfg.get('janus:global', 'enabled_authorities')
authority_names = authorities_str.split(',')
for authority_name in authority_names:
authority_section = "janus:ca_{}".format(authority_name)
if not cfg.has_section(authority_section):
err = "Authority section for {} not found".format(authority_section)
print(err)
continue
if cfg.has_option(authority_section, 'uuid'):
authority_id = str(uuid.UUID(cfg.get(authority_section, 'uuid')))
else:
authority_id = str(uuid.uuid5(AUTHORITY_NAMESPACE, authority_name))
authority = SSHCertAuthority.from_configparser(cfg, authority_section)
authorities[authority_id] = authority
return SSHCertAuthorityManager(authorities=authorities)
# vim: ts=4 expandtab
评论列表
文章目录