Beispiel #1
0
        public IBatch RetrieveExecutionIdentification(ComponentAccessKey key)
        {
            // Check the cache before trying to unfold/decrypt the key. The first time
            // we look into the cache it will be empty and we will be forced to unfold/decrypt
            // the key but that is the plan. :-)
            if (CheckCache(key))
            {
                return(BatchExecutionIdentification);
            }


            // Let's try to unfold/decrypt the key and validate whether or not the key represents
            // the correct permissions.
            ComponentDeclaration accessKey = UnfoldKey(key);

            if ((accessKey & ComponentDeclaration.ExecutionId) != ComponentDeclaration.ExecutionId)
            {
                throw new ArgumentException("Invalid key! The key did NOT contain permissions for retrieving the execution identification.");
            }


            // Key contained the correct permissions, so let's update the cache.
            InsertInCache(key);


            // We should be ready to release the proxy object...
            return(BatchExecutionIdentification);
        }
Beispiel #2
0
 private void InsertInCache(ComponentAccessKey key)
 {
     Cache.Add(new CacheItem(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture), key.KeyConsumer),
               new CacheItemPolicy {
         AbsoluteExpiration = ObjectCache.InfiniteAbsoluteExpiration, Priority = CacheItemPriority.NotRemovable
     });
 }
Beispiel #3
0
        public static OutputKeyKeeper InitializeInstance(ComponentAccessKey componentAccessKey)
        {
            if (componentAccessKey == null)
            throw new ArgumentNullException("componentAccessKey");

              IsInitialized = true;

              OutputKeyKeeper keyKeeper = Instance;
              keyKeeper.AccessKey = componentAccessKey;
              return keyKeeper;
        }
Beispiel #4
0
        public static MatchKeyKeeper InitializeInstance(ComponentAccessKey componentAccessKey)
        {
            if (componentAccessKey == null)
            {
                throw new ArgumentNullException("componentAccessKey");
            }

            IsInitialized = true;

            MatchKeyKeeper keyKeeper = Instance;

            keyKeeper.AccessKey = componentAccessKey;
            return(keyKeeper);
        }
Beispiel #5
0
        private ComponentDeclaration UnfoldKey(ComponentAccessKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            AesCryptography aes = new AesCryptography();

            byte[] bytes = aes.Decrypt(SecurityIds.Password, Encoding.UTF8.GetBytes(SecurityIds.Salt), key.Key);

            string keyString = Encoding.UTF8.GetString(bytes);

            ComponentDeclaration accessKey;
            bool result = Enum.TryParse(keyString, true, out accessKey);

            if (!result)
            {
                throw new ArgumentException("Invalid key! Unable to parse key");
            }
            return(accessKey);
        }
 protected override void InitializeKeyKeeper(ComponentAccessKey componentAccessKey)
 {
     KeyKeeper = EngineKeyKeeper.InitializeInstance(componentAccessKey);
 }
Beispiel #7
0
        private ComponentDeclaration UnfoldKey(ComponentAccessKey key)
        {
            if (key == null)
            throw new ArgumentNullException("key");

              AesCryptography aes = new AesCryptography();
              byte[] bytes = aes.Decrypt(SecurityIds.Password, Encoding.UTF8.GetBytes(SecurityIds.Salt), key.Key);

              string keyString = Encoding.UTF8.GetString(bytes);

              ComponentDeclaration accessKey;
              bool result = Enum.TryParse(keyString, true, out accessKey);
              if (!result)
            throw new ArgumentException("Invalid key! Unable to parse key");
              return accessKey;
        }
Beispiel #8
0
 private void InsertInCache(ComponentAccessKey key)
 {
     Cache.Add(new CacheItem(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture), key.KeyConsumer),
         new CacheItemPolicy { AbsoluteExpiration = ObjectCache.InfiniteAbsoluteExpiration, Priority = CacheItemPriority.NotRemovable });
 }
Beispiel #9
0
 private bool CheckCache(ComponentAccessKey key)
 {
     return Cache.Contains(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture));
 }
Beispiel #10
0
        public IStatisticsProxy RetrieveStatisticsProxy(ComponentAccessKey key)
        {
            // Check the cache before trying to unfold/decrypt the key. The first time
              // we look into the cache it will be empty and we will be forced to unfold/decrypt
              // the key but that is the plan. :-)
              if (CheckCache(key))
            return StatisticsProxy;

              // Let's try to unfold/decrypt the key and validate whether or not the key represents
              // the correct permissions.
              ComponentDeclaration accessKey = UnfoldKey(key);
              if ((accessKey & ComponentDeclaration.Statistics) != ComponentDeclaration.Statistics)
            throw new ArgumentException("Invalid key! The key did NOT contain permissions for retrieving the statistics proxy.");

              // Key contained the correct permissions, so let's update the cache.
              InsertInCache(key);

              // We should be ready to release the proxy object...
              return StatisticsProxy;
        }
Beispiel #11
0
 public IMatchDataAccessProxy RetrieveMatchDataAccessProxy(ComponentAccessKey key)
 {
     return RetrieveDataAccessProxy(key);
 }
Beispiel #12
0
 public IMatchDataAccessProxy RetrieveMatchDataAccessProxy(ComponentAccessKey key)
 {
     return(RetrieveDataAccessProxy(key));
 }
Beispiel #13
0
 protected abstract void InitializeKeyKeeper(ComponentAccessKey componentAccessKey);
Beispiel #14
0
 protected abstract void InitializeKeyKeeper(ComponentAccessKey componentAccessKey);
Beispiel #15
0
 private bool CheckCache(ComponentAccessKey key)
 {
     return(Cache.Contains(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture)));
 }
Beispiel #16
0
 public IConfigDataAccessProxy RetrieveConfigDataAccessProxy(ComponentAccessKey key)
 {
     return RetrieveDataAccessProxy(key);
 }
Beispiel #17
0
 protected override void InitializeKeyKeeper(ComponentAccessKey componentAccessKey)
 {
     KeyKeeper = EngineKeyKeeper.InitializeInstance(componentAccessKey);
 }
Beispiel #18
0
 public IConfigDataAccessProxy RetrieveConfigDataAccessProxy(ComponentAccessKey key)
 {
     return(RetrieveDataAccessProxy(key));
 }