Пример #1
0
        public BearTermInputRouter(IKeyConsumer gameControlConsumer)
        {
            _gameControlConsumer = gameControlConsumer;

            _mouseLast       = MousePos();
            _windowListeners = new OrderedDictionary <PaneBounds, IInputListener>();
        }
Пример #2
0
        public ComponentAccessKey(byte[] key, string description, IKeyConsumer keyConsumer)
            : base(key)
        {
            #region Validate input arguments...
              if (key.Length <= 0)
            throw new ArgumentException("Invalid key.");

              if (string.IsNullOrWhiteSpace(description))
            throw new ArgumentNullException("description");

              if (keyConsumer == null)
            throw new ArgumentNullException("keyConsumer");
              #endregion

              Description = description;
              KeyConsumer = keyConsumer;
        }
Пример #3
0
        public ComponentAccessKey(byte[] key, string description, IKeyConsumer keyConsumer) : base(key)
        {
            #region Validate input arguments...
            if (key.Length <= 0)
            {
                throw new ArgumentException("Invalid key.");
            }

            if (string.IsNullOrWhiteSpace(description))
            {
                throw new ArgumentNullException("description");
            }

            if (keyConsumer == null)
            {
                throw new ArgumentNullException("keyConsumer");
            }
            #endregion

            Description = description;
            KeyConsumer = keyConsumer;
        }
Пример #4
0
 public ComponentAccessKey ProvideComponentAccessKey(IKeyConsumer keyConsumer)
 {
     KeyFactory keyFactory = new KeyFactory();
       return keyFactory.GenerateComponentAccessKey(SecurityIds.Password, SecurityIds.Salt, keyConsumer);
 }
Пример #5
0
        internal ComponentAccessKey GenerateComponentAccessKey(string password, string salt, IKeyConsumer keyConsumer)
        {
            #region Validate input arguments...
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new ArgumentNullException("password");
            }

            if (string.IsNullOrWhiteSpace(salt))
            {
                throw new ArgumentNullException("salt");
            }

            if (keyConsumer == null)
            {
                throw new ArgumentNullException("keyConsumer");
            }
            #endregion


            // All flags are default cleared!
            ComponentDeclaration accessSetup = ComponentDeclaration.NotDefined;


            #region Setup the component access flags for the 'Configuration' component
            if (keyConsumer is IConfigurationProxy)
            {
                accessSetup = accessSetup | ComponentDeclaration.Configuration;
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
                accessSetup = accessSetup | ComponentDeclaration.DataAccess;
            }
            #endregion


            #region Setup the component access flags for the 'Configuration' component
            if (keyConsumer is IConfigurationFactory)
            {
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
            }
            #endregion


            #region Setup the component access flags for the 'Engine' component
            if (keyConsumer is IEngineProxy)
            {
                // Setup the component access flags for the configuration component.
                accessSetup = accessSetup | ComponentDeclaration.Configuration;
                accessSetup = accessSetup | ComponentDeclaration.Engine;
                accessSetup = accessSetup | ComponentDeclaration.Matches;
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
            }
            #endregion


            #region Setup the component access flags for the 'Output' component
            if (keyConsumer is IOutputProxy)
            {
                // Setup the component access flags for the configuration component.
                accessSetup = accessSetup | ComponentDeclaration.Configuration;
                // accessSetup = accessSetup | ComponentDeclaration.Engine;
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
                accessSetup = accessSetup | ComponentDeclaration.Matches;
            }
            #endregion


            #region Setup the component access flags for the 'Matches' component
            if (keyConsumer is IMatchProxy)
            {
                // Setup the component access flags for the configuration component.
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
                accessSetup = accessSetup | ComponentDeclaration.DataAccess;
            }
            #endregion


            #region Setup the component access flags for the 'Statistics' component
            if (keyConsumer is IStatisticsProxy)
            {
                // Setup the component access flags for the configuration component.
                accessSetup = accessSetup | ComponentDeclaration.Statistics;
            }
            #endregion


            #region Setup the component access flags for the 'DataAccess' component
            if (keyConsumer is IDataAccessProxy)
            {
                // Setup the component access flags for the configuration component.
                accessSetup = accessSetup | ComponentDeclaration.DataAccess;
                accessSetup = accessSetup | ComponentDeclaration.Configuration;
            }
            #endregion


            // Create the description for the key - the description must declare
            // what components the flags give access to.
            string description = GenerateKeyDescription(accessSetup);

            // Let's do the actual encryption...
            AesCryptography aes   = new AesCryptography();
            byte[]          bytes = aes.Encrypt(password, Encoding.UTF8.GetBytes(salt), Encoding.UTF8.GetBytes(accessSetup + ""));

            // Constructing the actual key for accessing the components...
            return(new ComponentAccessKey(bytes, description, keyConsumer));
        }
Пример #6
0
        public ComponentAccessKey ProvideComponentAccessKey(IKeyConsumer keyConsumer)
        {
            KeyFactory keyFactory = new KeyFactory();

            return(keyFactory.GenerateComponentAccessKey(SecurityIds.Password, SecurityIds.Salt, keyConsumer));
        }
Пример #7
0
        internal ComponentAccessKey GenerateComponentAccessKey(string password, string salt, IKeyConsumer keyConsumer)
        {
            #region Validate input arguments...
              if (string.IsNullOrWhiteSpace(password))
            throw new ArgumentNullException("password");

              if (string.IsNullOrWhiteSpace(salt))
            throw new ArgumentNullException("salt");

              if (keyConsumer == null)
            throw new ArgumentNullException("keyConsumer");
              #endregion

              // All flags are default cleared!
              ComponentDeclaration accessSetup = ComponentDeclaration.NotDefined;

              #region Setup the component access flags for the 'Configuration' component
              if (keyConsumer is IConfigurationProxy)
              {
            accessSetup = accessSetup | ComponentDeclaration.Configuration;
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
            accessSetup = accessSetup | ComponentDeclaration.DataAccess;
              }
              #endregion

              #region Setup the component access flags for the 'Configuration' component
              if (keyConsumer is IConfigurationFactory)
              {
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
              }
              #endregion

              #region Setup the component access flags for the 'Engine' component
              if (keyConsumer is IEngineProxy)
              {
            // Setup the component access flags for the configuration component.
            accessSetup = accessSetup | ComponentDeclaration.Configuration;
            accessSetup = accessSetup | ComponentDeclaration.Engine;
            accessSetup = accessSetup | ComponentDeclaration.Matches;
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
              }
              #endregion

              #region Setup the component access flags for the 'Output' component
              if (keyConsumer is IOutputProxy)
              {
            // Setup the component access flags for the configuration component.
            accessSetup = accessSetup | ComponentDeclaration.Configuration;
            // accessSetup = accessSetup | ComponentDeclaration.Engine;
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
            accessSetup = accessSetup | ComponentDeclaration.Matches;
              }
              #endregion

              #region Setup the component access flags for the 'Matches' component
            if (keyConsumer is IMatchProxy)
              {
            // Setup the component access flags for the configuration component.
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
            accessSetup = accessSetup | ComponentDeclaration.DataAccess;
              }
              #endregion

              #region Setup the component access flags for the 'Statistics' component
              if (keyConsumer is IStatisticsProxy)
              {
            // Setup the component access flags for the configuration component.
            accessSetup = accessSetup | ComponentDeclaration.Statistics;
              }
              #endregion

              #region Setup the component access flags for the 'DataAccess' component
              if (keyConsumer is IDataAccessProxy)
              {
            // Setup the component access flags for the configuration component.
            accessSetup = accessSetup | ComponentDeclaration.DataAccess;
            accessSetup = accessSetup | ComponentDeclaration.Configuration;
              }
              #endregion

              // Create the description for the key - the description must declare
              // what components the flags give access to.
              string description = GenerateKeyDescription(accessSetup);

              // Let's do the actual encryption...
              AesCryptography aes = new AesCryptography();
              byte[]        bytes = aes.Encrypt(password, Encoding.UTF8.GetBytes(salt), Encoding.UTF8.GetBytes(accessSetup + ""));

              // Constructing the actual key for accessing the components...
              return new ComponentAccessKey(bytes, description, keyConsumer);
        }