Inheritance: System.Security.CodeAccessPermission, System.Security.Permissions.IUnrestrictedPermission
Esempio n. 1
0
    private void senMail(string maintainEmail)
    {
        DataTable dt = new Facade().GetEmailAddressFromPublisherByPublisherId(ddlSupplier.SelectedValue.ToString());

        if (!dt.Rows[0]["email"].ToString().Equals(""))
        {
            try
            {
                System.Net.Mail.SmtpClient     client   = new System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings["mail-server"]);
                System.Net.Mail.MailAddress    fromAddr = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
                System.Net.Mail.SmtpPermission sett     = new System.Net.Mail.SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
                //client.UseDefaultCredentials = true;
                System.Net.Mail.MailAddress toAddr = new System.Net.Mail.MailAddress(dt.Rows[0]["email"].ToString());
                //System.Net.Mail.MailAddress toAddr = new System.Net.Mail.MailAddress("*****@*****.**");
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(fromAddr, toAddr);
                MailAddress copy = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
                message.CC.Add(copy);
                message.Subject    = "Order From Boeijenga";
                message.Body       = maintainEmail;
                message.IsBodyHtml = true;
                client.Send(message);
            }
            catch (Exception ex)
            {
                Boeijenga.Common.Utils.LogWriter.Log(ex);
                throw new Exception("SMTP Server Error: " + ex.Message);
            }
        }
        else
        {
            lblMessage.Text = "Order can not be send! email address is invalid!!";
        }
    }
Esempio n. 2
0
 public override IPermission CreatePermission()
 {
     SmtpPermission perm = null;
     if (Unrestricted)
     {
         perm = new SmtpPermission(PermissionState.Unrestricted);
     }
     else
     {
         perm = new SmtpPermission(PermissionState.None);
         if (_access != null)
         {
             if (string.Equals(_access, "Connect", StringComparison.OrdinalIgnoreCase))
             {
                 perm.AddPermission(SmtpAccess.Connect);
             }
             else if (string.Equals(_access, "ConnectToUnrestrictedPort", StringComparison.OrdinalIgnoreCase))
             {
                 perm.AddPermission(SmtpAccess.ConnectToUnrestrictedPort);
             }
             else if (string.Equals(_access, "None", StringComparison.OrdinalIgnoreCase))
             {
                 perm.AddPermission(SmtpAccess.None);
             }
             else
             {
                 throw new ArgumentException(SR.Format(SR.net_perm_invalid_val, strAccess, _access));
             }
         }
     }
     return perm;
 }
 public override IPermission CreatePermission()
 {
     SmtpPermission permission = null;
     if (base.Unrestricted)
     {
         return new SmtpPermission(PermissionState.Unrestricted);
     }
     permission = new SmtpPermission(PermissionState.None);
     if (this.access != null)
     {
         if (string.Compare(this.access, "Connect", StringComparison.OrdinalIgnoreCase) == 0)
         {
             permission.AddPermission(SmtpAccess.Connect);
             return permission;
         }
         if (string.Compare(this.access, "ConnectToUnrestrictedPort", StringComparison.OrdinalIgnoreCase) == 0)
         {
             permission.AddPermission(SmtpAccess.ConnectToUnrestrictedPort);
             return permission;
         }
         if (string.Compare(this.access, "None", StringComparison.OrdinalIgnoreCase) != 0)
         {
             throw new ArgumentException(SR.GetString("net_perm_invalid_val", new object[] { "Access", this.access }));
         }
         permission.AddPermission(SmtpAccess.None);
     }
     return permission;
 }
Esempio n. 4
0
    private void senMail(string maintainEmail)
    {
        if (Session["user"] != null)
        {
            User   user     = (User)Session["user"];
            string mailFrom = System.Configuration.ConfigurationManager.AppSettings["mail-from"].ToString();
            string mailTo   = user.Email;

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = System.Configuration.ConfigurationManager.AppSettings["mail-server"].ToString();

            System.Net.Mail.MailAddress    fromAddr = new System.Net.Mail.MailAddress(mailFrom);
            System.Net.Mail.SmtpPermission sett     = new System.Net.Mail.SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
            //client.UseDefaultCredentials = true;
            System.Net.Mail.MailAddress toAddr  = new System.Net.Mail.MailAddress(mailTo);
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(mailFrom, mailTo);
            message.CC.Add(mailFrom);
            message.Subject    = "Ordered Successfully";
            message.Body       = maintainEmail;
            message.IsBodyHtml = true;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
            }
        }
    }
Esempio n. 5
0
		public void PermissionState_Bad ()
		{
			PermissionState ps = (PermissionState) Int32.MinValue;
			SmtpPermission sp = new SmtpPermission (ps);
			// no ArgumentException here
			Assert.IsFalse (sp.IsUnrestricted ());
			Assert.AreEqual (SmtpAccess.None, sp.Access, "Access");
		}
Esempio n. 6
0
		public void PermissionState_Unrestricted ()
		{
			PermissionState ps = PermissionState.Unrestricted;
			SmtpPermission sp = new SmtpPermission (ps);
			Assert.IsTrue (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, sp.Access, "Access");

			SecurityElement se = sp.ToXml ();
			Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted");
			Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes#");
			Assert.IsNull (se.Children, "Xml-Children");

			SmtpPermission copy = (SmtpPermission) sp.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (sp, copy), "ReferenceEquals");
			Assert.AreEqual (sp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()");
			Assert.AreEqual (sp.Access, copy.Access, "copy.Access");
		}
Esempio n. 7
0
		public void PermissionState_None ()
		{
			PermissionState ps = PermissionState.None;
			SmtpPermission sp = new SmtpPermission (ps);
			Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (SmtpAccess.None, sp.Access, "Access");

			SecurityElement se = sp.ToXml ();
			// only class and version are present
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes#");
			Assert.IsNull (se.Children, "Xml-Children");

			SmtpPermission copy = (SmtpPermission) sp.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (sp, copy), "ReferenceEquals");
			Assert.AreEqual (sp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()");
			Assert.AreEqual (sp.Access, copy.Access, "copy.Access");
		}
Esempio n. 8
0
 /// <summary>
 /// send the mail
 /// </summary>
 /// <param name="maintainEmail"></param>
 private void SendMail(string maintainEmail)
 {
     try
     {
         System.Net.Mail.SmtpClient     client   = new System.Net.Mail.SmtpClient(System.Configuration.ConfigurationManager.AppSettings["mail-server"]);
         System.Net.Mail.MailAddress    fromAddr = new System.Net.Mail.MailAddress(txtEmail.Text);                                                      //new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
         System.Net.Mail.SmtpPermission sett     = new System.Net.Mail.SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);
         System.Net.Mail.MailAddress    toAddr   = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-from"]); //new System.Net.Mail.MailAddress(user.Email.ToString());
         System.Net.Mail.MailMessage    message  = new System.Net.Mail.MailMessage(fromAddr, toAddr);
         ////MailAddress copy = new MailAddress(System.Configuration.ConfigurationManager.AppSettings["mail-company"]);
         ////message.CC.Add(copy);
         message.Subject    = subject;
         message.Body       = maintainEmail;
         message.IsBodyHtml = true;
         client.Send(message);
     }
     catch (Exception ex) { throw new Exception("SMTP Server Error: " + ex.Message); }
 }
Esempio n. 9
0
		public void FromXml_NoClass ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			SecurityElement se = sp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			sp.FromXml (w);
			// note: normally IPermission classes (in corlib) DO NOT care about
			// attribute "class" name presence in the XML
		}
Esempio n. 10
0
		public void FromXml_WrongVersion ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			SecurityElement se = sp.ToXml ();
			se.Attributes.Remove ("version");
			se.Attributes.Add ("version", "2");
			sp.FromXml (se);
		}
Esempio n. 11
0
		public void FromXml_WrongTagCase ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			SecurityElement se = sp.ToXml ();
			se.Tag = "IPERMISSION"; // instead of IPermission
			sp.FromXml (se);
			// note: normally IPermission classes (in corlib) DO care about the
			// IPermission tag
		}
Esempio n. 12
0
		public void FromXml_WrongClass ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			SecurityElement se = sp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
			w.AddAttribute ("version", se.Attribute ("version"));
			sp.FromXml (w);
			// doesn't care of the class name at that stage
			// anyway the class has already be created so...
		}
Esempio n. 13
0
		public void Union_BadPermission ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			sp.Union (new SecurityPermission (PermissionState.Unrestricted));
		}
Esempio n. 14
0
		public void FromXml_Null ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			sp.FromXml (null);
		}
Esempio n. 15
0
		public void AddPermission_Invalid ()
		{
			SmtpAccess sa = (SmtpAccess) Int32.MinValue;
			SmtpPermission sp = new SmtpPermission (false);
			sp.AddPermission (sa);
			Assert.AreEqual (SmtpAccess.None, sp.Access, "None");
		}
Esempio n. 16
0
		public void Intersect_SmtpAccess ()
		{
			SmtpPermission spn = new SmtpPermission (false);
			SmtpPermission spu = new SmtpPermission (true);
			SmtpPermission spctup = new SmtpPermission (SmtpAccess.ConnectToUnrestrictedPort);
			SmtpPermission spconnect = new SmtpPermission (SmtpAccess.Connect);
			SmtpPermission spnone = new SmtpPermission (SmtpAccess.None);

			SmtpPermission intersect = (SmtpPermission) spn.Intersect (spctup);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "None N ConnectToUnrestrictedPort");
			intersect = (SmtpPermission) spn.Intersect (spconnect);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "None N Connect");
			intersect = (SmtpPermission) spn.Intersect (spnone);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "None N SmtpAccess.None");

			intersect = (SmtpPermission) spu.Intersect (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "Unrestricted N ConnectToUnrestrictedPort");
			intersect = (SmtpPermission) spu.Intersect (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, intersect.Access, "Unrestricted N Connect");
			intersect = (SmtpPermission) spu.Intersect (spnone);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "Unrestricted N SmtpAccess.None");

			intersect = (SmtpPermission) spctup.Intersect (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "ConnectToUnrestrictedPort N ConnectToUnrestrictedPort");
			intersect = (SmtpPermission) spctup.Intersect (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, intersect.Access, "ConnectToUnrestrictedPort N Connect");
			intersect = (SmtpPermission) spctup.Intersect (spnone);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "ConnectToUnrestrictedPort N SmtpAccess.None");
			intersect = (SmtpPermission) spctup.Intersect (spn);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "ConnectToUnrestrictedPort N None");
			intersect = (SmtpPermission) spctup.Intersect (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "ConnectToUnrestrictedPort N Unrestricted");

			intersect = (SmtpPermission) spconnect.Intersect (spctup);
			Assert.AreEqual (SmtpAccess.Connect, intersect.Access, "Connect N ConnectToUnrestrictedPort");
			intersect = (SmtpPermission) spconnect.Intersect (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, intersect.Access, "Connect N Connect");
			intersect = (SmtpPermission) spconnect.Intersect (spnone);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "Connect N SmtpAccess.None");
			intersect = (SmtpPermission) spconnect.Intersect (spn);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "Connect N None");
			intersect = (SmtpPermission) spconnect.Intersect (spu);
			Assert.AreEqual (SmtpAccess.Connect, intersect.Access, "Connect N Unrestricted");

			intersect = (SmtpPermission) spnone.Intersect (spctup);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "SmtpAccess.None N ConnectToUnrestrictedPort");
			intersect = (SmtpPermission) spnone.Intersect (spconnect);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "SmtpAccess.None N Connect");
			intersect = (SmtpPermission) spnone.Intersect (spnone);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "SmtpAccess.None N SmtpAccess.None");
			intersect = (SmtpPermission) spnone.Intersect (spn);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "SmtpAccess.None N None");
			intersect = (SmtpPermission) spnone.Intersect (spu);
			Assert.AreEqual (SmtpAccess.None, intersect.Access, "SmtpAccess.None N Unrestricted");
		}
Esempio n. 17
0
		public void IsSubset_BadPermission ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			sp.IsSubsetOf (new SecurityPermission (PermissionState.Unrestricted));
		}
Esempio n. 18
0
		public void Ctor_SmtpAccess_Invalid ()
		{
			SmtpAccess sa = (SmtpAccess)Int32.MinValue;
			SmtpPermission sp = new SmtpPermission (sa);
			// no exception
			Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (sa, sp.Access, "Access");

			// invalid access doesn't get serialized to XML
			SecurityElement se = sp.ToXml ();
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes#");
			Assert.IsNull (se.Children, "Xml-Children");

			// but it doesn't roundtrip
			SmtpPermission copy = (SmtpPermission) sp.Copy ();
			Assert.AreEqual (sp.Access, copy.Access, "copy.Access");
		}
Esempio n. 19
0
		public void IsSubset_SmtpAccess ()
		{
			SmtpPermission spn = new SmtpPermission (false);
			SmtpPermission spu = new SmtpPermission (true);
			SmtpPermission spctup = new SmtpPermission (SmtpAccess.ConnectToUnrestrictedPort);
			SmtpPermission spconnect = new SmtpPermission (SmtpAccess.Connect);
			SmtpPermission spnone = new SmtpPermission (SmtpAccess.None);

			Assert.IsTrue (spn.IsSubsetOf (spctup), "None IsSubsetOf ConnectToUnrestrictedPort");
			Assert.IsTrue (spn.IsSubsetOf (spconnect), "None IsSubsetOf Connect");
			Assert.IsTrue (spn.IsSubsetOf (spnone), "None IsSubsetOf SmtpAccess.None");

			Assert.IsFalse (spu.IsSubsetOf (spctup), "Unrestricted IsSubsetOf ConnectToUnrestrictedPort");
			Assert.IsFalse (spu.IsSubsetOf (spconnect), "Unrestricted IsSubsetOf Connect");
			Assert.IsFalse (spu.IsSubsetOf (spnone), "Unrestricted IsSubsetOf SmtpAccess.None");

			Assert.IsTrue (spctup.IsSubsetOf (spctup), "ConnectToUnrestrictedPort IsSubsetOf ConnectToUnrestrictedPort");
			Assert.IsFalse (spctup.IsSubsetOf (spconnect), "ConnectToUnrestrictedPort IsSubsetOf Connect");
			Assert.IsFalse (spctup.IsSubsetOf (spnone), "ConnectToUnrestrictedPort IsSubsetOf SmtpAccess.None");
			Assert.IsFalse (spctup.IsSubsetOf (spn), "ConnectToUnrestrictedPort IsSubsetOf None");
			Assert.IsTrue (spctup.IsSubsetOf (spu), "ConnectToUnrestrictedPort IsSubsetOf Unrestricted");

			Assert.IsTrue (spconnect.IsSubsetOf (spctup), "Connect IsSubsetOf ConnectToUnrestrictedPort");
			Assert.IsTrue (spconnect.IsSubsetOf (spconnect), "Connect IsSubsetOf Connect");
			Assert.IsFalse (spconnect.IsSubsetOf (spnone), "Connect IsSubsetOf SmtpAccess.None");
			Assert.IsFalse (spconnect.IsSubsetOf (spn), "Connect IsSubsetOf None");
			Assert.IsTrue (spconnect.IsSubsetOf (spu), "Connect IsSubsetOf Unrestricted");

			Assert.IsTrue (spnone.IsSubsetOf (spctup), "SmtpAccess.None IsSubsetOf ConnectToUnrestrictedPort");
			Assert.IsTrue (spnone.IsSubsetOf (spconnect), "SmtpAccess.None IsSubsetOf Connect");
			Assert.IsTrue (spnone.IsSubsetOf (spnone), "SmtpAccess.None IsSubsetOf SmtpAccess.None");
			Assert.IsTrue (spnone.IsSubsetOf (spn), "SmtpAccess.None IsSubsetOf None");
			Assert.IsTrue (spnone.IsSubsetOf (spu), "SmtpAccess.None IsSubsetOf Unrestricted");
		}
Esempio n. 20
0
		public void IsSubset ()
		{
			SmtpPermission spn = new SmtpPermission (PermissionState.None);
			SmtpPermission spu = new SmtpPermission (PermissionState.Unrestricted);

			Assert.IsTrue (spn.IsSubsetOf (null), "None IsSubsetOf null");
			Assert.IsFalse (spu.IsSubsetOf (null), "Unrestricted IsSubsetOf null");

			Assert.IsTrue (spn.IsSubsetOf (spn), "None IsSubsetOf None");
			Assert.IsTrue (spu.IsSubsetOf (spu), "Unrestricted IsSubsetOf Unrestricted");

			Assert.IsTrue (spn.IsSubsetOf (spu), "None IsSubsetOf Unrestricted");
			Assert.IsFalse (spu.IsSubsetOf (spn), "Unrestricted IsSubsetOf None");
		}
Esempio n. 21
0
		public void Intersect_BadPermission ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			sp.Intersect (new SecurityPermission (PermissionState.Unrestricted));
		}
Esempio n. 22
0
		public void FromXml_NoVersion ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			SecurityElement se = sp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			sp.FromXml (w);
		}
Esempio n. 23
0
		public void Ctor_SmtpAccess_ConnectToUnrestrictedPort ()
		{
			SmtpPermission sp = new SmtpPermission (SmtpAccess.ConnectToUnrestrictedPort);
			Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, sp.Access, "Access");

			SecurityElement se = sp.ToXml ();
			// only class and version are present
			Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes#");
			Assert.AreEqual ("ConnectToUnrestrictedPort", se.Attribute ("Access"), "Xml-Access");
			Assert.IsNull (se.Children, "Xml-Children");
		}
Esempio n. 24
0
		public void AddPermission_Unrestricted ()
		{
			SmtpPermission sp = new SmtpPermission (true);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, sp.Access, "Access-default");
			sp.AddPermission (SmtpAccess.None);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, sp.Access, "ConnectToUnrestrictedPort");
		}
Esempio n. 25
0
		public void Intersect ()
		{
			SmtpPermission spn = new SmtpPermission (PermissionState.None);
			Assert.IsNull (spn.Intersect (null), "None N null");
			SmtpPermission inter = (SmtpPermission) spn.Intersect (spn);
			Assert.AreEqual (SmtpAccess.None, inter.Access, "None N None");

			SmtpPermission spu = new SmtpPermission (PermissionState.Unrestricted);
			Assert.IsNull (spu.Intersect (null), "Unrestricted N null");

			SmtpPermission result = (SmtpPermission) spu.Intersect (spu);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted N Unrestricted");

			inter = (SmtpPermission) spn.Intersect (spu);
			Assert.AreEqual (SmtpAccess.None, inter.Access, "None N Unrestricted");

			inter = (SmtpPermission) spu.Intersect (spn);
			Assert.AreEqual (SmtpAccess.None, inter.Access, "Unrestricted N None");
		}
Esempio n. 26
0
		public void Ctor_Boolean_True ()
		{
			SmtpPermission sp = new SmtpPermission (true);
			Assert.IsTrue (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, sp.Access, "Access");

			SecurityElement se = sp.ToXml ();
			Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted");
			Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes#");
			Assert.IsNull (se.Children, "Xml-Children");
		}
Esempio n. 27
0
		public void Union_SmtpAccess ()
		{
			SmtpPermission spn = new SmtpPermission (false);
			SmtpPermission spu = new SmtpPermission (true);
			SmtpPermission spctup = new SmtpPermission (SmtpAccess.ConnectToUnrestrictedPort);
			SmtpPermission spconnect = new SmtpPermission (SmtpAccess.Connect);
			SmtpPermission spnone = new SmtpPermission (SmtpAccess.None);

			SmtpPermission union = (SmtpPermission) spn.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "None U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spn.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "None U Connect");
			union = (SmtpPermission) spn.Union (spnone);
			Assert.AreEqual (SmtpAccess.None, union.Access, "None U SmtpAccess.None");

			union = (SmtpPermission) spu.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spu.Union (spconnect);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U Connect");
			union = (SmtpPermission) spu.Union (spnone);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U SmtpAccess.None");

			union = (SmtpPermission) spctup.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spctup.Union (spconnect);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U Connect");
			union = (SmtpPermission) spctup.Union (spnone);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U SmtpAccess.None");
			union = (SmtpPermission) spctup.Union (spn);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U None");
			union = (SmtpPermission) spctup.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U Unrestricted");

			union = (SmtpPermission) spconnect.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Connect U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spconnect.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U Connect");
			union = (SmtpPermission) spconnect.Union (spnone);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U SmtpAccess.None");
			union = (SmtpPermission) spconnect.Union (spn);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U None");
			union = (SmtpPermission) spconnect.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Connect U Unrestricted");

			union = (SmtpPermission) spnone.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "SmtpAccess.None U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spnone.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "SmtpAccess.None U Connect");
			union = (SmtpPermission) spnone.Union (spnone);
			Assert.AreEqual (SmtpAccess.None, union.Access, "SmtpAccess.None U SmtpAccess.None");
			union = (SmtpPermission) spnone.Union (spn);
			Assert.AreEqual (SmtpAccess.None, union.Access, "SmtpAccess.None U None");
			union = (SmtpPermission) spnone.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "SmtpAccess.None U Unrestricted");
		}
Esempio n. 28
0
		public void Union ()
		{
			SmtpPermission spn = new SmtpPermission (PermissionState.None);
			SmtpPermission spu = new SmtpPermission (PermissionState.Unrestricted);

			SmtpPermission result = (SmtpPermission) spn.Union (null);
			Assert.IsFalse (result.IsUnrestricted (), "None U null");

			result = (SmtpPermission) spu.Union (null);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U null");

			result = (SmtpPermission) spn.Union (spn);
			Assert.IsFalse (result.IsUnrestricted (), "None U None");

			result = (SmtpPermission) spu.Union (spu);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U Unrestricted");

			result = (SmtpPermission) spn.Union (spu);
			Assert.IsTrue (result.IsUnrestricted (), "None U Unrestricted");

			result = (SmtpPermission) spu.Union (spn);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U None");
		}
Esempio n. 29
0
		public void Ctor_Boolean_False ()
		{
			SmtpPermission sp = new SmtpPermission (false);
			Assert.IsFalse (sp.IsUnrestricted (), "IsUnrestricted");
			Assert.AreEqual (SmtpAccess.None, sp.Access, "Access");

			SecurityElement se = sp.ToXml ();
			// only class and version are present
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes#");
			Assert.IsNull (se.Children, "Xml-Children");
		}