public IHttpActionResult GetCollaborationSigns(int?roleId) { _logger.WriteDebug(new LogMessage(string.Concat("GetCollaborationSigns -> roleId = ", roleId)), LogCategories); return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric <IHttpActionResult>(() => { ICollection <CollaborationSignModel> signers = new List <CollaborationSignModel>(); if (!roleId.HasValue) { _logger.WriteError(new LogMessage("GetCollaborationSigns -> Errore validazione parametri in ingresso, roleId non valorizzato"), LogCategories); return BadRequest("GetCollaborationSigns -> Errore validazione parametri in ingresso, roleId non valorizzato"); } Role role = _unitOfWork.Repository <Role>().Find(roleId.Value); WorkflowRoleMapping workflowRoleMapping = new WorkflowRoleMapping() { AuthorizationType = WorkflowAuthorizationType.AllSigner, Role = role }; ICollection <WorkflowAuthorization> workflowAuthorizations = _workflowAuthorizationService.GetAuthorizationsByMappings(new List <WorkflowRoleMapping>() { workflowRoleMapping }); short incremental = 1; foreach (WorkflowAuthorization workflowAuthorization in workflowAuthorizations) { DomainUserModel user = _security.GetUser(workflowAuthorization.Account); CollaborationSignModel collaborationSign = _domainSignMapper.Map(user, new CollaborationSignModel()); collaborationSign.SignUser = workflowAuthorization.Account; collaborationSign.Incremental = incremental++; signers.Add(collaborationSign); } return Ok(signers); }, _logger, LogCategories)); }
public BaseController(IDSWDataContext dswDataContext, ISecurity security) { _dswDataContext = dswDataContext; _domainUserModel = security.GetCurrentUser() ?? new DomainUserModel() { Name = "anonymous", Domain = "system" }; }
public IHttpActionResult GetUser(string username, string domain) { return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric(() => { string account = string.Concat(domain, "\\", username); DomainUserModel results = _security.GetUser(account); return Ok(results); }, _logger, LogCategories)); }
protected override void ValidateObject(WorkflowActivityValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool res = CurrentUnitOfWork.Repository <WorkflowActivity>().IsAuthorized(currentUser.Name, currentUser.Domain, objectToValidate.UniqueId); if (!res) { GenerateInvalidateResult(); } }
protected override void ValidateObject(ProtocolValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool res = (currentUser == null || objectToValidate.Container == null) ? false : CurrentUnitOfWork.Repository <Container>().CountProtocolInsertRight(currentUser.Name, currentUser.Domain) > 0; if (!res) { GenerateInvalidateResult(); } }
public ProtocolsController(IProtocolService service, IDataUnitOfWork unitOfWork, ILogger logger, IProtocolTableValuedModelMapper mapperTableValued, ISecurity security) : base(service, unitOfWork, logger, security) { _mapperTableValued = mapperTableValued; _logger = logger; _unitOfWork = unitOfWork; _security = security; _currentUser = security.GetCurrentUser(); }
protected override void ValidateObject(UDSDocumentUnitValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool res = (currentUser == null || objectToValidate.Repository.Container == null) ? false : CurrentUnitOfWork.Repository <Container>().HasUDSDocumentUnitModifyRight(currentUser.Name, currentUser.Domain, objectToValidate.Repository.Container.EntityShortId); if (!res) { GenerateInvalidateResult(); } }
protected override void ValidateObject(DossierFolderValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool result = (currentUser == null || objectToValidate.Dossier == null) ? false : CurrentUnitOfWork.Repository <Dossier>().HasDossierManageable(objectToValidate.Dossier.UniqueId, currentUser.Name, currentUser.Domain); if (!result) { GenerateInvalidateResult(); } }
public async Task <DomainUserModel> GetSignerInformationAsync(string username, string domain) { return(await ExecuteHelper(async() => { _httpClient.SetEntityODATA <DomainUserModel>(); DomainUserModel result = (await _httpClient.GetAsync <DomainUserModel>() .WithRowQuery(string.Format("/DomainUserService.GetUser(username='******',domain='{1}')", username, domain)) .ResponseToModelAsync <DomainUserModel>()); return result; }, $"WebAPIClient.GetDefaultCategoryFascicleAsync -> GET entities error", lookingWarningMessage : "not found in ActiveDirectory")); }
protected override void ValidateObject(DossierRoleValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool res = (currentUser == null || objectToValidate.Dossier == null) ? false : CurrentUnitOfWork.Repository <Dossier>().HasDossierModifyRight(currentUser.Name, currentUser.Domain, objectToValidate.Dossier.UniqueId); if (!res) { GenerateInvalidateResult(); } }
protected override void ValidateObject(FascicleValidator objectToValidate) { DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool result = currentUser == null ? false : CurrentUnitOfWork.Repository <Fascicle>().GetIfCurrentUserIsManagerOnActivityFascicle(currentUser.DisplayName, objectToValidate.UniqueId); if (!result) { GenerateInvalidateResult(); } }
public IHttpActionResult GetCurrentRights() { return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric(() => { DomainUserModel domainUserModel = _security.GetCurrentUser(); if (!domainUserModel.Rights.Any()) { domainUserModel.Rights = _unitOfWork.Repository <RoleUser>().GetUserRights(domainUserModel.Name, domainUserModel.Domain, _parameterEnvService.RoleGroupPECRightEnabled); } return Ok(domainUserModel); }, _logger, LogCategories)); }
protected BaseService(IDataUnitOfWork unitOfWork, ILogger logger, IValidatorService validationService, IValidatorRuleset validatorRuleset, IMapperUnitOfWork mapperUnitOfWork, ISecurity security) { _unitOfWork = unitOfWork; _mapperUnitOfWork = mapperUnitOfWork; _repositoryAsync = unitOfWork.Repository <TEntity>(); _logger = logger; _validationService = validationService; _instanceId = Guid.NewGuid(); _validatorRuleset = validatorRuleset; _mapper = mapperUnitOfWork.Repository <IDomainMapper <TEntity, TEntity> >(); _currentDomainUser = security.GetCurrentUser(); }
/// <summary> /// Ritorna informazione sull'utente specificato /// </summary> /// <param name="fullUserName"> Nome account nel formato [domain\account]</param> /// <returns></returns> public DomainUserModel GetUser(string fullUserName) { return(ActionHelper.TryUserPrincipalCatchWithLogger((d, x) => { DomainUserModel user = _mapperUnitOfWork.Repository <IDomainUserModelMapper>().Map(x, new DomainUserModel(), d); try { user.DomainGroups = _mapperUnitOfWork.Repository <IDomainGroupModelMapper>().MapCollection(x.GetAuthorizationGroups()); } catch { } return user; }, _logger, _parameterEnvService, fullUserName, _cache_getCurrentUser, LogCategories)); }
public IHttpActionResult GetCollaborationUsers(string mappingName, Guid workflowInstanceId, string internalActivityId) { _logger.WriteDebug(new LogMessage(string.Concat("GetCollaborationUsers -> mappingName = ", mappingName, ", workflowInstanceId = ", workflowInstanceId, ", internalActivityId = ", internalActivityId)), LogCategories); return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric <IHttpActionResult>(() => { ICollection <CollaborationUserModel> users = new List <CollaborationUserModel>(); if (string.IsNullOrEmpty(mappingName)) { _logger.WriteError(new LogMessage("GetCollaborationUsers -> Errore validazione parametri in ingresso, mappingName non valorizzato"), LogCategories); return BadRequest("GetCollaborationUsers -> Errore validazione parametri in ingresso, mappingName non valorizzato"); } WorkflowRepository repository = _unitOfWork.Repository <WorkflowRepository>().GetByInstanceId(workflowInstanceId); if (repository == null) { _logger.WriteError(new LogMessage("Nessun repository trovato"), LogCategories); return BadRequest("Nessun repository trovato"); } IEnumerable <WorkflowRoleMapping> workflowRoleMappings; if (string.IsNullOrEmpty(internalActivityId)) { workflowRoleMappings = _unitOfWork.Repository <WorkflowRoleMapping>().GetByMappingTag(mappingName, repository.UniqueId); } else { workflowRoleMappings = _unitOfWork.Repository <WorkflowRoleMapping>().GetByMappingTag(mappingName, repository.UniqueId, internalActivityId); } short incremental = 1; foreach (WorkflowRoleMapping workflowRoleMapping in workflowRoleMappings) { CollaborationUserModel collaborationUser = new CollaborationUserModel(); if (workflowRoleMapping.AuthorizationType == WorkflowAuthorizationType.UserName) { DomainUserModel user = _security.GetUser(workflowRoleMapping.AccountName); collaborationUser = _domainUserMapper.Map(user, new CollaborationUserModel()); collaborationUser.Account = workflowRoleMapping.AccountName; } else { collaborationUser = _mapperCollaborationUser.Map(workflowRoleMapping, collaborationUser); } collaborationUser.Incremental = incremental++; users.Add(collaborationUser); } return Ok(users); }, _logger, LogCategories)); }
protected override void ValidateObject(FascicleValidator objectToValidate) { if (objectToValidate.FascicleType == Entity.Fascicles.FascicleType.Legacy) { return; } Contact temp = objectToValidate.Contacts?.FirstOrDefault(); DomainUserModel currentUser = objectToValidate.CurrentSecurity?.GetCurrentUser(); bool result = (currentUser == null || temp == null || objectToValidate.Category == null) ? true : (!(temp.EmailAddress == objectToValidate.CurrentSecurity.CurrentUserEmail || temp.CertifiedMail == objectToValidate.CurrentSecurity.CurrentUserEmail)) && (!CurrentUnitOfWork.Repository <RoleUser>().IsProcedureSecretary(currentUser.Name, currentUser.Domain, objectToValidate.Category.EntityShortId)); if (result) { GenerateInvalidateResult(); } }
public IHttpActionResult GetCollaborationSigns(string domain, string account) { _logger.WriteDebug(new LogMessage(string.Concat("GetCollaborationSigns -> domain = ", domain, ", account = ", account)), LogCategories); return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric <IHttpActionResult>(() => { ICollection <CollaborationSignModel> signers = new List <CollaborationSignModel>(); if (string.IsNullOrEmpty(account)) { _logger.WriteError(new LogMessage("GetCollaborationSigns -> Errore validazione parametri in ingresso, account non valorizzato"), LogCategories); return BadRequest("GetCollaborationSigns -> Errore validazione parametri in ingresso, account non valorizzato"); } DomainUserModel user = _security.GetUser(account); CollaborationSignModel collaborationSign = _domainSignMapper.Map(user, new CollaborationSignModel()); collaborationSign.SignUser = string.Concat(domain, "\\", account); collaborationSign.Incremental = 1; signers.Add(collaborationSign); return Ok(signers); }, _logger, LogCategories)); }
public DomainUserModel domainUserModel() { string odataFilter = $"/DomainUserService.GetCurrentRights()"; IBaseAddress webApiAddress = DocSuiteContext.Current.CurrentTenant.WebApiClientConfig.Addresses.Single(x => x.AddressName.Eq(WebApiHttpClient.ODATA_ADDRESS_NAME)); TenantEntityConfiguration domainuserEndpoint = DocSuiteContext.Current.CurrentTenant.Entities.Single(x => x.Key.Eq(ODATA_DOMAINUSER_ENDPOINT_NAME)).Value; HttpClientConfiguration customHttpConfiguration = new HttpClientConfiguration(); customHttpConfiguration.Addresses.Add(webApiAddress); WebApiControllerEndpoint endpoint = new WebApiControllerEndpoint { AddressName = webApiAddress.AddressName, ControllerName = domainuserEndpoint.ODATAControllerName, EndpointName = ODATA_DOMAINUSER_ENDPOINT_NAME }; customHttpConfiguration.EndPoints.Add(endpoint); DomainUserModel result = WebAPIImpersonatorFacade.ImpersonateRawRequest <DomainUser, DomainUserModel>(WebAPIHelper, odataFilter, customHttpConfiguration); return(result); }
public IHttpActionResult GetMessageRecipients(string mappingName, Guid workflowInstanceId, string internalActivityId) { _logger.WriteDebug(new LogMessage(string.Concat("GetMessageRecipients -> mappingName = ", mappingName, ", workflowInstanceId = ", workflowInstanceId, ", internalActivityId = ", internalActivityId)), LogCategories); return(CommonHelpers.ActionHelper.TryCatchWithLoggerGeneric <IHttpActionResult>(() => { ICollection <MessageContactModel> recipients = new List <MessageContactModel>(); if (string.IsNullOrEmpty(mappingName)) { _logger.WriteError(new LogMessage("GetMessageRecipients -> Errore validazione parametri in ingresso, mappingName non valorizzato"), LogCategories); return BadRequest("GetMessageRecipients -> Errore validazione parametri in ingresso, mappingName non valorizzato"); } WorkflowRepository repository = _unitOfWork.Repository <WorkflowRepository>().GetByInstanceId(workflowInstanceId); if (repository == null) { _logger.WriteError(new LogMessage("Nessun repository trovato"), LogCategories); return BadRequest("Nessun repository trovato"); } IEnumerable <WorkflowRoleMapping> workflowRoleMappings; if (string.IsNullOrEmpty(internalActivityId)) { workflowRoleMappings = _unitOfWork.Repository <WorkflowRoleMapping>().GetByMappingTag(mappingName, repository.UniqueId); } else { workflowRoleMappings = _unitOfWork.Repository <WorkflowRoleMapping>().GetByMappingTag(mappingName, repository.UniqueId, internalActivityId); } ICollection <WorkflowAuthorization> workflowAuthorizations = _workflowAuthorizationService.GetAuthorizationsByMappings(workflowRoleMappings); foreach (WorkflowAuthorization workflowAuthorization in workflowAuthorizations) { DomainUserModel user = _security.GetUser(workflowAuthorization.Account); MessageContactModel messageContact = _domainUserModelMessageContactModelMapper.Map(user, new MessageContactModel()); messageContact.MessageContactEmail.First().User = workflowAuthorization.Account; recipients.Add(messageContact); } return Ok(recipients); }, _logger, LogCategories)); }
protected BaseODataController(TService service, IDataUnitOfWork unitOfWork, ILogger logger, ISecurity security) : base() { _service = service; _unitOfWork = unitOfWork; _logger = logger; _instanceId = Guid.NewGuid(); DomainUserModel currentUser = security.GetCurrentUser(); Username = currentUser?.Name; Domain = currentUser?.Domain; if (string.IsNullOrEmpty(Username)) { _logger.WriteError(new LogMessage("BaseODataController -> Lo Username non è presente o non è corretto."), LogCategories); throw new DSWException(string.Concat("Il nome utente non è presente o non è corretto."), null, DSWExceptionCode.SC_InvalidAccount); } if (string.IsNullOrEmpty(Domain)) { _logger.WriteError(new LogMessage("BaseODataController -> l Domain non è presente o non è corretto."), LogCategories); throw new DSWException(string.Concat("Il dominio non è presente o non è corretto."), null, DSWExceptionCode.SC_InvalidAccount); } }
internal abstract IQueryable <T> GetDataSet(IDSWDataContext dataUnitOfWork, DomainUserModel domainUserModel, bool applySecurity, bool onlyToRead);