Inheritance: IIdentityPermissionFactory, IBuiltInEvidence
示例#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;
		}
示例#2
0
		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;
		}
示例#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);
 }
示例#4
0
        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);
                }
示例#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));
        }
示例#9
0
                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
                }
示例#10
0
        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();
        }
示例#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
     {
     }
 }
示例#12
0
 protected abstract Url GetImageLink(Url pageUrl);
示例#13
0
文件: URL.cs 项目: sjyanxin/WPFSource
 private Url(Url url) 
 {
     Contract.Assert(url != null);
     m_url = url.m_url;
 } 
示例#14
0
        public Object Copy()
        {
            Url url = new Url();

            url.m_url = this.m_url;

            return url;
        }
示例#15
0
 public IpModule(Url alarmUrl, int panelCode, string password)
 {
     Url = alarmUrl;
     PanelCode = panelCode;
     Password = password;
 }
示例#16
0
 public abstract IEnumerable<MangaClasses.Manga> GetMangas(Url pageUrl);
示例#17
0
文件: Dummy.cs 项目: kumpera/mono
		public static void AddHostEvidence (this Evidence evidence, Url url)
		{
			throw new NotImplementedException ();
		}
示例#18
0
        public Chapter(Url link)
        {
            HelperClass.ArgumentNull(link);

            this.Link = link;
        }
示例#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;
		}
示例#20
0
 public abstract List<ComboBoxItem> GetChapterList(Url pageUrl);
示例#21
0
 public abstract List<ComboBoxItem> GetPageList(Url pageUrl);
示例#22
0
文件: URL.cs 项目: kouvel/coreclr
 private Url(Url url)
 {
     Debug.Assert(url != null);
     m_url = url.m_url;
 }