Client library: make MT-safe; add get_default_identity()
[moonshot-ui.git] / src / moonshot-server.vala
index 5774e32..145d6bf 100644 (file)
@@ -10,28 +10,15 @@ public class MoonshotServer : Object {
         this.main_window = (MainWindow) window;
     }
 
-    /**
-     * This is the function used by the GSS mechanism to get the NAI,
-     * password and certificate of the ID card for the specificated service.
-     *
-     * The function will block until the user choose the ID card.
-     *
-     * @param nai NAI of the ID Card (optional)
-     * @param password Password of the ID Card (optional)
-     * @param service Service application request an ID Card for (optional)
-     * @param nai_out NAI stored in the ID Card
-     * @param password_out Password stored in the ID Card
-     * @param certificate Certificate stored in th ID Card
-     *
-     * @return true if the user choose a correct ID card for that service,
-     *         false otherwise.
-     */
     public async bool get_identity (string nai,
                                     string password,
                                     string service,
                                     out string nai_out,
                                     out string password_out,
-                                    out string certificate_out)
+                                    out string server_certificate_hash,
+                                    out string ca_certificate,
+                                    out string subject_name_constraint,
+                                    out string subject_alt_name_constraint)
     {
         var request = new IdentityRequest (main_window,
                                            nai,
@@ -43,14 +30,18 @@ public class MoonshotServer : Object {
 
         nai_out = "";
         password_out = "";
-        certificate_out = "";
+        server_certificate_hash = "";
+        ca_certificate = "";
+        subject_name_constraint = "";
+        subject_alt_name_constraint = "";
 
         var id_card = request.id_card;
 
         if (id_card != null) {
             nai_out = id_card.nai;
             password_out = id_card.password;
-            certificate_out = "certificate";
+
+            server_certificate_hash = "certificate";
 
             // User should have been prompted if there was no p/w.
             return_if_fail (nai_out != null);
@@ -62,16 +53,12 @@ public class MoonshotServer : Object {
         return false;
     }
 
-    /**
-     * Returns the default identity - most recently used.
-     *
-     * @param nai_out NAI stored in the ID card
-     * @param password_out Password stored in the ID card
-     *
-     * @return true on success, false if no identities are stored
-     */
     public async bool get_default_identity (out string nai_out,
-                                            out string password_out)
+                                            out string password_out,
+                                            out string server_certificate_hash,
+                                            out string ca_certificate,
+                                            out string subject_name_constraint,
+                                            out string subject_alt_name_constraint)
     {
         var request = new IdentityRequest.default (main_window);
         request.set_callback ((IdentityRequest) => get_default_identity.callback());
@@ -80,12 +67,18 @@ public class MoonshotServer : Object {
 
         nai_out = "";
         password_out = "";
+        server_certificate_hash = "";
+        ca_certificate = "";
+        subject_name_constraint = "";
+        subject_alt_name_constraint = "";
 
         if (request.id_card != null)
         {
             nai_out = request.id_card.nai;
             password_out = request.id_card.password;
 
+            server_certificate_hash = "certificate";
+
             // User should have been prompted if there was no p/w.
             return_val_if_fail (nai_out != null, false);
             return_val_if_fail (password_out != null, false);
@@ -128,14 +121,17 @@ public class MoonshotServer : Object {
         return instance;
     }
 
-    [CCode (cname = "moonshot_get_identity")]
+    [CCode (cname = "moonshot_get_identity_rpc")]
     public static void get_identity (Rpc.AsyncCall call,
                                      string nai,
                                      string password,
                                      string service,
                                      ref string nai_out,
                                      ref string password_out,
-                                     ref string certificate_out)
+                                     ref string server_certificate_hash,
+                                     ref string ca_certificate,
+                                     ref string subject_name_constraint,
+                                     ref string subject_alt_name_constraint)
     {
         bool result = false;
 
@@ -157,7 +153,10 @@ public class MoonshotServer : Object {
 
         nai_out = "";
         password_out = "";
-        certificate_out = "";
+        server_certificate_hash = "";
+        ca_certificate = "";
+        subject_name_constraint = "";
+        subject_alt_name_constraint = "";
 
         var id_card = request.id_card;
 
@@ -165,7 +164,7 @@ public class MoonshotServer : Object {
             // The strings are freed by the RPC runtime
             nai_out = id_card.nai;
             password_out = id_card.password;
-            certificate_out = "certificate";
+            server_certificate_hash = "certificate";
 
             return_if_fail (nai_out != null);
             return_if_fail (password_out != null);
@@ -183,7 +182,7 @@ public class MoonshotServer : Object {
         request.mutex.unlock ();
     }
 
-    [CCode (cname = "moonshot_get_default_identity")]
+    [CCode (cname = "moonshot_get_default_identity_rpc")]
     public static void get_default_identity (Rpc.AsyncCall call,
                                              ref string nai_out,
                                              ref string password_out)