Exemplo n.º 1
0
 public ACLEntry GetReader(Principal prin)
 {
     if (readers.ContainsKey(prin.ToString()))
     {
         return(readers[prin.ToString()]);
     }
     return(null);
 }
Exemplo n.º 2
0
 public string GetPubKey(Principal prin)
 {
     logger.Log("GetPubKey request for " + prin.ToString());
     // TODO(trinabh): return should be signed
     if (keytable.ContainsKey(prin.ToString()))
     {
         return(keytable[prin.ToString()]);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 public bool RegisterPubKey(Principal prin, string key)
 {
     logger.Log("RegisterPubKey request for " + prin.ToString());
     if (keytable.ContainsKey(prin.ToString()))
     {
         return(false);
     }
     else
     {
         keytable[prin.ToString()] = key;
     }
     return(true);
 }
Exemplo n.º 4
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);
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
0
 public bool RegisterPubKey(Principal prin, string key)
 {
     if (logger != null) logger.Log("RegisterPubKey request for " + prin.ToString());
     if (keytable.ContainsKey(prin.ToString()))
     {
         return false;
     }
     else
     {
         keytable[prin.ToString()] = key;
     }
     return true;
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 public string GetPubKey(Principal prin)
 {
     if (logger != null) logger.Log("GetPubKey request for " + prin.ToString());
     // TODO(trinabh): return should be signed
     if (keytable.ContainsKey(prin.ToString()))
     {
         return keytable[prin.ToString()];
     }
     else
     {
         return null;
     }
 }
 public ACLEntry GetReader(Principal prin)
 {
     if (readers.ContainsKey(prin.ToString()))
     {
         return readers[prin.ToString()];
     }
     return null;
 }