public RoleUserController(IRoleUser repoRoleUser
     , IRole repoRole, IPermission repoPer)
 {
     dalRoleUser = repoRoleUser;
     dalRole = repoRole;
     dalPermission = repoPer;
 }
	// Determine if a specific permission has been granted.
	public static bool IsGranted(IPermission perm)
			{
				// Bail out if the requested permission is null.
				if(perm == null)
				{
					return true;
				}

				// Get the current permission state.
				ClrPermissions current = ClrSecurity.GetPermissionsFrom(1);
				if(current == null)
				{
					// Null is equivalent to "unrestricted".
					return true;
				}

				// Build a permission set with just this permission.
				PermissionSet set = new PermissionSet(PermissionState.None);
				set.AddPermission(perm);

				// If "PermitOnly" is set, then only check that set.
				if(current.permitOnly != null)
				{
					return set.IsSubsetOf(current.permitOnly);
				}

				// The permission must be granted, but not denied.
				if(!set.IsSubsetOf(current.granted) ||
				   set.IsSubsetOf(current.denied))
				{
					return false;
				}
				return true;
			}
 public override bool IsSubsetOf(IPermission target)
 {
     bool flag;
     if (target == null)
     {
         return !this.unrestricted;
     }
     try
     {
         DistributedTransactionPermission permission = (DistributedTransactionPermission) target;
         if (!this.unrestricted)
         {
             return true;
         }
         if (permission.unrestricted)
         {
             return true;
         }
         flag = false;
     }
     catch (InvalidCastException)
     {
         throw new ArgumentException(System.Transactions.SR.GetString("ArgumentWrongType"), "target");
     }
     return flag;
 }
 public override IPermission Intersect(IPermission target)
 {
     if (target == null)
     {
         return null;
     }
     if (!base.VerifyType(target))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
     }
     SecurityPermission permission = (SecurityPermission) target;
     SecurityPermissionFlag noFlags = SecurityPermissionFlag.NoFlags;
     if (permission.IsUnrestricted())
     {
         if (this.IsUnrestricted())
         {
             return new SecurityPermission(PermissionState.Unrestricted);
         }
         noFlags = this.m_flags;
     }
     else if (this.IsUnrestricted())
     {
         noFlags = permission.m_flags;
     }
     else
     {
         noFlags = this.m_flags & permission.m_flags;
     }
     if (noFlags == SecurityPermissionFlag.NoFlags)
     {
         return null;
     }
     return new SecurityPermission(noFlags);
 }
 internal static SecurityElement CreatePermissionElement(IPermission perm, string permname)
 {
     SecurityElement element = new SecurityElement("IPermission");
     XMLUtil.AddClassAttribute(element, perm.GetType(), permname);
     element.AddAttribute("version", "1");
     return element;
 }
 public override bool IsSubsetOf(IPermission target)
 {
     bool flag;
     if (target == null)
     {
         return (this.access == FileDialogPermissionAccess.None);
     }
     try
     {
         FileDialogPermission permission = (FileDialogPermission) target;
         if (permission.IsUnrestricted())
         {
             return true;
         }
         if (this.IsUnrestricted())
         {
             return false;
         }
         int num = ((int) this.access) & 1;
         int num2 = ((int) this.access) & 2;
         int num3 = ((int) permission.Access) & 1;
         int num4 = ((int) permission.Access) & 2;
         flag = (num <= num3) && (num2 <= num4);
     }
     catch (InvalidCastException)
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
     }
     return flag;
 }
Ejemplo n.º 7
0
        public TestBase()
        {
            var builder = new ContainerBuilder();
               builder.RegisterType<DatabaseFactory>().As<IDatabaseFactory>().InstancePerLifetimeScope();
               builder.RegisterType<UnityOfWork>().As<IUnitOfWork>();

               builder.RegisterType<ContactRepostory>().AsImplementedInterfaces();
               builder.RegisterType<ContactServices>().AsImplementedInterfaces();
               builder.RegisterType<ProductRepository>().AsImplementedInterfaces();
               builder.RegisterType<LodgingRepository>().AsImplementedInterfaces();
               builder.RegisterType<ResortRepository>().AsImplementedInterfaces();

               builder.RegisterType<ProductService>().AsImplementedInterfaces();
               builder.RegisterType<LodgingService>().AsImplementedInterfaces();
               builder.RegisterType<ResortService>().AsImplementedInterfaces();

               #region 权限
               builder.RegisterType<PermissionModuleRepository>().AsImplementedInterfaces();
               builder.RegisterType<PermissionRoleRepository>().AsImplementedInterfaces();
               builder.RegisterType<PermissionReRoleModuleRepostory>().AsImplementedInterfaces();
               builder.RegisterType<PermissionSvc>().AsImplementedInterfaces();
               #endregion
               container= builder.Build();
               this.unitOfWork = container.Resolve<IUnitOfWork>();
               this.contact=container.Resolve<IContact>();
               this.productsvc=container.Resolve<IProduct>();
               this.resortSvc = container.Resolve<IResort>();
               this.lodgingsvc = container.Resolve<ILodging>();
               this.permissionSvc = container.Resolve<IPermission>();
             //  StartUp();
        }
 public override IPermission Intersect(IPermission target)
 {
     if (target == null)
     {
         return null;
     }
     if (!base.VerifyType(target))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
     }
     IsolatedStorageFilePermission permission = (IsolatedStorageFilePermission) target;
     if (permission.IsUnrestricted())
     {
         return this.Copy();
     }
     if (base.IsUnrestricted())
     {
         return target.Copy();
     }
     IsolatedStorageFilePermission permission2 = new IsolatedStorageFilePermission(PermissionState.None) {
         m_userQuota = IsolatedStoragePermission.min(base.m_userQuota, permission.m_userQuota),
         m_machineQuota = IsolatedStoragePermission.min(base.m_machineQuota, permission.m_machineQuota),
         m_expirationDays = IsolatedStoragePermission.min(base.m_expirationDays, permission.m_expirationDays),
         m_permanentData = base.m_permanentData && permission.m_permanentData,
         m_allowed = (IsolatedStorageContainment) ((int) IsolatedStoragePermission.min((long) base.m_allowed, (long) permission.m_allowed))
     };
     if ((((permission2.m_userQuota == 0L) && (permission2.m_machineQuota == 0L)) && ((permission2.m_expirationDays == 0L) && !permission2.m_permanentData)) && (permission2.m_allowed == IsolatedStorageContainment.None))
     {
         return null;
     }
     return permission2;
 }
     //------------------------------------------------------
     //
     // IPERMISSION IMPLEMENTATION
     //
     //------------------------------------------------------
     
     public override IPermission Union(IPermission target)
     {
         if (target == null)
         {
             return this.Copy();
         }
         else if (!VerifyType(target))
         {
             throw new 
                 ArgumentException(
                                 Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                                  );
         }
         
         IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target;
 
         if (this.IsUnrestricted() || operand.IsUnrestricted()) 
         {
             return new IsolatedStorageFilePermission( PermissionState.Unrestricted );
         }
         else
         {
             IsolatedStorageFilePermission union;
             union = new IsolatedStorageFilePermission( PermissionState.None );
             union.m_userQuota = max(m_userQuota,operand.m_userQuota);   
             union.m_machineQuota = max(m_machineQuota,operand.m_machineQuota);  
             union.m_expirationDays = max(m_expirationDays,operand.m_expirationDays);    
             union.m_permanentData = m_permanentData || operand.m_permanentData; 
             union.m_allowed = (IsolatedStorageContainment)max((long)m_allowed,(long)operand.m_allowed); 
             return union;
         }
     }   
        public override bool IsSubsetOf(IPermission target)
        {
            if (target == null)
            {
                return ((m_userQuota == 0) &&
                        (m_machineQuota == 0) &&
                        (m_expirationDays == 0) &&
                        (m_permanentData == false) &&
                        (m_allowed == IsolatedStorageContainment.None));
            }

            try
            {
                IsolatedStorageFilePermission operand = (IsolatedStorageFilePermission)target;

                if (operand.IsUnrestricted())
                    return true;

                return ((operand.m_userQuota >= m_userQuota) &&
                        (operand.m_machineQuota >= m_machineQuota) &&
                        (operand.m_expirationDays >= m_expirationDays) &&
                        (operand.m_permanentData || !m_permanentData) &&
                        (operand.m_allowed >= m_allowed));
            }
            catch (InvalidCastException)
            {
                throw new 
                    ArgumentException(
                                    Environment.GetResourceString("Argument_WrongType", this.GetType().FullName)
                                     );
            }                

        }
Ejemplo n.º 11
0
        public override IPermission Intersect(IPermission target)
        {
            //If nothing was passed, return null.
            if (null == target)
            {
                return null;
            }
            try
            {
                //Create a new instance of RobocodeInternalPermission from the passed object.
                var PassedPermission = (RobocodeInternalPermission) target;

                //If one class has an unrestricted value of false, then the
                //intersection will have an unrestricted value of false.
                //Return the passed class with the unrestricted value of false.
                if (!PassedPermission.unrestricted)
                {
                    return target;
                }
                //Return a copy of the current class if the passed one has
                //an unrestricted value of true.
                return Copy();
            }
                //Catch an InvalidCastException.
                //Throw ArgumentException to notify the user.
            catch (InvalidCastException)
            {
                throw new ArgumentException("Argument_WrongType", GetType().FullName);
            }
        }
      public override IPermission Intersect(IPermission target)
      {
          if (target == null)
              return null;

          return this.Copy();
      }
Ejemplo n.º 13
0
 [System.Security.SecurityCritical]  // auto-generated
 private static bool FrameDescHelper(FrameSecurityDescriptor secDesc,
                                        IPermission demandIn, 
                                        PermissionToken permToken,
                                        RuntimeMethodHandleInternal rmh)
 {
     return secDesc.CheckDemand((CodeAccessPermission) demandIn, permToken, rmh);
 }
Ejemplo n.º 14
0
		public override IPermission Intersect (IPermission target)
		{
			GacIdentityPermission gip = Cast (target);
			if (gip == null)
				return null;

			return Copy ();
		}
Ejemplo n.º 15
0
		public override bool IsSubsetOf (IPermission target)
		{
			ZoneIdentityPermission zip = Cast (target);
			if (zip == null)
				return (zone == SecurityZone.NoZone);

			return ((zone == SecurityZone.NoZone) || (zone == zip.zone));
		}
Ejemplo n.º 16
0
 public void Add(IPermission permission)
 {
     if (Permissions == null)
     {
         Permissions = new HashSet<IPermission>();
     }
     Permissions.Add(permission);
 }
Ejemplo n.º 17
0
		public override bool IsSubsetOf (IPermission target) 
		{
			DnsPermission dp = Cast (target);
			if (dp == null)
				return IsEmpty ();

			return (dp.IsUnrestricted () || (m_noRestriction == dp.m_noRestriction));
		}
        public ModuleController(IModule repoModule, IModuleFunction repoFun, IPermission repoAction)
        {
            dalModule = repoModule;
            dalFunction = repoFun;
            //dalAction = repoAction;
            dalPermission = repoAction;

        }
Ejemplo n.º 19
0
 public override bool IsSubsetOf(IPermission target) 
 { 
     if (target == null)
         return false; 
     if (!(target is GacIdentityPermission))
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
     return true;
 } 
Ejemplo n.º 20
0
 public override IPermission Intersect(IPermission target) 
 { 
     if (target == null)
         return null; 
     if (!(target is GacIdentityPermission))
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", this.GetType().FullName));
     return this.Copy();
 } 
Ejemplo n.º 21
0
		// IBuiltInPermission is internal but we can test it's values
		// using reflection.
		private int GetTokenIndex (IPermission p)
		{
			Type t = p.GetType ();
			int result = (int) t.InvokeMember ("System.Security.Permissions.IBuiltInPermission.GetTokenIndex", 
				BindingFlags.InvokeMethod | BindingFlags.NonPublic |  BindingFlags.Instance,
				null, p, null);
			return result;
		}
 static bool IsNotGranted(IPermission permission) {
     var securityComplex = ((SecurityBase)SecuritySystem.Instance);
     bool isGrantedForNonExistentPermission = securityComplex.IsGrantedForNonExistentPermission;
     securityComplex.IsGrantedForNonExistentPermission = true;
     bool granted = SecuritySystem.IsGranted(permission);
     securityComplex.IsGrantedForNonExistentPermission = isGrantedForNonExistentPermission;
     return granted;
 }
Ejemplo n.º 23
0
        public IPermission Intersect(IPermission other)
        {
            IList<String> permissions = GetOther(other).Permissions.Intersect(Permissions).ToList();

              return 0 != permissions.Count ?
            new PolicyPermission(permissions) :
            null;
        }
Ejemplo n.º 24
0
 public void AddObjectPermission(IPermission permission)
 {
     if (_objectPermissions == null)
     {
         _objectPermissions = new HashSet<IPermission>();
     }
     _objectPermissions.Add(permission);
 }
 public override IPermission Union(IPermission target)
 {
     if ((target != null) && !(target is GacIdentityPermission))
     {
         throw new ArgumentException(Environment.GetResourceString("Argument_WrongType", new object[] { base.GetType().FullName }));
     }
     return this.Copy();
 }
 public override bool IsSubsetOf(IPermission target) {
     var isSubsetOf = base.IsSubsetOf(target);
     if (isSubsetOf) {
         var stateMachineTransitionPermission = ((StateMachineTransitionPermission)target);
         return stateMachineTransitionPermission.StateCaption == StateCaption &&
                stateMachineTransitionPermission.StateMachineName == StateMachineName;
     }
     return false;
 }
Ejemplo n.º 27
0
		public override IPermission Intersect (IPermission target)
		{
			DnsPermission dp = Cast (target);
			if (dp == null)
				return null;
			if (IsUnrestricted () && dp.IsUnrestricted ())
				return new DnsPermission (PermissionState.Unrestricted);
			return null;
		}
 private static XamlLoadPermission CastPermission(IPermission other, string argName)
 {
     XamlLoadPermission permission = other as XamlLoadPermission;
     if (permission == null)
     {
         throw new ArgumentException(System.Xaml.SR.Get("ExpectedLoadPermission"), argName);
     }
     return permission;
 }
Ejemplo n.º 29
0
        public Boolean IsSubsetOf(IPermission other)
        {
            PolicyPermission policyPermission = GetOther(other);

              foreach (String permission in Permissions)
            if (false == policyPermission.Permissions.Contains(permission))
              return false;

              return true;
        }
        //
        // Public APIs
        //

        public static bool IsGranted( IPermission perm )
        {
            if (perm == null)
                return true;

            PermissionSet granted, denied;
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
            _GetGrantedPermissions( out granted, out denied, ref stackMark );
            return granted.Contains( perm ) && (denied == null || !denied.Contains( perm ));
        }
Ejemplo n.º 31
0
        public void KeyContainer()
        {
            IPermission p = (IPermission) new KeyContainerPermission(PermissionState.None);

            Assert.AreEqual(16, GetTokenIndex(p));
        }
Ejemplo n.º 32
0
 public SecurityException(string message, object deny, object permitOnly, MethodInfo method, object demanded, IPermission permThatFailed) : base(message)
 {
     PermissionSet.s_fullTrust.Assert();
     base.SetErrorCode(-2146233078);
     this.Action = SecurityAction.Demand;
     if (permThatFailed != null)
     {
         this.m_typeOfPermissionThatFailed = permThatFailed.GetType();
     }
     this.FirstPermissionThatFailed = permThatFailed;
     this.Demanded              = demanded;
     this.m_granted             = "";
     this.m_refused             = "";
     this.DenySetInstance       = deny;
     this.PermitOnlySetInstance = permitOnly;
     this.m_assemblyName        = null;
     this.Method        = method;
     this.m_zone        = SecurityZone.NoZone;
     this.m_url         = "";
     this.m_debugString = this.ToString(true, false);
 }
Ejemplo n.º 33
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();
     base.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 hostEvidence = evidence.GetHostEvidence <System.Security.Policy.Url>();
         if (hostEvidence != null)
         {
             this.m_url = hostEvidence.GetURLString().ToString();
         }
         System.Security.Policy.Zone zone = evidence.GetHostEvidence <System.Security.Policy.Zone>();
         if (zone != null)
         {
             this.m_zone = zone.SecurityZone;
         }
     }
     this.m_debugString = this.ToString(true, false);
 }
Ejemplo n.º 34
0
        internal static Exception MakeSecurityException(AssemblyName asmName, Evidence asmEvidence, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, object demand, IPermission permThatFailed)
        {
            HostProtectionPermission permission = permThatFailed as HostProtectionPermission;

            if (permission != null)
            {
                return(new HostProtectionException(GetResString("HostProtection_HostProtection"), HostProtectionPermission.protectedResources, permission.Resources));
            }
            string     message = "";
            MethodInfo method  = null;

            try
            {
                if (((granted == null) && (refused == null)) && (demand == null))
                {
                    message = GetResString("Security_NoAPTCA");
                }
                else if ((demand != null) && (demand is IPermission))
                {
                    message = string.Format(CultureInfo.InvariantCulture, GetResString("Security_Generic"), new object[] { demand.GetType().AssemblyQualifiedName });
                }
                else if (permThatFailed != null)
                {
                    message = string.Format(CultureInfo.InvariantCulture, GetResString("Security_Generic"), new object[] { permThatFailed.GetType().AssemblyQualifiedName });
                }
                else
                {
                    message = GetResString("Security_GenericNoType");
                }
                method = SecurityRuntime.GetMethodInfo(rmh);
            }
            catch (Exception exception)
            {
                if (exception is ThreadAbortException)
                {
                    throw;
                }
            }
            return(new SecurityException(message, asmName, granted, refused, method, action, demand, permThatFailed, asmEvidence));
        }
Ejemplo n.º 35
0
 /// <summary>Adds a specified permission to the <see cref="T:System.Security.PermissionSet" />.</summary>
 /// <returns>The union of the permission added and any permission of the same type that already exists in the <see cref="T:System.Security.PermissionSet" />.</returns>
 /// <param name="perm">The permission to add. </param>
 /// <PermissionSet>
 ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" />
 /// </PermissionSet>
 public IPermission AddPermission(IPermission perm)
 {
     return(perm);
 }
Ejemplo n.º 36
0
        public void Environment()
        {
            IPermission p = (IPermission) new EnvironmentPermission(PermissionState.None);

            Assert.AreEqual(0, GetTokenIndex(p));
        }
 public override IPermission Union(IPermission target)
 {
     return(default(IPermission));
 }
 public override bool IsSubsetOf(IPermission target)
 {
     return(false);
 }
 public override IPermission Union(IPermission target)
 {
     return(null);
 }
 public override IPermission Intersect(IPermission target)
 {
     return(default(IPermission));
 }
Ejemplo n.º 41
0
 public override bool IsSubsetOf(IPermission target) => false;
Ejemplo n.º 42
0
 } //Copy()
 
 public override IPermission Intersect(IPermission target) 
 {
   if (target == null) return null;
   if (typeof(myperm) != target.GetType()) return null;
   return new myperm();
 } //Intersect()
Ejemplo n.º 43
0
        public void Principal()
        {
            IPermission p = (IPermission) new PrincipalPermission(PermissionState.None);

            Assert.AreEqual(8, GetTokenIndex(p));
        }
Ejemplo n.º 44
0
        public void GacIdentity()
        {
            IPermission p = (IPermission) new GacIdentityPermission(PermissionState.None);

            Assert.AreEqual(15, GetTokenIndex(p));
        }
 public override IPermission Intersect(IPermission target)
 {
     return(null);
 }
Ejemplo n.º 46
0
  } //Intersect()

  public override IPermission Union(IPermission target) 
  {
    if (target == null) return new myperm();
    if (typeof(myperm) != target.GetType()) return null;
    return new myperm();
  } //Union()
Ejemplo n.º 47
0
  } //FromXml()

  public override bool IsSubsetOf(IPermission target) 
  {
    if (target == null) return false;
    if (typeof(myperm) != target.GetType()) return false;
    return true;
  } //IsSubsetOf()
Ejemplo n.º 48
0
        internal PermissionToken GetToken(Type cls, IPermission perm)
        {
            Contract.Assert(cls != null, "Must pass in valid type");

            IntPtr typePtr = cls.TypeHandle.Value;
            object tok     = m_handleTable[typePtr];

            if (tok == null)
            {
                String typeStr = cls.AssemblyQualifiedName;
                tok = m_tokenTable != null ? m_tokenTable[typeStr] : null; // Assumes asynchronous lookups are safe

                if (tok == null)
                {
                    lock (this)
                    {
                        if (m_tokenTable != null)
                        {
                            tok = m_tokenTable[typeStr]; // Make sure it wasn't just added
                        }
                        else
                        {
                            m_tokenTable = new Hashtable(m_size, 1.0f, new PermissionTokenKeyComparer());
                        }

                        if (tok == null)
                        {
                            if (perm != null)
                            {
                                tok = new PermissionToken(m_index++, PermissionTokenType.IUnrestricted, typeStr);
                            }
                            else
                            {
                                if (cls.GetInterface(s_unrestrictedPermissionInferfaceName) != null)
                                {
                                    tok = new PermissionToken(m_index++, PermissionTokenType.IUnrestricted, typeStr);
                                }
                                else
                                {
                                    tok = new PermissionToken(m_index++, PermissionTokenType.Normal, typeStr);
                                }
                            }
                            m_tokenTable.Add(typeStr, tok);
                            m_indexTable.Add(m_index - 1, tok);
                            PermissionToken.s_tokenSet.SetItem(((PermissionToken)tok).m_index, tok);
                        }

                        if (!m_handleTable.Contains(typePtr))
                        {
                            m_handleTable.Add(typePtr, tok);
                        }
                    }
                }
                else
                {
                    lock (this)
                    {
                        if (!m_handleTable.Contains(typePtr))
                        {
                            m_handleTable.Add(typePtr, tok);
                        }
                    }
                }
            }

            if ((((PermissionToken)tok).m_type & PermissionTokenType.DontKnow) != 0)
            {
                if (perm != null)
                {
                    Contract.Assert(!(perm is IBuiltInPermission), "This should not be called for built-ins");
                    ((PermissionToken)tok).m_type = PermissionTokenType.IUnrestricted;
                }
                else
                {
                    Contract.Assert(cls.GetInterface("System.Security.Permissions.IBuiltInPermission") == null, "This shoudl not be called for built-ins");
                    if (cls.GetInterface(s_unrestrictedPermissionInferfaceName) != null)
                    {
                        ((PermissionToken)tok).m_type = PermissionTokenType.IUnrestricted;
                    }
                    else
                    {
                        ((PermissionToken)tok).m_type = PermissionTokenType.Normal;
                    }
                }
            }

            return((PermissionToken)tok);
        }
Ejemplo n.º 49
0
        public void UI()
        {
            IPermission p = (IPermission) new UIPermission(PermissionState.None);

            Assert.AreEqual(7, GetTokenIndex(p));
        }