Inheritance: SaaSOvation.Common.Domain.Model.Identity
        public UserDescriptor Authenticate(
                TenantId tenantId,
                string username,
                string password)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "TenantId must not be null.");
            AssertionConcern.AssertArgumentNotEmpty(username, "Username must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(password, "Password must be provided.");

            UserDescriptor userDescriptor = UserDescriptor.NullDescriptorInstance();

            Tenant tenant = this.TenantRepository.TenantOfId(tenantId);

            if (tenant != null && tenant.Active)
            {
                String encryptedPassword = this.EncryptionService.EncryptedValue(password);

                User user =
                        this.UserRepository
                            .UserFromAuthenticCredentials(
                                tenantId,
                                username,
                                encryptedPassword);

                if (user != null && user.Enabled)
                {
                    userDescriptor = user.UserDescriptor;
                }
            }

            return userDescriptor;
        }
Exemplo n.º 2
0
 public GroupProvisioned(TenantId tenantId, string name)
 {
     this.EventVersion = 1;
     this.Name = name;
     this.OccurredOn = new DateTime();
     this.TenantId = tenantId.Id;
 }
Exemplo n.º 3
0
        internal User(
                TenantId tenantId,
                string username,
                string password,
                Enablement enablement,
                Person person)
            : this()
        {
            this.Enablement = enablement;
            this.Person = person;
            this.TenantId = tenantId;
            this.Username = username;

            this.ProtectPassword("", password);

            person.User = this;

            DomainEventPublisher
                .Instance
                .Publish(new UserRegistered(
                        tenantId,
                        username,
                        person.Name,
                        person.ContactInformation.EmailAddress));
        }
Exemplo n.º 4
0
        public User(
                TenantId tenantId,
                string username,
                string password,
                Enablement enablement,
                Person person)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "The tenantId is required.");
            AssertionConcern.AssertArgumentNotNull(person, "The person is required.");
            AssertionConcern.AssertArgumentNotEmpty(username, "The username is required.");
            AssertionConcern.AssertArgumentLength(username, 3, 250, "The username must be 3 to 250 characters.");

            this.Enablement = enablement;
            this.Person = person;
            this.TenantId = tenantId;
            this.Username = username;

            ProtectPassword("", password);

            person.User = this;

            DomainEventPublisher
                .Instance
                .Publish(new UserRegistered(
                        tenantId,
                        username,
                        person.Name,
                        person.ContactInformation.EmailAddress));
        }
Exemplo n.º 5
0
 public RoleProvisioned(TenantId tenantId, string name)
 {
     this.EventVersion = 1;
     this.Name = name;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
 }
 public void ProvisionRole(ProvisionRoleCommand command)
 {
     var tenantId = new TenantId(command.TenantId);
     var tenant = this.tenantRepository.Get(tenantId);
     var role = tenant.ProvisionRole(command.RoleName, command.Description, command.SupportsNesting);
     this.roleRepository.Add(role);
 }
Exemplo n.º 7
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Person"/> class.
		/// </summary>
		/// <param name="tenantId">
		/// Initial value of the <see cref="TenantId"/> property.
		/// </param>
		/// <param name="name">
		/// Initial value of the <see cref="Name"/> property.
		/// </param>
		/// <param name="contactInformation">
		/// Initial value of the <see cref="ContactInformation"/> property.
		/// </param>
		public Person(TenantId tenantId, FullName name, ContactInformation contactInformation)
		{
			// Defer validation to the property setters.
			this.ContactInformation = contactInformation;
			this.Name = name;
			this.TenantId = tenantId;
		}
Exemplo n.º 8
0
 public Group(TenantId tenantId, string name, string description)
     : this()
 {
     this.Description = description;
     this.Name = name;
     this.TenantId = tenantId;
 }
 public InvitationDescriptor(TenantId tenantId, string invitationId, string description, DateTime startingOn, DateTime until)
 {
     this.Description = description;
     this.InvitationId = invitationId;
     this.StartingOn = startingOn;
     this.TenantId = tenantId.Id;
     this.Until = until;
 }
Exemplo n.º 10
0
 public Role(TenantId tenantId, string name, string description, bool supportsNesting)
 {
     this.Description = description;
     this.Name = name;
     this.SupportsNesting = supportsNesting;
     this.TenantId = tenantId;
     this.group = CreateInternalGroup();
 }
Exemplo n.º 11
0
 public GroupUserAdded(TenantId tenantId, string groupName, string username)
 {
     this.EventVersion = 1;
     this.GroupName = groupName;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
Exemplo n.º 12
0
 public UserUnassignedFromRole(TenantId tenantId, string roleName, string username)
 {
     this.EventVersion = 1;
     this.OccurredOn = DateTime.Now;
     this.RoleName = roleName;
     this.TenantId = tenantId;
     this.Username = username;
 }
 public GroupUnassignedFromRole(TenantId tenantId, string roleName, string groupName)
 {
     this.EventVersion = 1;
     this.GroupName = groupName;
     this.OccurredOn = DateTime.Now;
     this.RoleName = roleName;
     this.TenantId = tenantId;
 }
Exemplo n.º 14
0
 public GroupGroupRemoved(TenantId tenantId, string groupName, string nestedGroupName)
 {
     this.EventVersion = 1;
     this.GroupName = groupName;
     this.NestedGroupName = nestedGroupName;
     this.OccurredOn = new DateTime();
     this.TenantId = tenantId.Id;
 }
Exemplo n.º 15
0
 public GroupGroupAdded(TenantId tenantId, string groupName, string nestedGroupName)
 {
     this.EventVersion = 1;
     this.GroupName = groupName;
     this.NestedGroupName = nestedGroupName;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
 }
Exemplo n.º 16
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Group"/> class.
		/// </summary>
		/// <param name="tenantId">
		/// Initial value of the <see cref="TenantId"/> property.
		/// </param>
		/// <param name="name">
		/// Initial value of the <see cref="Name"/> property.
		/// </param>
		/// <param name="description">
		/// Initial value of the <see cref="Description"/> property.
		/// </param>
		public Group(TenantId tenantId, string name, string description)
			: this()
		{
			// Defer validation to the property setters.
			this.Description = description;
			this.Name = name;
			this.TenantId = tenantId;
		}
Exemplo n.º 17
0
 public GroupAssignedToRole(TenantId tenantId, string roleName, string groupName)
 {
     this.EventVersion = 1;
     this.GroupName = groupName;
     this.OccurredOn = new DateTime();
     this.RoleName = roleName;
     this.TenantId = tenantId;
 }
        public bool IsUserInRole(TenantId tenantId, string username, string roleName)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "TenantId must not be null.");
            AssertionConcern.AssertArgumentNotEmpty(username, "Username must not be provided.");
            AssertionConcern.AssertArgumentNotEmpty(roleName, "Role name must not be null.");

            var user = this.userRepository.UserWithUsername(tenantId, username);
            return user == null ? false : this.IsUserInRole(user, roleName);
        }
Exemplo n.º 19
0
 public UserPasswordChanged(
         TenantId tenantId,
         String username)
 {
     this.EventVersion = 1;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
Exemplo n.º 20
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Role"/> class.
		/// </summary>
		/// <param name="tenantId">
		/// Initial value of the <see cref="TenantId"/> property.
		/// </param>
		/// <param name="name">
		/// Initial value of the <see cref="Name"/> property.
		/// </param>
		/// <param name="description">
		/// Initial value of the <see cref="Description"/> property.
		/// </param>
		/// <param name="supportsNesting">
		/// Initial value of the <see cref="SupportsNesting"/> property.
		/// </param>
		public Role(TenantId tenantId, string name, string description, bool supportsNesting)
		{
			// Defer validation to the property setters.
			this.Description = description;
			this.Name = name;
			this.SupportsNesting = supportsNesting;
			this.TenantId = tenantId;

			this.internalGroup = this.CreateInternalGroup();
		}
Exemplo n.º 21
0
        internal GroupMember(TenantId tenantId, string name, GroupMemberType type)
        {
            AssertionConcern.AssertArgumentNotNull(tenantId, "The tenantId must be provided.");
            AssertionConcern.AssertArgumentNotEmpty(name, "Member name is required.");
            AssertionConcern.AssertArgumentLength(name, 1, 100, "Member name must be 100 characters or less.");

            this.Name = name;
            this.TenantId = tenantId;
            this.Type = type;
        }
Exemplo n.º 22
0
 public UserEnablementChanged(
         TenantId tenantId,
         String username,
         Enablement enablement)
 {
     this.Enablement = enablement;
     this.EventVersion = 1;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
Exemplo n.º 23
0
 public PersonNameChanged(
         TenantId tenantId,
         String username,
         FullName name)
 {
     this.EventVersion = 1;
     this.Name = name;
     this.OccurredOn = new DateTime();
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
 public PersonContactInformationChanged(
         TenantId tenantId,
         String username,
         ContactInformation contactInformation)
 {
     this.ContactInformation = contactInformation;
     this.EventVersion = 1;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
 public void AssignUserToRole(AssignUserToRoleCommand command)
 {
     var tenantId = new TenantId(command.TenantId);
     var user = this.userRepository.UserWithUsername(tenantId, command.Username);
     if (user != null)
     {
         var role = this.roleRepository.RoleNamed(tenantId, command.RoleName);
         if (role != null)
         {
             role.AssignUser(user);
         }
     }
 }
Exemplo n.º 26
0
 public UserRegistered(
         TenantId tenantId,
         String username,
         FullName name,
         EmailAddress emailAddress)
 {
     this.EmailAddress = emailAddress;
     this.EventVersion = 1;
     this.Name = name;
     this.OccurredOn = DateTime.Now;
     this.TenantId = tenantId.Id;
     this.Username = username;
 }
Exemplo n.º 27
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Tenant"/> class.
		/// </summary>
		/// <param name="tenantId">
		/// Initial value of the <see cref="TenantId"/> property.
		/// </param>
		/// <param name="name">
		/// Initial value of the <see cref="Name"/> property.
		/// </param>
		/// <param name="description">
		/// Initial value of the <see cref="Description"/> property.
		/// </param>
		/// <param name="active">
		/// Initial value of the <see cref="Active"/> property.
		/// </param>
		public Tenant(TenantId tenantId, string name, string description, bool active)
		{
			AssertionConcern.AssertArgumentNotNull(tenantId, "TenentId is required.");
			AssertionConcern.AssertArgumentNotEmpty(name, "The tenant name is required.");
			AssertionConcern.AssertArgumentLength(name, 1, 100, "The name must be 100 characters or less.");
			AssertionConcern.AssertArgumentNotEmpty(description, "The tenant description is required.");
			AssertionConcern.AssertArgumentLength(description, 1, 100, "The name description be 100 characters or less.");

			this.TenantId = tenantId;
			this.Name = name;
			this.Description = description;
			this.Active = active;

			this.registrationInvitations = new HashSet<RegistrationInvitation>();
		}
 public TenantAdministratorRegistered(
     TenantId tenantId,
     string name,
     FullName administorName,
     EmailAddress emailAddress,
     string username,
     string temporaryPassword)
 {
     this.AdministorName = administorName;
     this.EventVersion = 1;
     this.Name = name;
     this.OccurredOn = DateTime.Now;
     this.TemporaryPassword = temporaryPassword;
     this.TenantId = tenantId.Id;
 }
Exemplo n.º 29
0
 public UserAssignedToRole(
     TenantId tenantId,
     string roleName,
     string username,
     string firstName,
     string lastName,
     string emailAddress)
 {
     this.EmailAddress = emailAddress;
     this.EventVersion = 1;
     this.FirstName = firstName;
     this.LastName = lastName;
     this.OccurredOn = DateTime.Now;
     this.RoleName = roleName;
     this.TenantId = tenantId;
     this.Username = username;
 }
 public User UserInRole(string tenantId, string userName, string roleName)
 {
     var id = new TenantId(tenantId);
     var user = this.userRepository.UserWithUsername(id, userName);
     if (user != null)
     {
         var role = this.roleRepository.RoleNamed(id, roleName);
         if (role != null)
         {
             if (role.IsInRole(user, new GroupMemberService(this.userRepository, this.groupRepository)))
             {
                 return user;
             }
         }
     }
     return null;
 }
Exemplo n.º 31
0
 public Person(TenantId tenantId, FullName name, ContactInformation contactInformation)
 {
     this.ContactInformation = contactInformation;
     this.Name     = name;
     this.TenantId = tenantId;
 }
Exemplo n.º 32
0
 public TenantProvisioned(TenantId tenantId)
 {
     this.EventVersion = 1;
     this.OccurredOn   = DateTime.Now;
     this.TenantId     = tenantId.Id;
 }
Exemplo n.º 33
0
 public RegistrationInvitation(TenantId tenantId, string invitationId, string description)
     : this(tenantId, invitationId, description, DateTime.MinValue, DateTime.MinValue)
 {
 }
 public TenantProvisioned(TenantId tenantId)
 {
     EventVersion = 1;
     OccurredOn   = DateTime.Now;
     TenantId     = tenantId.Id;
 }