Adding UI elements

This commit is contained in:
kevgliss
2015-11-27 13:27:14 -08:00
parent 920d595c12
commit 8eeed821d3
11 changed files with 139 additions and 35 deletions

View File

@ -77,22 +77,18 @@ def find_duplicates(cert_body):
return Certificate.query.filter_by(body=cert_body).all()
def export(cert_id, export_options):
def export(cert, export_plugin):
"""
Exports a certificate to the requested format. This format
may be a binary format.
:param export_options:
:param cert_id:
:param export_plugin:
:param cert:
:return:
"""
cert = get(cert_id)
export_plugin = plugins.get(export_options['slug'])
plugin = plugins.get(export_plugin['slug'])
data = export_plugin.export(cert.body, cert.key)
if export_options.get('encrypted'):
pass
return data
return plugin.export(cert.body, cert.chain, cert.private_key, export_plugin['pluginOptions'])
def update(cert_id, owner, description, active, destinations, notifications, replaces):

View File

@ -775,10 +775,10 @@ class CertificatesReplacementsList(AuthenticatedResource):
return service.get(certificate_id).replaces
class CertficiateExport(AuthenticatedResource):
class CertificateExport(AuthenticatedResource):
def __init__(self):
self.reqparse = reqparse.RequestParser()
super(CertficiateExport, self).__init__()
super(CertificateExport, self).__init__()
def post(self, certificate_id):
"""
@ -808,6 +808,7 @@ class CertficiateExport(AuthenticatedResource):
:statuscode 200: no error
:statuscode 403: unauthenticated
"""
self.reqparse.add_argument('export', type=dict, required=True, location='json')
args = self.reqparse.parse_args()
cert = service.get(certificate_id)
@ -816,7 +817,7 @@ class CertficiateExport(AuthenticatedResource):
permission = UpdateCertificatePermission(certificate_id, getattr(role, 'name', None))
if permission.can():
data = service.export(certificate_id)
passphrase, data = service.export(cert, args['export']['plugin'])
response = make_response(data)
response.headers['content-type'] = 'application/octet-stream'
return response
@ -829,5 +830,6 @@ api.add_resource(Certificates, '/certificates/<int:certificate_id>', endpoint='c
api.add_resource(CertificatesStats, '/certificates/stats', endpoint='certificateStats')
api.add_resource(CertificatesUpload, '/certificates/upload', endpoint='certificateUpload')
api.add_resource(CertificatePrivateKey, '/certificates/<int:certificate_id>/key', endpoint='privateKeyCertificates')
api.add_resource(CertificateExport, '/certificates/<int:certificate_id>/export', endpoint='exportCertificate')
api.add_resource(NotificationCertificatesList, '/notifications/<int:notification_id>/certificates', endpoint='notificationCertificates')
api.add_resource(CertificatesReplacementsList, '/certificates/<int:certificate_id>/replacements', endpoint='replacements')