/// <summary> /// Retrieves all groups for the currently logged-in user. /// </summary> /// <param name="identity">The identity of the logged in user. This value cannot be null.</param> /// <returns>The list of user groups.</returns> public IEnumerable <string> GetUserGroups(IUserIdentity identity) { if (!Code.ValidateArgument(identity, nameof(identity), TaggingUtilities.ReserveTag(0x2382109d /* tag_967c3 */))) { return(Enumerable.Empty <string>()); } ITestGroupsDataSet testGroupsDataSet = GetTestGroupsDataSet(); if (testGroupsDataSet == null) { return(Enumerable.Empty <string>()); } if (!identity.IsAuthenticated) { return(testGroupsDataSet.DefaultGroups); } IEnumerable <string> result = new List <string>(); if (!string.IsNullOrWhiteSpace(identity.EmailAddressSignIn)) { result = result.Union(GetUserGroups(identity.EmailAddressSignIn), StringComparer.OrdinalIgnoreCase); } if (!string.IsNullOrWhiteSpace(identity.EmailAddressPreferred)) { result = result.Union(GetUserGroups(identity.EmailAddressPreferred), StringComparer.OrdinalIgnoreCase); } return(result); }
/// <summary> /// Retrieves all users for a group /// </summary> /// <remarks>This search is not meant to be efficient, to be used for diagnostics only</remarks> /// <param name="groupName">Group name. This value cannot be null.</param> /// <returns>List of group users</returns> public IEnumerable <string> GetGroupUsers(string groupName) { if (!Code.ValidateNotNullOrWhiteSpaceArgument(groupName, nameof(groupName), TaggingUtilities.ReserveTag(0x2382109f /* tag_967c5 */))) { return(Enumerable.Empty <string>()); } ITestGroupsDataSet testGroupsDataSet = GetTestGroupsDataSet(); if (testGroupsDataSet == null) { return(Enumerable.Empty <string>()); } return(testGroupsDataSet.GetGroupUsers(groupName)); }
/// <summary> /// Retrieves all groups for a user /// </summary> /// <param name="userEmail">User email. This value cannot be null.</param> /// <returns>List of user groups</returns> public IEnumerable <string> GetUserGroups(string userEmail) { if (!Code.ValidateNotNullOrWhiteSpaceArgument(userEmail, nameof(userEmail), TaggingUtilities.ReserveTag(0x2382109e /* tag_967c4 */))) { return(Enumerable.Empty <string>()); } ITestGroupsDataSet testGroupsDataSet = GetTestGroupsDataSet(); if (testGroupsDataSet == null) { return(Enumerable.Empty <string>()); } return(testGroupsDataSet.GetUserGroups(userEmail)); }
/// <summary> /// Retrieves currently loaded TestGroups DataSet /// </summary> /// <returns>Currently loaded TestGroups DataSet</returns> private ITestGroupsDataSet GetTestGroupsDataSet() { ITestGroupsDataSet dataSet = m_testGroupsDataSetLoader.LoadedDataSet; if (dataSet == null) { ULSLogging.LogTraceTag(0x238210c0 /* tag_967da */, Categories.TestGroupsDataSet, Levels.Error, "TestGroupsDataSet is null, TestGroups authentication will fail."); } else if (!dataSet.IsHealthy) { ULSLogging.LogTraceTag(0x238210c1 /* tag_967db */, Categories.TestGroupsDataSet, Levels.Error, "TestGroupsDataSet is not healthy."); } return(dataSet); }
/// <summary> /// Is one or more of the groups specified equal to a default? /// </summary> /// <param name="groupNames">A semicolon-delimited list of group names. This value cannot be null.</param> /// <returns>True if one or more of the groups specified is equal to a default; false /// otherwise.</returns> public bool IsDefault(string groupNames) { if (!Code.ValidateNotNullOrWhiteSpaceArgument(groupNames, nameof(groupNames), TaggingUtilities.ReserveTag(0x2382109c /* tag_967c2 */))) { return(false); } ITestGroupsDataSet testGroupsDataSet = GetTestGroupsDataSet(); if (testGroupsDataSet == null) { return(false); } IEnumerable <string> groupNamesList = groupNames.Split(s_listSeparatorArray, StringSplitOptions.RemoveEmptyEntries); if (groupNamesList.Intersect(testGroupsDataSet.DefaultGroups, StringComparer.OrdinalIgnoreCase).Any()) { return(true); } return(false); }