public AuthorizationService(
     IUnitOfWork unitOfWork, 
     ISymmetricAlgorithmProvider symmetricAlgorithmProvider,
     ITraceManager traceManager)
     : base(unitOfWork, symmetricAlgorithmProvider)
 {
     this._traceManager = traceManager;
 }
        public SymmetricObjectFormatter(ISymmetricAlgorithmProvider symmetricAlgorithmProvider, IObjectFormatter inner)
            : base(inner)
        {
            var algorithm = symmetricAlgorithmProvider.Create();

            m_encryptor = algorithm.CreateEncryptor();
            m_decryptor = algorithm.CreateDecryptor();
        }
        /// <summary>
        /// Initialises a new instance of the <see cref="DbEncryptedStringTypeConverter"/> class.
        /// </summary>
        /// <param name="algorithmProvider">The symmetric algorithm provider to be used.</param>
        public DbEncryptedStringTypeConverter(ISymmetricAlgorithmProvider algorithmProvider)
        {
            if (algorithmProvider == null)
            {
                throw new ArgumentNullException("algorithmProvider");
            }

            this.algorithmProvider = algorithmProvider;
        }
 public AuthenticationService(
     IUnitOfWork unitOfWork, 
     ISymmetricAlgorithmProvider symmetricAlgorithmProvider,
     ITraceManager traceManager)
     : base(unitOfWork, symmetricAlgorithmProvider)
 {
     this._priorAuthenticationRequired = false;
     this._traceManager = traceManager;
 }
        private static void Encrypt_Decrypt(ISymmetricAlgorithmProvider provider)
        {
            // Arrange
            var data = Encoding.UTF8.GetBytes(RandomHelper.NextSentence(g_random, RandomHelper.NextInt(g_random, 10, 200)));

            var formatter = new SymmetricObjectFormatter(provider, null);

            // Act
            var decrypted = formatter.Decrypt(formatter.Encrypt(new ArraySegment <byte>(data)));
            var result    = new byte[decrypted.Count];

            Buffer.BlockCopy(decrypted.Array, decrypted.Offset, result, 0, decrypted.Count);

            // Assert
            Assert.Equal(data, result);
        }
Example #6
0
        public SymmetricAlgorithmContextPool(SymmetricAlgorithmOptions options, ISymmetricAlgorithmProvider provider)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            m_options  = options;
            m_provider = provider;
            Pool       = new WaitPool <ISymmetricAlgorithmContext>(
                new LazyPool <ISymmetricAlgorithmContext>(
                    new SynchronizedPool <ISymmetricAlgorithmContext>(m_sync,
                                                                      new StackPool <ISymmetricAlgorithmContext>(String.Concat("SymmetricAlgorithm ", options.Name), options.MaxPoolSize),
                                                                      options.PoolAccessTimeout),
                    CreateFactory, ReleaseFactory),
                options.PoolWaitTimeout);
        }
Example #7
0
 public SynchronizedSymmetricAlgorithmContext(ISymmetricAlgorithmProvider provider)
     : this(provider.Create())
 {
 }