Пример #1
0
 public TenantAuditSettings GetAuditSettings()
 {
     if (!SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
     {
         throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
     }
     SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
     return(TenantAuditSettings.LoadForTenant(TenantProvider.CurrentTenantID));
 }
Пример #2
0
        public IEnumerable <AuditEventWrapper> GetLastAuditEvents()
        {
            if (!SetupInfo.IsVisibleSettings(ManagementType.AuditTrail.ToString()))
            {
                throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
            }
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            return(AuditEventsRepository.GetLast(TenantProvider.CurrentTenantID, 20).Select(x => new AuditEventWrapper(x)));
        }
Пример #3
0
        public string CreateLoginHistoryReport()
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var tenantId = TenantProvider.CurrentTenantID;

            if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
            {
                throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
            }

            var settings = TenantAuditSettings.LoadForTenant(tenantId);

            var to   = DateTime.UtcNow;
            var from = to.Subtract(TimeSpan.FromDays(settings.LoginHistoryLifeTime));

            var reportName = string.Format(AuditReportResource.LoginHistoryReportName + ".csv", from.ToShortDateString(), to.ToShortDateString());
            var events     = LoginEventsRepository.Get(tenantId, from, to);
            var result     = AuditReportCreator.CreateCsvReport(events, reportName);

            MessageService.Send(Request, MessageAction.LoginHistoryReportDownloaded);
            return(result);
        }
Пример #4
0
        public TenantAuditSettings SetAuditSettings(TenantAuditSettings settings)
        {
            if (!TenantExtra.GetTenantQuota().Audit || !SetupInfo.IsVisibleSettings(ManagementType.LoginHistory.ToString()))
            {
                throw new BillingException(Resource.ErrorNotAllowedOption, "Audit");
            }
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            if (settings.LoginHistoryLifeTime <= 0 || settings.LoginHistoryLifeTime > TenantAuditSettings.MaxLifeTime)
            {
                throw new ArgumentException("LoginHistoryLifeTime");
            }

            if (settings.AuditTrailLifeTime <= 0 || settings.AuditTrailLifeTime > TenantAuditSettings.MaxLifeTime)
            {
                throw new ArgumentException("AuditTrailLifeTime");
            }

            settings.SaveForTenant(TenantProvider.CurrentTenantID);

            MessageService.Send(Request, MessageAction.AuditSettingsUpdated);

            return(settings);
        }