本文整理匯總了Python中sfa.trust.gid.GID.decode方法的典型用法代碼示例。如果您正苦於以下問題:Python GID.decode方法的具體用法?Python GID.decode怎麽用?Python GID.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfa.trust.gid.GID
的用法示例。
在下文中一共展示了GID.decode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read_cert_from_file
# 需要導入模塊: from sfa.trust.gid import GID [as 別名]
# 或者: from sfa.trust.gid.GID import decode [as 別名]
def read_cert_from_file(cert_fname):
"""Read a GCF certificate from a file.
Read the certificate from a file and put it into a C{sfa.trust.gid.GID}
object. The returned certificate is already decoded.
@param cert_fname: The filename to read the cert from
@type cert_fname: C{str}
@return: The certificate stored in the file at C{cert_fname}
@rtype: C{sfa.trust.gid.GID}
"""
cert = GID(filename=cert_fname)
cert.decode()
return cert
示例2: get_trusted_certs
# 需要導入模塊: from sfa.trust.gid import GID [as 別名]
# 或者: from sfa.trust.gid.GID import decode [as 別名]
def get_trusted_certs(registry=None, verbose=False):
"""
refresh our list of trusted certs.
"""
# define useful variables
config = Config()
data_dir = config.SFA_DATA_DIR
config_dir = config.SFA_CONFIG_DIR
trusted_certs_dir = config.get_trustedroots_dir()
keyfile = data_dir + os.sep + "server.key"
certfile = data_dir + os.sep + "server.cert"
node_gid_file = config_dir + os.sep + "node.gid"
node_gid = GID(filename=node_gid_file)
hrn = node_gid.get_hrn()
# get credential
cred = GetCredential(registry=registry, verbose=verbose)
# make sure server key cert pair exists
create_server_keypair(keyfile=keyfile, certfile=certfile, hrn=hrn, verbose=verbose)
registry = server_proxy(url=registry, keyfile=keyfile, certfile=certfile)
# get the trusted certs and save them in the right place
if verbose:
print "Getting trusted certs from registry"
trusted_certs = registry.get_trusted_certs(cred)
trusted_gid_names = []
for gid_str in trusted_certs:
gid = GID(string=gid_str)
gid.decode()
relative_filename = gid.get_hrn() + ".gid"
trusted_gid_names.append(relative_filename)
gid_filename = trusted_certs_dir + os.sep + relative_filename
if verbose:
print "Writing GID for %s as %s" % (gid.get_hrn(), gid_filename)
gid.save_to_file(gid_filename, save_parents=True)
# remove old certs
all_gids_names = os.listdir(trusted_certs_dir)
for gid_name in all_gids_names:
if gid_name not in trusted_gid_names:
if verbose:
print "Removing old gid ", gid_name
os.unlink(trusted_certs_dir + os.sep + gid_name)
示例3: install_trusted_certs
# 需要導入模塊: from sfa.trust.gid import GID [as 別名]
# 或者: from sfa.trust.gid.GID import decode [as 別名]
def install_trusted_certs(api):
cred = api.getCredential()
registry = api.get_registry()
trusted_certs = registry.get_trusted_certs(cred)
trusted_gid_names = []
for gid_str in trusted_certs:
gid = GID(string=gid_str)
gid.decode()
relative_filename = gid.get_hrn() + ".gid"
trusted_gid_names.append(relative_filename)
gid_filename = trusted_certs_dir + os.sep + relative_filename
if verbose:
print("Writing GID for %s as %s" % (gid.get_hrn(), gid_filename))
gid.save_to_file(gid_filename, save_parents=True)
# remove old certs
all_gids_names = os.listdir(trusted_certs_dir)
for gid_name in all_gids_names:
if gid_name not in trusted_gid_names:
if verbose:
print("Removing old gid ", gid_name)
os.unlink(trusted_certs_dir + os.sep + gid_name)