private IHttpActionResult Handle(GenerateTokenRequest request)
        {
            var claimsIdentity = _claimsIdentityRetriever
                .Retrieve(request.UserIdentifier, request.Secret);

            if (claimsIdentity.IsNull())
                throw new UserCredentialsException();

            var response = new GenerateTokenResponse(
                _jwtSecurityTokenGenerator.Generate(claimsIdentity, GetOptions()));

            return Ok(response);
        }
        public IHttpActionResult GenerateToken(GenerateTokenRequest request)
        {
            try
            {
                Validate(request);

                return Handle(request);
            }
            catch (Exception e)
            {
                return HandleException(e);
            }
        }
 /// <summary>
 /// Validates the request
 /// </summary>
 /// <param name="request">The request to validate</param>
 /// <exception cref="ValidationException">If request is not valid</exception>
 protected virtual void Validate(GenerateTokenRequest request)
 {
     GetValidator()
         .ThrowIf(request);
 }
 /// <summary>
 /// Validates the request
 /// </summary>
 /// <param name="request">The request to validate</param>
 /// <exception cref="ValidationException">If request is not valid</exception>
 protected virtual void Validate(GenerateTokenRequest request)
 {
     GetValidator()
     .ThrowIf(request);
 }