1 public class TrustAnchor : Object
3 public string ca_cert {get; set; default = "";}
4 public string subject {get; set; default = "";}
5 public string subject_alt {get; set; default = "";}
6 public string server_cert {get; set; default = "";}
7 public int Compare(TrustAnchor other)
9 if (this.ca_cert != other.ca_cert)
11 if (this.subject != other.subject)
13 if (this.subject_alt != other.subject_alt)
15 if (this.server_cert != other.server_cert)
23 public string pattern;
24 public string always_confirm;
25 public int Compare(Rule other) {
26 if (this.pattern != other.pattern)
28 if (this.always_confirm != other.always_confirm)
34 public class IdCard : Object
36 public const string NO_IDENTITY = "No Identity";
40 public string display_name { get; set; default = ""; }
42 public string username { get; set; default = ""; }
44 private unowned string _password;
45 public string password {
47 return (_password!=null) ? _password : "";
50 if (_password != null) {
51 GnomeKeyring.memory_free((void *)_password);
55 _password = GnomeKeyring.memory_strdup(value);
59 public string password { get; set; default = null; }
62 public string issuer { get; set; default = ""; }
64 public Rule[] rules {get; set; default = {};}
65 public string[] services { get; set; default = {}; }
66 public bool temporary {get; set; default = false; }
68 public TrustAnchor trust_anchor { get; set; default = new TrustAnchor (); }
70 public unowned string nai { get { _nai = username + "@" + issuer; return _nai;}}
72 public bool store_password { get; set; default = false; }
74 public bool IsNoIdentity()
76 return (display_name == NO_IDENTITY);
79 public enum DiffFlags {
89 public int Compare(IdCard other)
92 if (this.display_name != other.display_name)
93 diff |= 1 << DiffFlags.DISPLAY_NAME;
94 if (this.username != other.username)
95 diff |= 1 << DiffFlags.USERNAME;
96 if (this.password != other.password)
97 diff |= 1 << DiffFlags.PASSWORD;
98 if (this.issuer != other.issuer)
99 diff |= 1 << DiffFlags.ISSUER;
100 if (CompareRules(this.rules, other.rules)!=0)
101 diff |= 1 << DiffFlags.RULES;
102 if (CompareStringArray(this.services, other.services)!=0)
103 diff |= 1 << DiffFlags.SERVICES;
104 if (this.trust_anchor.Compare(other.trust_anchor)!=0)
105 diff |= 1 << DiffFlags.TRUST_ANCHOR;
106 stdout.printf("Diff Flags: %x\n", diff);
110 public static IdCard NewNoIdentity()
112 IdCard card = new IdCard();
113 card.display_name = NO_IDENTITY;
122 public int CompareRules(Rule[] a, Rule[] b)
124 if (a.length != b.length)
126 for (int i=0; i<a.length; i++) {
127 if (a[i].Compare(b[i]) != 0)
133 public int CompareStringArray(string[] a, string [] b)
135 if (a.length != b.length)
137 for (int i=0; i<a.length; i++) {