+ public unowned string nai { get { _nai = username + "@" + issuer; return _nai;}}
+
+ public bool store_password { get; set; default = false; }
+
+ public bool is_no_identity()
+ {
+ 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 (CompareStringArrayList(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();
+ card.display_name = NO_IDENTITY;
+ return card;
+ }
+
+ ~IdCard() {
+ password = null;
+ }
+
+ internal void add_rule(Rule rule) {
+ _rules += rule;
+ }
+}
+
+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 CompareStringArrayList(ArrayList<string> a, ArrayList<string> b)
+{
+ if (a.size != b.size) {
+ return 1;
+ }