Exemplo n.º 1
0
        public void UnassignUser(ユーザー user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this user.");

            this.internalGroup.RemoveUser(user);

            DomainEventPublisher
                .Instance
                .Publish(new ユーザーロールアサイン解除時(
                        this.TenantId,
                        this.Name,
                        user.Username));
        }
Exemplo n.º 2
0
        public void AssignUser(ユーザー user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this user.");

            this.internalGroup.AddUser(user);

            DomainEventPublisher
                .Instance
                .Publish(new UserAssignedToRole(
                        this.TenantId,
                        this.Name,
                        user.Username,
                        user.Person.Name.FirstName,
                        user.Person.Name.LastName,
                        user.Person.EmailAddress.Address));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Uses a <see cref="グループメンバーサービス"/> to determine
 /// whether a given <see cref="ユーザー"/> has this role, including
 /// by way of nested <see cref="グループ"/> membership.
 /// </summary>
 /// <param name="user">
 /// A <see cref="ユーザー"/> entity to check.
 /// </param>
 /// <param name="groupMemberService">
 /// The instance of <see cref="グループメンバーサービス"/>
 /// relayed to the <see cref="グループ.IsMember"/> method.
 /// </param>
 /// <returns>
 /// <c>true</c> if the given <paramref name="user"/>
 /// has this role; otherwise, <c>false</c>.
 /// </returns>
 public bool IsInRole(ユーザー user, グループメンバーサービス groupMemberService)
 {
     return this.internalGroup.IsMember(user, groupMemberService);
 }
        /// <summary>
        /// Determines whether a <see cref="ユーザー"/> has a <see cref="ロール"/>,
        /// given the user and the name of the role.
        /// </summary>
        /// <param name="user">
        /// A <see cref="ユーザー"/> instance.
        /// </param>
        /// <param name="roleName">
        /// The unique name identifying a <see cref="ロール"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the <see cref="ユーザー"/> has the
        /// <see cref="ロール"/>; otherwise, <c>false</c>.
        /// </returns>
        public bool IsUserInRole(ユーザー user, string roleName)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentNotEmpty(roleName, "Role name must not be null.");

            bool authorized = false;
            if (user.IsEnabled)
            {
                ロール role = this.roleRepository.RoleNamed(user.TenantId, roleName);
                if (role != null)
                {
                    authorized = role.IsInRole(user, new グループメンバーサービス(this.userRepository, this.groupRepository));
                }
            }

            return authorized;
        }
Exemplo n.º 5
0
        public void RemoveUser(ユーザー user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");

            // not a nested remove, only direct member
            if (this.GroupMembers.Remove(user.ToGroupMember()) && (!this.IsInternalGroup))
            {
                DomainEventPublisher
                    .Instance
                    .Publish(new グループユーザー削除時(
                            this.TenantId,
                            this.Name,
                            user.Username));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Uses a <see cref="グループメンバーサービス"/> to determine
        /// whether a given <see cref="ユーザー"/> is a member of this
        /// or of a nested <see cref="グループ"/>.
        /// </summary>
        /// <param name="user">
        /// A <see cref="ユーザー"/> entity to check.
        /// </param>
        /// <param name="groupMemberService">
        /// The instance of <see cref="グループメンバーサービス"/>
        /// to use for checking nested group membership.
        /// </param>
        /// <returns>
        /// <c>true</c> if the given <paramref name="user"/>
        /// is a member of this group or of a nested group;
        /// otherwise, <c>false</c>.
        /// </returns>
        public bool IsMember(ユーザー user, グループメンバーサービス groupMemberService)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.IsEnabled, "User is not enabled.");

            bool isMember = this.GroupMembers.Contains(user.ToGroupMember());
            if (isMember)
            {
                isMember = groupMemberService.ConfirmUser(this, user);
            }
            else
            {
                isMember = groupMemberService.IsUserInNestedGroup(this, user);
            }

            return isMember;
        }
Exemplo n.º 7
0
        public void AddUser(ユーザー user)
        {
            AssertionConcern.AssertArgumentNotNull(user, "User must not be null.");
            AssertionConcern.AssertArgumentEquals(this.TenantId, user.TenantId, "Wrong tenant for this group.");
            AssertionConcern.AssertArgumentTrue(user.IsEnabled, "User is not enabled.");

            if (this.GroupMembers.Add(user.ToGroupMember()) && (!this.IsInternalGroup))
            {
                DomainEventPublisher
                    .Instance
                    .Publish(new グループユーザー追加時(
                            this.TenantId,
                            this.Name,
                            user.Username));
            }
        }
Exemplo n.º 8
0
        public ユーザー RegisterUser(string invitationIdentifier, string username, string password, 有効化 enablement, 人 person)
        {
            AssertionConcern.AssertStateTrue(this.Active, "Tenant is not active.");

            ユーザー user = null;
            if (this.IsRegistrationAvailableThrough(invitationIdentifier))
            {
                // ensure same tenant
                person.TenantId = this.TenantId;
                user = new ユーザー(this.TenantId, username, password, enablement, person);
            }

            return user;
        }