public bool IsInRole(string roleName) { bool retVal = false; UserIdentityService userIdentity = UserIdentityService.GetInstance(); string userName = userIdentity.IdentityProvider.GetUserName(); List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterUserName, userName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterRoleName, roleName); parameters.Add(p); //get data from data command DataTable dt = sql.GetDataForDataCommand(DataCommandRoleGetByUserAndRoleName, parameters); if (dt.Rows.Count > 0) { retVal = true; } return(retVal); }
/// <summary> /// Initializes a new instance of the <see cref="UserIdentityController" /> class. /// </summary> /// <param name="userService">The user service.</param> /// <param name="identityService">The identity service.</param> /// <param name="mailService">The mail service.</param> /// <param name="appCountersService">The application counters service.</param> public UserIdentityController(UserService userService, UserIdentityService identityService, MailService mailService, AppCountersService appCountersService) { _userService = userService; _identityService = identityService; _mailService = mailService; _appCountersService = appCountersService; }
public bool HasPermission(string permissionName) { bool retVal = false; UserIdentityService userIdentity = UserIdentityService.GetInstance(); string userName = userIdentity.IdentityProvider.GetUserName(); List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterUserName, userName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterPermissionName, permissionName); parameters.Add(p); //get data from data command DataTable dt = sql.GetDataForDataCommand(DataCommandUserGetPermissions, parameters); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { if (Convert.ToBoolean(row[ColumnHasPermission])) { retVal = true; break; } } } return(retVal); }
public void SetStep(CodeTorch.Core.Workflow workflow, WorkflowStep step, string entityIDValue, string comment) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterWorkflowStatusID, null); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowCode, workflow.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterWorkflowStepCode, step.Code); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityID, entityIDValue); parameters.Add(p); string userName; userName = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); p = new ScreenDataCommandParameter(ParameterCreatedBy, userName); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterComment, comment); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterUpdateCurrent, step.UpdateEntityWithStatusCode); parameters.Add(p); //get data from data command ExecuteDataCommand(DataCommandWorkflowSetStep, parameters); }
public ProfileController(UserIdentityService userIdentity, UsersService users, ClientCurrencyService clientCurrency, ClientThemeService clientTheme) { _userIdentity = userIdentity; _users = users; _clientCurrency = clientCurrency; _clientTheme = clientTheme; }
public OrderController(JewellisDbContext dbContext, UserIdentityService userIdentity, UsersService users, AuthenticateService authenticateService, ClientShoppingCartService clientCart) { _dbContext = dbContext; _userIdentity = userIdentity; _users = users; _authenticateService = authenticateService; _clientCart = clientCart; }
public bool ChangeWorkflowStep(CodeTorch.Core.Workflow workflow, WorkflowNextStep nextStep, string entityIDValue, string comment) { bool success = false; //get current workflow step WorkflowStep currentStep = GetCurrentWorkflowStep(workflow, entityIDValue); //see if next workflowstep is in possible WorkflowNextStep validNextStep = currentStep.PossibleNextSteps. Where(s => s.Code.ToLower() == nextStep.Code.ToLower()).SingleOrDefault(); if (validNextStep != null) { //check comments if ((validNextStep.RequireComment) && (String.IsNullOrEmpty(comment))) { throw new ApplicationException("Comments are required to change to this step"); } else { WorkflowStep step = workflow.GetStepByCode(validNextStep.Code); string userName; userName = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); using (TransactionScope rootScope = TransactionUtils.CreateTransactionScope()) { foreach (BaseWorkflowAction action in step.Actions) { action.Execute(null, workflow.Code, currentStep.Code, validNextStep.Code, entityIDValue, comment, userName); } //update workflow step SetStep(workflow, step, entityIDValue, comment); if (step.UpdateEntityWithStatusCode) { //update existing table status SetEntityStatus(workflow, step, entityIDValue); } success = true; rootScope.Complete(); } } } else { //invalid - someone may have changed status throw new ApplicationException("Status cannot be changed at this time"); } return(success); }
//To Associate Dealer And Customer public string CreateValueSingleCustomerUserWithUID() { if (SingleCustomerUserUID == string.Empty) { TPaaSServicesConfig.SetupEnvironment(); SingleCustomerUserUID = UserIdentityService.CreateUser(SingleCustomerUserLoginId, SingleCustomerUserPassword); } return(SingleCustomerUserUID); }
/// <summary> /// Represents a service (scoped) for managing the client's shopping cart. /// </summary> public ClientShoppingCartService(IHttpContextAccessor httpContextAccessor, IMemoryCache cache, JewellisDbContext dbContext, UserIdentityService userIdentity, UserCacheService userCache) { _httpContextAccessor = httpContextAccessor; _cache = cache; _dbContext = dbContext; _userIdentity = userIdentity; _userCache = userCache; this.InitializeClientCart(); }
public void Init() { _repository = new UserIdentityRepository(); _missionRepository = new MissionRepository(); _userRepository = new UserRepository(); _ratingRepository = new RatingRepository(); _service = new UserIdentityService(_repository); _userService = new UserService(_userRepository, _missionRepository, _ratingRepository, new AppCountersService(new AppCountersRepository())); _controller = new UserIdentityController(_userService, _service, new MailService(null, _repository), null); }
/// <summary> /// Initializes a new instance of the <see cref="UserController" /> class. /// </summary> /// <param name="userService">The user service.</param> /// <param name="imageService">The image service.</param> /// <param name="ratingService">The rating service.</param> /// <param name="userIdentityService">The user identity service.</param> public UserController( UserService userService, ImageService imageService, RatingService ratingService, UserIdentityService userIdentityService) { _userService = userService; _imageService = imageService; _ratingService = ratingService; _userIdentityService = userIdentityService; }
public static IMobilePage GetPage(string pageName) { IMobilePage retVal = null; MobileScreen screen = MobileScreen.GetByName(pageName); switch (screen.Type.ToLower()) { case "mobilecontent": retVal = new MobileContentPage(screen); break; case "mobiletabbed": retVal = new MobileTabbedPage(screen); break; case "mobilenavigation": Page root = GetPage(((MobileNavigationScreen)screen).GetRootScreen()).GetPage(); retVal = new MobileNavigationPage(screen, root); break; } if (retVal != null) { string loginScreen = Configuration.GetInstance().App.LoginScreen; if (!String.IsNullOrEmpty(loginScreen)) { if (retVal.Screen != null) { if (retVal.Screen.RequireAuthentication) { UserIdentityService identity = UserIdentityService.GetInstance(); string userName = identity.IdentityProvider.GetUserName(); if (String.IsNullOrEmpty(userName)) { retVal = GetPage(loginScreen); } } } } } return(retVal); }
private void UploadDocument( Document doc ) { doc.ID = Guid.NewGuid().ToString(); string modifiedBy = null; string fileExtension = Path.GetExtension(doc.FileName); string storageProviderFolder = null; byte[] fileContents = null; modifiedBy = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); foreach (Setting setting in doc.Settings) { switch (setting.Name.ToLower()) { case "modifiedby": if (!string.IsNullOrEmpty(setting.Value)) { modifiedBy = setting.Value; } break; } } fileContents = new byte[doc.Size]; using (Stream str = doc.Stream) { str.Read(fileContents, 0, doc.Size); // more code } DocumentFunctions utility = new DocumentFunctions(); utility.InsertDocument( doc.ID, "DB", doc.EntityID, doc.EntityType, doc.FileName, doc.DocumentType, doc.ContentType, doc.Size, 1, doc.Url, fileContents, false, modifiedBy); }
public void SetUp() { this._mockUserManger = MockHelpers.MockUserManager <User>(); this._mockSystemClock = new Mock <ISystemClock>(); this.mockEmailHelperService = new Mock <IEmailHelperService>(); this.mockUserMapper = new Mock <IBaseMapper <User, UserDto> >(); this.mockPublishEndpoint = new Mock <IPublishEndpoint>(); var logger = new Mock <ILogger <UserIdentityService> >(); _mockUserRepository = new Mock <IUserRepository>(); this.sut = new UserIdentityService( _mockUserManger.Object, _mockUserRepository.Object, _mockSystemClock.Object, mockEmailHelperService.Object, mockUserMapper.Object, logger.Object, mockPublishEndpoint.Object); }
public void Init() { _repository = new UserRepository(); _userIdentityRepository = new UserIdentityRepository(); _missionRepository = new MissionRepository(); _ratingRepository = new RatingRepository(); var imageProvider = new ImageProvider(); _imageService = new ImageService(imageProvider, _repository); _ratingService = new RatingService(_repository, _ratingRepository, true); _service = new UserService(_repository, _missionRepository, _ratingRepository, _appCountersService); _userIdentityService = new UserIdentityService(_userIdentityRepository); var principal = new ClaimsPrincipal(); principal.AddIdentity(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Sid, "User1Id") })); _controller = new UserController(_service, _imageService, _ratingService, _userIdentityService) { User = principal }; }
public void InsertMailMessage(EmailMessage message) { List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter p = null; p = new ScreenDataCommandParameter(ParameterMailMessageID, message.ID); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterMailSubject, message.Subject); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterMailBody, message.Body); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterPriority, message.Priority); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterIsBodyHtml, message.IsBodyHtml); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterTemplate, message.Template); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityType, message.EntityType); parameters.Add(p); p = new ScreenDataCommandParameter(ParameterEntityID, message.EntityID); parameters.Add(p); string userName; userName = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); p = new ScreenDataCommandParameter(ParameterCreatedBy, userName); parameters.Add(p); //get data from data command sql.ExecuteDataCommand(DataCommandWMailInsertMailMessage, parameters); }
/// <summary> /// Represents a service (scoped) for getting the client's preferred theme. /// </summary> /// <param name="options">The options to configure the <see cref="ClientThemeService"/>.</param> public ClientThemeService(IOptions <ClientThemeOptions> options, IHttpContextAccessor httpContextAccessor, JewellisDbContext dbContext, UserIdentityService userIdentity, UsersService users) { if (string.IsNullOrEmpty(options.Value.DefaultTheme)) { throw new ArgumentNullException("{options.DefaultTheme} cannot be null or empty."); } if (options.Value.SupportedThemes == null) { throw new ArgumentNullException("{options.SupportedThemes} cannot be null."); } if (options.Value.SupportedThemes.Length < 1) { throw new ArgumentException("{options.SupportedThemes} must have at least 1 supported theme."); } this.Options = options.Value; _httpContextAccessor = httpContextAccessor; _dbContext = dbContext; _userIdentity = userIdentity; _users = users; this.InitializeClientTheme(); }
public AnfAuthenticationHandler(UserIdentityService userIdentityService) { this.userIdentityService = userIdentityService; }
private void UploadDocument( Document doc ) { string modifiedBy = null; string fileExtension = Path.GetExtension(doc.FileName); string storageProviderFolder = null; byte[] fileContents = null; modifiedBy = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); foreach (Setting setting in doc.Settings) { switch (setting.Name.ToLower()) { case "folder": storageProviderFolder = setting.Value; break; case "modifiedby": if (!string.IsNullOrEmpty(setting.Value)) { modifiedBy = setting.Value; } break; } } string accessKeyID = GetUserName(storageProviderUserNameSource, storageProviderUserNameKey); string secretAccessKey = GetPassword(storageProviderPasswordSource, storageProviderPasswordKey); string region = GetRegion(storageProviderRegionSource, storageProviderRegionKey); TransferUtility fileTransferUtility = new TransferUtility(accessKeyID, secretAccessKey, RegionEndpoint.GetBySystemName(region)); TransferUtilityUploadRequest request = new TransferUtilityUploadRequest(); request.BucketName = GetBucket(storageProviderContainerSource, storageProviderContainerKey); //TODO - need to secure and provide options for ACL and storage class request.CannedACL = S3CannedACL.PublicRead; request.StorageClass = S3StorageClass.ReducedRedundancy; doc.ID = Guid.NewGuid().ToString(); if (String.IsNullOrEmpty(storageProviderFolder)) { request.Key = String.Format("{0}{1}", doc.ID, fileExtension); } else { request.Key = String.Format("{0}/{1}{2}", storageProviderFolder, doc.ID, fileExtension); } request.AutoCloseStream = false; request.ContentType = doc.ContentType; request.InputStream = doc.Stream; request.InputStream.Position = 0; fileTransferUtility.Upload(request); doc.Url = String.Format("{0}.s3.amazonaws.com/{1}", request.BucketName, request.Key); DocumentFunctions utility = new DocumentFunctions(); utility.InsertDocument( doc.ID, "AmazonS3", doc.EntityID, doc.EntityType, doc.FileName, doc.DocumentType, doc.ContentType, doc.Size, 1, doc.Url, fileContents, false, modifiedBy); }
public WishlistController(UserIdentityService userIdentity, UsersService users) { _userIdentity = userIdentity; _users = users; }
public OrdersController(UserIdentityService userIdentity, UsersService users, OrdersService orders) { _userIdentity = userIdentity; _users = users; _orders = orders; }
public HomeController(JewellisDbContext dbContext, UserIdentityService userIdentity, ClientCurrencyService clientCurrency) { _dbContext = dbContext; _userIdentity = userIdentity; _clientCurrency = clientCurrency; }
public static object GetParameterInputValue(BasePage page, IScreenParameter parameter, Control container) { object retVal = null; App app = CodeTorch.Core.Configuration.GetInstance().App; CodeTorch.Web.FieldTemplates.BaseFieldTemplate f = null; switch (parameter.InputType) { case ScreenInputType.AppSetting: retVal = ConfigurationManager.AppSettings[parameter.InputKey]; break; case ScreenInputType.Control: if (container == null) { f = page.FindFieldRecursive(parameter.InputKey); } else { f = page.FindFieldRecursive(container, parameter.InputKey); } if (f != null) { retVal = f.Value; } break; case ScreenInputType.ControlText: if (container == null) { f = page.FindFieldRecursive(parameter.InputKey); } else { f = page.FindFieldRecursive(container, parameter.InputKey); } if (f != null) { retVal = f.DisplayText; } break; case ScreenInputType.Cookie: retVal = page.Request.Cookies[parameter.InputKey].Value; break; case ScreenInputType.Form: retVal = page.Request.Form[parameter.InputKey]; break; case ScreenInputType.Header: retVal = page.Request.Headers[parameter.InputKey]; break; case ScreenInputType.QueryString: retVal = page.Request.QueryString[parameter.InputKey]; break; case ScreenInputType.Session: retVal = page.Session[parameter.InputKey]; break; case ScreenInputType.Special: switch (parameter.InputKey.ToLower()) { case "null": retVal = null; break; case "dbnull": retVal = DBNull.Value; break; case "username": retVal = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); break; case "hostheader": retVal = HttpContext.Current.Request.ServerVariables["HTTP_HOST"]; break; case "applicationpath": retVal = HttpContext.Current.Request.ApplicationPath; break; case "absoluteapplicationpath": retVal = String.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], ((HttpContext.Current.Request.ApplicationPath == "/") ? String.Empty : HttpContext.Current.Request.ApplicationPath)); break; } break; case ScreenInputType.User: try { retVal = GetProfileProperty(parameter.InputKey); } catch { } break; case ScreenInputType.Constant: retVal = parameter.InputKey; break; case ScreenInputType.ServerVariables: retVal = HttpContext.Current.Request.ServerVariables[parameter.InputKey]; break; } if (parameter.InputType != ScreenInputType.Special) { if (retVal == null) { retVal = parameter.Default; } } return(retVal); }
private object GetParameterInputValue(IScreenParameter parameter, object newID) { object retVal = null; App app = CodeTorch.Core.Configuration.GetInstance().App; CodeTorch.Web.FieldTemplates.BaseFieldTemplate f = null; switch (parameter.InputType) { case ScreenInputType.AppSetting: retVal = ConfigurationManager.AppSettings[parameter.InputKey]; break; case ScreenInputType.Control: throw new NotSupportedException(); //if (container == null) //{ // f = page.FindFieldRecursive(parameter.InputKey); //} //else //{ // f = page.FindFieldRecursive(container, parameter.InputKey); //} //if (f != null) //{ // retVal = f.Value; //} break; case ScreenInputType.ControlText: //if (container == null) //{ // f = page.FindFieldRecursive(parameter.InputKey); //} //else //{ // f = page.FindFieldRecursive(container, parameter.InputKey); //} //if (f != null) //{ // retVal = f.DisplayText; //} throw new NotSupportedException(); break; case ScreenInputType.Cookie: retVal = HttpContext.Current.Request.Cookies[parameter.InputKey].Value; break; case ScreenInputType.File: //currently onlu supports storage to database if (HttpContext.Current.Request.ContentType.ToLower().Contains("multipart")) { HttpPostedFile file = null; if (HttpContext.Current.Request.Files.Count == 1) { //for refit support file = HttpContext.Current.Request.Files[0] as HttpPostedFile; } else { file = HttpContext.Current.Request.Files[parameter.InputKey] as HttpPostedFile; } file = HttpContext.Current.Request.Files[parameter.InputKey] as HttpPostedFile; if (file != null) { if (file.ContentLength > 0) { DocumentService documentService = DocumentService.GetInstance(); if (String.IsNullOrEmpty(parameter.Default)) { retVal = ReadFully(file.InputStream); } else { DocumentRepository repo = DocumentRepository.GetByName(parameter.Default); if (repo == null) { throw new Exception(String.Format("Parameter {0} is assigned to a missing document repository - {1}. Please check configuration.", parameter.Name, parameter.Default)); } IDocumentProvider documentProvider = documentService.GetProvider(repo); if (documentProvider == null) { throw new Exception(String.Format("Parameter {0} is assigned to document repository - {1}. The provider for this repository could not be found. Please check configuration", parameter.Name, parameter.Default)); } // AppendDocumentID(DocumentID); Document document = new Document(); //need to clone from config document.FileName = file.FileName; document.ContentType = file.ContentType; if (String.IsNullOrEmpty(document.ContentType)) { document.ContentType = "application / octet - stream"; } document.Size = Convert.ToInt32(file.ContentLength); document.Stream = file.InputStream; document.EntityID = "TEMP"; document.EntityType = "TEMP"; document.Settings.Add(new Setting("ModifiedBy", "SYSTEM")); //perform actual upload document.ID = documentProvider.Upload(document); retVal = document.ID; } } } } break; case ScreenInputType.Form: retVal = HttpContext.Current.Request.Form[parameter.InputKey]; break; case ScreenInputType.Header: retVal = HttpContext.Current.Request.Headers[parameter.InputKey]; break; case ScreenInputType.QueryString: retVal = HttpContext.Current.Request.QueryString[parameter.InputKey]; break; case ScreenInputType.Session: retVal = HttpContext.Current.Session[parameter.InputKey]; break; case ScreenInputType.Special: switch (parameter.InputKey.ToLower()) { case "null": retVal = null; break; case "newid": retVal = newID; break; case "dbnull": retVal = DBNull.Value; break; case "username": retVal = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); break; case "hostheader": retVal = HttpContext.Current.Request.ServerVariables["HTTP_HOST"]; break; case "applicationpath": retVal = HttpContext.Current.Request.ApplicationPath; break; case "urlsegment": try { retVal = this.RouteData.Values[parameter.Default]; } catch { } break; case "absoluteapplicationpath": retVal = String.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], ((HttpContext.Current.Request.ApplicationPath == "/") ? String.Empty : HttpContext.Current.Request.ApplicationPath)); break; } break; case ScreenInputType.User: try { List <string> profileProperties = CodeTorch.Core.Configuration.GetInstance().App.ProfileProperties; int propertyIndex = Enumerable.Range(0, profileProperties.Count).First(i => profileProperties[i].ToLower() == parameter.InputKey.ToLower()); FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket ticket = identity.Ticket; retVal = ticket.UserData.Split('|')[propertyIndex]; } catch { } break; case ScreenInputType.Constant: retVal = parameter.InputKey; break; case ScreenInputType.ServerVariables: retVal = HttpContext.Current.Request.ServerVariables[parameter.InputKey]; break; } if ( (parameter.InputType != ScreenInputType.Special) && (parameter.InputType != ScreenInputType.File) ) { if (retVal == null) { retVal = parameter.Default; } } return(retVal); }