def _sign_agent_package(agent_package, **kwargs): '''Sign an agent package''' if not os.path.exists(agent_package): raise AgentPackageError('Invalid package {}'.format(agent_package)) cert_type = _cert_type_from_kwargs(**kwargs) files = _files_from_kwargs(**kwargs) certs_dir = kwargs.get('certs_dir', None) certsobj = None if certs_dir is not None: certsobj = certs.Certs(certs_dir) if cert_type == 'admin': if files: raise AgentPackageError("admin's aren't allowed to add files.") verified = auth.sign_as_admin(agent_package, 'admin', certsobj = certsobj) elif cert_type == 'creator': verified = auth.sign_as_creator(agent_package, 'creator', files, certsobj = certsobj) elif cert_type == 'initiator': verified = auth.sign_as_initiator(agent_package, 'initiator', files, certsobj = certsobj) elif cert_type == 'platform': verified = auth.sign_as_platform(agent_package, 'platform', files) else: raise AgentPackageError('Unknown packaging options') if verified: print('{} signed as {}'.format(agent_package, cert_type)) else: print('Verification of signing failed!')
def _sign_agent_package(agent_package, **kwargs): '''Sign an agent package''' if not os.path.exists(agent_package): raise AgentPackageError('Invalid package {}'.format(agent_package)) cert_type = _cert_type_from_kwargs(**kwargs) files = _files_from_kwargs(**kwargs) certs_dir = kwargs.get('certs_dir', None) certsobj = None if certs_dir is not None: certsobj = certs.Certs(certs_dir) if cert_type == 'admin': if files: raise AgentPackageError("admin's aren't allowed to add files.") verified = auth.sign_as_admin(agent_package, 'admin', certsobj = certsobj) elif cert_type == 'creator': verified = auth.sign_as_creator(agent_package, 'creator', files, certsobj = certsobj) elif cert_type == 'initiator': verified = auth.sign_as_initiator(agent_package, 'initiator', files, certsobj = certsobj) elif cert_type == 'platform': verified = auth.sign_as_platform(agent_package, 'platform', files) else: raise AgentPackageError('Unknown packaging options') if verified: print('{} signed as {}'.format(agent_package, cert_type)) else: print('Verification of signing failed!')