Example #1
0
 private static bool InvokeFindDCSettingsMethod(out IConfigurable dcSettings)
 {
     dcSettings = null;
     HygieneDCSettings.BuildMethodsAndProperties();
     try
     {
         MethodBase methodBase = HygieneDCSettings.findDCSettingsMethod;
         object     obj        = HygieneDCSettings.globalConfigSession;
         object[]   array      = new object[4];
         array[2] = false;
         IConfigurable[] array2 = methodBase.Invoke(obj, array) as IConfigurable[];
         if (array2 != null)
         {
             dcSettings = array2.FirstOrDefault <IConfigurable>();
         }
         if (dcSettings == null)
         {
             TaskLogger.LogError(new Exception("Find<DataCenterSettings> method returned empty result"));
             return(false);
         }
     }
     catch (TargetInvocationException ex)
     {
         TaskLogger.LogError(ex.InnerException);
         return(false);
     }
     return(true);
 }
Example #2
0
        public static bool GetFfoDCPublicIPAddresses(out MultiValuedProperty <IPRange> ffoIPs)
        {
            ffoIPs = null;
            IConfigurable obj = null;

            if (HygieneDCSettings.InvokeFindDCSettingsMethod(out obj))
            {
                ffoIPs = (HygieneDCSettings.ffoDCPublicIPsProperty.GetValue(obj, null) as MultiValuedProperty <IPRange>);
                return(true);
            }
            return(false);
        }
Example #3
0
        public static bool GetSettings(out MultiValuedProperty <IPRange> ffoIPs, out MultiValuedProperty <SmtpX509IdentifierEx> ffoSmtpCerts, out MultiValuedProperty <ServiceProviderSettings> serviceProviderSettings)
        {
            ffoIPs                  = null;
            ffoSmtpCerts            = null;
            serviceProviderSettings = null;
            IConfigurable obj = null;

            if (HygieneDCSettings.InvokeFindDCSettingsMethod(out obj))
            {
                ffoIPs                  = (HygieneDCSettings.ffoDCPublicIPsProperty.GetValue(obj, null) as MultiValuedProperty <IPRange>);
                ffoSmtpCerts            = (HygieneDCSettings.ffoFrontDoorSmtpCertificatesProperty.GetValue(obj, null) as MultiValuedProperty <SmtpX509IdentifierEx>);
                serviceProviderSettings = (HygieneDCSettings.serviceProvidersProperty.GetValue(obj, null) as MultiValuedProperty <ServiceProviderSettings>);
                return(true);
            }
            return(false);
        }
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            if (base.Fields.IsModified("AssociatedAcceptedDomains"))
            {
                NewInboundConnector.ValidateAssociatedAcceptedDomains(this.AssociatedAcceptedDomains, base.DataSession, this.DataObject, this.RootId, this, new Func <IIdentityParameter, IConfigDataProvider, ObjectId, LocalizedString?, LocalizedString?, IConfigurable>(base.GetDataObject <AcceptedDomain>));
            }
            if (this.DataObject.SenderDomains == null)
            {
                base.WriteError(new LocalizedException(new LocalizedString("Sender Domain cannot be null.")), ErrorCategory.InvalidArgument, null);
            }
            bool flag = false;

            if (this.DataObject.SenderIPAddresses != null && this.DataObject.Enabled)
            {
                flag = true;
                NewInboundConnector.ValidateSenderIPAddresses(this.DataObject.SenderIPAddresses, this, this.BypassValidation);
                NewInboundConnector.CheckSenderIpAddressesOverlap(base.DataSession, this.DataObject, this);
            }
            if (this.DataObject.ConnectorType == TenantConnectorType.OnPremises)
            {
                bool flag2 = flag || this.DataObject.IsChanged(TenantInboundConnectorSchema.ConnectorType);
                bool flag3 = this.DataObject.IsChanged(TenantInboundConnectorSchema.ConnectorType) || this.DataObject.IsChanged(TenantInboundConnectorSchema.TlsSenderCertificateName);
                if ((flag2 || flag3) && !this.BypassValidation)
                {
                    MultiValuedProperty <IPRange> ffoDCIPs;
                    MultiValuedProperty <SmtpX509IdentifierEx>    ffoFDSmtpCerts;
                    MultiValuedProperty <ServiceProviderSettings> serviceProviders;
                    if (!HygieneDCSettings.GetSettings(out ffoDCIPs, out ffoFDSmtpCerts, out serviceProviders))
                    {
                        base.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                    }
                    if (flag2)
                    {
                        NewInboundConnector.ValidateSenderIPAddressRestrictions(this.DataObject.SenderIPAddresses, ffoDCIPs, serviceProviders, this);
                    }
                    if (flag3)
                    {
                        NewInboundConnector.ValidateTlsSenderCertificateRestrictions(this.DataObject.TlsSenderCertificateName, ffoFDSmtpCerts, serviceProviders, this);
                    }
                }
            }
        }
 private static void ValidateSmartHostRestrictions(TenantOutboundConnector tenantOutboundConnector, Task task, bool skipIpIsNotReservedValidation)
 {
     if (tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.SmartHosts) && !MultiValuedPropertyBase.IsNullOrEmpty(tenantOutboundConnector.SmartHosts))
     {
         MultiValuedProperty <IPRange> multiValuedProperty = null;
         bool flag = false;
         using (MultiValuedProperty <SmartHost> .Enumerator enumerator = tenantOutboundConnector.SmartHosts.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 SmartHost smartHost = enumerator.Current;
                 if (smartHost.IsIPAddress)
                 {
                     if (smartHost.Address.AddressFamily != AddressFamily.InterNetwork || !IPAddressValidation.IsValidIPv4Address(smartHost.Address.ToString()))
                     {
                         task.WriteError(new SmartHostsIPValidationFailedException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                     }
                     if (!skipIpIsNotReservedValidation)
                     {
                         if (IPAddressValidation.IsReservedIPv4Address(smartHost.Address.ToString()))
                         {
                             task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                         }
                         if (!flag)
                         {
                             if (!HygieneDCSettings.GetFfoDCPublicIPAddresses(out multiValuedProperty))
                             {
                                 task.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                             }
                             flag = true;
                         }
                         if (!MultiValuedPropertyBase.IsNullOrEmpty(multiValuedProperty))
                         {
                             if (multiValuedProperty.Any((IPRange ffoDCIP) => ffoDCIP.Contains(smartHost.Address)))
                             {
                                 task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            if (base.Fields.IsModified("AssociatedAcceptedDomains"))
            {
                NewInboundConnector.ValidateAssociatedAcceptedDomains(this.AssociatedAcceptedDomains, base.DataSession, this.DataObject, this.RootId, this, new Func <IIdentityParameter, IConfigDataProvider, ObjectId, LocalizedString?, LocalizedString?, IConfigurable>(base.GetDataObject <AcceptedDomain>));
            }
            NewInboundConnector.ValidateSenderIPAddresses(this.DataObject.SenderIPAddresses, this, this.BypassValidation);
            if (this.DataObject.ConnectorType == TenantConnectorType.OnPremises && !this.BypassValidation)
            {
                MultiValuedProperty <IPRange> ffoDCIPs;
                MultiValuedProperty <SmtpX509IdentifierEx>    ffoFDSmtpCerts;
                MultiValuedProperty <ServiceProviderSettings> serviceProviders;
                if (!HygieneDCSettings.GetSettings(out ffoDCIPs, out ffoFDSmtpCerts, out serviceProviders))
                {
                    base.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                }
                NewInboundConnector.ValidateSenderIPAddressRestrictions(this.DataObject.SenderIPAddresses, ffoDCIPs, serviceProviders, this);
                NewInboundConnector.ValidateTlsSenderCertificateRestrictions(this.DataObject.TlsSenderCertificateName, ffoFDSmtpCerts, serviceProviders, this);
            }
            IEnumerable <TenantInboundConnector> enumerable = base.DataSession.FindPaged <TenantInboundConnector>(null, ((IConfigurationSession)base.DataSession).GetOrgContainerId().GetDescendantId(this.DataObject.ParentPath), false, null, ADGenericPagedReader <TenantInboundConnector> .DefaultPageSize);

            foreach (TenantInboundConnector tenantInboundConnector in enumerable)
            {
                if (StringComparer.OrdinalIgnoreCase.Equals(this.DataObject.Name, tenantInboundConnector.Name))
                {
                    base.WriteError(new ErrorInboundConnectorAlreadyExistsException(tenantInboundConnector.Name), ErrorCategory.InvalidOperation, null);
                    break;
                }
            }
            NewInboundConnector.CheckSenderIpAddressesOverlap(base.DataSession, this.DataObject, this);
            TaskLogger.LogExit();
        }