def pki_chain(request, model, id): """Display the CA chain as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Type (ca/cert) and ID are used to determine the object. Create object chain PNG using graphviz and return it to the user. """ if PKI_ENABLE_GRAPHVIZ is not True: messages.warning(request, "Chain view is disabled unless setting PKI_ENABLE_GRAPHVIZ is set to True") return HttpResponseRedirect(urlresolvers.reverse('admin:pki_%s_changelist' % model)) if model == "certificateauthority": obj = get_object_or_404(CertificateAuthority, pk=id) elif model == "certificate": obj = get_object_or_404(Certificate, pk=id) png = generate_temp_file() ObjectChain(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError as e: logger.error( "Failed to load depency tree: %s" % e) raise Exception( e ) response = HttpResponse(x, mimetype='image/png') return response
def pki_tree(request, id): """Display the CA tree as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Only works for Certificate Authorities. All object related to the CA obj are fetched and displayed in a Graphviz tree. """ if PKI_ENABLE_GRAPHVIZ is not True: messages.warning(request, "Tree view is disabled unless setting PKI_ENABLE_GRAPHVIZ is set to True") return HttpResponseRedirect(urlresolvers.reverse('admin:pki_certificateauthority_changelist')) obj = get_object_or_404(CertificateAuthority, pk=id) png = generate_temp_file() ObjectTree(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError as e: logger.error( "Failed to load depency tree: %s" % e) raise Exception( e ) response = HttpResponse(x, mimetype='image/png') return response
def pki_chain(request, model, id): """Display the CA chain as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Type (ca/cert) and ID are used to determine the object. Create object chain PNG using graphviz and return it to the user. """ if PKI_ENABLE_GRAPHVIZ is not True: messages.warning( request, "Chain view is disabled unless setting PKI_ENABLE_GRAPHVIZ is set to True" ) return HttpResponseRedirect( urlresolvers.reverse('admin:pki_%s_changelist' % model)) if model == "certificateauthority": obj = get_object_or_404(CertificateAuthority, pk=id) elif model == "certificate": obj = get_object_or_404(Certificate, pk=id) png = generate_temp_file() ObjectChain(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError, e: logger.error("Failed to load depency tree: %s" % e) raise Exception(e)
def pki_tree(request, id): """Display the CA tree as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Only works for Certificate Authorities. All object related to the CA obj are fetched and displayed in a Graphviz tree. """ if PKI_ENABLE_GRAPHVIZ is not True: messages.warning( request, "Tree view is disabled unless setting PKI_ENABLE_GRAPHVIZ is set to True" ) return HttpResponseRedirect( urlresolvers.reverse('admin:pki_certificateauthority_changelist')) obj = get_object_or_404(CertificateAuthority, pk=id) png = generate_temp_file() ObjectTree(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError, e: logger.error("Failed to load depency tree: %s" % e) raise Exception(e)
def pki_tree(request, id): """Display the CA tree as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Only works for Certificate Authorities. All object related to the CA obj are fetched and displayed in a Graphviz tree. """ if PKI_ENABLE_GRAPHVIZ is not True: raise Exception( "Tree view is inoperable unless PKI_ENABLE_GRAPHVIZ is enabled!" ) obj = get_object_or_404(CertificateAuthority, pk=id) png = generate_temp_file() ObjectTree(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError,e: logger.error( "Failed to load depency tree: %s" % e) raise Exception( e )
def pki_chain(request, type, id): """Display the CA chain as PNG. Requires PKI_ENABLE_GRAPHVIZ set to true. Type (ca/cert) and ID are used to determine the object. Create object chain PNG using graphviz and return it to the user. """ if PKI_ENABLE_GRAPHVIZ is not True: raise Exception( "Chain view is inoperable unless PKI_ENABLE_GRAPHVIZ is enabled" ) if type == "ca": obj = get_object_or_404(CertificateAuthority, pk=id) elif type == "cert": obj = get_object_or_404(Certificate, pk=id) png = generate_temp_file() ObjectChain(obj, png) try: if os.path.exists(png): f = open(png) x = f.read() f.close() os.remove(png) except OSError,e: logger.error( "Failed to load depency tree: %s" % e) raise Exception( e )