Exemple #1
0
 public StreamInfo(FQStreamID sname)
 {
     stream            = sname;
     owner             = new Principal(sname.HomeId, sname.AppId);
     accounts          = new Dictionary <int, AccountInfo>();
     readers           = new Dictionary <string, ACLEntry>();
     latest_keyversion = 0;
 }
        public bool UpdateReaderKey(Principal caller, FQStreamID stream, ACLEntry entry)
        {
            if (logger != null) logger.Log("UpdateReaderKey request from caller " + caller.ToString() + " for stream "
                + stream.ToString() + " and principal " + entry.readerName.ToString()
                + " key version " + entry.keyVersion);
            
            // Authentication is not required for unlisted streams
            /*
            RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
            string callerpubkey = GetPubKey(caller);
            if (callerpubkey == null)
                return false;
            RSA.FromXmlString(callerpubkey);

            Byte[] data = { };
            data = data.Concat(this.GetBytes(caller.HomeId)).ToArray();
            data = data.Concat(this.GetBytes(caller.AppId)).ToArray();
            data = data.Concat(this.GetBytes(stream.HomeId)).ToArray();
            data = data.Concat(this.GetBytes(stream.AppId)).ToArray();
            data = data.Concat(this.GetBytes(stream.StreamId)).ToArray();
            data = data.Concat(this.GetBytes(entry.readerName.HomeId)).ToArray();
            data = data.Concat(this.GetBytes(entry.readerName.AppId)).ToArray();
            data = data.Concat(entry.encKey).ToArray();
            data = data.Concat(entry.IV).ToArray();
            data = data.Concat(this.GetBytes("" + entry.keyVersion)).ToArray();

            if (RSA.VerifyData(data, new SHA256CryptoServiceProvider(), caller.Auth) == false)
            {
                if (logger != null) logger.Log("Verification of request failed");
                return false;
            }
            //
            */

            if (caller.HomeId == stream.HomeId && caller.AppId == stream.AppId)
            {
                if (!mdtable.ContainsKey(stream.ToString()))
                    mdtable[stream.ToString()] = new StreamInfo(stream);
                mdtable[stream.ToString()].UpdateReader(entry);
                return true;
            }
            else
            {
                return false;
            }
        }
 public StreamInfo(FQStreamID sname)
 {
     stream = sname;
     owner = new Principal(sname.HomeId, sname.AppId);
     accounts = new Dictionary<int, AccountInfo>();
     readers = new Dictionary<string, ACLEntry>();
     latest_keyversion = 0;
 }
 public void RemoveAllInfo(FQStreamID stream)
 {
     if (logger != null) logger.Log("Removing all info for stream "
         + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         mdtable.Remove(stream.ToString());
     }
 }
 public AccountInfo GetMdAccount(FQStreamID stream)
 {
     if (logger != null) logger.Log("Serving md account info for stream "
         + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetMdAccount();
     }
     return null;
 }
 public Dictionary<int, AccountInfo> GetAllAccounts(FQStreamID stream)
 {
     if (logger != null) logger.Log("Serving account info for stream "
         + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetAllAccounts();
     }
     return null;
 }
 public bool AddAccount(FQStreamID stream, AccountInfo accinfo)
 {
     if (logger != null) logger.Log("Adding account info for stream "
         + stream.ToString());
     if (!mdtable.ContainsKey(stream.ToString()))
     {
         mdtable[stream.ToString()] = new StreamInfo(stream);
     }
     return mdtable[stream.ToString()].AddAccount(accinfo);
 }
 public List<Principal> GetAllReaders(FQStreamID stream)
 {
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetAllReaders();
     }
     return null;
 }
 public ACLEntry GetReaderKey(FQStreamID stream, Principal p)
 {
     if (logger != null) logger.Log("GetReaderKey from caller " + p.ToString() + " for stream "
         + stream.ToString());
     // TODO(trinabh): Return should be signed
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetReader(p);
     }
     return null;
 }