Beispiel #1
0
        public MainViewModel(IEventAggregator eventAggregator, ISignalRClient signalRClient, IAuthStore authStore,
            IProductsRepository productsRepository)
        {
            this.eventAggregator = eventAggregator;
            this.signalRClient = signalRClient;
            this.productsRepository = productsRepository;

            deleteRequest = new InteractionRequest<Confirmation>();
            CreateProductCommand = new DelegateCommand(CreateProduct);
            OpenProductCommand = new DelegateCommand<Product>(EditProduct);
            changePriceCommand = new DelegateCommand(ChangePrice, HasSelectedProducts);
            deleteCommand = new DelegateCommand(PromtDelete, HasSelectedProducts);

            cvs = new CollectionViewSource();
            items = new ObservableCollection<Product>();
            cvs.Source = items;
            cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            cvs.SortDescriptions.Add(new SortDescription("Size", ListSortDirection.Ascending));

            var token = authStore.LoadToken();
            if (token != null)
            {
                IsEditor = token.IsEditor();
                IsAdmin = token.IsAdmin();
            }
        }
Beispiel #2
0
        public BearerHttpClient(IAuthStore authStore, IApplicationSettings settings)
        {
            BaseAddress = new Uri(settings.Endpoint, UriKind.Absolute);

            var token = authStore.LoadToken();
            DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(Bearer, token.AccessToken);
        }
Beispiel #3
0
        public FilesViewModel(IFilesRepository filesRepository, IAuthStore authStore, IProductsRepository productsRepository, 
            Func<CreateFileViewModel> createFactory, Func<EditFileViewModel> editFactory)
        {
            this.filesRepository = filesRepository;
            this.productsRepository = productsRepository;
            this.createFactory = createFactory;
            this.editFactory = editFactory;

            var token = authStore.LoadToken();
            if (token != null)
            {
                IsEditor = token.IsEditor();
                IsAdmin = token.IsAdmin();
            }

            cvs = new CollectionViewSource();
            items = new ObservableCollection<FileDescription>();
            cvs.Source = items;
            cvs.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            cvs.SortDescriptions.Add(new SortDescription("Id", ListSortDirection.Ascending));

            editRequest = new InteractionRequest<IConfirmation>();
            BrowseCommand = new DelegateCommand(Browse);
            EditCommand = new DelegateCommand<FileDescription>(Edit);

            deleteCommand = new DelegateCommand(PromtDelete, HasSelectedItems);
            deleteRequest = new InteractionRequest<Confirmation>();
        }
Beispiel #4
0
        /// <summary>
        ///     Initialize the podio class with Client ID and Client Secret
        ///     <para>You can get the Client ID and Client Secret from here: https://developers.podio.com/api-key </para>
        /// </summary>
        /// <param name="clientId">Client ID</param>
        /// <param name="clientSecret">Client Secret</param>
        /// <param name="authStore">
        ///     If you need to persist the access tokens for a longer period (in your session, database or whereever), Implement
        ///     PodioAPI.Utils.IAuthStore Interface and pass it in.
        ///     <para> You can use the IsAuthenticated method to check if there is a stored access token already present</para>
        /// </param>
        public Podio(string clientId, string clientSecret, IAuthStore authStore = null)
        {
            ClientId     = clientId;
            ClientSecret = clientSecret;
            ApiUrl       = "https://api.podio.com:443";

            AuthStore = authStore ?? new NullAuthStore();
        }
        public ProductEditViewModel(IProductsRepository repository, IEventAggregator eventAggregator, IAuthStore authStore, AttachmentsViewModel attachmentsViewModel)
        {
            this.repository = repository;
            this.eventAggregator = eventAggregator;
            this.authStore = authStore;
            this.attachmentsViewModel = attachmentsViewModel;

            SaveCommand = new DelegateCommand<ChildWindow>(Save);
            TabLoadedCommand = new DelegateCommand<object>(OnTabLoaded);
        }
Beispiel #6
0
        public ShellViewModel(IAuthStore authStore, IAuthService authService, ISignalRClient signalRClient,
            Func<LoginViewModel> loginFactory, Func<LoggedInViewModel> loggedInFactory)
        {
            this.authStore = authStore;
            this.authService = authService;
            this.signalRClient = signalRClient;
            this.loginFactory = loginFactory;
            this.loggedInFactory = loggedInFactory;

            Refresh();
        }
        public PixivOAuthHandler(string loginHost, string oAuth2TokenPath, PixivOAuthRequest request, IAuthStore authStore, IHttpClientProvider httpClientProvider)
        {
            var factory = new EasyHttpClientFactory();

            factory.Config.HttpClientProvider = httpClientProvider;

            this._request         = request;
            this._oAuth2TokenPath = oAuth2TokenPath.Trim('/');
            this._oAuth2Api       = factory.Create <IOAuth2Api>(loginHost);
            this._authStore       = authStore;
        }
Beispiel #8
0
 public PermissionService(
     IPermissionRepository permissionRepository,
     IRoleRepository roleRepository,
     IAuthStore authStore,
     ICacheManager cacheManager
     )
 {
     _permissionRepository = permissionRepository;
     _roleRepository       = roleRepository;
     _authStore            = authStore;
     _cacheManager         = cacheManager;
 }
Beispiel #9
0
        public TopMenuViewModel(IAuthStore authStore, INavigationService navigationService,
            IRegionManager regionManager, ISignalRClient signalRClient)
        {
            this.authStore = authStore;
            this.navigationService = navigationService;
            this.regionManager = regionManager;
            this.signalRClient = signalRClient;

            LogoutCommand = new DelegateCommand(Logout);

            NavigateToPageCommand = new DelegateCommand<string>(NavigateToPage);
        }
 public ServerConnectionHandler(ILogger <ServerConnectionHandler> logger,
                                IPackageParser packageParser,
                                IUserRepository UserRepo,
                                ICharacterRepositiory CharacterRepo,
                                IAuthStore authStore)
 {
     this.logger        = logger;
     this.packageParser = packageParser;
     this.UserRepo      = UserRepo;
     this.CharacterRepo = CharacterRepo;
     this.authStore     = authStore;
 }
Beispiel #11
0
        public SettingsViewModel(IAuthStore authStore, IUsersRepository usersRepository)
        {
            this.usersRepository = usersRepository;

            SaveCommand = new DelegateCommand(Save);

            var token = authStore.LoadToken();
            if (token != null && token.IsAuthenticated())
            {
                UserName = token.UserName;
                Role = token.Role;
            }
        }
        public ResourceGuruClient(string clientId, string clientSecret, IAuthStore authStore = null, WebProxy proxy = null)
        {
            Proxy        = proxy;
            ClientId     = clientId;
            ClientSecret = clientSecret;
            if (authStore != null)
            {
                AuthStore = authStore;
            }
            else
            {
                AuthStore = new NullAuthStore();
            }

            OAuthInfo = AuthStore.Get();
        }
        //private readonly AttachmentsViewModel attachmentsViewModel;

        public ProductEditWindowViewModel(IProductsRepository repository, IEventAggregator eventAggregator,
            IAuthStore authStore/*, AttachmentsViewModel attachmentsViewModel*/)
        {
            this.repository = repository;
            this.eventAggregator = eventAggregator;
            //this.attachmentsViewModel = attachmentsViewModel;

            var token = authStore.LoadToken();
            if (token != null)
            {
                canSave = token.IsEditor();
                canEditPrice = token.IsAdmin();
            }

            SaveCommand = new DelegateCommand(Save, () => canSave);
            CancelCommand = new DelegateCommand(() => IsWindowOpen = false);
        }
Beispiel #14
0
        /// <summary>
        /// Internals the constructor.
        /// </summary>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="clientSecret">The client secret.</param>
        /// <param name="authStore">The authentication store.</param>
        private void internalConstructor(string clientId, string clientSecret, IAuthStore authStore)
        {
            ClientId     = clientId;
            ClientSecret = clientSecret;
            ApiUrl       = "https://api.podio.com:443";

            if (authStore != null)
            {
                AuthStore = authStore;
            }
            else
            {
                AuthStore = new NullAuthStore();
            }

            OAuth = AuthStore.Get();
        }
Beispiel #15
0
        public SettingsViewModel(IAuthStore authStore, Func<ChangePasswordViewModel> changePasswordFactory)
        {
            this.changePasswordFactory = changePasswordFactory;

            var v = Assembly.GetEntryAssembly().GetName().Version;
            Version = (v.Build > 0)
                ? string.Join(".", new[] { v.Major, v.Minor, v.Build })
                : string.Join(".", new[] { v.Major, v.Minor });

            changePasswordRequest = new InteractionRequest<IConfirmation>();
            ChangePasswordCommand = new DelegateCommand(ChangePassword);

            var token = authStore.LoadToken();
            if (token != null && token.IsAuthenticated())
            {
                UserName = token.UserName;
                Role = token.Role;
            }
        }
Beispiel #16
0
 /// <summary>
 /// Initialize the podio class with Client ID and Client Secret
 /// <para>You can get the Client ID and Client Secret from here: https://developers.podio.com/api-key </para>
 /// </summary>
 /// <param name="clientId">The client identifier.</param>
 /// <param name="clientSecret">The client secret.</param>
 /// <param name="authStore">The authentication store.</param>
 public Podio(string clientId, string clientSecret, IAuthStore authStore = null)
 {
     internalConstructor(clientId, clientSecret, authStore);
 }
 public PixivOAuthHandler(string loginHost, PixivOAuthRequest request, IAuthStore authStore, IHttpClientProvider httpClientProvider)
     : this(loginHost, "auth/token", request, authStore, httpClientProvider)
 {
 }
Beispiel #18
0
 public ProductsRepository(IAuthStore authStore)
 {
     this.authStore = authStore;
 }
Beispiel #19
0
 public FilesRepository(IAuthStore authStore)
 {
     this.authStore = authStore;
 }
Beispiel #20
0
 public AuthController(IAuthStore authStore)
 {
     this.AuthStore = authStore;
 }
Beispiel #21
0
 public AuthenticationService(IAuthStore authStore)
 {
     _authStore = authStore;
 }
Beispiel #22
0
        protected override async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            if (_responseStore == null)
            {
                _responseStore = AuthAPIConfiguration.Instance.ResponseStore;
            }
            if (_authStore == null)
            {
                _authStore = AuthAPIConfiguration.Instance.AuthStore;
            }

            var authHeader = new AuthHeader(request.Headers.Authorization == null ? string.Empty : request.Headers.Authorization.Parameter);

            if (authHeader.IsValid)
            {
                var clientSecret = await _authStore.GetClientSecretById(authHeader.Request.ClientId);

                var userPassword = await _authStore.GetPasswordByUserName(authHeader.Request.UserName);

                var cachedResponseIdentifier = await _responseStore.GetResponse(authHeader.Request.Identifier);

                if (cachedResponseIdentifier != null)
                {
                    var expectedRequestPayload = authHeader.Request.Copy <RequestPayload>();
                    expectedRequestPayload.RequestCount = string.Format("{0:D8}", int.Parse(cachedResponseIdentifier.Response.RequestCount) + 1);

                    var content = await request.Content.ReadAsByteArrayAsync();

                    var contentString = System.Text.Encoding.UTF8.GetString(content);

                    var expectedAuthHeader = new AuthHeader
                    {
                        Request = expectedRequestPayload,
                        Data    = new DataPayload
                        {
                            ClientId          = authHeader.Request.ClientId,
                            Method            = request.Method.Method,
                            Password          = userPassword,
                            RequestBodyBase64 = Convert.ToBase64String(content),
                            RequestURI        = request.RequestUri.PathAndQuery,
                            UserName          = authHeader.Request.UserName
                        }
                    };

                    if (expectedAuthHeader.ToHMAC(clientSecret).Equals(request.Headers.Authorization.Parameter.Split(':')[1]))
                    {
                        var newResponse = authHeader.Request.ToResponsePayload();

                        await _responseStore.UpdateResponse(newResponse.Identifier, newResponse);

                        request.GetRequestContext().Principal = new GenericPrincipal(new GenericIdentity(authHeader.Request.UserName),
                                                                                     new string[] { });
                    }
                }
            }

            return(await base.SendAsync(request, cancellationToken)
                   .ContinueWith(task =>
            {
                var response = task.Result;
                if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                {
                    var responsePayload = new ResponsePayload
                    {
                        Identifier = Guid.NewGuid().ToString(),
                        RequestCount = string.Format("{0:D8}", 0)
                    };

                    response.Headers.WwwAuthenticate.Add(new AuthenticationHeaderValue("AuthAPI",
                                                                                       responsePayload.ToBase64()));

                    _responseStore.StoreResponse(responsePayload, DateTime.Now.AddMilliseconds(AuthAPIConfiguration.Instance.TokenExpirationMiliseconds));
                }

                return response;
            }));
        }
Beispiel #23
0
 public AuthService(IAuthStore store)
 {
     this.store = store;
 }
Beispiel #24
0
 public AuthService(IAuthStore store, IApplicationSettings settings)
 {
     this.store = store;
     this.settings = settings;
 }
Beispiel #25
0
 public UsersRepository(IAuthStore authStore)
 {
     this.authStore = authStore;
 }
Beispiel #26
0
 public ApiClient(IAuthStore authStore, IApiSettings apiSettings)
 {
     _authStore   = authStore;
     _apiSettings = apiSettings;
 }