Inheritance: IIdentityPermissionFactory, IBuiltInEvidence
Beispiel #1
0
		public static Evidence CreateEvidenceForUrl (string securityUrl)
		{
			Evidence e = new Evidence ();

			if ((securityUrl != null) && (securityUrl.Length > 0)) {
				try {
					Url url = new Url (securityUrl);
					e.AddHost (url);
				} catch (ArgumentException) {
				}

				try {
					Zone zone = Zone.CreateFromUrl (securityUrl);
					e.AddHost (zone);
				} catch (ArgumentException) {
				}

				try {
					Site site = Site.CreateFromUrl (securityUrl);
					e.AddHost (site);
				} catch (ArgumentException) {
				}
			}

			return e;
		}
		internal UrlMembershipCondition (Url url, string userUrl)
		{
			// as the Url object has already been validated there's no
			// need to restart the whole process by converting to string
			this.url = (Url) url.Copy ();
			this.userUrl = userUrl;
		}
Beispiel #3
0
 public SecurityException(string message, AssemblyName assemblyName, PermissionSet grant, PermissionSet refused, MethodInfo method, SecurityAction action, object demanded, IPermission permThatFailed, Evidence evidence)
     : base(message)
 {
     PermissionSet.s_fullTrust.Assert();
     this.SetErrorCode(-2146233078);
     this.Action = action;
     if (permThatFailed != null)
     {
         this.m_typeOfPermissionThatFailed = permThatFailed.GetType();
     }
     this.FirstPermissionThatFailed = permThatFailed;
     this.Demanded       = demanded;
     this.m_granted      = grant == null ? "" : grant.ToXml().ToString();
     this.m_refused      = refused == null ? "" : refused.ToXml().ToString();
     this.m_denied       = "";
     this.m_permitOnly   = "";
     this.m_assemblyName = assemblyName;
     this.Method         = method;
     this.m_url          = "";
     this.m_zone         = SecurityZone.NoZone;
     if (evidence != null)
     {
         System.Security.Policy.Url hostEvidence1 = evidence.GetHostEvidence <System.Security.Policy.Url>();
         if (hostEvidence1 != null)
         {
             this.m_url = hostEvidence1.GetURLString().ToString();
         }
         System.Security.Policy.Zone hostEvidence2 = evidence.GetHostEvidence <System.Security.Policy.Zone>();
         if (hostEvidence2 != null)
         {
             this.m_zone = hostEvidence2.SecurityZone;
         }
     }
     this.m_debugString = this.ToString(true, false);
 }
        public void ProcessEmail(string emailTo, Url link)
        {
            using(var smtpClient = new SmtpClient(ServerName,ServerPort))
            {
                smtpClient.EnableSsl = UseSsl;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(UserName, Password);
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.Timeout = Timeout;

                var body = new StringBuilder()
                    .AppendLine("Olá,")
                    .AppendLine(string.Empty)
                    .AppendLine("Para completar o seu registo clique no link abaixo sff")
                    .AppendLine(link.Value)
                    .AppendLine(string.Empty)
                    .AppendLine("Atentamente,")
                    .AppendLine(string.Empty)
                    .AppendLine("PI TRELLO ADMINISTRATION");

                var mailMessage = new MailMessage(
                            MailFromAddress,
                            emailTo,
                            "PI_Trello: Novo utilizador!",
                            body.ToString()
                    );

                mailMessage.BodyEncoding = Encoding.UTF8;
                mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                smtpClient.Send(mailMessage);
            }
        }
		// Methods
		public bool Check (Evidence evidence)
		{
			if (evidence == null)
				return false;

			string codebase = Assembly.GetCallingAssembly ().CodeBase;
			Uri local = new Uri (codebase);
			Url ucode = new Url (codebase);

			// *both* ApplicationDirectory and Url must be in *Host* evidences
			bool adir = false;
			bool url = false;
			IEnumerator e = evidence.GetHostEnumerator ();
			while (e.MoveNext ()) {
				object o = e.Current;

				if (!adir && (o is ApplicationDirectory)) {
					ApplicationDirectory ad = (o as ApplicationDirectory);
					string s = ad.Directory;
					adir = (String.Compare (s, 0, local.ToString (), 0, s.Length, true, CultureInfo.InvariantCulture) == 0);
				}
				else if (!url && (o is Url)) {
					url = ucode.Equals (o);
				}

				// got both ?
				if (adir && url)
					return true;
			}
			return false;
		}
                public UrlMembershipCondition (string url)
                {
			if (url == null)
				throw new ArgumentNullException ("url");
			CheckUrl (url);
			userUrl = url;
                        this.url = new Url (url);
                }
Beispiel #7
0
 public bool AddLink(Url link, string text)
 {
     var parameters = new VkParameters
     {
         { "link", link.Value },
         { "text", text }
     };
     return _vk.Call("fave.addLink", parameters);
 }
        public void AddEntry()
        {
            var ipAddress = IPAddress.Parse("127.0.0.1");
            var url = new Url("http://localhost/");

            this.Model.AddEntry(ipAddress, url);
            Assert.That(this.Model.ContainsEntry(ipAddress, url));
            Assert.That(this.Model.IndexOf(ipAddress, url), Is.EqualTo(this.Model.Length - 1));
        }
                public UrlMembershipCondition (string url)
                {
			if (url == null)
				throw new ArgumentNullException ("url");
#if NET_2_0
			CheckUrl (url);
			userUrl = url;
                        this.url = new Url (url);
#else
                        this.url = new Url (url);
			userUrl = this.url.Value;
#endif
                }
        protected string CrawlSite(Url pageUrl)
        {
            var oRequest = WebRequest.CreateHttp(pageUrl.Value);
            var oResponse = (HttpWebResponse) oRequest.GetResponse();

            var oResult = new StringBuilder();

            using (var oReader = new StreamReader(oResponse.GetResponseStream()))
            {
                string sLine = null;

                while ((sLine = oReader.ReadLine()) != null)
                    oResult.AppendLine(sLine);
            }

            return oResult.ToString();
        }
Beispiel #11
0
 private static List <StockPrice> requestStocks(string year)
 {
     System.Security.Policy.Url url;
     System.Text.StringBuilder  response = new System.Text.StringBuilder();
     try
     {
         url = new System.Security.Policy.Url("https://jsonmock.hackerrank.com/api/stocks/search?date=" + year);
         string  req         = CreateRequest(url.Value);
         dynamic responseObj = JsonConvert.DeserializeObject(req, typeof(ResponseClass));
         return(responseObj.data);
     }
     catch (IOException e)
     {
         throw e;
     }
     finally
     {
     }
 }
 protected abstract Url GetImageLink(Url pageUrl);
Beispiel #13
0
 private Url(Url url) 
 {
     Contract.Assert(url != null);
     m_url = url.m_url;
 } 
Beispiel #14
0
        public Object Copy()
        {
            Url url = new Url();

            url.m_url = this.m_url;

            return url;
        }
Beispiel #15
0
 public IpModule(Url alarmUrl, int panelCode, string password)
 {
     Url = alarmUrl;
     PanelCode = panelCode;
     Password = password;
 }
 public abstract IEnumerable<MangaClasses.Manga> GetMangas(Url pageUrl);
Beispiel #17
0
		public static void AddHostEvidence (this Evidence evidence, Url url)
		{
			throw new NotImplementedException ();
		}
Beispiel #18
0
        public Chapter(Url link)
        {
            HelperClass.ArgumentNull(link);

            this.Link = link;
        }
Beispiel #19
0
		public void FromXml (SecurityElement e, PolicyLevel level)
		{
			MembershipConditionHelper.CheckSecurityElement (e, "e", version, version);
			
			string u = e.Attribute ("Url");
#if NET_2_0
			if (u != null) {
				CheckUrl (u);
				url = new Url (u);
			} else {
				url = null;
			}
#else
			url = (u == null) ? null : new Url (u);
#endif
			userUrl = u;
		}
 public abstract List<ComboBoxItem> GetChapterList(Url pageUrl);
 public abstract List<ComboBoxItem> GetPageList(Url pageUrl);
Beispiel #22
0
 private Url(Url url)
 {
     Debug.Assert(url != null);
     m_url = url.m_url;
 }