Account: Download user PEM Certificate
authorLoic Baron <loic.baron@lip6.fr>
Tue, 17 Jun 2014 22:24:31 +0000 (17:24 -0500)
committerLoic Baron <loic.baron@lip6.fr>
Tue, 17 Jun 2014 22:24:31 +0000 (17:24 -0500)
portal/accountview.py
portal/templates/account-view.html
portal/templates/fed4fire/fed4fire_account-view.html

index 5c8d15f..0f14da7 100644 (file)
@@ -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/")
index 7d161ea..b07ec0a 100644 (file)
                                        <td class="odd"> {{ row.cred_exp }} </td>
                                                <td class="odd">
                                                        <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential">
-                                                               <span class="glyphicon glyphicon-download"></span> Download
+                                                               <span class="glyphicon glyphicon-download"></span> Credential
+                                                       </button>
+                                                       <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate">
+                                                               <span class="glyphicon glyphicon-download"></span> Crertificate
                                                        </button>
+
                                                </td>
                                        </tr>
                                        {%endfor%}
                                 </table>
                                <p></p>
-                               <table class="mytable table table-bordered table-hover">
+                               <table class="mytable table table-bordered table-hover" style="width:100px;">
                                        <caption><b>Delegated Slice Credentials</b></caption>  
                                <tr class="odd"> 
                                                <th>Slice Name</th> 
                                {%endfor%}
                                </table>
                                <p></p>
-                               <table class="mytable table table-bordered table-hover">
+                               <table class="mytable table table-bordered table-hover" style="width:100px;">
                                        <caption><b>Delegated Authority Credentials</b></caption>
                                        <tr class="odd"> 
                                        <th>Authority Name</th> 
index 464de45..9a594b3 100644 (file)
                                        <td class="odd"> {{ row.cred_exp }} </td>
                                                <td class="odd">
                                                        <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential">
-                                                               <span class="glyphicon glyphicon-download"></span> Download
+                                                               <span class="glyphicon glyphicon-download"></span> Credential
+                                                       </button>
+                                                       <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate">
+                                                               <span class="glyphicon glyphicon-download"></span> Crertificate
                                                        </button>
                                                </td>
                                        </tr>
                                        {%endfor%}
                                 </table>
                                <p></p>
-                               <table class="mytable table table-bordered table-hover">
+                               <table class="mytable table table-bordered table-hover" style="width:100px;">
                                        <caption><b>Delegated Slice Credentials</b></caption>  
                                <tr class="odd"> 
                                                <th>Slice Name</th> 
                                {%endfor%}
                                </table>
                                <p></p>
-                               <table class="mytable table table-bordered table-hover">
+                               <table class="mytable table table-bordered table-hover" style="width:100px;">
                                        <caption><b>Delegated Authority Credentials</b></caption>
                                        <tr class="odd"> 
                                        <th>Authority Name</th>