Пример #1
0
 public List<Principal> GetAllReaders(FQStreamID stream)
 {
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetAllReaders();
     }
     return null;
 }
Пример #2
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;
 }
Пример #3
0
 public List <Principal> GetAllReaders(FQStreamID stream)
 {
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return(mdtable[stream.ToString()].GetAllReaders());
     }
     return(null);
 }
Пример #4
0
 public void RemoveAllInfo(FQStreamID stream)
 {
     logger.Log("Removing all info for stream "
                + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         mdtable.Remove(stream.ToString());
     }
 }
Пример #5
0
 public AccountInfo GetMdAccount(FQStreamID stream)
 {
     logger.Log("Serving md account info for stream "
         + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetMdAccount();
     }
     return null;
 }
Пример #6
0
 public Dictionary<int, AccountInfo> GetAllAccounts(FQStreamID stream)
 {
     logger.Log("Serving account info for stream "
         + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return mdtable[stream.ToString()].GetAllAccounts();
     }
     return null;
 }
Пример #7
0
 public bool AddMdAccount(FQStreamID stream, AccountInfo accinfo)
 {
     logger.Log("Adding md account info for stream "
         + stream.ToString());
     if (!mdtable.ContainsKey(stream.ToString()))
     {
         mdtable[stream.ToString()] = new StreamInfo(stream);
     }
     return mdtable[stream.ToString()].AddMdAccount(accinfo);
 }
Пример #8
0
 public bool AddMdAccount(FQStreamID stream, AccountInfo accinfo)
 {
     logger.Log("Adding md account info for stream "
                + stream.ToString());
     if (!mdtable.ContainsKey(stream.ToString()))
     {
         mdtable[stream.ToString()] = new StreamInfo(stream);
     }
     return(mdtable[stream.ToString()].AddMdAccount(accinfo));
 }
Пример #9
0
 public Dictionary <int, AccountInfo> GetAllAccounts(FQStreamID stream)
 {
     logger.Log("Serving account info for stream "
                + stream.ToString());
     if (mdtable.ContainsKey(stream.ToString()))
     {
         return(mdtable[stream.ToString()].GetAllAccounts());
     }
     return(null);
 }
Пример #10
0
 public ACLEntry GetReaderKey(FQStreamID stream, Principal p)
 {
     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);
 }
Пример #11
0
        public AccountInfo GetMdAccount(FQStreamID stream)
        {
            AccountInfo retVal = null;

            if (mdtable.ContainsKey(stream.ToString()))
            {
                retVal = mdtable[stream.ToString()].GetMdAccount();
            }

            logger.Log("Serving md account info for stream " + stream.ToString() + " as " + retVal);
            return(retVal);
        }
Пример #12
0
        public bool UpdateReaderKey(Principal caller, FQStreamID stream, ACLEntry entry)
        {
            logger.Log("UpdateReaderKey request from caller " + caller.ToString() + " for stream "
                       + stream.ToString() + " and principal " + entry.readerName.ToString()
                       + " key version " + entry.keyVersion);
            // TODO(trinabh): Authenticate caller
            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)
            {
                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);
            }
        }
Пример #13
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;
            }
        }
Пример #14
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());
     }
 }
Пример #15
0
 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;
 }
 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;
 }