Ejemplo n.º 1
0
        public void AddTest()
        {
            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long   domainId   = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName   = BuildSMTPDomainName(1, 1);
            int    preference = 10;
            MX     mx         = new MX(domainId
                                       , SMTPName
                                       , preference);

            mgr.Add(mx);
            Assert.Equal(1, mgr.Count());
            mx = mgr.Get(SMTPName);
            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preference, mx.Preference);
        }
Ejemplo n.º 2
0
        public void FindDeviceAsync(string SearchTarget)
        {
            HTTPMessage packet = new HTTPMessage();

            packet.Directive    = "M-SEARCH";
            packet.DirectiveObj = "*";
            packet.AddTag("ST", SearchTarget);
            packet.AddTag("MX", MX.ToString());
            packet.AddTag("MAN", "\"ssdp:discover\"");
            packet.AddTag("HOST", "239.255.255.250:1900");
            IPAddress[] localAddresses = this.NetInfo.GetLocalAddresses();
            IPEndPoint  dest           = new IPEndPoint(IPAddress.Parse("239.255.255.250"), 0x76c);

            for (int i = 0; i < localAddresses.Length; i++)
            {
                try
                {
                    Socket theSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                    theSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                    theSocket.Bind(new IPEndPoint(localAddresses[i], 0));
                    SSDPSession session = new SSDPSession(theSocket, new SSDPSession.ReceiveHandler(this.HandleAsyncSearch));
                    this.SSDPSessions[session] = session;
                    session.SendTo(packet, dest);
                    session.SendTo(packet, dest);
                    this.Lifetime.Add(session, 7);
                }
                catch (Exception exception)
                {
                    EventLogger.Log(this, EventLogEntryType.Error, "CP Failure: " + localAddresses[i].ToString());
                    EventLogger.Log(exception);
                }
            }
        }
Ejemplo n.º 3
0
        public IActionResult Delete(MX mx)
        {
            int bikeId = mx.BikeId;

            _repository.Delete(mx);
            return(RedirectToAction("Details", "Bike", new { id = bikeId }));
        }
Ejemplo n.º 4
0
		internal static bool CheckClientCertificate (TlsContext context, MX.X509CertificateCollection certificates)
		{
			if (certificates == null || certificates.Count < 1) {
				if (!context.SettingsProvider.AskForClientCertificate)
					return false;
				if (context.SettingsProvider.RequireClientCertificate)
					throw new TlsException (AlertDescription.CertificateUnknown);
			}

			if (context.SettingsProvider.HasClientCertificateParameters) {
				var certParams = context.SettingsProvider.ClientCertificateParameters;
				if (certParams.CertificateAuthorities.Count > 0) {
					if (!certParams.CertificateAuthorities.Contains (certificates [0].IssuerName))
						throw new TlsException (AlertDescription.BadCertificate);
				}
			}

			var helper = context.Configuration.CertificateValidator;
			if (helper == null)
				helper = CertificateValidationHelper.CreateDefaultValidator (context.Configuration.TlsSettings);

			var result = helper.ValidateClientCertificate (certificates);
			if (result != null && result.Trusted && !result.UserDenied)
				return true;

			throw new TlsException (AlertDescription.CertificateUnknown);
		}
Ejemplo n.º 5
0
        public void RemoveDomainTest()
        {
            InitMXRecords();
            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

                //----------------------------------------------------------------------------------------------------
                //---make sure that the domains are actually there
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX     obj  = mgr.Get(db, name);
                    Assert.NotNull(obj);
                }

                //----------------------------------------------------------------------------------------------------
                //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)

                mgr.RemoveDomain(db, 1);
                //----------------------------------------------------------------------------------------------------
                //---there should be no items left with domain id of 1, use the count to check number of matching
                //---per domain as well as a loop to ensure that each entry has been removed for the given domain
                for (int t = 1; t <= MAXSMTPCOUNT; t++)
                {
                    string name = BuildSMTPDomainName(1, t);
                    MX     obj  = mgr.Get(db, name);
                    Assert.Null(obj);
                }
                Assert.Equal(0, mgr.Count(1));
            }
        }
Ejemplo n.º 6
0
        public IActionResult Create(int bikeid)
        {
            MX mx = new MX {
                Date = DateTime.Now.Date, BikeId = bikeid
            };

            return(View(mx));
        }
Ejemplo n.º 7
0
        public void MXConstructorTest2()
        {
            MX target = new MX();

            Assert.Equal(String.Empty, target.SMTPDomainName);
            Assert.Equal(0, target.Preference);
            Assert.Equal(target.CreateDate, target.UpdateDate);
        }
Ejemplo n.º 8
0
 public void UpdateDateTest()
 {
     MX target = new MX(1, "testSMTPDomainName", 1);
     DateTime expected = DateTime.UtcNow;
     DateTime actual;
     target.UpdateDate = expected;
     actual = target.UpdateDate;
     Assert.Equal(expected, actual);
 }
Ejemplo n.º 9
0
		static SslPolicyErrors GetStatus (MX.X509ChainStatusFlags flags)
		{
			switch (flags) {
			case MX.X509ChainStatusFlags.NoError:
				return SslPolicyErrors.None;
			default:
				return SslPolicyErrors.RemoteCertificateChainErrors;
			}
		}
Ejemplo n.º 10
0
 public void SMTPDomainNameTest()
 {
     MX target = new MX(1, "testSMTPDomainName", 1);
     string expected = "some.smtp.name.value";
     string actual;
     target.SMTPDomainName = expected;
     actual = target.SMTPDomainName;
     Assert.Equal(expected, actual);
 }
Ejemplo n.º 11
0
 public void PreferenceTest()
 {
     MX target = new MX(1, "testSMTPDomainName", 1);
     int expected = 200;
     int actual;
     target.Preference = expected;
     actual = target.Preference;
     Assert.Equal(expected, actual);
 }
Ejemplo n.º 12
0
 public IActionResult Edit(MX mx)
 {
     if (ModelState.IsValid)
     {
         _repository.Update(mx);
         return(RedirectToAction("Details", new { id = mx.Id }));
     }
     return(View(mx));
 }
Ejemplo n.º 13
0
 public void IDTest()
 {
     MX target = new MX(1, "testSMTPDomainName", 1);
     long expected = 777;
     long actual;
     target.ID = expected;
     actual = target.ID;
     Assert.Equal(expected, actual);
     
 }
Ejemplo n.º 14
0
        public void SMTPDomainNameTest()
        {
            MX     target   = new MX(1, "testSMTPDomainName", 1);
            string expected = "some.smtp.name.value";
            string actual;

            target.SMTPDomainName = expected;
            actual = target.SMTPDomainName;
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 15
0
        public void PreferenceTest()
        {
            MX  target   = new MX(1, "testSMTPDomainName", 1);
            int expected = 200;
            int actual;

            target.Preference = expected;
            actual            = target.Preference;
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 16
0
        public void IDTest()
        {
            MX   target   = new MX(1, "testSMTPDomainName", 1);
            long expected = 777;
            long actual;

            target.ID = expected;
            actual    = target.ID;
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 17
0
        public void CreateDateTest()
        {
            MX       target   = new MX(1, "testSMTPDomainName", 1);
            DateTime expected = DateTime.UtcNow;
            DateTime actual;

            target.CreateDate = expected;
            actual            = target.CreateDate;
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 18
0
        public IActionResult Delete(int id)
        {
            MX mx = _repository.GetMXById(id);

            if (mx == null)
            {
                return(RedirectToAction("Index, Bike"));
            }
            return(View(mx));
        }
Ejemplo n.º 19
0
        public void MXConstructorTest1()
        {
            long   domainID       = 1;
            string SMTPDomainName = "some.smtp.name.here";
            MX     target         = new MX(domainID, SMTPDomainName);

            Assert.Equal(domainID, target.DomainID);
            Assert.Equal(SMTPDomainName, target.SMTPDomainName);
            Assert.Equal(0, target.Preference);
            Assert.Equal(target.CreateDate, target.UpdateDate);
        }
Ejemplo n.º 20
0
        public void CopyFixedTest()
        {
            MX source = new MX(1, "testSMTPDomainName", 1);
            MX target = new MX();

            target.CopyFixed(source);
            Assert.Equal(source.ID, target.ID);
            Assert.Equal(source.CreateDate, target.CreateDate);
            Assert.Equal(source.DomainID, target.DomainID);
            Assert.Equal(source.SMTPDomainName, target.SMTPDomainName);
            Assert.Equal(source.UpdateDate, target.UpdateDate);
            Assert.Equal(source.Preference, target.Preference);
        }
Ejemplo n.º 21
0
        public void GetTest5()
        {
            InitMXRecords();
            MXManager mgr      = new MXManager(new ConfigStore(CONNSTR));
            string    name     = BuildSMTPDomainName(1, 1);
            MX        mxActual = mgr.Get(name);

            Assert.NotNull(mxActual);
            //----------------------------------------------------------------------------------------------------
            //---check basic values
            Assert.Equal(name, mxActual.SMTPDomainName);
            Assert.Equal(1, mxActual.DomainID);
            //----------------------------------------------------------------------------------------------------
            //---preference should always be the same as smtp id used to create the name
            Assert.Equal(1, mxActual.Preference);
        }
Ejemplo n.º 22
0
		internal static void CheckRemoteCertificate (TlsConfiguration config, MX.X509CertificateCollection certificates)
		{
			if (certificates == null || certificates.Count < 1)
				throw new TlsException (AlertDescription.CertificateUnknown);

			var helper = config.CertificateValidator;
			if (helper == null)
				helper = CertificateValidationHelper.CreateDefaultValidator (config.TlsSettings);

			var result = helper.ValidateChain (config.TargetHost, certificates);
			if (result != null && result.Trusted && !result.UserDenied)
				return;

			// FIXME: check other values to report correct error type.
			throw new TlsException (AlertDescription.CertificateUnknown);
		}
Ejemplo n.º 23
0
        public void RemoveTest()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);
            MX     obj  = mgr.Get(name);

            Assert.NotNull(obj);
            mgr.Remove(name);
            obj = mgr.Get(name);
            Assert.Null(obj);
        }
Ejemplo n.º 24
0
        public void UpdateTest()
        {
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));

            InitMXRecords();
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            MX obj = mgr.Get(BuildSMTPDomainName(1, 1));

            Assert.NotNull(obj);
            //----------------------------------------------------------------------------------------------------
            //---since we set pref to the same as the smtp[x].domain[y].test.com x value, check it here
            Assert.Equal(1, obj.Preference);
            obj.Preference = 4;
            mgr.Update(obj);
        }
Ejemplo n.º 25
0
        /*************************************************************************
         * v is the n word data vector
         * k is the 4 word key,128bits
         * n is negative for decoding
         * if n is zero result is 1 and no coding or decoding takes place,
         * otherwise the result is zero
         * assumes 32 bit 'long' and same endian coding and decoding
         **************************************************************************/
        void btea(uint32_t *v, int16_t n, uint32_t *key)
        {
            const DELTA =;
            const MX    =;

            uint32_t y, z, sum;
            uint32_t p, rounds, e;

            if (n > 1)
            { // dencrypt
                rounds = 6 + 52 / n;
                sum    = 0;
                z      = v[n - 1];
                do
                {
                    sum += 0x9e3779b9;
                    e    = (sum >> 2) & 3;
                    for (p = 0; p < n - 1; p++)
                    {
                        y = v[p + 1];
                        z = v[p] += (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
                    }
                    y = v[0];
                    z = v[n - 1] += (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
                } while (--rounds);
            }
            else if (n < -1)
            { //dencrypt
                n      = -n;
                rounds = 6 + 52 / n;
                sum    = rounds * 0x9e3779b9;
                y      = v[0];
                do
                {
                    e = (sum >> 2) & 3;
                    for (p = n - 1; p > 0; p--)
                    {
                        z = v[p - 1];
                        y = v[p] -= (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
                    }
                    z    = v[n - 1];
                    y    = v[0] -= (((z >> 5 ^ y << 2) + (y >> 3 ^ z << 4)) ^ ((sum ^ y) + (key[(p & 3) ^ e] ^ z)));
                    sum -= 0x9e3779b9;
                } while (--rounds);
            }
        }
Ejemplo n.º 26
0
        public void RemoveTest1()
        {
            InitMXRecords();

            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            //----------------------------------------------------------------------------------------------------
            //---get the first domain (knowing that domain of 1 with smtp 1 should exist since the init passed)
            string name = BuildSMTPDomainName(1, 1);

            using (ConfigDatabase db = new ConfigDatabase(CONNSTR))
            {
                MX obj = db.MXs.Get(name);
                Assert.NotNull(obj);
                mgr.Remove(db, name);
                db.SubmitChanges();
                obj = db.MXs.Get(name);
                Assert.Null(obj);
            }
        }
Ejemplo n.º 27
0
        public void ApplyChangesTest()
        {
            MX target = new MX(1, "target.smtp.name", 1);

            Assert.Equal(1, target.DomainID);
            Assert.Equal(1, target.Preference);
            Assert.Equal("target.smtp.name", target.SMTPDomainName);

            MX source = new MX(1, "source.smtp.name", 2);


            Assert.Equal(1, source.DomainID);
            Assert.Equal(2, source.Preference);
            Assert.Equal("source.smtp.name", source.SMTPDomainName);

            target.ApplyChanges(source);
            Assert.Equal(1, target.DomainID);
            Assert.Equal(source.Preference, target.Preference);
            Assert.Equal(source.SMTPDomainName, target.SMTPDomainName);
        }
Ejemplo n.º 28
0
		internal static void CheckRemoteCertificate (TlsConfiguration config, MX.X509CertificateCollection certificates)
		{
			if (certificates == null || certificates.Count < 1)
				throw new TlsException (AlertDescription.CertificateUnknown);

			var helper = CertificateValidationHelper.GetValidator (config.TlsSettings);

			X509Certificate2Collection scerts = null;
			if (certificates != null) {
				scerts = new X509Certificate2Collection ();
				for (int i = 0; i < certificates.Count; i++)
					scerts.Add (new X509Certificate2 (certificates [i].RawData));
			}

			var result = helper.ValidateChain (config.TargetHost, scerts);
			if (result != null && result.Trusted && !result.UserDenied)
				return;

			// FIXME: check other values to report correct error type.
			throw new TlsException (AlertDescription.CertificateUnknown);
		}
Ejemplo n.º 29
0
		internal static bool VerifyServerCertificate (TlsContext context, MX.X509Certificate certificate, ExchangeAlgorithmType algorithm)
		{
			if (context.NegotiatedProtocol == TlsProtocolCode.Tls12 && certificate.Version < 3)
				throw new TlsException (AlertDescription.UnsupportedCertificate, "X.509v3 server certificate required");

			if (certificate.KeyAlgorithm != null && !certificate.KeyAlgorithm.Equals (OidKeyAlgorithmRsa))
				return false;
			if (certificate.SignatureAlgorithm != null && !VerifySignatureAlgorithm (certificate.SignatureAlgorithm))
				return false;

			switch (algorithm) {
			case ExchangeAlgorithmType.Rsa:
				return VerifyKeyUsage (certificate, KeyUsages.keyEncipherment, OidServerAuth);

			case ExchangeAlgorithmType.Dhe:
			case ExchangeAlgorithmType.EcDhe:
				return VerifyKeyUsage (certificate, KeyUsages.digitalSignature, OidServerAuth);

			default:
				throw new TlsException (AlertDescription.InternalError);
			}
		}
Ejemplo n.º 30
0
		internal static void CheckClientCertificate (TlsContext context, MX.X509CertificateCollection certificates)
		{
			if (context.SettingsProvider.HasClientCertificateParameters) {
				var certParams = context.SettingsProvider.ClientCertificateParameters;
				if (certParams.CertificateAuthorities.Count > 0) {
					if (!certParams.CertificateAuthorities.Contains (certificates [0].IssuerName))
						throw new TlsException (AlertDescription.BadCertificate);
				}
			}

			var helper = CertificateValidationHelper.GetValidator (context.Configuration.TlsSettings);

			X509Certificate2Collection scerts = null;
			if (certificates != null) {
				scerts = new X509Certificate2Collection ();
				for (int i = 0; i < certificates.Count; i++)
					scerts.Add (new X509Certificate2 (certificates [i].RawData));
			}

			var result = helper.ValidateClientCertificate (scerts);
			if (result == null || !result.Trusted || result.UserDenied)
				throw new TlsException (AlertDescription.CertificateUnknown);
		}
Ejemplo n.º 31
0
        protected override void ProcessRecord()
        {
            this.SetOptions();
            this.SetScope(Server);
            this.SetManagementPath(Identity);
            ManagementObject wmiRecord = this.Get();

            WmiRecordClass WmiRecordClassName = (WmiRecordClass)Enum.Parse(typeof(WmiRecordClass), (String)wmiRecord.Properties["__CLASS"].Value);
            String         NewPath            = String.Empty;

            #region Parameter Set validation
            Boolean Terminate = false;
            switch (ParameterSetName)
            {
            case "PS0": break;

            case "PS1":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AAAAType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WKSType)
                {
                    Terminate = true;
                }
                break;

            case "PS2":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_CNAMEType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MBType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MDType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MFType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_NSType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_PTRType)
                {
                    Terminate = true;
                }
                break;

            case "PS3":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MGType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MRType)
                {
                    Terminate = true;
                }
                break;

            case "PS4":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_TXTType)
                {
                    Terminate = true;
                }
                break;

            case "PS5":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_HINFOType)
                {
                    Terminate = true;
                }
                break;

            case "PS6":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_ISDNType)
                {
                    Terminate = true;
                }
                break;

            case "PS7":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MINFOType)
                {
                    Terminate = true;
                }
                break;

            case "PS8":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_NXTType)
                {
                    Terminate = true;
                }
                break;

            case "PS9":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_RPType)
                {
                    Terminate = true;
                }
                break;

            case "PS10":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_AFSDBType)
                {
                    Terminate = true;
                }
                break;

            case "PS11":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_MXType &
                    WmiRecordClassName != WmiRecordClass.MicrosoftDNS_RTType)
                {
                    Terminate = true;
                }
                break;

            case "PS12":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_X25Type)
                {
                    Terminate = true;
                }
                break;

            case "PS13":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_SOAType)
                {
                    Terminate = true;
                }
                break;

            case "PS14":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_SRVType)
                {
                    Terminate = true;
                }
                break;

            case "PS15":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WINSType)
                {
                    Terminate = true;
                }
                break;

            case "PS16":
                if (WmiRecordClassName != WmiRecordClass.MicrosoftDNS_WINSRType)
                {
                    Terminate = true;
                }
                break;
            }

            if (Terminate)
            {
                ThrowTerminatingError(
                    new ErrorRecord(
                        new PSInvalidOperationException("InvalidParameterSetForRecordType"),
                        "InvalidOperation",
                        ErrorCategory.InvalidOperation,
                        typeof(ManagementCmdlet)));
            }
            #endregion

            if (ShouldProcess((String)wmiRecord.Properties["TextRepresentation"].Value))
            {
                switch (WmiRecordClassName)
                {
                case WmiRecordClass.MicrosoftDNS_AType:
                    A ARecord = new A(wmiRecord, Server);
                    NewPath = ARecord.Modify(TTL, Address.ToString());
                    break;

                case WmiRecordClass.MicrosoftDNS_AAAAType:
                    AAAA AAAARecord = new AAAA(wmiRecord, Server);
                    NewPath = AAAARecord.Modify(TTL, Address.ToString());
                    break;

                case WmiRecordClass.MicrosoftDNS_AFSDBType:
                    AFSDB AFSDBRecord = new AFSDB(wmiRecord, Server);
                    NewPath = AFSDBRecord.Modify(TTL, SubType, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_CNAMEType:
                    CNAME CNAMERecord = new CNAME(wmiRecord, Server);
                    NewPath = CNAMERecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_HINFOType:
                    HINFO HINFORecord = new HINFO(wmiRecord, Server);
                    NewPath = HINFORecord.Modify(TTL, CPU, OS);
                    break;

                case WmiRecordClass.MicrosoftDNS_ISDNType:
                    ISDN ISDNRecord = new ISDN(wmiRecord, Server);
                    NewPath = ISDNRecord.Modify(TTL, ISDNNumber, SubAddress);
                    break;

                case WmiRecordClass.MicrosoftDNS_MBType:
                    MB MBRecord = new MB(wmiRecord, Server);
                    NewPath = MBRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MDType:
                    MD MDRecord = new MD(wmiRecord, Server);
                    NewPath = MDRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MFType:
                    MF MFRecord = new MF(wmiRecord, Server);
                    NewPath = MFRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_MGType:
                    MG MGRecord = new MG(wmiRecord, Server);
                    NewPath = MGRecord.Modify(TTL, MailboxName);
                    break;

                case WmiRecordClass.MicrosoftDNS_MINFOType:
                    MINFO MINFORecord = new MINFO(wmiRecord, Server);
                    NewPath = MINFORecord.Modify(TTL, ResponsibleMailbox, ErrorMailbox);
                    break;

                case WmiRecordClass.MicrosoftDNS_MRType:
                    MR MRRecord = new MR(wmiRecord, Server);
                    NewPath = MRRecord.Modify(TTL, MailboxName);
                    break;

                case WmiRecordClass.MicrosoftDNS_MXType:
                    MX MXRecord = new MX(wmiRecord, Server);
                    NewPath = MXRecord.Modify(TTL, Preference, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_NSType:
                    NS NSRecord = new NS(wmiRecord, Server);
                    NewPath = NSRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_NXTType:
                    NXT NXTRecord = new NXT(wmiRecord, Server);
                    NewPath = NXTRecord.Modify(TTL, NextDomainName, Types);
                    break;

                case WmiRecordClass.MicrosoftDNS_PTRType:
                    PTR PTRRecord = new PTR(wmiRecord, Server);
                    NewPath = PTRRecord.Modify(TTL, Hostname);
                    break;

                case WmiRecordClass.MicrosoftDNS_RPType:
                    RP RPRecord = new RP(wmiRecord, Server);
                    NewPath = RPRecord.Modify(TTL, ResponsibleMailbox, TXTDomainName);
                    break;

                case WmiRecordClass.MicrosoftDNS_RTType:
                    RT RTRecord = new RT(wmiRecord, Server);
                    NewPath = RTRecord.Modify(TTL, Preference, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_SOAType:
                    SOA SOARecord = new SOA(wmiRecord, Server);
                    NewPath = SOARecord.Modify(TTL, SerialNumber,
                                               SOAServer, ResponsibleMailbox, RefreshInterval,
                                               RetryDelay, ExpireLimit, MinimumTTL);
                    break;

                case WmiRecordClass.MicrosoftDNS_SRVType:
                    SRV SRVRecord = new SRV(wmiRecord, Server);
                    NewPath = SRVRecord.Modify(TTL, Priority, Weight, Port, TargetName);
                    break;

                case WmiRecordClass.MicrosoftDNS_TXTType:
                    TXT TXTRecord = new TXT(wmiRecord, Server);
                    NewPath = TXTRecord.Modify(TTL, Text);
                    break;

                case WmiRecordClass.MicrosoftDNS_WINSType:
                    WINS WINSRecord = new WINS(wmiRecord, Server);
                    NewPath = WINSRecord.Modify(TTL, MappingFlag, LookupTimeout,
                                                CacheTimeout, String.Join(" ", WinsServers));
                    break;

                case WmiRecordClass.MicrosoftDNS_WINSRType:
                    WINSR WINSRRecord = new WINSR(wmiRecord, Server);
                    NewPath = WINSRRecord.Modify(TTL, MappingFlag, LookupTimeout,
                                                 CacheTimeout, ResultDomain);
                    break;

                case WmiRecordClass.MicrosoftDNS_WKSType:
                    WKS WKSRecord = new WKS(wmiRecord, Server);
                    NewPath = WKSRecord.Modify(Address, TTL, IPProtocol, String.Join(" ", Services));
                    break;

                case WmiRecordClass.MicrosoftDNS_X25Type:
                    X25 X25Record = new X25(wmiRecord, Server);
                    NewPath = X25Record.Modify(TTL, PSDNAddress);
                    break;

                default:
                    ThrowTerminatingError(
                        new ErrorRecord(
                            new PSNotSupportedException("Unsupported Record Type"),
                            "RecordModificationNotSupported",
                            ErrorCategory.NotImplemented,
                            typeof(ManagementCmdlet)));
                    break;
                }

                if (PassThru)
                {
                    this.SetManagementPath(NewPath);
                    wmiRecord = this.Get();

                    WriteRecord(wmiRecord);
                }
            }
        }
Ejemplo n.º 32
0
		internal static bool VerifyKeyUsage (MX.X509Certificate certificate, KeyUsages keyUsages, string purpose)
		{
			if (certificate.Extensions == null)
				return true;

			KeyUsageExtension kux = null;
			ExtendedKeyUsageExtension eku = null;

			var xtn = certificate.Extensions [OidKeyUsage];
			if (xtn != null)
				kux = new KeyUsageExtension (xtn);

			xtn = certificate.Extensions [OidExtendedKeyUsage];
			if (xtn != null)
				eku = new ExtendedKeyUsageExtension (xtn);

			if ((kux != null) && (eku != null)) {
				// RFC3280 states that when both KeyUsageExtension and
				// ExtendedKeyUsageExtension are present then BOTH should
				// be valid
				if (!kux.Support (keyUsages))
					return false;
				return eku.KeyPurpose.Contains (purpose);
			} else if (kux != null) {
				return kux.Support (keyUsages);
			} else if (eku != null) {
				return eku.KeyPurpose.Contains (purpose);
			}

			return true;
		}
Ejemplo n.º 33
0
        public void AddTest()
        {
            //----------------------------------------------------------------------------------------------------
            //---only init the domain records which will force a cleaning of the mx records
            InitDomainRecords();
            MXManager mgr = new MXManager(new ConfigStore(CONNSTR));
            //----------------------------------------------------------------------------------------------------
            //---make sure there are no mx records that exist
            Assert.Equal(0, mgr.Count());

            long domainId = 1; //--we always have domain id of 1 (unless someone changed testing values in base)
            string SMTPName = BuildSMTPDomainName(1, 1);
            int preference = 10;
            MX mx = new MX(domainId
                           , SMTPName
                           , preference);

            mgr.Add(mx);
            Assert.Equal(1, mgr.Count());
            mx = mgr.Get(SMTPName);
            Assert.Equal(domainId, mx.DomainID);
            Assert.Equal(SMTPName, mx.SMTPDomainName);
            Assert.Equal(preference, mx.Preference);
            
        }
Ejemplo n.º 34
0
 public void DrawFrame(MX.Frame frame, ITransformable transformObj, IRenderable renderableObj)
 {
     if (transformObj.X + this.Width - Camera.X > 0 && transformObj.Y + this.Height - Camera.Y > 0 &&
         transformObj.X - Camera.X < Width && transformObj.Y - Camera.Y < Height &&
         renderableObj.Visible)
     {
         Vector3 Position = new Vector3((float)transformObj.Position.X, (float)transformObj.Position.Y, 0);
         Position.X -= (float)Camera.X;
         Position.Y -= (float)Camera.Y;
         SetTransform((float)frame._BaseWidth, (float)frame._BaseHeight, (float)transformObj.X, (float)transformObj.Y, (float)transformObj.W, (float)transformObj.H, (float)transformObj.Rotation);
         SpriteBatch.Draw(frame.Texture.Surface, frame.FrameArea, Vector3.Empty, Position, renderableObj.Color.ToArgb());
     }
 }
Ejemplo n.º 35
0
        public void CopyFixedTest()
        {
            MX source = new MX(1, "testSMTPDomainName", 1);
            MX target = new MX();
            target.CopyFixed(source);
            Assert.Equal(source.ID, target.ID);
            Assert.Equal(source.CreateDate, target.CreateDate);
            Assert.Equal(source.DomainID, target.DomainID);
            Assert.Equal(source.SMTPDomainName, target.SMTPDomainName);
            Assert.Equal(source.UpdateDate, target.UpdateDate);
            Assert.Equal(source.Preference, target.Preference);

        }
Ejemplo n.º 36
0
 public void DrawFrame(MX.Animation animation, ITransformable transformObj, IRenderable renderableObj)
 {
     DrawFrame(animation.Frames[animation.CurrentFrame], transformObj, renderableObj);
 }
Ejemplo n.º 37
0
        public IActionResult Edit(int id)
        {
            MX mx = _repository.GetMXById(id);

            return(View(mx));
        }
Ejemplo n.º 38
0
 public void MXConstructorTest2()
 {
     MX target = new MX();
     Assert.Equal(String.Empty, target.SMTPDomainName);
     Assert.Equal(0, target.Preference);
     Assert.Equal(target.CreateDate, target.UpdateDate);
 }
 public MXDetailPage(MX mx)
 {
     InitializeComponent();
     BindingContext = ViewModel = new MXDetailsViewModel();
     ViewModel.SetData(mx);
 }
Ejemplo n.º 40
0
        public void ApplyChangesTest()
        {
            MX target = new MX(1, "target.smtp.name",1);

            Assert.Equal(1, target.DomainID);
            Assert.Equal(1, target.Preference);
            Assert.Equal("target.smtp.name", target.SMTPDomainName);
            
            MX source = new MX(1, "source.smtp.name",2);


            Assert.Equal(1, source.DomainID); 
            Assert.Equal(2, source.Preference);
            Assert.Equal("source.smtp.name", source.SMTPDomainName);
            
            target.ApplyChanges(source);
            Assert.Equal(1, target.DomainID);
            Assert.Equal(source.Preference, target.Preference);
            Assert.Equal(source.SMTPDomainName, target.SMTPDomainName);
        }
 public void SetData(MX finalsession)
 {
     MX = finalsession;
 }
Ejemplo n.º 42
0
        internal void SetTransform(MX.ITransformable objTransformable)
        {
            //rotation
            Quaternion rotate = new Quaternion();
            rotate.RotateYawPitchRoll(0, 0, (float)objTransformable.Rotation);

            //scaling
            Vector3 scale = new Vector3((float)(objTransformable.Size.X / objTransformable.W), (float)(objTransformable.Size.Y / objTransformable.H), 1.0f);
            Vector3 translation = Vector3.Empty;
            if (scale.X != 1 || scale.Y != 1)
                translation = new Vector3((float)(Camera.X * (scale.X - 1)), (float)(Camera.Y * (1 - scale.Y)), 0);

            this.SpriteBatch.Transform = Matrix.Transformation(
                new Vector3((float)objTransformable.Position.X, (float)objTransformable.Position.Y, 0), //scales from top left
                Quaternion.Identity,
                scale,
                new Vector3((float)(objTransformable.Position.X + objTransformable.Size.X / 2), (float)(objTransformable.Position.Y + objTransformable.Size.Y / 2), 0.0f), //rotates from center
                rotate,
                translation);
        }
Ejemplo n.º 43
0
        public void DrawSprite(MX.Sprite sprite)
        {
            if (sprite.X + this.Width - Camera.X > 0 && sprite.Y + this.Height - Camera.Y > 0 &&
                sprite.X - Camera.X < Width && sprite.Y - Camera.Y < Height &&
                sprite.Visible)
            {

                Vector3 Position = new Vector3((float)(sprite.Position.X - sprite.CurrentFrame.Offset.X), (float)(sprite.Position.Y - sprite.CurrentFrame.Offset.Y), 0);
                Position.X -= (float)Camera.X;
                Position.Y -= (float)Camera.Y;
                SetTransform((float)sprite.CurrentFrame._BaseWidth, (float)sprite.CurrentFrame._BaseHeight, (float)sprite.X, (float)sprite.Y, (float)sprite.W, (float)sprite.H, (float)sprite.Rotation);
                SpriteBatch.Draw(sprite.CurrentFrame.Texture.Surface, sprite.CurrentFrame.FrameArea, Vector3.Empty, Position, sprite.Color.ToArgb());
            }
        }
Ejemplo n.º 44
0
        public void MXConstructorTest()
        {

            long domainID = 1;
            string SMTPDomainName = "some.smtp.name.here";
            short preference = 777;
            MX target = new MX(domainID, SMTPDomainName, preference);
            Assert.Equal(domainID, target.DomainID);
            Assert.Equal(SMTPDomainName, target.SMTPDomainName);
            Assert.Equal(preference, target.Preference);
            Assert.Equal(target.CreateDate, target.UpdateDate);
            
        }