public IAuthorizationResult Authorize(IAuthorizationOptions AOptions)
        {
            if (!AOptions.IsInteractiveMode)
            {
                return new AuthorizationResult {
                           IsSuccess = false, ErrorMessage = "Authorization onle for interactive mode!"
                }
            }
            ;

            var application    = AOptions.Application;
            var dialogsFactory = application.GetProperty("DialogsFactory");
            var dialogFactory  = dialogsFactory.GetProperty("DialogFactory", "AuthorizationDialog");
            var dialog         = dialogFactory.InvokeMethod("CreateNew", GetType().Name);

            try
            {
                var dialogResult = (int)dialog.InvokeMethod("Show");

                const int OK_RESULT = 1;

                if (dialogResult == OK_RESULT)
                {
                    return new AuthorizationResult {
                               IsSuccess = true, ErrorMessage = ""
                    }
                }
                ;
            }
            finally
            {
                Marshal.FinalReleaseComObject(dialog);
                Marshal.FinalReleaseComObject(dialogFactory);
                Marshal.FinalReleaseComObject(dialogsFactory);
                Marshal.FinalReleaseComObject(application);
                Marshal.FinalReleaseComObject(AOptions);
            }

            return(new AuthorizationResult {
                IsSuccess = false, ErrorMessage = "Authorization canceled!"
            });
        }
    }
 public AuthorizeUserCommandHandler(IUserRepository userRepository, IAuthorizationOptions authorizationOptions, IValidator <AuthorizeUserCommand> validator)
 {
     _userRepository       = userRepository;
     _authorizationOptions = authorizationOptions;
     _validator            = validator;
 }
Exemple #3
0
 /// <summary>
 /// Gets the scopes list.
 /// </summary>
 /// <param name="authorizationOptions">The authorization options.</param>
 /// <returns></returns>
 public static IList <string> GetScopesList(this IAuthorizationOptions authorizationOptions)
 {
     return(authorizationOptions.Scopes.EmptyIfNull().Select(item => item.GetDescription()).Concat(authorizationOptions.DynamicScopes.EmptyIfNull()).Distinct().ToList());
 }
 public AuthorizationService(IAuthorizationOptions <TUser> options, IServiceProvider services)
 {
     this.options  = options;
     this.services = services;
 }
Exemple #5
0
 public RefreshAuthorizationTokenCommandHandler(IUserRepository userRepository, IAuthorizationOptions authorizationOptions)
 {
     _userRepository       = userRepository;
     _authorizationOptions = authorizationOptions;
 }