public static PermissionSet PermissionSetFromStandardSet(StandardPermissionSet standardSet) { PermissionSetAttribute attribute = new PermissionSetAttribute(SecurityAction.Demand); attribute.Name = standardSet.ToString(); return(attribute.CreatePermissionSet()); }
/// <summary> /// Build a copy of a given standard permission set, optionally extending it with same site /// permission for the given source URL. /// </summary> /// <param name="permissionSet">standard permission set to generate</param> /// <param name="sourceUrl">optional source URL to generate same site permission for</param> /// <exception cref="ArgumentOutOfRangeException"> /// if <paramref name="permissionSet" /> is not one of the standard permission sets /// </exception> public static PermissionSet GetStandardPermissionSet(StandardPermissionSet permissionSet, Url sourceUrl) { switch (permissionSet) { case StandardPermissionSet.Everything: return(GetEverythingPermissionSet()); case StandardPermissionSet.Execution: return(GetExecutionPermissionSet()); case StandardPermissionSet.FullTrust: return(GetFullTrustPermissionSet()); case StandardPermissionSet.Internet: return(GetInternetPermissionSet(sourceUrl)); case StandardPermissionSet.LocalIntranet: return(GetLocalIntranetPermissionSet(sourceUrl)); case StandardPermissionSet.Nothing: return(GetNothingPermissionSet()); default: throw new ArgumentOutOfRangeException("permissionSet"); } }
internal static PermissionSet GetStandardPermissionSet(StandardPermissionSet permissionSet, Url sourceUrl) { switch (permissionSet) { // We need to handle Internet, LocalIntranet, and Everything ourselves, since // PermissionSetFactory will use deprecated CAS policy to calculate those case StandardPermissionSet.Internet: return(GetInternetPermissionSet(sourceUrl)); case StandardPermissionSet.LocalIntranet: return(GetLocalIntranetPermissionSet(sourceUrl)); case StandardPermissionSet.Everything: return(GetEverythingPermissionSet()); // Everything else can be obtained through PermissionSetFactory default: return(PermissionSetFactory.GetStandardPermissionSet(permissionSet, sourceUrl)); } }
public AppDomainHost(Type serviceType, StandardPermissionSet standardSet, string appDomainName, params Uri[] baseAddresses) : this(serviceType, CodeAccessSecurityHelper.PermissionSetFromStandardSet(standardSet), appDomainName, baseAddresses) { }
public AppDomainHost(Type serviceType,StandardPermissionSet standardSet,string appDomainName,params Uri[] baseAddresses) : this(serviceType,CodeAccessSecurityHelper.PermissionSetFromStandardSet(standardSet),appDomainName,baseAddresses) {}
/// <summary> /// Build a copy of a given standard permission set, without including any same site permissions. /// </summary> /// <param name="permissionSet">standard permission set to generate</param> /// <exception cref="ArgumentOutOfRangeException"> /// if <paramref name="permissionSet" /> is not one of the standard permission sets /// </exception> public static PermissionSet GetStandardPermissionSet(StandardPermissionSet permissionSet) { return(GetStandardPermissionSet(permissionSet, null)); }