Rebuild for wheezy-backports.
[moonshot-ui.git] / src / moonshot-server.vala
index 81fdccd..74288f7 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2011-2014, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+*/
 #if IPC_DBUS
 
 [DBus (name = "org.janet.Moonshot")]
@@ -49,7 +80,10 @@ public class MoonshotServer : Object {
 
         if ((id_card != null) && (id_card.display_name != IdCard.NO_IDENTITY)) {
             nai_out = id_card.nai;
-            password_out = id_card.password;
+            if ((request.password!=null) && (request.password != ""))
+                password_out = request.password;
+            else
+                password_out = id_card.password;
 
             server_certificate_hash = id_card.trust_anchor.server_cert;
             ca_certificate = id_card.trust_anchor.ca_cert;
@@ -152,13 +186,15 @@ public class MoonshotServer : Object {
 
       if (rules_patterns.length == rules_always_confirm.length)
       {
-        idcard.rules = new Rule[rules_patterns.length];
+        /* workaround Centos vala array property bug: use temp array */
+        Rule[] rules = new Rule[rules_patterns.length];
          
-        for (int i=0; i<idcard.rules.length; i++)
+        for (int i=0; i<rules.length; i++)
         { 
-          idcard.rules[i].pattern = rules_patterns[i];
-          idcard.rules[i].always_confirm = rules_always_confirm[i];
+          rules[i].pattern = rules_patterns[i];
+          rules[i].always_confirm = rules_always_confirm[i];
         }
+        idcard.rules = rules;
       }
 
       return parent_app.add_identity (idcard, force_flat_file_store!=0);
@@ -285,7 +321,10 @@ public class MoonshotServer : Object {
             // The strings are freed by the RPC runtime
             nai_out = id_card.nai;
             password_out = id_card.password;
-            server_certificate_hash = "certificate";
+            server_certificate_hash = id_card.trust_anchor.server_cert;
+            ca_certificate = id_card.trust_anchor.ca_cert;
+            subject_name_constraint = id_card.trust_anchor.subject;
+            subject_alt_name_constraint = id_card.trust_anchor.subject_alt;
 
             return_if_fail (nai_out != null);
             return_if_fail (password_out != null);