Ejemplo n.º 1
0
        protected void InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
        {
            PermissionSet   newGrant  = (PermissionSet)null;
            PermissionSet   newDenied = (PermissionSet)null;
            RuntimeAssembly caller    = System.IO.IsolatedStorage.IsolatedStorage.GetCaller();

            System.IO.IsolatedStorage.IsolatedStorage.GetControlEvidencePermission().Assert();
            if (System.IO.IsolatedStorage.IsolatedStorage.IsDomain(scope))
            {
                AppDomain domain = Thread.GetDomain();
                if (!System.IO.IsolatedStorage.IsolatedStorage.IsRoaming(scope))
                {
                    newGrant = domain.PermissionSet;
                    if (newGrant == null)
                    {
                        throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_DomainGrantSet"));
                    }
                }
                this._InitStore(scope, domain.Evidence, domainEvidenceType, caller.Evidence, assemblyEvidenceType, (Evidence)null, (Type)null);
            }
            else
            {
                if (!System.IO.IsolatedStorage.IsolatedStorage.IsRoaming(scope))
                {
                    caller.GetGrantSet(out newGrant, out newDenied);
                    if (newGrant == null)
                    {
                        throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_AssemblyGrantSet"));
                    }
                }
                this._InitStore(scope, (Evidence)null, (Type)null, caller.Evidence, assemblyEvidenceType, (Evidence)null, (Type)null);
            }
            this.SetQuota(newGrant, newDenied);
        }
Ejemplo n.º 2
0
        internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
        {
            PermissionSet grantedSet;
            PermissionSet refusedSet;

            asm.GetGrantSet(out grantedSet, out refusedSet);
            CodeAccessSecurityEngine.CheckHelper(grantedSet, refusedSet, demand, PermissionToken.GetToken(demand), RuntimeMethodHandleInternal.EmptyHandle, asm, SecurityAction.Demand, true);
        }
        internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
        {
            PermissionSet set;
            PermissionSet set2;

            asm.GetGrantSet(out set, out set2);
            CheckHelper(set, set2, demand, PermissionToken.GetToken(demand), RuntimeMethodHandleInternal.EmptyHandle, asm, SecurityAction.Demand, true);
        }
        internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
        {
            PermissionSet newGrant;
            PermissionSet newDenied;

            asm.GetGrantSet(out newGrant, out newDenied);
            CodeAccessSecurityEngine.CheckHelper(newGrant, newDenied, demand, PermissionToken.GetToken((IPermission)demand), RuntimeMethodHandleInternal.EmptyHandle, (object)asm, SecurityAction.Demand, true);
        }
Ejemplo n.º 5
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static void CheckAssembly(RuntimeAssembly asm, CodeAccessPermission demand)
        {
            Contract.Assert(asm != null, "Must pass in a good assembly");
            Contract.Assert(demand != null, "Must pass in a good demand");

            PermissionSet granted, refused;

            asm.GetGrantSet(out granted, out refused);
#pragma warning disable 618
            CheckHelper(granted, refused, demand, PermissionToken.GetToken(demand), RuntimeMethodHandleInternal.EmptyHandle, asm, SecurityAction.Demand, true);
#pragma warning restore 618
        }
        internal void InitStore(IsolatedStorageScope scope, object domain, object assem, object app)
        {
            PermissionSet newGrant  = null;
            PermissionSet newDenied = null;
            Evidence      domainEv  = null;
            Evidence      assemEv   = null;
            Evidence      appEv     = null;

            if (IsApp(scope))
            {
                EvidenceBase evidence = app as EvidenceBase;
                if (evidence == null)
                {
                    evidence = new LegacyEvidenceWrapper(app);
                }
                appEv = new Evidence();
                appEv.AddHostEvidence <EvidenceBase>(evidence);
            }
            else
            {
                EvidenceBase base3 = assem as EvidenceBase;
                if (base3 == null)
                {
                    base3 = new LegacyEvidenceWrapper(assem);
                }
                assemEv = new Evidence();
                assemEv.AddHostEvidence <EvidenceBase>(base3);
                if (IsDomain(scope))
                {
                    EvidenceBase base4 = domain as EvidenceBase;
                    if (base4 == null)
                    {
                        base4 = new LegacyEvidenceWrapper(domain);
                    }
                    domainEv = new Evidence();
                    domainEv.AddHostEvidence <EvidenceBase>(base4);
                }
            }
            this._InitStore(scope, domainEv, null, assemEv, null, appEv, null);
            if (!IsRoaming(scope))
            {
                RuntimeAssembly caller = GetCaller();
                GetControlEvidencePermission().Assert();
                caller.GetGrantSet(out newGrant, out newDenied);
                if (newGrant == null)
                {
                    throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_AssemblyGrantSet"));
                }
            }
            this.SetQuota(newGrant, newDenied);
        }
Ejemplo n.º 7
0
        internal void InitStore(IsolatedStorageScope scope, object domain, object assem, object app)
        {
            PermissionSet psAllowed = (PermissionSet)null;
            PermissionSet psDenied  = (PermissionSet)null;
            Evidence      domainEv  = (Evidence)null;
            Evidence      assemEv   = (Evidence)null;
            Evidence      appEv     = (Evidence)null;

            if (System.IO.IsolatedStorage.IsolatedStorage.IsApp(scope))
            {
                EvidenceBase evidence = app as EvidenceBase ?? (EvidenceBase) new LegacyEvidenceWrapper(app);
                appEv = new Evidence();
                appEv.AddHostEvidence <EvidenceBase>(evidence);
            }
            else
            {
                EvidenceBase evidence1 = assem as EvidenceBase ?? (EvidenceBase) new LegacyEvidenceWrapper(assem);
                assemEv = new Evidence();
                assemEv.AddHostEvidence <EvidenceBase>(evidence1);
                if (System.IO.IsolatedStorage.IsolatedStorage.IsDomain(scope))
                {
                    EvidenceBase evidence2 = domain as EvidenceBase ?? (EvidenceBase) new LegacyEvidenceWrapper(domain);
                    domainEv = new Evidence();
                    domainEv.AddHostEvidence <EvidenceBase>(evidence2);
                }
            }
            this._InitStore(scope, domainEv, (Type)null, assemEv, (Type)null, appEv, (Type)null);
            if (!System.IO.IsolatedStorage.IsolatedStorage.IsRoaming(scope))
            {
                RuntimeAssembly caller = System.IO.IsolatedStorage.IsolatedStorage.GetCaller();
                System.IO.IsolatedStorage.IsolatedStorage.GetControlEvidencePermission().Assert();
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                PermissionSet& newGrant = @psAllowed;
                // ISSUE: explicit reference operation
                // ISSUE: variable of a reference type
                PermissionSet& newDenied = @psDenied;
                caller.GetGrantSet(newGrant, newDenied);
                if (psAllowed == null)
                {
                    throw new IsolatedStorageException(Environment.GetResourceString("IsolatedStorage_AssemblyGrantSet"));
                }
            }
            this.SetQuota(psAllowed, psDenied);
        }