Esempio n. 1
0
        public Project(
            string name, 
            ISet<ProjectType> projectTypes, 
            string info, 
            ProjectStatus projectStatus, 
            Image landingImage, 
            AccessLevel accessLevel,
            VersionControlSystemInfo versionControlSystemInfo,
            RedmineProjectInfo redmineProjectInfo, 
            ISet<Issue> issues, 
            ISet<ProjectMembership> projectDevelopers,
            ISet<Image> screenshots)
        {
            Require.NotEmpty(name, nameof(name));
            Require.NotNull(info, nameof(info));
            Require.NotNull(versionControlSystemInfo, nameof(versionControlSystemInfo));
            Require.NotNull(redmineProjectInfo, nameof(redmineProjectInfo));
            Require.NotEmpty(projectTypes, nameof(projectTypes));

            Name = name;
            ProjectTypes = projectTypes;
            AccessLevel = accessLevel;
            Info = info;
            ProjectStatus = projectStatus;
            LandingImage = landingImage;
            VersionControlSystemInfo = versionControlSystemInfo;
            RedmineProjectInfo = redmineProjectInfo;
            Issues = issues ?? new HashSet<Issue>();
            ProjectMemberships = projectDevelopers ?? new HashSet<ProjectMembership>();
            Screenshots = screenshots ?? new HashSet<Image>();
        }
Esempio n. 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="accessLevel">访问级别</param>
 /// <param name="cacheType">缓存的类型</param>
 /// <param name="isStoreInDb">是否存储到DB</param>
 public SchemaTable(AccessLevel accessLevel, CacheType cacheType, bool isStoreInDb)
 {
     AccessLevel = accessLevel;
     CacheType = cacheType;
     Keys = new string[0];
     _columns = new ConcurrentDictionary<string, SchemaColumn>();
 }
Esempio n. 3
0
 public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
     : base(property, string.Format(
     "You must be at least {0} to {1} this property.",
     Mobile.GetAccessLevelName(neededAccess),
     accessType))
 {
 }
Esempio n. 4
0
        public override void OnDoubleClick(Mobile from)
        {
            if (m_User == from && from.AccessLevel == AccessLevel.Player)
            {
                try
                {
                    from.AccessLevel = m_AL;
                    m_User = null;
                    m_AL = AccessLevel.Player;

                    if ( !from.Alive )
                    {
                        from.Hidden = true;
                        from.Resurrect();
                    }
                }
                catch
                {
                    from.SendMessage("An error occurred... Contact your supervisor or something! Don't stand there. I get so tired of people like you, gosh.");
                }
            }
            else if (m_User == null && from.AccessLevel > AccessLevel.Player)
            {
                m_AL = from.AccessLevel;
                m_User = from;
                from.AccessLevel = AccessLevel.Player;

                if ( from.Backpack != null && (!this.IsChildOf(from) || !this.IsAccessibleTo(from)))
                    from.Backpack.DropItem(this);
            }
            else
            {
                from.SendMessage("You can't use this...");
            }
        }
Esempio n. 5
0
        public bool IsGranted(AccessComponent component, AccessLevel requiredLevel)
        {
            AccessLevel storedLevel;
            if (!AccessDict.TryGetValue(component, out storedLevel)) return false;

            return storedLevel >= requiredLevel;
        }
Esempio n. 6
0
 public ComponentInfo(Component component, AccessLevel access)
 {
     ComponentId = component.ComponentId;
     Name = component.ComponentName;
     IsReadOnlyAccess = component.IsReadOnlyAccess;
     AccessLevel = access;
 }
Esempio n. 7
0
		public override bool OnEquip(Mobile from)
		{
			m_Wearer = from;
			m_PrevLevel = from.AccessLevel;
			from.AccessLevel = AccessLevel.Player;
			return true;
		}
 public void UpdatedAccessLevelEventArgsConstructorTest()
 {
     AccessLevel oldAccessLevel = new AccessLevel(); // TODO: 初始化为适当的值
     BaseCharacter character = null; // TODO: 初始化为适当的值
     UpdatedAccessLevelEventArgs target = new UpdatedAccessLevelEventArgs( oldAccessLevel, character );
     Assert.Inconclusive( "TODO: 实现用来验证目标的代码" );
 }
Esempio n. 9
0
        public AdminProject(
            int projectId,
            string name,
            ProjectType[] projectType,
            string info,
            ProjectStatus projectStatus,
            Common.Image landingImage,
            AccessLevel accessLevel,
            Uri versionControlSystemUri,
            Uri projectManagementSystemUri,
            HashSet<Issue> issues,
            HashSet<ProjectMembership> projectDevelopers,
            HashSet<Common.Image> screenshots)
        {
            Require.Positive(projectId, nameof(projectId));
            Require.NotEmpty(name, nameof(name));
            Require.NotNull(info, nameof(info));
            Require.NotNull(versionControlSystemUri, nameof(versionControlSystemUri));
            Require.NotNull(projectManagementSystemUri, nameof(projectManagementSystemUri));

            ProjectId = projectId;
            Name = name;
            ProjectType = projectType ?? new[] {Common.ProjectType.Other};
            AccessLevel = accessLevel;
            Info = info;
            ProjectStatus = projectStatus;
            LandingImage = landingImage;
            VersionControlSystemUri = versionControlSystemUri;
            ProjectManagementSystemUri = projectManagementSystemUri;
            Issues = issues ?? new HashSet<Issue>();
            ProjectMemberships = projectDevelopers ?? new HashSet<ProjectMembership>();
            Screenshots = screenshots ?? new HashSet<Common.Image>();
        }
Esempio n. 10
0
		public TypeDefinitionStatement(AccessLevel accessLevel, String name) : base(StatementType.TypeDefinition)
		{
			statements = new ASTNodeCollection(this);

			this.accessLevel = accessLevel;
			this.name = name;
		}
        //Use only ASCII messages, not unicode.
		public static void Broadcast( AccessLevel level, int font, int hue, string text, string channel )
		{
			ArrayList mobiles = NetState.Instances;

			for( int i = 0; i < mobiles.Count; i++ )
				BroadcastTo( (NetState)mobiles[i], level, font, hue, text );
		}
 public static IEnumerable<TDSMCommandInfo> GetTDSMCommandsForAccessLevel(this OTA.Commands.CommandParser parser, AccessLevel accessLevel)
 {
     return OTA.Commands.CommandManager.Parser.commands
         .Where(x => x.Value is TDSMCommandInfo)
         .Select(y => y.Value as TDSMCommandInfo)
         .Where(z => z._accessLevel.HasValue && z._accessLevel == accessLevel);
 }
Esempio n. 13
0
        public static void Access( string command, AccessLevel level )
        {
            try{

            if ( Server.Commands.Entries[command] == null )
                return;

            DefaultInfo info = new DefaultInfo();

            if ( !HasMod( command ) )
            {
                info = new DefaultInfo();
                info.OldCommand = command;
                info.NewCommand = command;
                info.NewAccess = level;
                info.OldAccess = ((CommandEntry)Server.Commands.Entries[command]).AccessLevel;
                s_Defaults[command] = info;
            }
            else
            {
                info = (DefaultInfo)s_Defaults[command];
                info.NewAccess = level;
            }

            CommandEntry entry = new CommandEntry( command, ((CommandEntry)Server.Commands.Entries[command]).Handler, info.NewAccess );
            Server.Commands.Entries[command] = entry;

            foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
                foreach( string str in new ArrayList( imp.Commands.Keys ) )
                    if ( str == command )
                        ((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;

            }catch{ Errors.Report( "Commands-> Access-> AccessLevel" ); }
        }
Esempio n. 14
0
 //protected bool Equals(UserAccount other)
 //{
 //    return this.IsActive.Equals(other.IsActive)
 //        && string.Equals(this.Id, other.Id)
 //        && string.Equals(this.FirstName, other.FirstName)
 //        && string.Equals(this.LastName, other.LastName)
 //        && this.AccessLevel == other.AccessLevel;
 //}
 //public override bool Equals(object obj)
 //{
 //    if (ReferenceEquals(null, obj))
 //    {
 //        return false;
 //    }
 //    if (ReferenceEquals(this, obj))
 //    {
 //        return true;
 //    }
 //    if (obj.GetType() != this.GetType())
 //    {
 //        return false;
 //    }
 //    return Equals((UserAccount)obj);
 //}
 //public override int GetHashCode()
 //{
 //    unchecked
 //    {
 //        int hashCode = this.IsActive.GetHashCode();
 //        hashCode = (hashCode * 397) ^ (this.Id != null ? this.Id.GetHashCode() : 0);
 //        hashCode = (hashCode * 397) ^ (this.FirstName != null ? this.FirstName.GetHashCode() : 0);
 //        hashCode = (hashCode * 397) ^ (this.LastName != null ? this.LastName.GetHashCode() : 0);
 //        hashCode = (hashCode * 397) ^ (int)this.AccessLevel;
 //        return hashCode;
 //    }
 //}
 //public static bool operator ==(UserAccount left, UserAccount right)
 //{
 //    return Equals(left, right);
 //}
 //public static bool operator !=(UserAccount left, UserAccount right)
 //{
 //    return !Equals(left, right);
 //}
 public UserAccount(int id, string firstName, string lastName, AccessLevel accessLevel)
 {
     Id = id;
     FirstName = firstName;
     LastName = lastName;
     AccessLevel = accessLevel;
 }
Esempio n. 15
0
		public static void Initialize()
		{
			m_Threads = new ArrayList();
			m_Moderators = new ArrayList();
			m_PlayerStatistics = new Hashtable();

			Server.EventSink.WorldSave += new WorldSaveEventHandler( EventSink_WorldSave );
            CommandSystem.Register( "Forum", AccessLevel.Player, new CommandEventHandler( ViewForums_OnCommand ) );
            CommandSystem.Register( "Forums", AccessLevel.Player, new CommandEventHandler( ViewForums_OnCommand ) );
			
			Console.Write( "Ingame Forums: " );
			
			if( File.Exists( Path.Combine( m_SavePath, "forumdata.sig" ) ) )
			{
				Load();
			}
			else
			{
				Console.WriteLine( "No save file was found. Using default settings." );
				m_ThreadLockAccesLevel = AccessLevel.GameMaster;
				m_ThreadDeleteAccessLevel = AccessLevel.Administrator;
				m_AutoCleanup = false;
				m_AutoCleanupDays = 30;
				m_MinPostCharactersCount = 5;
				m_MaxPostCharactersCount = 10000;
			}
		}
Esempio n. 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="route"></param>
 /// <param name="method"></param>
 /// <param name="isSecure"></param>
 /// <param name="roleLevel"></param>
 public ApiAttribute(string route, ApiMethod method, bool isSecure, AccessLevel roleLevel)
 {
     this._route = route;
     this._method = method;
     this._isSecure = isSecure;
     this._roleLevel = (int)roleLevel;
 }
Esempio n. 17
0
 public AccessLevelStone() : base( 0x1870 )
     {
     Weight = 1.0;
     Hue = 0x38;
     Name = "Staff To Player To Staff To ..."; //Je.
     LootType = LootType.Blessed;
     m_StoredAccessLevel = AccessLevel.Player;
     }
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberOrderHelper"/> struct.
        /// </summary>
        /// <param name="member">The member to wrap.</param>
        public MemberOrderHelper(MemberDeclarationSyntax member)
        {
            this.Member = member;
            var modifiers = member.GetModifiers();

            this.modifierFlags = GetModifierFlags(modifiers);
            this.accessibilty = AccessLevelHelper.GetAccessLevel(modifiers);
        }
 /// <summary>
 /// Creates a new function.
 /// </summary>
 /// <param name="name">The name of this function.</param>
 /// <param name="returnType">The return type of this function, including reference type.</param>
 /// <param name="accessModifier">The access modifier for this function.</param>
 /// <param name="isVirtual">Whether this function is virtual, i.e., designed to be overriden.</param>
 /// <param name="args">A list of arguments to this function.</param>
 public FunctionDeclaration(string name, TypeReference returnType, AccessLevel accessModifier, bool isVirtual, params VariableDeclaration[] args)
 {
     Name = name;
     ReturnType = returnType;
     AccessModifier = accessModifier;
     Virtual = isVirtual;
     Arguments = args.ToList();
 }
Esempio n. 20
0
 public Command(AccessLevel requiredLevel, string trigger, string description, string usage, Func<IRequest, Task> handler)
 {
     this.RequiredLevel = requiredLevel;
     this.Trigger = trigger;
     this.Description = description;
     this.Usage = usage;
     this.Handler = handler;
 }
 public Authentification(string username, string password, AccessLevel level)
 {
     Username = username;
     Password = password;
     this.AccessLevel = level;
     var guid = Guid.NewGuid();
     AccessToken = Convert.ToBase64String(guid.ToByteArray());
 }
Esempio n. 22
0
		public UOFCentralOptions()
			: base(typeof(UOFCentral))
		{
			PopupCommand = "UOF";
			LoginPopup = false;
			VirtuePopup = true;
			EditAccess = UOFCentral.Access;
		}
 public void ReadLevelTest()
 {
     AccessLevel level = new AccessLevel(); // TODO: 初始化为适当的值
     CommandPropertyAttribute target = new CommandPropertyAttribute( level ); // TODO: 初始化为适当的值
     AccessLevel actual;
     actual = target.ReadLevel;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
Esempio n. 24
0
        public AccessLevel GetAccessFlag(string name, AccessLevel defaultValue = default(AccessLevel), bool required = false)
        {
            AccessLevel level;
            if (GetAccessFlag(name, out level, required))
                return level;

            return defaultValue;
        }
 public static bool HasAccess(AccessLevel channelAccess, AccessLevel level)
 {
     if (level == AccessLevel.None)
         return channelAccess == AccessLevel.None;
     else if (level == AccessLevel.Normal)
         return channelAccess == AccessLevel.Normal || channelAccess == AccessLevel.Admin;
     else
         return channelAccess == AccessLevel.Admin;
 }
Esempio n. 26
0
 public StaffTool()
     : base(0x0E73)
 {
     Weight = 0.0;
     Name = "Unassigned Staff Stone";
     LootType = LootType.Blessed;
     m_StaffLevel = AccessLevel.Player;
     deleting = false;
 }
Esempio n. 27
0
		public PvPBattleCommandInfo(
			string command, string desc, string usage, AccessLevel access, Func<PvPBattleCommandState, bool> handler)
		{
			Command = command;
			Description = desc;
			Usage = usage;
			Access = access;
			Handler = handler;
		}
Esempio n. 28
0
 public static void Register(string name,
                             dynamic callback,
                             uint minArgs = 0,
                             uint maxArgs = 0,
                             AccessLevel access = AccessLevel.Unregistered,
                             uint rateControl = 0)
 {
     Commands.Add(name, new Command(callback, name, access, minArgs, maxArgs, rateControl));
 }
 public void OldAccessLevelTest()
 {
     AccessLevel oldAccessLevel = new AccessLevel(); // TODO: 初始化为适当的值
     BaseCharacter character = null; // TODO: 初始化为适当的值
     UpdatedAccessLevelEventArgs target = new UpdatedAccessLevelEventArgs( oldAccessLevel, character ); // TODO: 初始化为适当的值
     AccessLevel actual;
     actual = target.OldAccessLevel;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
Esempio n. 30
0
 public static void BroadcastMessage(AccessLevel ac, int hue, string message)
 {
     foreach (NetState state in NetState.Instances)
     {
         Mobile m = state.Mobile;
         if (m != null && m.AccessLevel >= ac)
             m.SendMessage(hue, message);
     }
 }
Esempio n. 31
0
 public ClearanceException(Property property, AccessLevel playerAccess, AccessLevel neededAccess, string accessType)
     : base(property,
            $"You must be at least {Mobile.GetAccessLevelName(neededAccess)} to {accessType} this property.")
 {
 }
Esempio n. 32
0
 public void SetAccessLevel(AccessLevel value)
 {
     AccessLevel_Binder = (uint)value;
 }
Esempio n. 33
0
 public TransferAccess(AccessLevel level)
 {
     m_Level = level;
 }
Esempio n. 34
0
 public static void Register(string command, AccessLevel access, CommandEventHandler handler)
 {
     CommandSystem.Register(command, access, handler);
 }
Esempio n. 35
0
 public void SetAccessLevel(AccessLevel accountAccesslevel)
 {
     AccessLevel = accountAccesslevel;
 }
Esempio n. 36
0
        public static TokenInfo ParseToken(string token, bool validateHmac = true)
        {
            TokenInfo ti = new TokenInfo();

            var parts        = token.Split('.');
            var headerBase64 = parts[0];
            var bodyBase64   = parts[1];
            var signature    = parts[2];

            // parse the header and body into objects
            var headerJson = Encoding.UTF8.GetString(JwtUtil.Base64UrlDecode(headerBase64));
            var headerData = JObject.Parse(headerJson);
            var bodyJson   = Encoding.UTF8.GetString(JwtUtil.Base64UrlDecode(bodyBase64));
            var bodyData   = JObject.Parse(bodyJson);

            // verify algorithm
            var algorithm = (string)headerData["alg"];

            if (algorithm != "HS256")
            {
                throw new NotSupportedException("Only HS256 is supported for this algorithm.");
            }

            if (validateHmac)
            {
                // verify signature
                byte[] bytesToSign = GetBytes(string.Join(".", headerBase64, bodyBase64));
                var    alg         = new HMACSHA256(Convert.FromBase64String(HmacSecret));
                var    hash        = alg.ComputeHash(bytesToSign);
                var    computedSig = JwtUtil.Base64UrlEncode(hash);

                if (computedSig != signature)
                {
                    throw new AuthenticationException("Invalid JWT signature");
                }
            }

            // verify expiration
            var expirationUtc = JwtUtil.ConvertFromUnixTimestamp((long)bodyData["exp"]);

            if (DateTime.UtcNow > expirationUtc)
            {
                throw new AuthenticationException("Token has expired");
            }

            // verify audience
            var jwtAudience = (string)bodyData["aud"];

            if (jwtAudience != JwtManager.AceAudience)
            {
                throw new AuthenticationException($"Invalid audience '{jwtAudience}'.  Expected '{JwtManager.AceAudience}'.");
            }

            ti.Name = (string)bodyData["account_name"];

            /// TODO: Convert to SecurityLevel instead of AccessLevel
            AccessLevel   thisGuy = AccessLevel.Player;
            List <string> roles   = new List <string>();

            if (Enum.TryParse((string)bodyData["role"], out thisGuy))
            {
                foreach (AccessLevel level in Enum.GetValues(typeof(AccessLevel)))
                {
                    if (thisGuy >= level)
                    {
                        roles.Add(level.ToString());
                    }
                }
            }

            ti.AccountGuid   = Guid.Parse((string)bodyData["account_guid"]);
            ti.IssuingServer = (string)bodyData["issuing_server"];

            return(ti);
        }
Esempio n. 37
0
        public Account(XmlElement node)
        {
            m_Username = Utility.GetText(node["username"], "empty");

            string plainPassword    = Utility.GetText(node["password"], null);
            string cryptPassword    = Utility.GetText(node["cryptPassword"], null);
            string newCryptPassword = Utility.GetText(node["newCryptPassword"], null);

            switch (AccountHandler.ProtectPasswords)
            {
            case PasswordProtection.None:
            {
                if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            case PasswordProtection.Crypt:
            {
                if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }

            default:                     // PasswordProtection.NewCrypt
            {
                if (newCryptPassword != null)
                {
                    m_NewCryptPassword = newCryptPassword;
                }
                else if (plainPassword != null)
                {
                    SetPassword(plainPassword);
                }
                else if (cryptPassword != null)
                {
                    m_CryptPassword = cryptPassword;
                }
                else
                {
                    SetPassword("empty");
                }

                break;
            }
            }

            m_AccessLevel = (AccessLevel)Enum.Parse(typeof(AccessLevel), Utility.GetText(node["accessLevel"], "Player"), true);
            m_Flags       = Utility.GetInt32(Utility.GetText(node["flags"], "0"), 0);
            m_Created     = Utility.GetDateTime(Utility.GetText(node["created"], null), DateTime.Now);
            m_LastLogin   = Utility.GetDateTime(Utility.GetText(node["lastLogin"], null), DateTime.Now);

            m_Mobiles        = LoadMobiles(node);
            m_Comments       = LoadComments(node);
            m_Tags           = LoadTags(node);
            m_LoginIPs       = LoadAddressList(node);
            m_IPRestrictions = LoadAccessCheck(node);

            for (int i = 0; i < m_Mobiles.Length; ++i)
            {
                if (m_Mobiles[i] != null)
                {
                    m_Mobiles[i].Account = this;
                }
            }

            TimeSpan totalGameTime = Utility.GetTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero);

            if (totalGameTime == TimeSpan.Zero)
            {
                for (int i = 0; i < m_Mobiles.Length; i++)
                {
                    PlayerMobile m = m_Mobiles[i] as PlayerMobile;

                    if (m != null)
                    {
                        totalGameTime += m.GameTime;
                    }
                }
            }
            m_TotalGameTime = totalGameTime;

            if (this.Young)
            {
                CheckYoung();
            }

            Accounts.Add(this);
        }
Esempio n. 38
0
 public CommandPropertyAttribute(AccessLevel readLevel, AccessLevel writeLevel)
 {
     m_ReadLevel  = readLevel;
     m_WriteLevel = writeLevel;
 }
Esempio n. 39
0
 public ReadAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
     : base(property, playerAccess, neededAccess, "read")
 {
 }
Esempio n. 40
0
 public CommandPropertyAttribute(AccessLevel level, bool readOnly)
 {
     m_ReadLevel = level;
     m_ReadOnly  = readOnly;
 }
Esempio n. 41
0
 public CommandPropertyAttribute(AccessLevel level) : this(level, level)
 {
 }
Esempio n. 42
0
 public ConstructableAttribute(AccessLevel accessLevel)
 {
     m_AccessLevel = accessLevel;
 }
Esempio n. 43
0
        private static async Task AssertPermissions(User granter, User receiver, string path, AccessLevel level)
        {
            // Seems like there's some time delay before the permission realm is updated
            await Task.Delay(500);

            var granted  = (await granter.GetGrantedPermissionsAsync(Recipient.OtherUser)).SingleOrDefault(p => p.UserId == receiver.Identity);
            var received = (await receiver.GetGrantedPermissionsAsync(Recipient.CurrentUser)).SingleOrDefault(p => p.Path == path);

            if (level > AccessLevel.None)
            {
                Assert.That(granted, Is.Not.Null);
                Assert.That(granted.Path, Is.EqualTo(path));

                Assert.That(received, Is.Not.Null);
                Assert.That(received.MayRead, Is.EqualTo(level >= AccessLevel.Read));
                Assert.That(received.MayWrite, Is.EqualTo(level >= AccessLevel.Write));
                Assert.That(received.MayManage, Is.EqualTo(level >= AccessLevel.Admin));
            }
            else
            {
                Assert.That(granted, Is.Null);
                Assert.That(received, Is.Null);
            }
        }
Esempio n. 44
0
 public GrantAccessData(AccessLevel access, int durationInSeconds)
 {
     Access            = access;
     DurationInSeconds = durationInSeconds;
 }
 // Methods
 public CommandEntry(string command, CommandEventHandler handler, AccessLevel accessLevel)
 {
     this.m_Command     = command;
     this.m_Handler     = handler;
     this.m_AccessLevel = accessLevel;
 }
Esempio n. 46
0
 private static MembershipLevels TestMembership(AccessLevel accessLevel, MembershipLevels membershipLevel)
 {
     return(((int)accessLevel & (int)membershipLevel) == (int)membershipLevel ? membershipLevel : MembershipLevels.None);
 }
Esempio n. 47
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="access">no used</param>
 protected ShareEntity(AccessLevel access)
     : base(access)
 {
 }
Esempio n. 48
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 11:
            {
                // Version 11, we move all bools to a CorpseFlag
                m_Flags = (CorpseFlag)reader.ReadInt();

                m_TimeOfDeath = reader.ReadDeltaTime();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    Item item = reader.ReadItem();

                    if (reader.ReadBool())
                    {
                        SetRestoreInfo(item, reader.ReadPoint3D());
                    }
                    else if (item != null)
                    {
                        SetRestoreInfo(item, item.Location);
                    }
                }

                if (reader.ReadBool())
                {
                    BeginDecay(reader.ReadDeltaTime() - DateTime.Now);
                }

                m_Looters = reader.ReadStrongMobileList();
                m_Killer  = reader.ReadMobile();

                m_Aggressors = reader.ReadStrongMobileList();
                m_Owner      = reader.ReadMobile();

                m_CorpseName = reader.ReadString();

                m_AccessLevel = (AccessLevel)reader.ReadInt();
                reader.ReadInt();         // guild reserve
                m_Kills = reader.ReadInt();

                m_EquipItems = reader.ReadStrongItemList();
                break;
            }

            case 10:
            {
                m_TimeOfDeath = reader.ReadDeltaTime();

                goto case 9;
            }

            case 9:
            {
                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    Item item = reader.ReadItem();

                    if (reader.ReadBool())
                    {
                        SetRestoreInfo(item, reader.ReadPoint3D());
                    }
                    else if (item != null)
                    {
                        SetRestoreInfo(item, item.Location);
                    }
                }

                goto case 8;
            }

            case 8:
            {
                SetFlag(CorpseFlag.VisitedByTaxidermist, reader.ReadBool());

                goto case 7;
            }

            case 7:
            {
                if (reader.ReadBool())
                {
                    BeginDecay(reader.ReadDeltaTime() - DateTime.Now);
                }

                goto case 6;
            }

            case 6:
            {
                m_Looters = reader.ReadStrongMobileList();
                m_Killer  = reader.ReadMobile();

                goto case 5;
            }

            case 5:
            {
                SetFlag(CorpseFlag.Carved, reader.ReadBool());

                goto case 4;
            }

            case 4:
            {
                m_Aggressors = reader.ReadStrongMobileList();

                goto case 3;
            }

            case 3:
            {
                m_Owner = reader.ReadMobile();

                goto case 2;
            }

            case 2:
            {
                SetFlag(CorpseFlag.NoBones, reader.ReadBool());

                goto case 1;
            }

            case 1:
            {
                m_CorpseName = reader.ReadString();

                goto case 0;
            }

            case 0:
            {
                if (version < 10)
                {
                    m_TimeOfDeath = DateTime.Now;
                }

                if (version < 7)
                {
                    BeginDecay(m_DefaultDecayTime);
                }

                if (version < 6)
                {
                    m_Looters = new List <Mobile>();
                }

                if (version < 4)
                {
                    m_Aggressors = new List <Mobile>();
                }

                m_AccessLevel = (AccessLevel)reader.ReadInt();
                reader.ReadInt();         // guild reserve
                m_Kills = reader.ReadInt();
                SetFlag(CorpseFlag.Criminal, reader.ReadBool());

                m_EquipItems = reader.ReadStrongItemList();

                break;
            }
            }
        }
Esempio n. 49
0
 public void AddUsersToCourse(System.Guid CoursePublicID, AccessLevel Role, string[] UserKeys, string ApiUserKey, string AuthCode)
 {
     m_service.Channel.AddUsersToCourse(CoursePublicID, Role, UserKeys, ApiUserKey, AuthCode);
 }
Esempio n. 50
0
 public static void AddAuthenticationEntry(Guid authid, AccessLevel level, Mobile user)
 {
     AuthList.Add(new AuthEntry(authid, DateTime.Now, level, user));
 }
 public RequirePermission(AccessLevel accessLevel)
 {
     _accessLevel = accessLevel;
 }
Esempio n. 52
0
        public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List <Item> equipItems)
            : base(0x2006)
        {
            // To supress console warnings, stackable must be true
            Stackable = true;
            Amount    = owner.Body;          // protocol defines that for itemid 0x2006, amount=body
            Stackable = false;

            Movable   = false;
            Hue       = owner.Hue;
            Direction = owner.Direction;
            Name      = owner.Name;

            m_Owner = owner;

            m_CorpseName = GetCorpseName(owner);

            m_TimeOfDeath = DateTime.Now;

            m_AccessLevel = owner.AccessLevel;
            m_Guild       = owner.Guild as Guild;
            m_Kills       = owner.Kills;
            SetFlag(CorpseFlag.Criminal, owner.Criminal);

            m_Hair       = hair;
            m_FacialHair = facialhair;

#if false
            // This corpse does not turn to bones if:
            //    (the owner is not a player) and (the owner doesn't have a human body)
            m_NoBones = !owner.Player && !owner.Body.IsHuman;
#else
            // This corpse does not turn to bones if:
            //    (the owner is not a player)
            m_NoBones = !owner.Player;
#endif

            m_Looters    = new List <Mobile>();
            m_EquipItems = equipItems;

            m_Aggressors = new List <Mobile>(owner.Aggressors.Count + owner.Aggressed.Count);
            bool addToAggressors = !(owner is BaseCreature);

            TimeSpan lastTime = TimeSpan.MaxValue;

            for (int i = 0; i < owner.Aggressors.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressors[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Attacker;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors && !info.CriminalAggression)
                {
                    m_Aggressors.Add(info.Attacker);
                }
            }

            for (int i = 0; i < owner.Aggressed.Count; ++i)
            {
                AggressorInfo info = (AggressorInfo)owner.Aggressed[i];

                if ((DateTime.Now - info.LastCombatTime) < lastTime)
                {
                    m_Killer = info.Defender;
                    lastTime = (DateTime.Now - info.LastCombatTime);
                }

                if (addToAggressors)
                {
                    m_Aggressors.Add(info.Defender);
                }
            }

            if (!addToAggressors)
            {
                BaseCreature bc = (BaseCreature)owner;

                Mobile master = bc.ControlMaster;
                if (master != null)
                {
                    m_Aggressors.Add(master);
                }

                ArrayList rights = BaseCreature.GetLootingRights(bc.DamageEntries);
                for (int i = 0; i < rights.Count; ++i)
                {
                    DamageStore ds = (DamageStore)rights[i];

                    if (ds.m_HasRight)
                    {
                        m_Aggressors.Add(ds.m_Mobile);
                    }
                }
            }

            BeginDecay(m_DefaultDecayTime);
        }
Esempio n. 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ZyGames.Framework.Model.AbstractEntity"/> class.
 /// </summary>
 /// <param name="access">Access.</param>
 protected AbstractEntity(AccessLevel access)
     : this(access == AccessLevel.ReadOnly)
 {
 }
Esempio n. 54
0
 public MinPermissionsAttribute(AccessLevel level)
 {
     Level = level;
 }
Esempio n. 55
0
 public WriteAccessException(Property property, AccessLevel playerAccess, AccessLevel neededAccess)
     : base(property, playerAccess, neededAccess, "write")
 {
 }
Esempio n. 56
0
        /// <summary>
        /// Changes the permissions of a Realm.
        /// </summary>
        /// <returns>
        /// An awaitable task, that, upon completion, indicates that the permissions have been successfully applied by the server.
        /// </returns>
        /// <param name="condition">A <see cref="PermissionCondition"/> that will be used to match existing users against.</param>
        /// <param name="realmUrl">The Realm URL whose permissions settings should be changed. Use <c>*</c> to change the permissions of all Realms managed by this <see cref="User"/>.</param>
        /// <param name="accessLevel">
        /// The access level to grant matching users. Note that the access level setting is absolute, i.e. it may revoke permissions for users that
        /// previously had a higher access level. To revoke all permissions, use <see cref="AccessLevel.None" />
        /// </param>
        public Task ApplyPermissionsAsync(PermissionCondition condition, string realmUrl, AccessLevel accessLevel)
        {
            if (string.IsNullOrEmpty(realmUrl))
            {
                throw new ArgumentNullException(nameof(realmUrl));
            }

            var mayRead   = accessLevel >= AccessLevel.Read;
            var mayWrite  = accessLevel >= AccessLevel.Write;
            var mayManage = accessLevel >= AccessLevel.Admin;

            PermissionChange change = null;

            if (condition is UserIdCondition userIdCondition)
            {
                change = new PermissionChange(userIdCondition.UserId, realmUrl, mayRead, mayWrite, mayManage);
            }
            else if (condition is KeyValueCondition keyValueCondition)
            {
                change = new PermissionChange(keyValueCondition.Key, keyValueCondition.Value, realmUrl, mayRead, mayWrite, mayManage);
            }
            else
            {
                throw new NotSupportedException("Invalid PermissionCondition.");
            }

            return(WriteToManagementRealmAsync(change));
        }
Esempio n. 57
0
 public static void BroadcastMessage(AccessLevel ac, int hue, string message)
 {
     World.Broadcast(hue, false, ac, message);
 }
Esempio n. 58
0
 public void SetAccount(uint accountId, string account, AccessLevel accountAccesslevel)
 {
     AccountId   = accountId;
     Account     = account;
     AccessLevel = accountAccesslevel;
 }
Esempio n. 59
0
 public ConsoleCommand(AccessLevel accessLevel = AccessLevel.Admin)
 {
     this.accessLevel = accessLevel;
 }
Esempio n. 60
0
 public RequirePermissionAttribute(AccessLevel level)
 {
     _level = level;
 }