Exemple #1
0
        public UserGroup AddUserGroup(string applicationUrl, string name, string description)
        {
            var application = this.applicationTask.GetApplicationByUrl(applicationUrl);

            if (application == null)
            {
                return(null);
            }

            var userGroup = new UserGroup
            {
                ApplicationId = application.ApplicationId,
                Description   = description,
                Name          = name
            };

            using (var operation = BeginOperation())
            {
                this.userGroupRepository.Save(userGroup);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(UserGroupAction.Created, AuditInformation.Create().WithUserGroup(userGroup));
            return(userGroup);
        }
        public void AddCredentialValueAndAssociatedUserGroup(string applicationUrl, string credentialElementNid,
                                                             string value, string description = null)
        {
            var credentialValue = this.GetCredentialValue(applicationUrl, credentialElementNid, value, description);

            if (credentialValue == null)
            {
                return;
            }

            using (var operation = BeginOperation())
            {
                UserGroup createdUserGroup;
                this.credentialRepository.AddCredentialValueAndAssociatedUserGroup(credentialValue, out createdUserGroup);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create()
                                       .WithCredentialValues(credentialValue));

            this.auditTasks.WriteEntry(UserGroupAction.Created,
                                       AuditInformation.Create()
                                       .WithUserGroup(credentialValue.AssociatedUserGroup));

            this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                       AuditInformation.Create()
                                       .WithUserGroupCredentialValues(
                                           credentialValue.AssociatedUserGroupCredentialValue));
        }
        public CredentialValue AddLafCredentialValue(string lafApplicationUrl, string sourceApplicationUrl,
                                                     string credentialUrnName, string credentialValueValue,
                                                     string credentialValueDescription)
        {
            var newCredentialValue = this.GetCredentialValue(lafApplicationUrl, credentialUrnName, credentialValueValue,
                                                             credentialValueDescription);

            if (newCredentialValue == null)
            {
                throw new ApplicationException("An attempt was made to create a CredentialValue that already exists.");
            }

            var application = this.applicationTask.GetApplicationByUrl(sourceApplicationUrl);

            newCredentialValue.SourceApplicationId = application.ApplicationId;

            using (var operation = BeginOperation())
            {
                this.credentialRepository.Save(newCredentialValue);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create().WithCredentialValues(newCredentialValue));

            return(newCredentialValue);
        }
        public void AddCredentialValueAndAssociatedUserGroupToExistingDaUserGroup(string applicationUrl,
                                                                                  string credentialUrnName,
                                                                                  string credentialValueValue,
                                                                                  string credentialValueDescription,
                                                                                  int daUserGroupId,
                                                                                  out CredentialValue
                                                                                  createdCredentialValue,
                                                                                  out UserGroup createdUserGroup)
        {
            createdCredentialValue = this.GetCredentialValue(applicationUrl, credentialUrnName, credentialValueValue,
                                                             credentialValueDescription);
            if (createdCredentialValue == null)
            {
                throw new ApplicationException("An attempt was made to create a CredentialValue that already exists.");
            }

            CredentialValue createdLafUserGroupCredentialValueForExistingDaUserGroup;

            using (var operation = BeginOperation())
            {
                this.credentialRepository.AddCredentialValueAndAssociatedUserGroupToExistingDaUserGroup(
                    createdCredentialValue,
                    applicationUrl,
                    daUserGroupId,
                    out createdUserGroup,
                    out createdLafUserGroupCredentialValueForExistingDaUserGroup);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create().WithCredentialValues(createdCredentialValue));

            this.auditTasks.WriteEntry(UserGroupAction.Created,
                                       AuditInformation.Create()
                                       .WithUserGroup(createdCredentialValue.AssociatedUserGroup));

            this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                       AuditInformation.Create()
                                       .WithUserGroupCredentialValues(
                                           createdCredentialValue.AssociatedUserGroupCredentialValue));

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create()
                                       .WithCredentialValues(
                                           createdLafUserGroupCredentialValueForExistingDaUserGroup));

            var daUserGroupCredentialValues =
                this.credentialRepository.GetUserGroupCredentialValuesByUserGroupId(daUserGroupId);

            var createdUgcv =
                daUserGroupCredentialValues.FindAll(
                    x =>
                    x.CredentialValueId == createdLafUserGroupCredentialValueForExistingDaUserGroup.CredentialValueId)
                .ToArray();

            this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                       AuditInformation.Create()
                                       .WithUserGroupCredentialValues(createdUgcv));
        }
Exemple #5
0
        public void AddUserGroup(UserGroup userGroup)
        {
            using (var operation = BeginOperation())
            {
                this.userGroupRepository.Save(userGroup);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(UserGroupAction.Created, AuditInformation.Create().WithUserGroup(userGroup));
        }
        public void AddCredentialValue(CredentialValue credentialValue)
        {
            using (var operation = BeginOperation())
            {
                this.credentialRepository.Save(credentialValue);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create().WithCredentialValues(credentialValue));
        }
Exemple #7
0
        public void AddUserGroupCredentialValue(UserGroupCredentialValue userGroupCredentialValue)
        {
            using (var operation = BeginOperation())
            {
                this.userGroupRepository.Save(userGroupCredentialValue);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                       AuditInformation.Create()
                                       .WithUserGroupCredentialValues(userGroupCredentialValue));
        }
        public void Save(CredentialValue value)
        {
            var isNew  = value.IsNewEntity();
            var action = CredentialValueAction.Created;

            if (!isNew)
            {
                action = CredentialValueAction.Edited;
            }

            using (var operation = BeginOperation())
            {
                this.credentialRepository.Save(value);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(action, AuditInformation.Create().WithCredentialValues(value));
        }
Exemple #9
0
        public void Save(UserGroup userGroup)
        {
            var isNew  = userGroup.IsNewEntity();
            var action = UserGroupAction.Created;

            if (!isNew)
            {
                action = UserGroupAction.Edited;
            }

            using (var operation = BeginOperation())
            {
                this.userGroupRepository.Save(userGroup);
                operation.Complete();
            }

            this.auditTasks.WriteEntry(action, AuditInformation.Create().WithUserGroup(userGroup));
        }
Exemple #10
0
        public UserGroup AddDevolvedAdminUserGroup(string name, string description)
        {
            UserGroup userGroup;

            using (var operation = BeginOperation())
            {
                userGroup = this.userGroupRepository.AddDevolvedAdminUserGroup(name, description);

                var userGroupCredentialValues =
                    this.userGroupRepository.GetUserGroupCredentialValuesByUserGroupId(userGroup.UserGroupId).ToArray();

                this.auditTasks.WriteEntry(UserGroupAction.Created,
                                           AuditInformation.Create().WithUserGroup(userGroup));

                this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                           AuditInformation.Create()
                                           .WithUserGroupCredentialValues(userGroupCredentialValues));

                operation.Complete();
            }

            return(userGroup);
        }
        public void AddDevolvedAdminUserGroupForGivenUserGroup(string name, string description,
                                                               int idOfUserGroupForWhichADevolvedAdminUserGroupIsToBeCreated,
                                                               out UserGroup createdDaUserGroup)
        {
            var             userGroup = this.userGroupTask.GetById(idOfUserGroupForWhichADevolvedAdminUserGroupIsToBeCreated);
            CredentialValue createdLafUserGroupCredentialValueForCreatedDaUserGroup;

            if (!this.userGroupTask.DoesUserGroupAlreadyExist(idOfUserGroupForWhichADevolvedAdminUserGroupIsToBeCreated))
            {
                throw new ApplicationException("An attempt was made to create a LAF Devolved Administrators User Group for a User Group that does not exist.");
            }

            using (var operation = BeginOperation())
            {
                this.credentialRepository.AddDevolvedAdminUserGroupForGivenUserGroup(name, description, userGroup,
                                                                                     out createdDaUserGroup,
                                                                                     out createdLafUserGroupCredentialValueForCreatedDaUserGroup);
                operation.Complete();
            }

            var daUserGroupCredentialValues =
                this.credentialRepository.GetUserGroupCredentialValuesByUserGroupId(createdDaUserGroup.UserGroupId)
                .ToArray();

            this.auditTasks.WriteEntry(UserGroupAction.Created,
                                       AuditInformation.Create().WithUserGroup(createdDaUserGroup));

            this.auditTasks.WriteEntry(CredentialValueAction.Created,
                                       AuditInformation.Create()
                                       .WithCredentialValues(
                                           createdLafUserGroupCredentialValueForCreatedDaUserGroup));

            this.auditTasks.WriteEntry(UserGroupAction.CredentialAdded,
                                       AuditInformation.Create()
                                       .WithUserGroupCredentialValues(daUserGroupCredentialValues));
        }