Пример #1
0
        public override KeyValuePair <string, string>?FindParentKeyByIdentifier(string identifier)
        {
            if (_identifierMapper.ContainsKey(identifier) == false)
            {
                throw new ArgumentException(string.Format("Key with identifier='{0}' is not contained in the keystore", identifier));
            }

            InMemoryKeyInfo myKey = _identifierMapper[identifier];

            if (myKey.ParentFriendlyName == null || myKey.ParentFriendlyName == "srk")
            {
                return(null);
            }


            if (_friendlyNameMapper.ContainsKey(myKey.ParentFriendlyName) == false)
            {
                throw new ArgumentException(string.Format("Key store inconsistency detected, key with friendly name '{0}' not found", myKey.ParentFriendlyName));
            }

            InMemoryKeyInfo parentKey = _friendlyNameMapper[myKey.ParentFriendlyName];


            return(new KeyValuePair <string, string>(parentKey.FriendlyName, parentKey.Identifier));
        }
Пример #2
0
 public override void RemoveKey(string friendlyName)
 {
     if (_friendlyNameMapper.ContainsKey(friendlyName))
     {
         InMemoryKeyInfo keyInfo = _friendlyNameMapper[friendlyName];
         _friendlyNameMapper.Remove(friendlyName);
         _identifierMapper.Remove(keyInfo.Identifier);
     }
 }
Пример #3
0
        public override void AddKey(string friendlyName, string identifier, string parentFriendlyName, byte[] keyData)
        {
            if(_identifierMapper.ContainsKey(identifier))
                throw new ArgumentException("The key store already contains a key with the same identifier");

            if(_friendlyNameMapper.ContainsKey(friendlyName))
                throw new ArgumentException("The key store already contains a key with the same friendly name");

            InMemoryKeyInfo keyInfo = new InMemoryKeyInfo(friendlyName, identifier, parentFriendlyName, keyData);
            _identifierMapper.Add(identifier, keyInfo);
            _friendlyNameMapper.Add(friendlyName, keyInfo);
        }
Пример #4
0
        public override void AddKey(string friendlyName, string identifier, string parentFriendlyName, byte[] keyData)
        {
            if (_identifierMapper.ContainsKey(identifier))
            {
                throw new ArgumentException("The key store already contains a key with the same identifier");
            }

            if (_friendlyNameMapper.ContainsKey(friendlyName))
            {
                throw new ArgumentException("The key store already contains a key with the same friendly name");
            }

            InMemoryKeyInfo keyInfo = new InMemoryKeyInfo(friendlyName, identifier, parentFriendlyName, keyData);

            _identifierMapper.Add(identifier, keyInfo);
            _friendlyNameMapper.Add(friendlyName, keyInfo);
        }