Ejemplo n.º 1
0
        /// <summary>
        /// Get group users (email or deployment identifiers)
        /// </summary>
        /// <param name="groupName">Group name</param>
        /// <returns>List of user group emails or deployment ids</returns>
        public IEnumerable <string> GetGroupUsers(string groupName)
        {
            List <string> emptyList = new List <string>();

            if (string.IsNullOrWhiteSpace(groupName))
            {
                ULSLogging.LogCodeErrorTag(0x23821092 /* tag_967cs */, Categories.TestGroupsDataSet, false,
                                           false, "Null or empty group passed to TestGroupsDataSet.GetGroupUsers");
                return(emptyList);
            }

            if (m_groupUsers == null)
            {
                ULSLogging.LogCodeErrorTag(0x23821093 /* tag_967ct */, Categories.TestGroupsDataSet, false,
                                           false, "TestGroupsDataSet is not loaded.");
                return(emptyList);
            }

            string group = groupName.Trim();

            if (DefaultGroups.Contains(group))
            {
                return(m_userGroups.Keys.ToList());
            }

            if (m_groupUsers.TryGetValue(group, out List <string> groupUsers))
            {
                return(groupUsers);
            }

            return(emptyList);
        }
Ejemplo n.º 2
0
        protected void UpdateGroups()
        {
            if (!_groupsUpdated)
            {
                return;
            }
            _groupsUpdated  = false;
            _groups         = new List <HomeMenuGroup>();
            _groupedActions = new Dictionary <Guid, HomeMenuAction>();

            var settingsGroups = _settings.Settings.Groups;

            if (settingsGroups != null && settingsGroups.Count > 0)
            {
                _groups.AddRange(settingsGroups);
            }
            else
            {
                _groups.AddRange(DefaultGroups.Create());
            }

            foreach (var group in _groups)
            {
                foreach (var action in group.Actions)
                {
                    _groupedActions[action.ActionId] = action;
                }
            }
        }
        private static SPGroup AddGroupInternal(DefaultGroups associateGroup, SPWeb web, bool copyUsersFromParent)
        {
            switch (associateGroup)
            {
            case DefaultGroups.Owners:
                return(AddGroup(web,
                                web.Name + " Owners",
                                "Use this group to give people full control permissions to the SharePoint site: {0}",
                                "Full Control",
                                ASSOCIATE_OWNER_GROUP,
                                web.ParentWeb.AssociatedOwnerGroup,
                                copyUsersFromParent));

            case DefaultGroups.Members:
                return(AddGroup(web,
                                web.Name + " Members",
                                "Use this group to give people contribute permissions to the SharePoint site: {0}",
                                "Contribute",
                                "vti_associatemembergroup",
                                web.ParentWeb.AssociatedMemberGroup,
                                copyUsersFromParent));

            case DefaultGroups.Vistors:
                return(AddGroup(web,
                                web.Name + " Vistors",
                                "Use this group to give people read permissions to the SharePoint site: {0}",
                                "Read",
                                "vti_associatevisitorgroup",
                                web.ParentWeb.AssociatedVisitorGroup,
                                copyUsersFromParent));

            default:
                return(null);
            }
        }
Ejemplo n.º 4
0
 public void RestoreDefaults()
 {
     _items.Clear();
     _items.AddRange(DefaultGroups.Create());
     UpdateItems();
     _needsUpdate = true;
 }
Ejemplo n.º 5
0
        protected void LoadGroups()
        {
            _items.Clear();
            HomeEditorSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <HomeEditorSettings>();

            if (settings.Groups != null && settings.Groups.Count > 0)
            {
                _items.AddRange(settings.Groups);
            }
            else
            {
                _items.AddRange(DefaultGroups.Create());
            }
        }
Ejemplo n.º 6
0
            /// <summary>
            /// Get the wiki groups for the given domain groups, if any.
            /// </summary>
            /// <param name="domainGroups">The domain groups.</param>
            /// <returns>The list of wiki groups.</returns>
            public List <string> GetWikiGroups(List <string> domainGroups)
            {
                // find all the wiki groups from the given domain groups
                var wikiGroups = domainGroups.SelectMany(t => GetGroupMap(t)).ToList();

                // add groups common to all users
                wikiGroups.AddRange(CommonGroups);

                // remove duplicates
                wikiGroups = wikiGroups.Distinct(StringComparer.InvariantCultureIgnoreCase).ToList();

                // return the groups, if any
                if (wikiGroups.Count > 0)
                {
                    return(wikiGroups);
                }

                // return the default groups, if any
                return(DefaultGroups.ToList());
            }
Ejemplo n.º 7
0
        /// <summary>
        /// Load the Test Groups Data
        /// </summary>
        /// <param name="testGroupsRaw">Raw test groups data</param>
        /// <param name="userGroups">User groups</param>
        /// <param name="groupUsers">Group users</param>
        private void LoadGroupsData(Configuration.TestGroups testGroupsRaw,
                                    out Dictionary <string, List <string> > userGroups, out Dictionary <string, List <string> > groupUsers)
        {
            if (testGroupsRaw == null || testGroupsRaw.TestGroup == null)
            {
                ULSLogging.LogCodeErrorTag(0x23821095 /* tag_967cv */, Categories.TestGroupsDataSet, false,
                                           true, "Null raw data has been passed to TestGroupsDataSet.LoadGroupsData.");
                userGroups = null;
                groupUsers = null;
                return;
            }

            userGroups = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase);
            groupUsers = new Dictionary <string, List <string> >(StringComparer.OrdinalIgnoreCase);

            foreach (Configuration.TestGroupsTestGroup testGroup in testGroupsRaw.TestGroup)
            {
                string testGroupName = testGroup.name.Trim();
                if (string.IsNullOrWhiteSpace(testGroupName))
                {
                    ULSLogging.LogCodeErrorTag(0x23821096 /* tag_967cw */, Categories.TestGroupsDataSet, false,
                                               true, "A test user with empty name found, skipping.");
                    continue;
                }

                if (testGroupName.Contains(ListSeparator))
                {
                    ULSLogging.LogCodeErrorTag(0x23821097 /* tag_967cx */, Categories.TestGroupsDataSet, false,
                                               true, "Test user name '{0}' contains a semicolon. This name cannot be used as the semicolon is used to delimit groups within the asset field. Skipping.",
                                               testGroupName);
                    continue;
                }

                if (DefaultGroups.Contains(testGroupName))
                {
                    ULSLogging.LogCodeErrorTag(0x23821098 /* tag_967cy */, Categories.TestGroupsDataSet, false,
                                               true, "Test user name '{0}' is a restricted user name and cannot be manually specified. Skipping.", testGroupName);
                    continue;
                }

                if (testGroup.Member == null)
                {
                    ULSLogging.LogCodeErrorTag(0x23821099 /* tag_967cz */, Categories.TestGroupsDataSet, false,
                                               true, "Skipping test user '{0}' : the user has no members", testGroupName);
                    continue;
                }

                if (!groupUsers.ContainsKey(testGroupName))
                {
                    groupUsers.Add(testGroupName, new List <string>());
                }

                foreach (Configuration.TestGroupsTestGroupMember member in testGroup.Member)
                {
                    if (member.email != null)
                    {
                        UpdateGroups(userGroups, groupUsers, member.email, testGroupName);
                    }

                    if (member.deploymentId != null)
                    {
                        UpdateGroups(userGroups, groupUsers, member.deploymentId, testGroupName);
                    }
                }
            }
        }
Ejemplo n.º 8
0
 public DefaultEntities(IGroupStore groupStore)
 {
     _groups = new DefaultGroups(groupStore);
 }
 public static SPGroup AddGroup(SPWeb web, DefaultGroups associateGroup, bool copyUsersFromParent)
 {
     return(AddGroupInternal(associateGroup, web, copyUsersFromParent));
 }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Path != null)
         {
             hashCode = hashCode * 59 + Path.GetHashCode();
         }
         if (ServiceRanking != null)
         {
             hashCode = hashCode * 59 + ServiceRanking.GetHashCode();
         }
         if (IdpUrl != null)
         {
             hashCode = hashCode * 59 + IdpUrl.GetHashCode();
         }
         if (IdpCertAlias != null)
         {
             hashCode = hashCode * 59 + IdpCertAlias.GetHashCode();
         }
         if (IdpHttpRedirect != null)
         {
             hashCode = hashCode * 59 + IdpHttpRedirect.GetHashCode();
         }
         if (ServiceProviderEntityId != null)
         {
             hashCode = hashCode * 59 + ServiceProviderEntityId.GetHashCode();
         }
         if (AssertionConsumerServiceURL != null)
         {
             hashCode = hashCode * 59 + AssertionConsumerServiceURL.GetHashCode();
         }
         if (SpPrivateKeyAlias != null)
         {
             hashCode = hashCode * 59 + SpPrivateKeyAlias.GetHashCode();
         }
         if (KeyStorePassword != null)
         {
             hashCode = hashCode * 59 + KeyStorePassword.GetHashCode();
         }
         if (DefaultRedirectUrl != null)
         {
             hashCode = hashCode * 59 + DefaultRedirectUrl.GetHashCode();
         }
         if (UserIDAttribute != null)
         {
             hashCode = hashCode * 59 + UserIDAttribute.GetHashCode();
         }
         if (UseEncryption != null)
         {
             hashCode = hashCode * 59 + UseEncryption.GetHashCode();
         }
         if (CreateUser != null)
         {
             hashCode = hashCode * 59 + CreateUser.GetHashCode();
         }
         if (AddGroupMemberships != null)
         {
             hashCode = hashCode * 59 + AddGroupMemberships.GetHashCode();
         }
         if (GroupMembershipAttribute != null)
         {
             hashCode = hashCode * 59 + GroupMembershipAttribute.GetHashCode();
         }
         if (DefaultGroups != null)
         {
             hashCode = hashCode * 59 + DefaultGroups.GetHashCode();
         }
         if (NameIdFormat != null)
         {
             hashCode = hashCode * 59 + NameIdFormat.GetHashCode();
         }
         if (SynchronizeAttributes != null)
         {
             hashCode = hashCode * 59 + SynchronizeAttributes.GetHashCode();
         }
         if (HandleLogout != null)
         {
             hashCode = hashCode * 59 + HandleLogout.GetHashCode();
         }
         if (LogoutUrl != null)
         {
             hashCode = hashCode * 59 + LogoutUrl.GetHashCode();
         }
         if (ClockTolerance != null)
         {
             hashCode = hashCode * 59 + ClockTolerance.GetHashCode();
         }
         if (DigestMethod != null)
         {
             hashCode = hashCode * 59 + DigestMethod.GetHashCode();
         }
         if (SignatureMethod != null)
         {
             hashCode = hashCode * 59 + SignatureMethod.GetHashCode();
         }
         if (UserIntermediatePath != null)
         {
             hashCode = hashCode * 59 + UserIntermediatePath.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        /// Returns true if SamlConfigurationProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of SamlConfigurationProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(SamlConfigurationProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Path == other.Path ||
                     Path != null &&
                     Path.Equals(other.Path)
                     ) &&
                 (
                     ServiceRanking == other.ServiceRanking ||
                     ServiceRanking != null &&
                     ServiceRanking.Equals(other.ServiceRanking)
                 ) &&
                 (
                     IdpUrl == other.IdpUrl ||
                     IdpUrl != null &&
                     IdpUrl.Equals(other.IdpUrl)
                 ) &&
                 (
                     IdpCertAlias == other.IdpCertAlias ||
                     IdpCertAlias != null &&
                     IdpCertAlias.Equals(other.IdpCertAlias)
                 ) &&
                 (
                     IdpHttpRedirect == other.IdpHttpRedirect ||
                     IdpHttpRedirect != null &&
                     IdpHttpRedirect.Equals(other.IdpHttpRedirect)
                 ) &&
                 (
                     ServiceProviderEntityId == other.ServiceProviderEntityId ||
                     ServiceProviderEntityId != null &&
                     ServiceProviderEntityId.Equals(other.ServiceProviderEntityId)
                 ) &&
                 (
                     AssertionConsumerServiceURL == other.AssertionConsumerServiceURL ||
                     AssertionConsumerServiceURL != null &&
                     AssertionConsumerServiceURL.Equals(other.AssertionConsumerServiceURL)
                 ) &&
                 (
                     SpPrivateKeyAlias == other.SpPrivateKeyAlias ||
                     SpPrivateKeyAlias != null &&
                     SpPrivateKeyAlias.Equals(other.SpPrivateKeyAlias)
                 ) &&
                 (
                     KeyStorePassword == other.KeyStorePassword ||
                     KeyStorePassword != null &&
                     KeyStorePassword.Equals(other.KeyStorePassword)
                 ) &&
                 (
                     DefaultRedirectUrl == other.DefaultRedirectUrl ||
                     DefaultRedirectUrl != null &&
                     DefaultRedirectUrl.Equals(other.DefaultRedirectUrl)
                 ) &&
                 (
                     UserIDAttribute == other.UserIDAttribute ||
                     UserIDAttribute != null &&
                     UserIDAttribute.Equals(other.UserIDAttribute)
                 ) &&
                 (
                     UseEncryption == other.UseEncryption ||
                     UseEncryption != null &&
                     UseEncryption.Equals(other.UseEncryption)
                 ) &&
                 (
                     CreateUser == other.CreateUser ||
                     CreateUser != null &&
                     CreateUser.Equals(other.CreateUser)
                 ) &&
                 (
                     AddGroupMemberships == other.AddGroupMemberships ||
                     AddGroupMemberships != null &&
                     AddGroupMemberships.Equals(other.AddGroupMemberships)
                 ) &&
                 (
                     GroupMembershipAttribute == other.GroupMembershipAttribute ||
                     GroupMembershipAttribute != null &&
                     GroupMembershipAttribute.Equals(other.GroupMembershipAttribute)
                 ) &&
                 (
                     DefaultGroups == other.DefaultGroups ||
                     DefaultGroups != null &&
                     DefaultGroups.Equals(other.DefaultGroups)
                 ) &&
                 (
                     NameIdFormat == other.NameIdFormat ||
                     NameIdFormat != null &&
                     NameIdFormat.Equals(other.NameIdFormat)
                 ) &&
                 (
                     SynchronizeAttributes == other.SynchronizeAttributes ||
                     SynchronizeAttributes != null &&
                     SynchronizeAttributes.Equals(other.SynchronizeAttributes)
                 ) &&
                 (
                     HandleLogout == other.HandleLogout ||
                     HandleLogout != null &&
                     HandleLogout.Equals(other.HandleLogout)
                 ) &&
                 (
                     LogoutUrl == other.LogoutUrl ||
                     LogoutUrl != null &&
                     LogoutUrl.Equals(other.LogoutUrl)
                 ) &&
                 (
                     ClockTolerance == other.ClockTolerance ||
                     ClockTolerance != null &&
                     ClockTolerance.Equals(other.ClockTolerance)
                 ) &&
                 (
                     DigestMethod == other.DigestMethod ||
                     DigestMethod != null &&
                     DigestMethod.Equals(other.DigestMethod)
                 ) &&
                 (
                     SignatureMethod == other.SignatureMethod ||
                     SignatureMethod != null &&
                     SignatureMethod.Equals(other.SignatureMethod)
                 ) &&
                 (
                     UserIntermediatePath == other.UserIntermediatePath ||
                     UserIntermediatePath != null &&
                     UserIntermediatePath.Equals(other.UserIntermediatePath)
                 ));
        }