public string subject {get; set; default = "";}
public string subject_alt {get; set; default = "";}
public string server_cert {get; set; default = "";}
+ public int Compare(TrustAnchor other)
+ {
+ if (this.ca_cert != other.ca_cert)
+ return 1;
+ if (this.subject != other.subject)
+ return 1;
+ if (this.subject_alt != other.subject_alt)
+ return 1;
+ if (this.server_cert != other.server_cert)
+ return 1;
+ return 0;
+ }
}
public struct Rule
{
public string pattern;
public string always_confirm;
+ public int Compare(Rule other) {
+ if (this.pattern != other.pattern)
+ return 1;
+ if (this.always_confirm != other.always_confirm)
+ return 1;
+ return 0;
+ }
}
public class IdCard : Object
return (display_name == NO_IDENTITY);
}
+ public enum DiffFlags {
+ DISPLAY_NAME,
+ USERNAME,
+ PASSWORD,
+ ISSUER,
+ RULES,
+ SERVICES,
+ TRUST_ANCHOR;
+ }
+
+ public int Compare(IdCard other)
+ {
+ int diff = 0;
+ if (this.display_name != other.display_name)
+ diff |= 1 << DiffFlags.DISPLAY_NAME;
+ if (this.username != other.username)
+ diff |= 1 << DiffFlags.USERNAME;
+ if (this.password != other.password)
+ diff |= 1 << DiffFlags.PASSWORD;
+ if (this.issuer != other.issuer)
+ diff |= 1 << DiffFlags.ISSUER;
+ if (CompareRules(this.rules, other.rules)!=0)
+ diff |= 1 << DiffFlags.RULES;
+ if (CompareStringArray(this.services, other.services)!=0)
+ diff |= 1 << DiffFlags.SERVICES;
+ if (this.trust_anchor.Compare(other.trust_anchor)!=0)
+ diff |= 1 << DiffFlags.TRUST_ANCHOR;
+ stdout.printf("Diff Flags: %x\n", diff);
+ return diff;
+ }
+
public static IdCard NewNoIdentity()
{
IdCard card = new IdCard();
password = null;
}
}
+
+public int CompareRules(Rule[] a, Rule[] b)
+{
+ if (a.length != b.length)
+ return 1;
+ for (int i=0; i<a.length; i++) {
+ if (a[i].Compare(b[i]) != 0)
+ return 1;
+ }
+ return 0;
+}
+
+public int CompareStringArray(string[] a, string [] b)
+{
+ if (a.length != b.length)
+ return 1;
+ for (int i=0; i<a.length; i++) {
+ if (a[i] != b[i])
+ return 1;
+ }
+ return 0;
+}