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); }
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 }); }
public static OutputKeyKeeper InitializeInstance(ComponentAccessKey componentAccessKey) { if (componentAccessKey == null) throw new ArgumentNullException("componentAccessKey"); IsInitialized = true; OutputKeyKeeper keyKeeper = Instance; keyKeeper.AccessKey = componentAccessKey; return keyKeeper; }
public static MatchKeyKeeper InitializeInstance(ComponentAccessKey componentAccessKey) { if (componentAccessKey == null) { throw new ArgumentNullException("componentAccessKey"); } IsInitialized = true; MatchKeyKeeper keyKeeper = Instance; keyKeeper.AccessKey = componentAccessKey; return(keyKeeper); }
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); }
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; }
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 }); }
private bool CheckCache(ComponentAccessKey key) { return Cache.Contains(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture)); }
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; }
public IMatchDataAccessProxy RetrieveMatchDataAccessProxy(ComponentAccessKey key) { return RetrieveDataAccessProxy(key); }
public IMatchDataAccessProxy RetrieveMatchDataAccessProxy(ComponentAccessKey key) { return(RetrieveDataAccessProxy(key)); }
protected abstract void InitializeKeyKeeper(ComponentAccessKey componentAccessKey);
protected abstract void InitializeKeyKeeper(ComponentAccessKey componentAccessKey);
private bool CheckCache(ComponentAccessKey key) { return(Cache.Contains(key.KeyConsumer.GetHashCode().ToString(CultureInfo.InvariantCulture))); }
public IConfigDataAccessProxy RetrieveConfigDataAccessProxy(ComponentAccessKey key) { return RetrieveDataAccessProxy(key); }
protected override void InitializeKeyKeeper(ComponentAccessKey componentAccessKey) { KeyKeeper = EngineKeyKeeper.InitializeInstance(componentAccessKey); }
public IConfigDataAccessProxy RetrieveConfigDataAccessProxy(ComponentAccessKey key) { return(RetrieveDataAccessProxy(key)); }