示例#1
0
 public SubscriptionsService(IPlansRepository plansRepository, IPaymentRepository paymentsRepository, ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository)
 {
     _plansRepository       = plansRepository;
     _paymentsRepository    = paymentsRepository;
     _cacheProvider         = cacheProvider;
     _departmentsRepository = departmentsRepository;
 }
        public static bool AuthAndSetPrinciple(ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository, string authTokenString, HttpContextBase context, bool v3)
        {
            if (String.IsNullOrWhiteSpace(authTokenString))
            {
                return(false);
            }

            var encodedUserPass = authTokenString.Trim();

            if (v3)
            {
                var    authToken = V3AuthToken.Decode(encodedUserPass);
                string userId;

                if (Config.SecurityConfig.SystemLoginCredentials.ContainsKey(authToken.UserName))
                {
                    if (Config.SecurityConfig.SystemLoginCredentials[authToken.UserName] != encodedUserPass)
                    {
                        return(false);
                    }

                    authToken.UserId = authToken.UserName;
                }
                else
                {
                    if (!ValidateUserAndDepartmentByUser(cacheProvider, departmentsRepository, authToken.UserName, authToken.DepartmentId, null, out userId))
                    {
                        return(false);
                    }

                    authToken.UserId = userId;
                }

                var principal = new ResgridPrincipleV3(authToken);
                Thread.CurrentPrincipal = principal;
                if (context != null)
                {
                    context.User = principal;
                }
            }
            else
            {
                var    authToken = AuthToken.Decode(encodedUserPass);
                string userId;

                if (!ValidateUserAndDepartmentByUser(cacheProvider, departmentsRepository, authToken.UserName, authToken.DepartmentId, authToken.DepartmentCode, out userId))
                {
                    return(false);
                }

                var principal = new ResgridPrinciple(authToken);
                Thread.CurrentPrincipal = principal;
                if (context != null)
                {
                    context.User = principal;
                }
            }

            return(true);
        }
示例#3
0
 public AuthTokenMiddleware(RequestDelegate next, ILoggerFactory loggerFactory, IDepartmentsRepository departmentRepository, ICacheProvider cacheProvider)
 {
     _next   = next;
     _logger = loggerFactory.CreateLogger <AuthTokenMiddleware>();
     _departmentRepository = departmentRepository;
     _cacheProvider        = cacheProvider;
 }
示例#4
0
        public ReportController(IDepartmentsRepository departmentsRepository, IEmpCodeResolverService empCodeResolverService, ISalaryResolverService salaryResolverService, ILoggerProvider loggerProvider)
        {
            _DepartmentsRepository  = departmentsRepository;
            _EmpCodeResolverService = empCodeResolverService;
            _SalaryResolverService  = salaryResolverService;

            _Logger = loggerProvider.CreateLogger(GetType().FullName);
        }
        public DepartmentModelService(IDepartmentsRepository departmentsRepository)
        {
            _departmentsRepository = departmentsRepository;

            _departments.OnItemAdd    += item => DepartmentsAdded?.Invoke(this, new DepartmentModelCollectionChangedEventArgs(item));
            _departments.OnItemRemove += item => DepartmentsRemoved?.Invoke(this, new DepartmentModelCollectionChangedEventArgs(item));

            Departments = new ReadOnlyCollection <DepartmentModel>(_departments);
        }
示例#6
0
 public UsersController(IUserRepository userRepository, IOptions <AppSettings> appSettings, IRolesRepository rolesRepository, IDepartmentsRepository departmentsRepository, IMapper mapper)
 {
     //_repositoryWrapper = repositoryWrapper;
     _userRepository             = userRepository;
     this._rolesRepository       = rolesRepository;
     this._departmentsRepository = departmentsRepository;
     this._mapper = mapper;
     //this._dropdownsRepository = dropdownsRepository;
     _appSettings = appSettings.Value;
 }
示例#7
0
 public ResgridTokenAuthHandler(IOptionsMonitor <ResgridAuthenticationOptions> options, ILoggerFactory logger,
                                UrlEncoder encoder, ISystemClock clock, ICacheProvider cacheProvider, IDepartmentsRepository departmentRepository,
                                IUserClaimsPrincipalFactory <IdentityUser> claimsPrincipalFactory, IUsersService usersService)
     : base(options, logger, encoder, clock)
 {
     _cacheProvider          = cacheProvider;
     _departmentRepository   = departmentRepository;
     _claimsPrincipalFactory = claimsPrincipalFactory;
     _usersService           = usersService;
 }
示例#8
0
 public DataManager(IServiceTypesRepository serviceTypesRepository, IServicesRepository servicesRepository, IDepartmentsRepository departmentsRepository,
                    IOrdersRepository ordersRepository, IUsersRepository usersRepository, IAdditionsRepository additionsRepository)
 {
     ServicesRepository     = servicesRepository;
     ServiceTypesRepository = serviceTypesRepository;
     DepartmentsRepository  = departmentsRepository;
     OrdersRepository       = ordersRepository;
     UsersRepository        = usersRepository;
     AdditionsRepository    = additionsRepository;
 }
 public CustomersController(
     ICustomersRepository customersRepository,
     ICustomersProductsRepository customersProductsRepository,
     IProductsRepository productsRepository,
     IDepartmentsRepository departmentsRepository
     )
 {
     _customersRepository         = customersRepository;
     _customersProductsRepository = customersProductsRepository;
     _departmentRepository        = departmentsRepository;
     _productsRepository          = productsRepository;
 }
示例#10
0
        public static bool AuthAndSetPrinciple(ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository, HttpRequestHeaders headers, HttpContextBase context, bool v3)
        {
            var authHeader = headers.Authorization;

            if (authHeader == null)
            {
                return(false);
            }

            if (authHeader.Scheme != "Basic")
            {
                return(false);
            }

            return(AuthAndSetPrinciple(cacheProvider, departmentsRepository, authHeader.Parameter, context, v3));
        }
示例#11
0
        // For SignalR
        public static bool AuthAndSetPrinciple(ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository, NameValueCollection headers, HttpContextBase context)
        {
            var authToken = headers["Authentication"];

            if (string.IsNullOrEmpty(authToken))
            {
                return(false);
            }

            if (authToken.IndexOf("Basic ") != 0)
            {
                return(false);
            }

            authToken = authToken.Substring(5);

            return(AuthAndSetPrinciple(cacheProvider, departmentsRepository, authToken, context, false));
        }
示例#12
0
 public DepartmentsService(IDepartmentsRepository departmentRepository, IDepartmentMembersRepository departmentMembersRepository,
                           ISubscriptionsService subscriptionsService, IDepartmentCallEmailsRepository departmentCallEmailsRepository,
                           IGenericDataRepository <DepartmentCallPruning> departmentCallPruningRepository, ICacheProvider cacheProvider, IUsersService usersService,
                           IDepartmentSettingsService departmentSettingsService, IGenericDataRepository <UserProfile> userProfileRepository,
                           IEventAggregator eventAggregator, IIdentityRepository identityRepository)
 {
     _departmentRepository            = departmentRepository;
     _departmentMembersRepository     = departmentMembersRepository;
     _subscriptionsService            = subscriptionsService;
     _departmentCallEmailsRepository  = departmentCallEmailsRepository;
     _departmentCallPruningRepository = departmentCallPruningRepository;
     _cacheProvider             = cacheProvider;
     _usersService              = usersService;
     _departmentSettingsService = departmentSettingsService;
     _userProfileRepository     = userProfileRepository;
     _eventAggregator           = eventAggregator;
     _identityRepository        = identityRepository;
 }
 public ComplaintsController(
     IComplaintsRepository complaintsRepository,
     IComplaintsOptionsRepository complaintsOptionsRepository,
     IProductsRepository productsRepository,
     ICustomersRepository customeRepository,
     ITicketTypesRepository ticketTypesRepository,
     IBinnaclesRepository binnaclesRepository,
     IDepartmentsRepository departmentsRepository,
     IStatusRepository statusRepository
     )
 {
     _complaintsRepository        = complaintsRepository;
     _complaintsOptionsRepository = complaintsOptionsRepository;
     _productsRepository          = productsRepository;
     _customeRepository           = customeRepository;
     _ticketTypesRepository       = ticketTypesRepository;
     _binnaclesRepository         = binnaclesRepository;
     _departmentsRepository       = departmentsRepository;
     _statusRepository            = statusRepository;
 }
示例#14
0
        public static bool AuthAndSetPrinciple(ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository, HttpContext context, bool v3)
        {
            StringValues authHeader;

            if (context.Request.Headers.TryGetValue("Authorization", out authHeader))
            {
                if (authHeader.Count <= 0)
                {
                    return(false);
                }

                if (!authHeader[0].Contains("Basic"))
                {
                    return(false);
                }

                return(AuthAndSetPrinciple(cacheProvider, departmentsRepository, authHeader[0].Replace("Basic", "").Trim(), context, v3));
            }

            return(false);
        }
示例#15
0
 public DepartmentsController(IDepartmentsRepository departmentsRepository)
 {
     this.departmentsRepository = departmentsRepository;
 }
示例#16
0
        private static async Task <ValidateUserForDepartmentResult> GetValidateUserForDepartmentInfo(ICacheProvider cacheProvider, IDepartmentsRepository departmentRepository, string userName, bool bypassCache = true)
        {
            async Task <ValidateUserForDepartmentResult> validateForDepartment()
            {
                return(await departmentRepository.GetValidateUserForDepartmentDataAsync(userName));
            }

            if (!bypassCache)
            {
                return(await cacheProvider.RetrieveAsync(string.Format(ValidateUserInfoCacheKey, userName), validateForDepartment, CacheLength));
            }

            return(await validateForDepartment());
        }
示例#17
0
        private static async Task <AuthValidationResult> ValidateUserAndDepartmentByUser(ICacheProvider cacheProvider, IDepartmentsRepository departmentRepository, string userName, int departmentId, string departmentCode)
        {
            var result = new AuthValidationResult();

            var data = await GetValidateUserForDepartmentInfo(cacheProvider, departmentRepository, userName, false);

            result.UserId = string.Empty;

            result.IsValid = true;

            if (data == null)
            {
                result.IsValid = false;
            }

            result.UserId = data.UserId;

            if (data.DepartmentId != departmentId)
            {
                result.IsValid = false;
            }

            if (data.IsDisabled.GetValueOrDefault())
            {
                result.IsValid = false;
            }

            if (data.IsDeleted.GetValueOrDefault())
            {
                result.IsValid = false;
            }

            if (departmentCode != null)
            {
                if (!data.Code.Equals(departmentCode, StringComparison.InvariantCultureIgnoreCase))
                {
                    result.IsValid = false;
                }
            }

            return(result);
        }
示例#18
0
 public DepartmentsService(IDepartmentsRepository departmentsRepository, IUsersRepository userRepository)
 {
     _departmentsRepository = departmentsRepository;
     _userRepository        = userRepository;
 }
 public InstructorsController(IInstructorsRepository instructorsRepository,
                              IDepartmentsRepository departmentsRepository)
 {
     _instructorsRepository = instructorsRepository;
     _departmentsRepository = departmentsRepository;
 }
示例#20
0
 public DepartmentLinksService(IDepartmentLinksRepository departmentLinksRepository, IDepartmentsRepository departmentsRepository, ICacheProvider cacheProvider)
 {
     _departmentLinksRepository = departmentLinksRepository;
     _departmentsRepository     = departmentsRepository;
     _cacheProvider             = cacheProvider;
 }
 public ComplaintsOptionsController(IComplaintsOptionsRepository complaintsOptionsRepository, IProductsRepository productsRepository, IDepartmentsRepository departmentsRepository)
 {
     _complaintsOptionsRepository = complaintsOptionsRepository;
     _productsRepository          = productsRepository;
     _departmentsRepository       = departmentsRepository;
 }
示例#22
0
 public CasesService(ICasesRepository casesRepository, IDepartmentsRepository departmentsRepository, IUsersRepository usersRepository)
 {
     _casesRepository       = casesRepository;
     _usersRepository       = usersRepository;
     _departmentsRepository = departmentsRepository;
 }
 public DefaultLayoutCommonFilter(IDepartmentsRepository departmentsRepository, IDictionaryAdapterFactory dictionaryAdapterFactory)
 {
     this.departmentsRepository = departmentsRepository;
     this.dictionaryAdapterFactory = dictionaryAdapterFactory;
 }
示例#24
0
 public CoursesController(ICoursesRepository coursesRepository, IDepartmentsRepository departmentsRepository, SchoolContext context)
 {
     _coursesRepository     = coursesRepository;
     _departmentsRepository = departmentsRepository;
     _context = context;
 }
示例#25
0
 public AuthTokenMessageHandler()
 {
     _departmentRepository = new DepartmentsRepository(new DataContext(), new StandardIsolation());
     _cacheProvider        = new AzureRedisCacheProvider();
 }
示例#26
0
        public static async Task <bool> AuthAndSetPrinciple(ICacheProvider cacheProvider, IDepartmentsRepository departmentsRepository, string authTokenString, HttpContext context, bool v3)
        {
            if (string.IsNullOrWhiteSpace(authTokenString))
            {
                return(false);
            }

            var encodedUserPass = authTokenString.Trim();

            if (v3)
            {
                var authToken = V3AuthToken.Decode(encodedUserPass);

                if (authToken != null)
                {
                    string userId;

                    if (Config.SecurityConfig.SystemLoginCredentials.ContainsKey(authToken.UserName))
                    {
                        if (Config.SecurityConfig.SystemLoginCredentials[authToken.UserName] != encodedUserPass)
                        {
                            return(false);
                        }

                        authToken.UserId = authToken.UserName;
                    }
                    else
                    {
                        var result = await ValidateUserAndDepartmentByUser(cacheProvider, departmentsRepository, authToken.UserName, authToken.DepartmentId, null);

                        if (!result.IsValid)
                        {
                            return(false);
                        }

                        authToken.UserId = result.UserId;
                    }

                    var principal = new ResgridPrincipleV3(authToken);
                    Thread.CurrentPrincipal = principal;
                    if (context != null)
                    {
                        context.User = new System.Security.Claims.ClaimsPrincipal(principal);
                    }
                }
            }

            return(true);
        }
 public DepartmentsController(IDepartmentsRepository departmentsRepository)
 {
     _departmentsRepository = departmentsRepository;
 }
 public DepartmentsService(IDepartmentsRepository departmentsRepository)
 {
     _departmentsRepository = departmentsRepository;
 }
示例#29
0
 public DepartmentsService(IUnitOfWork unitOfWork, IDepartmentsRepository departmentsRepository)
 {
     _unitOfWork            = unitOfWork;
     _departmentsRepository = departmentsRepository;
 }
示例#30
0
        private static bool ValidateUserAndDepartmentByUser(ICacheProvider cacheProvider, IDepartmentsRepository departmentRepository, string userName, int departmentId, string departmentCode, out string userId)
        {
            var data = GetValidateUserForDepartmentInfo(cacheProvider, departmentRepository, userName, false);

            userId = string.Empty;

            if (data == null)
            {
                return(false);
            }

            userId = data.UserId;

            if (data.DepartmentId != departmentId)
            {
                return(false);
            }

            if (data.IsDisabled.GetValueOrDefault())
            {
                return(false);
            }

            if (data.IsDeleted.GetValueOrDefault())
            {
                return(false);
            }

            if (departmentCode != null)
            {
                if (!data.Code.Equals(departmentCode, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(false);
                }
            }

            return(true);
        }
 public DepartmentService(IDepartmentsRepository departmentsRepository):base(departmentsRepository)
 {
     this.departmentsRepository = departmentsRepository;
 }
示例#32
0
        private static ValidateUserForDepartmentResult GetValidateUserForDepartmentInfo(ICacheProvider cacheProvider, IDepartmentsRepository departmentRepository, string userName, bool bypassCache = true)
        {
            if (!bypassCache)
            {
                Func <ValidateUserForDepartmentResult> validateForDepartment = delegate()
                {
                    return(departmentRepository.GetValidateUserForDepartmentData(userName));
                };

                return(cacheProvider.Retrieve(string.Format(ValidateUserInfoCacheKey, userName), validateForDepartment, CacheLength));
            }
            else
            {
                return(departmentRepository.GetValidateUserForDepartmentData(userName));
            }
        }