From 37f257599d0d5d754b10c33f4362c1f3cbb563da Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Tue, 17 Jun 2014 17:24:31 -0500 Subject: [PATCH] Account: Download user PEM Certificate --- portal/accountview.py | 27 ++++++++++++++++++- portal/templates/account-view.html | 10 ++++--- .../fed4fire/fed4fire_account-view.html | 9 ++++--- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/portal/accountview.py b/portal/accountview.py index 5c8d15fd..0f14da7e 100644 --- a/portal/accountview.py +++ b/portal/accountview.py @@ -1,5 +1,7 @@ from unfold.loginrequired import LoginRequiredAutoLogoutView # +from sfa.trust.credential import Credential +# from manifold.core.query import Query from manifoldapi.manifoldapi import execute_query from portal.actions import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user @@ -513,7 +515,30 @@ def account_process(request): else: messages.error(request, 'Download error: User credential is not stored in the server') return HttpResponseRedirect("/portal/account/") - + + # Download user_cert + elif 'dl_user_cert' in request.POST: + if 'user_credential' in account_config: + user_cred = account_config['user_credential'] + obj_cred = Credential(string=user_cred) + obj_gid = obj_cred.get_gid_object() + str_cert = obj_gid.save_to_string() + response = HttpResponse(str_cert, content_type='text/plain') + response['Content-Disposition'] = 'attachment; filename="user_certificate.pem"' + return response + + elif 'delegated_user_credential' in account_config: + user_cred = account_config['delegated_user_credential'] + obj_cred = Credential(string=user_cred) + obj_gid = obj_cred.get_gid_object() + str_cert = obj_gid.save_to_string() + response = HttpResponse(str_cert, content_type='text/plain') + response['Content-Disposition'] = 'attachment; filename="user_certificate.pem"' + return response + else: + messages.error(request, 'Download error: User credential is not stored in the server') + return HttpResponseRedirect("/portal/account/") + else: messages.info(request, 'Under Construction. Please try again later!') return HttpResponseRedirect("/portal/account/") diff --git a/portal/templates/account-view.html b/portal/templates/account-view.html index 7d161ea3..b07ec0a0 100644 --- a/portal/templates/account-view.html +++ b/portal/templates/account-view.html @@ -200,14 +200,18 @@ {{ row.cred_exp }} + + {%endfor%}

- +
@@ -227,7 +231,7 @@ {%endfor%}
Delegated Slice Credentials
Slice Name

- +
diff --git a/portal/templates/fed4fire/fed4fire_account-view.html b/portal/templates/fed4fire/fed4fire_account-view.html index 464de454..9a594b3a 100644 --- a/portal/templates/fed4fire/fed4fire_account-view.html +++ b/portal/templates/fed4fire/fed4fire_account-view.html @@ -217,14 +217,17 @@ {%endfor%}
Delegated Authority Credentials
Authority Name {{ row.cred_exp }} +

- +
@@ -244,7 +247,7 @@ {%endfor%}
Delegated Slice Credentials
Slice Name

- +
-- 2.43.0
Delegated Authority Credentials
Authority Name