Client library: make MT-safe; add get_default_identity()
[moonshot-ui.git] / src / moonshot-server.vala
index 3f9c6fb..145d6bf 100644 (file)
@@ -10,30 +10,6 @@ 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.
-     *
-     * There are two types of trust anchor that may be returned. If
-     * server_certificate_hash is non-empty, the remaining parameters
-     * will be empty. Otherwise, the ca_certificate paramater and the
-     * subject name constraints will be returned.
-     *
-     * @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 server_certificate_hash Hash of the identity server's certificate
-     * @param ca_certificate Base64-encoded CA certificate
-     * @param subject_name_constraint Subject name constraint
-     * @param subject_alt_name_constraint Subject alternative name constraint
-     *
-     * @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,
@@ -77,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());
@@ -95,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);
@@ -143,7 +121,7 @@ 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,
@@ -204,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)