private static bool DoHasInheritanceDemand(SecurityDeclarationCollection decs)
		{
			foreach (SecurityDeclaration dec in decs)
			{
				if (dec.Action == SecurityAction.InheritDemand || dec.Action == SecurityAction.NonCasInheritance)
				{
					return true;
				}
			}
			
			return false;
		}
Пример #2
0
 public virtual void VisitSecurityDeclarationCollection(SecurityDeclarationCollection secDecls)
 {
 }
Пример #3
0
		static SecurityElement AddSecurityXml (SecurityDeclarationCollection declarations)
		{
			ArrayList list = new ArrayList ();
			foreach (SecurityDeclaration declsec in declarations) {
				SecurityElement child = new SecurityElement ("Action");
				AddAttribute (child, "Name", declsec.Action.ToString ());
				child.AddChild (declsec.PermissionSet.ToXml ());
				list.Add (child);
			}
			// sort actions
			list.Sort (Comparer);

			SecurityElement se = new SecurityElement ("Actions");
			foreach (SecurityElement child in list) {
				se.AddChild (child);
			}
			return se;
		}
Пример #4
0
		static void ShowSecurity (TextWriter tw, string header, SecurityDeclarationCollection declarations)
		{
			foreach (SecurityDeclaration declsec in declarations) {
				tw.WriteLine ("{0} {1} Permission Set:{2}{3}", header,
					declsec.Action, Environment.NewLine, declsec.PermissionSet);
			}
		}
        public virtual void VisitSecurityDeclarationCollection(SecurityDeclarationCollection secDecls)
        {

        }
Пример #6
0
        public override void VisitSecurityDeclarationCollection(SecurityDeclarationCollection secDecls)
        {
            if (secDecls.Count == 0)
                return;

            DeclSecurityTable dsTable = m_tableWriter.GetDeclSecurityTable ();
            foreach (SecurityDeclaration secDec in secDecls) {
                DeclSecurityRow dsRow = m_rowWriter.CreateDeclSecurityRow (
                    secDec.Action,
                    secDecls.Container.MetadataToken,
                    m_mdWriter.AddBlob (secDec.IsReadable ?
                        m_mod.GetAsByteArray (secDec) : secDec.Blob));

                dsTable.Rows.Add (dsRow);
            }
        }
 private void InitializeDeclarativeSecurity(AddDeclarativeSecurityDelegate addDeclarativeSecurity,
     SecurityDeclarationCollection securityDeclarations)
 {
     foreach (SecurityDeclaration securityDeclaration in securityDeclarations)
     {
         addDeclarativeSecurity(
             (System.Security.Permissions.SecurityAction)securityDeclaration.Action,
             securityDeclaration.PermissionSet);
     }
 }
 public virtual void VisitSecurityDeclarationCollection(SecurityDeclarationCollection secDecls)
 {
     foreach (SecurityDeclaration securityDeclaration in secDecls)
     {
         VisitSecurityDeclaration(securityDeclaration);
     }
 }
		private static string Security (SecurityDeclarationCollection declarations, bool stackmods)
		{
			StringBuilder sb = null;
			foreach (SecurityDeclaration declsec in declarations) {
				switch (declsec.Action) {
				case Mono.Cecil.SecurityAction.Assert:
				case Mono.Cecil.SecurityAction.PermitOnly:
				case Mono.Cecil.SecurityAction.Deny:
					if (!stackmods)
						continue;
					break;
				default:
					if (stackmods)
						continue;
					break;
				}

				if (sb == null) {
					sb = new StringBuilder ();
					sb.AppendFormat (",{0}label=\"", !stackmods ? String.Empty /*"head"*/ : "tail");
				}
				sb.AppendFormat ("{0}\\l", declsec.Action);
				PermissionSet pset = declsec.PermissionSet;
				if (pset.Count > 0) {
					foreach (IPermission p in pset) {
						if (p is SecurityPermission) {
							sb.AppendFormat ("  SecurityPermission\\l    {0}\\l", (p as SecurityPermission).Flags);
						} else if (p is ReflectionPermission) {
							sb.Append (GetReflectionPermission (p as ReflectionPermission));
						} else if (p is FileIOPermission) {
							sb.Append (GetFileIOPermission (p as FileIOPermission));
						} else if (p is EnvironmentPermission) {
							sb.Append (GetEnvironmentPermission (p as EnvironmentPermission));
						} else if (p is IsolatedStorageFilePermission) {
							sb.Append (GetIsolatedStorageFilePermission (p as IsolatedStorageFilePermission));
						} else {
							string ps = p.ToString ().Replace ('"', '\'');
							ps = ps.Replace (Environment.NewLine, "\\l");
							sb.AppendFormat ("  {0}\\l", ps);
						}
					}
				} else if (pset.IsUnrestricted ()) {
					sb.Append ("  PermissionSet Unrestricted\\l");
				}
			}
			if (sb == null)
				return String.Empty;
			return sb.Append ("\"").ToString ();
		}
Пример #10
0
		private static bool DoHasLinkDemand(SecurityDeclarationCollection decs)
		{
			foreach (SecurityDeclaration dec in decs)
			{
				if (dec.Action == SecurityAction.LinkDemand || dec.Action == SecurityAction.NonCasLinkDemand)	// TODO: why do we need the NonCas stuff?
				{
					return true;
				}
			}
			
			return false;
		}
		private Widget GetWidget (SecurityDeclarationCollection sdc)
		{
			FontDescription fd = FontDescription.FromString ("Courier 10 Pitch 10");

			VBox vbox = new VBox (false, 0);

			actions = new Action[list.Length];
			for (int i=0; i < list.Length; i++) {
				actions [i] = new Action (list [i]);
				actions [i].TextView.ModifyFont (fd);
				vbox.Add (actions [i].Expander);
			}

			ScrolledWindow sw = new ScrolledWindow ();
			sw.AddWithViewport (vbox);
			
			if ((sdc != null) && (sdc.Count >= 0)) {
				foreach (SecurityDeclaration declsec in sdc) {
					actions [(int)declsec.Action - 1].SetText (declsec.PermissionSet.ToString ());
				}
			}
			
			vbox.Show ();
			sw.Show ();
			return sw;
 		}
Пример #12
0
		private bool DoHasAssert(SecurityDeclarationCollection secs)
		{
			foreach (SecurityDeclaration dec in secs)
			{
				if (dec.Action == SecurityAction.Assert)	
				{
					Log.DebugLine(this, "   has an assert attr");
					return true;
				}
			}
			
			return false;
		}
Пример #13
0
		private bool DoHasDemand(SecurityDeclarationCollection secs)
		{
			foreach (SecurityDeclaration dec in secs)
			{
				if (dec.Action == SecurityAction.NonCasDemand || dec.Action == SecurityAction.NonCasLinkDemand || dec.Action == SecurityAction.Demand || dec.Action == SecurityAction.LinkDemand)	// TODO: may be a mono or cecil bug here, doesn't seem like we should have to check NonCasDemand
				{
					Log.DebugLine(this, "   has a demand attr");
					return true;
				}
			}
			
			return false;
		}