Example #1
0
        public SessionManager(
            IEncryptionManager encryptionManager,
            ITokenValidator tokenValidator,
            string hmacKey,
            int sessionExpirationTimeInMinutes,
            string siteName
            )
        {
            encryptionManager.Should().NotBeNull();
            tokenValidator.Should().NotBeNull();
            hmacKey.Should().NotBeNullOrEmpty();
            sessionExpirationTimeInMinutes.Should().BeGreaterThan(0);
            siteName.Should().NotBeNullOrEmpty();

            //We require a 32 character HMAC key. This should be a random string.
            //http://security.stackexchange.com/questions/95972/what-are-requirements-for-hmac-secret-key
            hmacKey.Length.Should().BeGreaterOrEqualTo(32);

            this._encryptionManager = encryptionManager;
            this._hmacKey           = hmacKey;
            this._sessionExpirationTimeInMinutes = sessionExpirationTimeInMinutes;
            this._siteName       = siteName;
            this._tokenValidator = tokenValidator;
        }