示例#1
0
        public void CreateJwtToken__Jwt_created_succeeded__Should_return_not_null_JwtSecurityToken()
        {
            var handler = new JwtTokenHandler(_jwtOptions, _logger);

            var result = handler.CreateJwtToken(_user, _roles);

            result.Should().NotBeNull();
        }
        public void GenerateJwtSecurityTokenSuccessMethod()
        {
            var    appSettings = _serviceProvider.GetService <AppSettings>();
            string userId      = "1";
            var    token       = new JwtTokenHandler(appSettings).GenerateJwtSecurityToken(userId);

            Assert.True(!string.IsNullOrEmpty(token));
        }
示例#3
0
        private string GenerateJwtToken()
        {
            var claims      = new[] { new Claim(ClaimTypes.Name, "testuser") };
            var credentials = new SigningCredentials(SecurityKey, SecurityAlgorithms.HmacSha256);
            var token       = new JwtSecurityToken("FunctionalTestServer", "FunctionalTests", claims, expires: DateTime.Now.AddSeconds(5), signingCredentials: credentials);

            return(JwtTokenHandler.WriteToken(token));
        }
示例#4
0
 public UserRepository(UserDbContext userDbContext, UserManager <User> userManager, SignInManager <User> signInManager, RoleManager <UserRole> roleManager, JwtTokenHandler jwtTokenHandler)
 {
     this._context       = userDbContext;
     this._userManager   = userManager;
     this._signInManager = signInManager;
     this._roleManager   = roleManager;
     this._tokenHandler  = jwtTokenHandler;
 }
示例#5
0
        public void VerifyJwtSecurityTokenSuccessMethod()
        {
            AppSettings appSettings = new AppSettings();

            appSettings.Secret = "1234567890 a very long word";
            var _jwtTokenHandler = new JwtTokenHandler(appSettings);
            var user             = _jwtTokenHandler.VerifyJwtSecurityToken("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjEiLCJuYmYiOjE1Njk5NTUwOTgsImV4cCI6MTU3MDU1OTg5OCwiaWF0IjoxNTY5OTU1MDk4fQ._d2vCroRoYMGfB76AG14gorMaVcowiOpp6mf_s49zuE");

            Assert.Equal("1", user);
        }
示例#6
0
        public void GenerateJwtSecurityTokenSuccessMethod()
        {
            AppSettings appSettings = new AppSettings();

            appSettings.Secret = "1234567890 a very long word";
            string userId = "1";
            var    token  = new JwtTokenHandler(appSettings).GenerateJwtSecurityToken(userId);

            Assert.True(!string.IsNullOrEmpty(token));
        }
示例#7
0
        public void InitializeContext()
        {
            var connectionString = AppsettingsConfig.Config.GetConnectionString("SqlDatabase");
            var dbOption         = new DbContextOptionsBuilder <UserDbContext>()
                                   .UseSqlServer(connectionString).Options;

            UserDbContext   = new UserDbContext(dbOption);
            JwtTokenHandler = new JwtTokenHandler(AppsettingsConfig.Config);
            AddIdentityFramework(connectionString);
        }
示例#8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = JwtTokenHandler.GetTokenValidationParameters();
            });
        }
        public AccountController(
            AccountAppService accountAppService,
            IAbpSession abpSession,
            JwtTokenHandler jwtTokenHandler)
        {
            _AccountAppService = accountAppService;

            _AbpSession = abpSession;

            _JwtTokenHandler = jwtTokenHandler;
        }
示例#10
0
        public void CreateToken_createNewToken_ReturnStringToken()
        {
            // Arrange
            JwtTokenHandler tokenHandler = new JwtTokenHandler(Config);
            var             user         = DummyUsers.TestUser();

            // Act
            string token = tokenHandler.CreateToken(user, false);

            // Assert
            Assert.IsNotNull(token);
        }
示例#11
0
        public void CreateRefreshToken_TryCreateNewRefreshJwtTokenWithNullUser_ReturnNULL()
        {
            // Arrange
            JwtTokenHandler tokenHandler = new JwtTokenHandler(Config);
            var             user         = DummyUsers.TestUser();

            // Act
            string token = tokenHandler.CreateRefreshToken(null);

            // Assert
            Assert.IsNull(token);
        }
示例#12
0
    public static string GenerateJwtToken(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            throw new InvalidOperationException("Name is not specified.");
        }

        var claims      = new[] { new Claim(ClaimTypes.Name, name) };
        var credentials = new SigningCredentials(SecurityKey, SecurityAlgorithms.HmacSha256);
        var token       = new JwtSecurityToken("ExampleServer", "ExampleClients", claims, expires: DateTime.Now.AddSeconds(60), signingCredentials: credentials);

        return(JwtTokenHandler.WriteToken(token));
    }
示例#13
0
        public void ValidateToken_CheckIfJwtTokenIsValid_ReturnTrue()
        {
            // Arrange
            JwtTokenHandler tokenHandler = new JwtTokenHandler(Config);
            var             user         = DummyUsers.TestUser();
            string          token        = tokenHandler.CreateToken(user);

            // Act
            var result = tokenHandler.ValidateToken(token)
                         .Identity
                         .IsAuthenticated;

            // Assert
            Assert.IsTrue(result);
        }
示例#14
0
        public async Task <Token> RefreshTokenLoginAsync(string refreshToken)
        {
            User user = await _userRepository.GetWhereAsync(x => x.RefreshToken == refreshToken);

            if (user != null && user?.RefreshTokenEndDate > DateTime.Now)
            {
                JwtTokenHandler tokenHandler = new JwtTokenHandler();
                Token           token        = tokenHandler.CreateAccessToken(user);

                user.RefreshToken        = token.RefreshToken;
                user.RefreshTokenEndDate = token.Expiration.AddMinutes(3);
                await _userRepository.UpdateAsync(user);

                return(token);
            }
            return(null);
        }
示例#15
0
        private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient,
                           ZoomClientOptions options, ILogger logger = null)
        {
            _mustDisposeHttpClient = disposeClient;
            _httpClient            = httpClient;
            var options1 = options ?? GetDefaultOptions();

            _fluentClient = new FluentClient(new Uri(ZoomV2BaseUri), httpClient)
                            .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)");

            _fluentClient.Filters.Remove <DefaultErrorFilter>();

            switch (connectionInfo)
            {
            // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler.
            case JwtConnectionInfo jwtConnectionInfo:
            {
                var tokenHandler = new JwtTokenHandler(jwtConnectionInfo);
                _fluentClient.Filters.Add(tokenHandler);
                _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler));
                break;
            }

            case OAuthConnectionInfo oauthConnectionInfo:
            {
                var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient);
                _fluentClient.Filters.Add(tokenHandler);
                _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler));
                break;
            }

            default:
                throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null);
            }

            // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project.
            _fluentClient.Filters.Add(new DiagnosticHandler(options1.LogLevelSuccessfulCalls,
                                                            options1.LogLevelFailedCalls));
            _fluentClient.Filters.Add(new ZoomErrorHandler());

            Meetings     = new Meetings(_fluentClient);
            PastMeetings = new PastMeetings(_fluentClient);
            PastWebinars = new PastWebinars(_fluentClient);
            Users        = new Users(_fluentClient);
            Webinars     = new Webinars(_fluentClient);
        }
示例#16
0
        private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool disposeClient, ZoomClientOptions options, ILogger logger = null)
        {
            _mustDisposeHttpClient = disposeClient;
            _httpClient            = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
            _options      = options ?? GetDefaultOptions();
            _logger       = logger ?? NullLogger.Instance;
            _fluentClient = new FluentClient(new Uri(ZOOM_V2_BASE_URI), httpClient)
                            .SetUserAgent($"ZoomNet/{Version} (+https://github.com/Jericho/ZoomNet)");

            _fluentClient.Filters.Remove <DefaultErrorFilter>();

            // Order is important: the token handler (either JWT or OAuth) must be first, followed by DiagnosticHandler and then by ErrorHandler.
            if (connectionInfo is JwtConnectionInfo jwtConnectionInfo)
            {
                var tokenHandler = new JwtTokenHandler(jwtConnectionInfo);
                _fluentClient.Filters.Add(tokenHandler);
                _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler));
            }
            else if (connectionInfo is OAuthConnectionInfo oauthConnectionInfo)
            {
                var tokenHandler = new OAuthTokenHandler(oauthConnectionInfo, httpClient);
                _fluentClient.Filters.Add(tokenHandler);
                _fluentClient.SetRequestCoordinator(new ZoomRetryCoordinator(new Http429RetryStrategy(), tokenHandler));
            }
            else
            {
                throw new ZoomException($"{connectionInfo.GetType()} is an unknown connection type", null, null, null, null);
            }

            // The list of filters must be kept in sync with the filters in Utils.GetFluentClient in the unit testing project.
            _fluentClient.Filters.Add(new DiagnosticHandler(_options.LogLevelSuccessfulCalls, _options.LogLevelFailedCalls, _logger));
            _fluentClient.Filters.Add(new ZoomErrorHandler());

            Accounts        = new Accounts(_fluentClient);
            Chat            = new Chat(_fluentClient);
            CloudRecordings = new CloudRecordings(_fluentClient);
            Contacts        = new Contacts(_fluentClient);
            DataCompliance  = new DataCompliance(_fluentClient);
            Meetings        = new Meetings(_fluentClient);
            PastMeetings    = new PastMeetings(_fluentClient);
            PastWebinars    = new PastWebinars(_fluentClient);
            Users           = new Users(_fluentClient);
            Webinars        = new Webinars(_fluentClient);
            Dashboards      = new Dashboards(_fluentClient);
        }
        public static string GetToken(this User user)
        {
            var tokenHandler    = JwtTokenHandler.GetTokenHandler();
            var key             = Encoding.ASCII.GetBytes(AppOptionProvider.JwtOptions.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, user.Id.ToString())
                }),
                Expires            = DateTime.UtcNow.AddDays(7),
                SigningCredentials = new SigningCredentials(
                    new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            return(tokenHandler.WriteToken(token));
        }
        public AccountController(
            IEventService events,
            IIdentityServerInteractionService interaction,
            ValidateCodeHelper validateCodeHelper,
            AccountAppService accountAppService,
            IAbpSession abpSession,
            JwtTokenHandler jwtTokenHandler)
        {
            _Events = events;

            _Interaction = interaction;

            _ValidateCodeHelper = validateCodeHelper;

            _AccountAppService = accountAppService;

            _AbpSession = abpSession;

            _JwtTokenHandler = jwtTokenHandler;
        }
示例#19
0
            public async Task <string> Handle(Command request, CancellationToken cancellationToken)
            {
                LoginDataDtoValidator validator = new LoginDataDtoValidator();
                ValidationResult      results   = validator.Validate(request.obj);

                if (!results.IsValid)
                {
                    validator.ValidateAndThrow(request.obj);
                }
                var User = await uow.Context.Users.SingleOrDefaultAsync(x => x.Username == request.obj.Username);

                if (User == null || !Validation.Validate(request.obj.Password, User.Salt, User.Password))
                {
                    throw new StatusCodeException(HttpStatusCode.NotFound, "Username and/or password is incorrect");
                }
                JwtTokenHandler handler = new JwtTokenHandler(uow, configuration);
                string          token   = handler.CreateJWTToken(request.obj.Username);

                uow.httpContextAccessor.HttpContext.Session.SetString("JwtToken", token);
                return(token);
            }
示例#20
0
        public async Task <TokenResponse> CreateJwtTokenAsync([FromBody] TokenRequest request)
        {
            if (request == null)
            {
                throw new ArgumentException(nameof(TokenRequest));
            }
            TokenResponse response;

            try
            {
                DateTime          expireDateTimeUtc = DateTime.UtcNow.AddMilliseconds(QLAuthenticationOptions.TokenLifetimeMS);
                ClaimsIdentityBox identityBox       = await GetUserIdentityAsync(request.Login, request.Password, request.GrantType);

                if (identityBox != null)
                {
                    JwtSecurityToken token = JwtTokenHandler
                                             .CreateJwtSecurityToken(
                        subject: identityBox.ClaimsIdentity,
                        signingCredentials: QLAuthenticationOptions.GetSigningCredentials(),
                        audience: QLAuthenticationOptions.Audience,
                        issuer: QLAuthenticationOptions.Issuer,
                        expires: expireDateTimeUtc);
                    response = new TokenResponse(
                        token.Issuer, token.Audiences.ToList(), JwtTokenHandler.WriteToken(token), TokenType, identityBox.Sub, expireDateTimeUtc,
                        await ParseIdentityInfoFromIdentityClaimsAsync(identityBox.ClaimsIdentity.Claims.ToDictionary((item) => item.Type, (item) => item.Value)));
                }
                else
                {
                    throw new AuthorizationException("Login or password is incorrect.");
                }
            }
            catch (AuthorizationException)
            {
                Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                response            = null;
            }
            return(response);
        }
示例#21
0
        public async Task <BaseResponseDto <UserDto> > Login(AuthDto auth)
        {
            try
            {
                var user = await GetByEmailAsync(auth.Email);

                BaseResponseDto <UserDto> userResponse = new BaseResponseDto <UserDto>();
                if (user == null)
                {
                    userResponse.Errors.Add("Email", "Enail is wrong");
                    return(userResponse);
                }

                var    locker          = CreateLockerInstance();
                string decrpytPassword = locker.Decrypt(user.Password);
                if (decrpytPassword != auth.Password)
                {
                    userResponse.Errors.Add("Password", "Password is wrong");
                    return(userResponse);
                }

                JwtTokenHandler tokenHandler = new JwtTokenHandler();
                var             token        = tokenHandler.CreateAccessToken(user);
                user.AccessToken         = token.AccessToken;
                user.RefreshToken        = token.RefreshToken;
                user.RefreshTokenEndDate = token.Expiration.AddDays(1);
                UserDto userDto = new UserDto(user.Id, user.FirstName, user.LastName, user.Address, user.AccessToken, user.Role);
                userResponse.Data = userDto;
                await _userRepository.UpdateAsync(user);

                return(userResponse);
            }
            catch (Exception)
            {
                throw;
            }
        }
 public void VerifyJwtSecurityToken()
 {
     var(isVerified, transactionId) = JwtTokenHandler.VerifyJwtSecurityToken(secret, token);
     Assert.True(isVerified);
 }
示例#23
0
        private ClaimsPrincipal ValidateToken(string token)
        {
            var securityTokenHandler = new JwtSecurityTokenHandler();

            return(securityTokenHandler.ValidateToken(token, JwtTokenHandler.GetTokenValidationParameters(), out _));
        }
        public static (int, ApplicationException) PayloadValidator(AppSettings lockerConfiguration, bool jwtToken, string jwtSecret, string token, string payloadType, string lockerId, string transactionId, string[] compartmentIds, string captureType)
        {
            int statusCode = StatusCode.Status200OK;
            ApplicationException result = null;

            try
            {
                #region Json Web Token

                if (jwtToken)
                {
                    if (string.IsNullOrEmpty(token))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidToken, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidToken)
                        };
                        return(statusCode, result);
                    }
                    var(isVerified, transactionid) = JwtTokenHandler.VerifyJwtSecurityToken(jwtSecret, token);
                    if ((!isVerified) || string.IsNullOrEmpty(transactionid))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidToken, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidToken)
                        };
                        return(statusCode, result);
                    }
                }

                #endregion


                #region Payload Validation

                switch (payloadType)
                {
                case PayloadTypes.OpenCompartment:

                    if (string.IsNullOrEmpty(transactionId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyTransactionId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyTransactionId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (string.IsNullOrEmpty(lockerId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (compartmentIds == null || compartmentIds.Length == 0)
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyCompartmentId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyCompartmentId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (compartmentIds.Length > 0 && !compartmentIds.Contains("All"))
                    {
                        if (lockerConfiguration != null && lockerConfiguration.Locker.LockerId != lockerId)
                        {
                            statusCode = StatusCode.Status422UnprocessableEntity;
                            result     = new ApplicationException {
                                Code = ApplicationErrorCodes.InvalidLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidLockerId)
                            };
                            Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                            return(statusCode, result);
                        }
                        if (lockerConfiguration != null && lockerConfiguration.Locker.Compartments.Count() > 0)
                        {
                            foreach (string compartmentId in compartmentIds)
                            {
                                var flag = lockerConfiguration.Locker.Compartments.Any(com => com.CompartmentId == compartmentId);
                                if (flag)
                                {
                                    continue;
                                }
                                else
                                {
                                    statusCode = StatusCode.Status422UnprocessableEntity;
                                    result     = new ApplicationException
                                    {
                                        Code    = ApplicationErrorCodes.InvalidCompartmentId,
                                        Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidCompartmentId)
                                    };
                                    Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                                    return(statusCode, result);
                                }
                            }
                        }
                    }
                    Log.Warning("[HCM][Locker Management Validator][Open Compartment]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                    return(statusCode, result);

                case PayloadTypes.CompartmentStatus:

                    if (string.IsNullOrEmpty(lockerId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Compartment Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (lockerConfiguration != null && lockerConfiguration.Locker.LockerId != lockerId)
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Compartment Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    if (lockerConfiguration != null && lockerConfiguration.Locker.Compartments.Count() > 0 && !compartmentIds.Contains("All"))
                    {
                        foreach (string compartmentId in compartmentIds)
                        {
                            var flag = lockerConfiguration.Locker.Compartments.Any(compartment => compartment.CompartmentId == compartmentId);
                            if (flag)
                            {
                                continue;
                            }
                            else
                            {
                                statusCode = StatusCode.Status422UnprocessableEntity;
                                result     = new ApplicationException
                                {
                                    Code    = ApplicationErrorCodes.InvalidCompartmentId,
                                    Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidCompartmentId)
                                };
                                Log.Warning("[HCM][Locker Management Validator][Compartment Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                                return(statusCode, result);
                            }
                        }
                    }
                    Log.Warning("[HCM][Locker Management Validator][Compartment Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                    return(statusCode, result);

                case PayloadTypes.LockerStatus:

                    if (string.IsNullOrEmpty(lockerId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Locker Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    if (lockerConfiguration != null && lockerConfiguration.Locker.LockerId != lockerId)
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Locker Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }

                    Log.Warning("[HCM][Locker Management Validator][Locker Status]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");
                    return(statusCode, result);

                case PayloadTypes.CaptureImage:

                    if (string.IsNullOrEmpty(lockerId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (lockerConfiguration != null && lockerConfiguration.Locker.LockerId != lockerId)
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidLockerId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidLockerId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (string.IsNullOrEmpty(captureType))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyCaptureType, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyCaptureType)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (!(captureType == CaptureType.Photo || captureType == CaptureType.Screen))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.InvalidCaptureType, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.InvalidCaptureType)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }
                    else if (string.IsNullOrEmpty(transactionId))
                    {
                        statusCode = StatusCode.Status422UnprocessableEntity;
                        result     = new ApplicationException {
                            Code = ApplicationErrorCodes.EmptyTransactionId, Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.EmptyTransactionId)
                        };
                        Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");

                        return(statusCode, result);
                    }

                    Log.Warning("[HCM][Locker Management Validator][Capture Image]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");
                    return(statusCode, result);
                }

                #endregion
            }
            catch (Exception)
            {
                statusCode = StatusCode.Status502BadGateway;
                result     = new ApplicationException
                {
                    Code    = ApplicationErrorCodes.UnknownError,
                    Message = ApplicationErrorCodes.GetMessage(ApplicationErrorCodes.UnknownError)
                };
                Log.Error("[HCM][Locker Management Validator]" + "[Status Code : " + statusCode + "]" + "[Result : " + result + "]");
            }
            return(statusCode, result);
        }
 public void VerifyJwtTokenContainsTransactionId()
 {
     var(isVerified, transactionId) = JwtTokenHandler.VerifyJwtSecurityToken(secret, token);
     Assert.NotEmpty(transactionId);
 }