[webp] Service parsing, ca-cert handling
authorAlberto Ruiz <aruiz@gnome.org>
Wed, 6 Jul 2011 11:21:13 +0000 (12:21 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Wed, 6 Jul 2011 11:38:00 +0000 (12:38 +0100)
example/sample.xml
src/moonshot-id.vala
src/moonshot-webp-parser.vala

index e8e7f5f..50feee4 100644 (file)
@@ -6,12 +6,17 @@
     <realm>issuer name</realm>
     <services>
       <service>xmpp@jabber.project-moonshot.org</service>
+      <service>email@project-moonshot.org</service>
     </services>
     <selection-rules>
       <rule>
         <pattern>PATTERN</pattern>
         <always_confirm>true</always_confirm>
       </rule>
+      <rule>
+        <pattern>ANOTHER_PATTERN</pattern>
+        <always_confirm>false</always_confirm>
+      </rule>
     </selection-rules>
     <trust-anchor>
       <ca-cert>ABCDEFGHIJKLMNOPQRSTUVWXYZ123455678910</ca-cert>
index d82f1a6..957ebe4 100644 (file)
@@ -18,7 +18,7 @@ public class IdCard : Object
   public TrustAnchor trust_anchor  { get; set; default = new TrustAnchor (); }
   
   public Gdk.Pixbuf pixbuf { get; set; default = null; }    
-  public string[] services { get; set; default = null; }
+  public string[] services { get; set; default = {}; }
 
   //TODO: Set the getter and remove the setter/default
   public string nai { get; set; default = null; }
index 4283e37..70eee92 100644 (file)
@@ -18,6 +18,30 @@ namespace WebProvisioning
   }
 
   bool
+  subject_alt_handler (SList<string> stack)
+  {
+    string[] subject_alt_path = {"subject-alt", "trust-anchor", "identity", "identities"};
+    
+    return check_stack (stack, subject_alt_path);
+  }
+
+  bool
+  subject_handler (SList<string> stack)
+  {
+    string[] subject_path = {"subject", "trust-anchor", "identity", "identities"};
+    
+    return check_stack (stack, subject_path);
+  }
+  
+  bool
+  ca_cert_handler (SList<string> stack)
+  {
+    string[] ca_path = {"ca-cert", "trust-anchor", "identity", "identities"};
+    
+    return check_stack (stack, ca_path);
+  }
+
+  bool
   realm_handler (SList<string> stack)
   {
     string[] realm_path = {"realm", "identity", "identities"};
@@ -76,7 +100,15 @@ namespace WebProvisioning
     }
     else if (stack.nth_data(0) == "service")
     {
+      string[] services = card.services;
+      card.services = new string[services.length + 1];
+      for (int i = 0; i<services.length; i++)
+      {
+        card.services[i] = services[i];
+      }
+      card.services[services.length] = text;
     }
+    /* Rules */
     else if (stack.nth_data(0) == "pattern")
     {
     }
@@ -85,13 +117,14 @@ namespace WebProvisioning
     }
     
     /*Trust anchor*/
-    else if (stack.nth_data(0) == "ca-cert")
+    else if (stack.nth_data(0) == "ca-cert" && ca_cert_handler (stack))
     {
+      card.trust_anchor.ca_cert = text;
     }
-    else if (stack.nth_data(0) == "subject")
+    else if (stack.nth_data(0) == "subject" && subject_handler (stack))
     {
     }
-    else if (stack.nth_data(0) == "ca-cert")
+    else if (stack.nth_data(0) == "subject-alt" && subject_alt_handler (stack))
     {
     }
   }
@@ -148,6 +181,11 @@ namespace WebProvisioning
     
     debug ("'%s' '%s' '%s' '%s'", card.display_name, card.username, card.password, card.issuer);
     
+    foreach (string srv in card.services)
+    {
+      debug ("service: %s", srv);
+    }
+    
     return 0;
   }
 }