Exemplo n.º 1
0
		public void SetDiscoInfo(DiscoInfo discoInfo)
		{
			if (discoInfo == null) return;
			var node = !string.IsNullOrEmpty(discoInfo.Node) ? discoInfo.Node : DEFAULT_NODE;
			discoCache[node] = discoInfo;
		}
Exemplo n.º 2
0
 /// <summary>
 ///   Builds and sets the caps ver attribute from a DiscoInfo object
 /// </summary>
 /// <param name="di"> </param>
 public void SetVersion(DiscoInfo di)
 {
     Version = BuildCapsVersion(di);
 }
Exemplo n.º 3
0
        private string BuildCapsVersion(DiscoInfo di)
        {
            /*
                1.  Initialize an empty string S.
                2. Sort the service discovery identities by category and then by type (if it exists), formatted as 'category' '/' 'type'.
                3. For each identity, append the 'category/type' to S, followed by the '<' character.
                4. Sort the supported features.
                5. For each feature, append the feature to S, followed by the '<' character.
                6. Compute ver by hashing S using the SHA-1 algorithm as specified in RFC 3174 [17] (with binary output) and 
                   encoding the hash using Base64 as specified in Section 4 of RFC 4648 [18] 
                   (note: the Base64 output MUST NOT include whitespace and MUST set padding bits to zero). [19]
             */
            var features = new ArrayList();
            var identities = new ArrayList();

            foreach (DiscoIdentity did in di.GetIdentities())
                identities.Add(did.Type == null ? did.Category : did.Category + "/" + did.Type);

            foreach (DiscoFeature df in di.GetFeatures())
                features.Add(df.Var);

            identities.Sort();
            features.Sort();

            var S = new StringBuilder();

            foreach (string s in identities)
                S.Append(s + "<");

            foreach (string s in features)
                S.Append(s + "<");

            byte[] sha1 = Hash.Sha1HashBytes(S.ToString());

#if CF
            return Convert.ToBase64String(sha1, 0, sha1.Length);
#else
            return Convert.ToBase64String(sha1);
#endif
        }
Exemplo n.º 4
0
 public XmppServiceBase()
 {
     Handlers = new List<IXmppHandler>();
     Registered = false;
     DiscoInfo = new DiscoInfo();
 }