authority.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:janus 作者: mikelovell 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号