public static void Serialize(Stream stream, GameProperties instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.CreationAttributes.Count > 0) { foreach (bnet.protocol.attribute.Attribute attribute in instance.CreationAttributes) { stream.WriteByte(10); ProtocolParser.WriteUInt32(stream, attribute.GetSerializedSize()); bnet.protocol.attribute.Attribute.Serialize(stream, attribute); } } if (instance.HasFilter) { stream.WriteByte(18); ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize()); AttributeFilter.Serialize(stream, instance.Filter); } if (instance.HasCreate) { stream.WriteByte(24); ProtocolParser.WriteBool(stream, instance.Create); } if (instance.HasOpen) { stream.WriteByte(32); ProtocolParser.WriteBool(stream, instance.Open); } if (instance.HasProgramId) { stream.WriteByte(45); binaryWriter.Write(instance.ProgramId); } }
public void NameAndNamespaceFiltering(string attributeName, string attributeNamespace, string elementName, string elementNamespace, bool expectedResult) { // Arrange var attribute = new XAttribute(XName.Get("a", "a-xmlns"), string.Empty); var element = new XElement(XName.Get("e", "e-xmlns")); element.Add(attribute); var settings = new[] { new XPathSetting { AttributeName = attributeName, AttributeNamespace = attributeNamespace, ElementName = elementName, ElementNamespace = elementNamespace } }; var filter = new AttributeFilter(settings); // Act var isIncluded = filter.IsIncluded(attribute); // Assert Assert.That(isIncluded, Is.EqualTo(expectedResult)); }
public async Task <ActionResult <LDAPSearchResult> > GetByIdentifier( [FromRoute] string serverProfile, [FromRoute] string catalogType, [FromRoute] string identifier, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalIdentifierAttributeBinder))] EntryAttribute?identifierAttribute, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalRequiredAttributesBinder))] RequiredEntryAttributes?requiredAttributes, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalQueryStringBinder))] string requestTag) { Logger.LogInformation($"Request path: {nameof(serverProfile)}={serverProfile}, {nameof(catalogType)}={catalogType}, {nameof(identifier)}={identifier}, {nameof(identifierAttribute)}={identifierAttribute}, {nameof(requiredAttributes)}={requiredAttributes}, {nameof(requestTag)}={requestTag}"); var ldapClientConfig = GetLdapClientConfiguration(serverProfile, IsGlobalCatalog(catalogType)); var ldapSearcher = await GetLdapSearcher(ldapClientConfig); var searchFilter = new AttributeFilter(identifierAttribute.Value, new FilterValue(identifier)); var searchResult = await ldapSearcher.SearchEntriesAsync(searchFilter, requiredAttributes.Value, requestTag); if (searchResult.Entries.Count() == 0 && searchResult.HasErrorInfo) { throw searchResult.ErrorObject; } if (searchResult.Entries.Count() > 1) { throw new InvalidOperationException($"More than one LDAP entry was obtained for the supplied identifier '{identifier}'. Verify the identifier and the attribute '{identifierAttribute}' to which it applies."); } Logger.LogInformation("Response body: {@result}", searchResult); return(Ok(searchResult)); }
/* * private void CreateDisplayFilters(FilteredBrowsing browsing) * { * List<RangeFilter> filters = null; * * if (browsing.AttributeRanges != null) * { * filters = new List<RangeFilter>(browsing.AttributeRanges); * } * else * { * filters = new List<RangeFilter>(); * } * * var filter = new RangeFilter(); * filter.Key = "DisplaySize"; * * var vals = new List<RangeFilterValue>(); * * vals.Add(CreateRange("20 Inches & Under", "under-i20", String.Empty, "20", "en")); * vals.Add(CreateRange("21 to 29 Inches", "i21-29", "21", "29", "en")); * vals.Add(CreateRange("30 to 39 Inches", "i21-29", "30", "39", "en")); * vals.Add(CreateRange("40 to 49 Inches", "i21-29", "40", "49", "en")); * vals.Add(CreateRange("50 Inches & Up", "over-i50", "50", String.Empty, "en")); * * filters.Add(filter); * * browsing.AttributeRanges = filters.ToArray(); * } */ private static void CreateFilters(FilteredBrowsing browsing) { var filters = browsing.Attributes != null ? new List <AttributeFilter>(browsing.Attributes) : new List <AttributeFilter>(); var vals = new List <AttributeFilterValue>(); var filter = new AttributeFilter { Key = "Brand" }; var val = new AttributeFilterValue { Id = "samsung", Value = "samsung" }; var val2 = new AttributeFilterValue { Id = "sony", Value = "sony" }; var val3 = new AttributeFilterValue { Id = "apple", Value = "apple" }; vals.Add(val); vals.Add(val2); vals.Add(val3); filter.Values = vals.ToArray(); filters.Add(filter); browsing.Attributes = filters.ToArray(); }
private String CreateContainsAllValuesExpressionInternal(AttributeFilter filter, Boolean not) { if (not) { return(null); } ConnectorAttribute attr = filter.GetAttribute(); // if there is only one thing to search on, and it's // a uid we need to convert the uid to something we // can search on. NOTE: only handling the case where // we are doing an equality search, and only one item // is in the equality search ... It's all that makes // sense for uid. if (attr is Uid) { String attrValue = ((Uid)attr).GetUidValue(); if (LooksLikeGUID(attrValue)) { String searchGuid = GetUidSearchString(((Uid)attr).GetUidValue()); attr = new Uid(searchGuid); } else { attr = new Name(attrValue); } } String[] attrNames = GetLdapNamesForAttribute(attr); if (attrNames == null) { return(null); } StringBuilder builder = new StringBuilder(); if (attr.Value == null) { return(null); } if (attr.Value.Count == 1) { BuildEqualityFilter(builder, attrNames, attr.Value[0]); } else { builder.Append("(&"); foreach (Object value in attr.Value) { BuildEqualityFilter(builder, attrNames, value); } builder.Append(')'); } return(builder.ToString()); }
private static AttributeFilter GetAttributeFilter(string[] ignoreAttributeFileNames) { AttributeFilter attributeFilter = new AttributeFilter(); AddFiles(ignoreAttributeFileNames, (file) => attributeFilter.AddIgnoreAttributeFile(file)); return(attributeFilter); }
public static ListFactoriesRequest Deserialize(Stream stream, ListFactoriesRequest instance, long limit) { instance.StartIndex = 0u; instance.MaxResults = 100u; while (limit < 0L || stream.get_Position() < limit) { int num = stream.ReadByte(); if (num == -1) { if (limit >= 0L) { throw new EndOfStreamException(); } return(instance); } else { int num2 = num; if (num2 != 10) { if (num2 != 16) { if (num2 != 24) { Key key = ProtocolParser.ReadKey((byte)num, stream); uint field = key.Field; if (field == 0u) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } else { instance.MaxResults = ProtocolParser.ReadUInt32(stream); } } else { instance.StartIndex = ProtocolParser.ReadUInt32(stream); } } else if (instance.Filter == null) { instance.Filter = AttributeFilter.DeserializeLengthDelimited(stream); } else { AttributeFilter.DeserializeLengthDelimited(stream, instance.Filter); } } } if (stream.get_Position() == limit) { return(instance); } throw new ProtocolBufferException("Read past max limit"); }
public void FindGame(byte[] requestGuid, BnetGameType gameType, int scenario, long deckId, long aiDeckId, bool setScenarioIdAttr) { if (this.s_gameRequest != 0) { Debug.LogWarning("WARNING: FindGame called with an active game"); this.CancelFindGame(this.s_gameRequest); this.s_gameRequest = 0L; } if (this.IsNoAccountTutorialGame(gameType)) { this.GoToNoAccountTutorialServer(scenario); } else { object[] args = new object[] { gameType, scenario, deckId, aiDeckId, !setScenarioIdAttr ? 0 : 1, (requestGuid != null) ? requestGuid.ToHexString() : "null" }; base.ApiLog.LogInfo("FindGame type={0} scenario={1} deck={2} aideck={3} setScenId={4} request_guid={5}", args); bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player(); Identity identity = new Identity(); identity.SetGameAccountId(base.m_battleNet.GameAccountId); val.SetIdentity(identity); val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)gameType)); val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)deckId))); val.AddAttribute(ProtocolHelper.CreateAttribute("aideck", (long)((int)aiDeckId))); val.AddAttribute(ProtocolHelper.CreateAttribute("request_guid", requestGuid)); GameProperties properties = new GameProperties(); AttributeFilter filter = new AttributeFilter(); filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL); if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX")) { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString())); } else if (BattleNet.IsVersionInt()) { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt())); } else { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString())); } filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)gameType)); if (setScenarioIdAttr) { filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario)); } properties.SetFilter(filter); properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)gameType)); properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); FindGameRequest request = new FindGameRequest(); request.AddPlayer(val); request.SetProperties(properties); request.SetAdvancedNotification(true); FindGameRequest request2 = request; this.PrintFindGameRequest(request2); this.IsFindGamePending = true; base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0); } }
public static ListFactoriesRequest Deserialize(Stream stream, ListFactoriesRequest instance, long limit) { instance.StartIndex = 0; instance.MaxResults = 100; while (true) { if (limit < (long)0 || stream.Position < limit) { int num = stream.ReadByte(); if (num == -1) { if (limit >= (long)0) { throw new EndOfStreamException(); } break; } else if (num == 10) { if (instance.Filter != null) { AttributeFilter.DeserializeLengthDelimited(stream, instance.Filter); } else { instance.Filter = AttributeFilter.DeserializeLengthDelimited(stream); } } else if (num == 16) { instance.StartIndex = ProtocolParser.ReadUInt32(stream); } else if (num == 24) { instance.MaxResults = ProtocolParser.ReadUInt32(stream); } else { Key key = ProtocolParser.ReadKey((byte)num, stream); if (key.Field == 0) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } } else { if (stream.Position != limit) { throw new ProtocolBufferException("Read past max limit"); } break; } } return(instance); }
protected virtual AggregationRequest GetAttributeFilterAggregationRequest(AttributeFilter attributeFilter, IEnumerable <IFilter> existingFilters) { return(new TermAggregationRequest { FieldName = attributeFilter.Key, Values = !attributeFilter.Values.IsNullOrEmpty() ? attributeFilter.Values.Select(v => v.Id).ToArray() : null, Filter = existingFilters.And(), Size = attributeFilter.FacetSize, }); }
public override void InternalToBinary(IBinaryRawWriter writer) { VersionSerializationHelper.EmitVersionByte(writer, VERSION_NUMBER); writer.WriteBoolean(AttributeFilter != null); AttributeFilter?.ToBinary(writer); writer.WriteBoolean(SpatialFilter != null); SpatialFilter?.ToBinary(writer); }
public void FindGame(byte[] requestGuid, int gameType, int scenario, long deckId, long aiDeckId, bool setScenarioIdAttr) { if (this.s_gameRequest != 0UL) { LogAdapter.Log(LogLevel.Warning, "WARNING: FindGame called with an active game"); this.CancelFindGame(this.s_gameRequest); this.s_gameRequest = 0UL; } Player player = new Player(); Identity identity = new Identity(); identity.SetGameAccountId(this.m_battleNet.GameAccountId); player.SetIdentity(identity); player.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)gameType)); player.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); player.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)deckId))); player.AddAttribute(ProtocolHelper.CreateAttribute("aideck", (long)((int)aiDeckId))); player.AddAttribute(ProtocolHelper.CreateAttribute("request_guid", requestGuid)); GameProperties gameProperties = new GameProperties(); AttributeFilter attributeFilter = new AttributeFilter(); attributeFilter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL); if (!BattleNet.IsVersionInt()) { attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersion())); } else { int num = 0; if (!int.TryParse(BattleNet.GetVersion(), out num)) { LogAdapter.Log(LogLevel.Error, "Could not convert BattleNetVersion to int: " + BattleNet.GetVersion()); } attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)num)); } attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)gameType)); if (setScenarioIdAttr) { attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario)); } gameProperties.SetFilter(attributeFilter); gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)gameType)); gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); FindGameRequest findGameRequest = new FindGameRequest(); findGameRequest.AddPlayer(player); findGameRequest.SetProperties(gameProperties); findGameRequest.SetAdvancedNotification(true); FindGameRequest findGameRequest2 = findGameRequest; this.PrintFindGameRequest(findGameRequest2); this.IsFindGamePending = true; this.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3u, findGameRequest2, new RPCContextDelegate(this.FindGameCallback), 0u); }
private AttributeFilter ConvertToAttributeFilter(Property property) { var values = _propertyService.SearchDictionaryValues(property.Id, null); var result = new AttributeFilter { Key = property.Name, Values = values.Select(ConvertToAttributeFilterValue).ToArray(), }; return(result); }
protected virtual Aggregation GetAttributeAggregation(AttributeFilter attributeFilter, IList <AggregationResponse> aggregationResponses) { var result = new Aggregation { AggregationType = "attr", Field = attributeFilter.Key, Labels = attributeFilter.DisplayNames ?.Select(d => new AggregationLabel { Language = d.Language, Label = d.Name }) .ToArray(), }; var aggregationId = attributeFilter.Key; var aggregationResponse = aggregationResponses.FirstOrDefault(a => a.Id.EqualsInvariant(aggregationId)); if (aggregationResponse != null) { if (attributeFilter.Values == null) { // Return all values result.Items = aggregationResponse.Values.Select(v => new AggregationItem { Value = v.Id, Count = (int)v.Count }).ToArray(); } else { // Return predefined values with localization var aggregationItems = new List <AggregationItem>(); foreach (var group in attributeFilter.Values.GroupBy(v => v.Id)) { var value = aggregationResponse.Values.FirstOrDefault(v => v.Id.EqualsInvariant(group.Key)); if (value != null) { var valueLabels = group.GetValueLabels(); var aggregationItem = new AggregationItem { Value = value.Id, Count = (int)value.Count, Labels = valueLabels }; aggregationItems.Add(aggregationItem); } } if (aggregationItems.Any()) { result.Items = aggregationItems; } } } return(result); }
public static GetGameStatsRequest Deserialize(Stream stream, GetGameStatsRequest instance, long limit) { BinaryReader binaryReader = new BinaryReader(stream); while (limit < 0L || stream.get_Position() < limit) { int num = stream.ReadByte(); if (num == -1) { if (limit >= 0L) { throw new EndOfStreamException(); } return(instance); } else { int num2 = num; if (num2 != 9) { if (num2 != 18) { Key key = ProtocolParser.ReadKey((byte)num, stream); uint field = key.Field; if (field == 0u) { throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream"); } ProtocolParser.SkipKey(stream, key); } else if (instance.Filter == null) { instance.Filter = AttributeFilter.DeserializeLengthDelimited(stream); } else { AttributeFilter.DeserializeLengthDelimited(stream, instance.Filter); } } else { instance.FactoryId = binaryReader.ReadUInt64(); } } } if (stream.get_Position() == limit) { return(instance); } throw new ProtocolBufferException("Read past max limit"); }
public async Task <ActionResult <DTO.LDAPAccountAuthenticationStatus> > PostAuthenticationAsync( [FromRoute] string serverProfile, [FromRoute] string catalogType, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalQueryStringBinder))] string requestTag, [FromBody] DTO.LDAPAccountCredentials accountCredentials) { Logger.LogInformation($"Request path: {nameof(serverProfile)}={serverProfile}, {nameof(catalogType)}={catalogType}, {nameof(requestTag)}={requestTag}"); Logger.LogInformation("Request body: {@credentials}", accountCredentials.Clone()); var ldapClientConfig = GetLdapClientConfiguration(serverProfile.ToString(), IsGlobalCatalog(catalogType)); var accountAuthenticationStatus = new DTO.LDAPAccountAuthenticationStatus { DomainName = accountCredentials.DomainName, AccountName = accountCredentials.AccountName, RequestTag = requestTag }; var attributeFilter = new AttributeFilter(EntryAttribute.sAMAccountName, new FilterValue(accountCredentials.AccountName)); var ldapSearcher = await GetLdapSearcher(ldapClientConfig); var ldapSearchResult = await ldapSearcher.SearchEntriesAsync(attributeFilter, RequiredEntryAttributes.OnlyObjectSid, null); if (ldapSearchResult.Entries.Count() == 0) { if (ldapSearchResult.HasErrorInfo) { throw ldapSearchResult.ErrorObject; } else { accountAuthenticationStatus.IsAuthenticated = false; accountAuthenticationStatus.Message = $"The account name {accountCredentials.AccountName} could not be found, verify that the account name exists."; } } else { var authenticator = new LDAPHelper.Authenticator(ldapClientConfig.ServerSettings); var domainAccountName = $"{accountCredentials.DomainName}\\{accountCredentials.AccountName}"; var credentialToAuthenticate = new LDAPHelper.Credentials(domainAccountName, accountCredentials.AccountPassword); var isAuthenticated = await authenticator.AuthenticateAsync(credentialToAuthenticate); accountAuthenticationStatus.IsAuthenticated = isAuthenticated; accountAuthenticationStatus.Message = isAuthenticated ? "The credentials are valid." : "Wrong Domain or password."; } Logger.LogInformation("Response body: {@status}", accountAuthenticationStatus); return(Ok(accountAuthenticationStatus)); }
private string PrintGameMasterAttributeFilter(AttributeFilter filter) { string str; string str1 = "Attribute Filter: ["; switch (filter.Op) { case AttributeFilter.Types.Operation.MATCH_NONE: { str = "MATCH_NONE"; break; } case AttributeFilter.Types.Operation.MATCH_ANY: { str = "MATCH_ANY"; break; } case AttributeFilter.Types.Operation.MATCH_ALL: { str = "MATCH_ALL"; break; } case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC: { str = "MATCH_ALL_MOST_SPECIFIC"; break; } default: { str = "UNKNOWN"; break; } } str1 = string.Concat(str1, "Operation: ", str, " "); str1 = string.Concat(str1, "Attributes: ["); int attributeCount = filter.AttributeCount; for (int i = 0; i < attributeCount; i++) { bnet.protocol.attribute.Attribute item = filter.Attribute[i]; string str2 = str1; str1 = string.Concat(new object[] { str2, "Name: ", item.Name, " Value: ", item.Value, " " }); } str1 = string.Concat(str1, "] "); return(str1); }
public static void Serialize(Stream stream, GetGameStatsRequest instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); stream.WriteByte(9); binaryWriter.Write(instance.FactoryId); if (instance.Filter == null) { throw new ArgumentNullException("Filter", "Required by proto specification."); } stream.WriteByte(18); ProtocolParser.WriteUInt32(stream, instance.Filter.GetSerializedSize()); AttributeFilter.Serialize(stream, instance.Filter); }
public void CreateFriendlyChallengeGame(long myDeck, long hisDeck, EntityId hisGameAccount, int scenario) { FindGameRequest request = new FindGameRequest(); bnet.protocol.game_master.Player val = new bnet.protocol.game_master.Player(); Identity identity = new Identity(); identity.SetGameAccountId(base.m_battleNet.GameAccountId); GameProperties properties = new GameProperties(); AttributeFilter filter = new AttributeFilter(); filter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL); if (!BattleNet.IsVersionInt() && (BattleNet.GetVersionString() == "PAX")) { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString() + BattleNet.GetVersionInt().ToString())); } else if (BattleNet.IsVersionInt()) { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)BattleNet.GetVersionInt())); } else { filter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersionString())); } filter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", (long)1L)); filter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario)); properties.SetFilter(filter); properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", (long)1L)); properties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); val.SetIdentity(identity); val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L)); val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)myDeck))); request.AddPlayer(val); identity = new Identity(); val = new bnet.protocol.game_master.Player(); identity.SetGameAccountId(hisGameAccount); val.SetIdentity(identity); val.AddAttribute(ProtocolHelper.CreateAttribute("type", (long)1L)); val.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); val.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)hisDeck))); request.AddPlayer(val); request.SetProperties(properties); request.SetAdvancedNotification(true); FindGameRequest request2 = request; this.PrintFindGameRequest(request2); this.IsFindGamePending = true; base.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3, request2, new RPCContextDelegate(this.FindGameCallback), 0); }
public async Task <ActionResult <LDAPSearchResult> > GetGroupsFilteringByAsync( [FromRoute] string serverProfile, [FromRoute] string catalogType, [FromQuery][ModelBinder(BinderType = typeof(Binders.SearchFiltersBinder))] Models.SearchFiltersModel searchFilters, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalRequiredAttributesBinder))] RequiredEntryAttributes?requiredAttributes, [FromQuery][ModelBinder(BinderType = typeof(Binders.OptionalQueryStringBinder))] string requestTag ) { Logger.LogInformation($"Request path: {nameof(serverProfile)}={serverProfile}, {nameof(catalogType)}={catalogType}, {nameof(searchFilters.filterAttribute)}={searchFilters.filterAttribute}, {nameof(searchFilters.filterValue)}={searchFilters.filterValue}, {nameof(searchFilters.secondFilterAttribute)}={searchFilters.secondFilterAttribute}, {nameof(searchFilters.secondFilterValue)}={searchFilters.secondFilterValue},{nameof(searchFilters.combineFilters)}={searchFilters.combineFilters},{nameof(requiredAttributes)}={requiredAttributes}, {nameof(requestTag)}={requestTag}"); var clientConfiguration = GetLdapClientConfiguration(serverProfile, IsGlobalCatalog(catalogType)); var ldapSearcher = await GetLdapSearcher(clientConfiguration); LDAPSearchResult searchResult; if (searchFilters.secondFilterAttribute.HasValue) { var onlyGroupsFilter = AttributeFilterCombiner.CreateOnlyGroupsFilterCombiner(); var firstAttributeFilter = new AttributeFilter(searchFilters.filterAttribute.Value, new FilterValue(searchFilters.filterValue)); var secondAttributeFilter = new AttributeFilter(searchFilters.secondFilterAttribute.Value, new FilterValue(searchFilters.secondFilterValue)); var combinedFilters = new AttributeFilterCombiner(false, searchFilters.combineFilters.Value, new ICombinableFilter[] { firstAttributeFilter, secondAttributeFilter }); var searchFilter = new AttributeFilterCombiner(false, true, new ICombinableFilter[] { onlyGroupsFilter, combinedFilters }); searchResult = await ldapSearcher.SearchEntriesAsync(searchFilter, requiredAttributes.Value, requestTag); } else { var onlyGroupsFilter = AttributeFilterCombiner.CreateOnlyGroupsFilterCombiner(); var attributeFilter = new AttributeFilter(searchFilters.filterAttribute.Value, new FilterValue(searchFilters.filterValue)); var searchFilter = new AttributeFilterCombiner(false, true, new ICombinableFilter[] { onlyGroupsFilter, attributeFilter }); searchResult = await ldapSearcher.SearchEntriesAsync(searchFilter, requiredAttributes.Value, requestTag); } var resultCount = searchResult.Entries.Count(); if (resultCount == 0 && searchResult.HasErrorInfo) { throw searchResult.ErrorObject; } Logger.LogInformation("Search result count: {0}", resultCount); return(Ok(searchResult)); }
public void CreateFriendlyChallengeGame(long myDeck, long hisDeck, bnet.protocol.EntityId hisGameAccount, int scenario) { FindGameRequest findGameRequest = new FindGameRequest(); Player player = new Player(); Identity identity = new Identity(); identity.SetGameAccountId(this.m_battleNet.GameAccountId); GameProperties gameProperties = new GameProperties(); AttributeFilter attributeFilter = new AttributeFilter(); attributeFilter.SetOp(AttributeFilter.Types.Operation.MATCH_ALL); if (!BattleNet.IsVersionInt()) { attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", BattleNet.GetVersion())); } else { int num = 0; if (!int.TryParse(BattleNet.GetVersion(), out num)) { LogAdapter.Log(LogLevel.Error, "Could not convert BattleNetVersion to int: " + BattleNet.GetVersion()); } attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("version", (long)num)); } attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("GameType", 1L)); attributeFilter.AddAttribute(ProtocolHelper.CreateAttribute("ScenarioId", (long)scenario)); gameProperties.SetFilter(attributeFilter); gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("type", 1L)); gameProperties.AddCreationAttributes(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); player.SetIdentity(identity); player.AddAttribute(ProtocolHelper.CreateAttribute("type", 1L)); player.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); player.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)myDeck))); findGameRequest.AddPlayer(player); identity = new Identity(); player = new Player(); identity.SetGameAccountId(hisGameAccount); player.SetIdentity(identity); player.AddAttribute(ProtocolHelper.CreateAttribute("type", 1L)); player.AddAttribute(ProtocolHelper.CreateAttribute("scenario", (long)scenario)); player.AddAttribute(ProtocolHelper.CreateAttribute("deck", (long)((int)hisDeck))); findGameRequest.AddPlayer(player); findGameRequest.SetProperties(gameProperties); findGameRequest.SetAdvancedNotification(true); FindGameRequest findGameRequest2 = findGameRequest; this.PrintFindGameRequest(findGameRequest2); this.IsFindGamePending = true; this.m_rpcConnection.QueueRequest(this.m_gameMasterService.Id, 3u, findGameRequest2, new RPCContextDelegate(this.FindGameCallback), 0u); }
public bool IsFilter(HeroData data) { if (AttributeFilter.HasFlag(data.Attribute)) { return(true); } if (RoleFilter.HasFlag(data.Role)) { return(true); } return(false); }
private AttributeFilter ConvertToAttributeFilter(Property property) { var values = _propertyService.SearchDictionaryValues(property.Id, null); var result = new AttributeFilter { Key = property.Name, Values = values.Select(ConvertToAttributeFilterValue).ToArray(), IsLocalized = property.Multilanguage, DisplayNames = property.DisplayNames.Select(ConvertToFilterDisplayName).ToArray(), }; return(result); }
public static ISearchFilter Convert(this ISearchFilterService helper, ISearchFilter filter, string[] keys) { // get values that we have filters set for var values = from v in filter.GetValues() where keys.Contains(v.Id) select v; var attributeFilter = filter as AttributeFilter; if (attributeFilter != null) { var newFilter = new AttributeFilter(); newFilter.InjectFrom(filter); newFilter.Values = values.OfType <AttributeFilterValue>().ToArray(); return(newFilter); } var rangeFilter = filter as RangeFilter; if (rangeFilter != null) { var newFilter = new RangeFilter(); newFilter.InjectFrom(filter); newFilter.Values = values.OfType <RangeFilterValue>().ToArray(); return(newFilter); } var priceRangeFilter = filter as PriceRangeFilter; if (priceRangeFilter != null) { var newFilter = new PriceRangeFilter(); newFilter.InjectFrom(filter); newFilter.Values = values.OfType <RangeFilterValue>().ToArray(); return(newFilter); } var categoryFilter = filter as CategoryFilter; if (categoryFilter != null) { var newFilter = new CategoryFilter(); newFilter.InjectFrom(filter); newFilter.Values = values.OfType <CategoryFilterValue>().ToArray(); return(newFilter); } return(null); }
protected virtual IFilter ConvertAttributeFilter(AttributeFilter attributeFilter, IList <string> valueIds) { var knownValues = attributeFilter.Values ?.Where(v => valueIds.Contains(v.Id, StringComparer.OrdinalIgnoreCase)) .Select(v => v.Id) .ToArray(); var result = new TermFilter { FieldName = attributeFilter.Key, Values = knownValues != null && knownValues.Any() ? knownValues : valueIds, }; return(result); }
private static IDictionary <String, Object> CreateFilter(String operation, AttributeFilter filter, bool not) { IDictionary <String, Object> dic = new Dictionary <String, Object>(); var name = filter.GetAttribute().Name; var value = ConnectorAttributeUtil.GetStringValue(filter.GetAttribute()); if (StringUtil.IsBlank(value)) { return(null); } dic.Add(Not, not); dic.Add(Operation, operation); dic.Add(Left, name); dic.Add(Right, value); return(dic); }
private string PrintGameMasterAttributeFilter(AttributeFilter filter) { string text = "Attribute Filter: ["; string text2; switch (filter.Op) { case AttributeFilter.Types.Operation.MATCH_NONE: text2 = "MATCH_NONE"; break; case AttributeFilter.Types.Operation.MATCH_ANY: text2 = "MATCH_ANY"; break; case AttributeFilter.Types.Operation.MATCH_ALL: text2 = "MATCH_ALL"; break; case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC: text2 = "MATCH_ALL_MOST_SPECIFIC"; break; default: text2 = "UNKNOWN"; break; } text = text + "Operation: " + text2 + " "; text += "Attributes: ["; int attributeCount = filter.AttributeCount; for (int i = 0; i < attributeCount; i++) { Attribute attribute = filter.Attribute.get_Item(i); string text3 = text; text = string.Concat(new object[] { text3, "Name: ", attribute.Name, " Value: ", attribute.Value, " " }); } return(text + "] "); }
public static void Serialize(Stream stream, FindChannelOptions instance) { BinaryWriter binaryWriter = new BinaryWriter(stream); if (instance.HasStartIndex) { stream.WriteByte(8); ProtocolParser.WriteUInt32(stream, instance.StartIndex); } if (instance.HasMaxResults) { stream.WriteByte(16); ProtocolParser.WriteUInt32(stream, instance.MaxResults); } if (instance.HasName) { stream.WriteByte(26); ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.Name)); } if (instance.HasProgram) { stream.WriteByte(37); binaryWriter.Write(instance.Program); } if (instance.HasLocale) { stream.WriteByte(45); binaryWriter.Write(instance.Locale); } if (instance.HasCapacityFull) { stream.WriteByte(48); ProtocolParser.WriteUInt32(stream, instance.CapacityFull); } if (instance.AttributeFilter == null) { throw new ArgumentNullException("AttributeFilter", "Required by proto specification."); } stream.WriteByte(58); ProtocolParser.WriteUInt32(stream, instance.AttributeFilter.GetSerializedSize()); AttributeFilter.Serialize(stream, instance.AttributeFilter); if (instance.HasChannelType) { stream.WriteByte(66); ProtocolParser.WriteBytes(stream, Encoding.UTF8.GetBytes(instance.ChannelType)); } }
private string PrintGameMasterAttributeFilter(AttributeFilter filter) { string text = "Attribute Filter: ["; string str; switch (filter.Op) { case AttributeFilter.Types.Operation.MATCH_NONE: str = "MATCH_NONE"; break; case AttributeFilter.Types.Operation.MATCH_ANY: str = "MATCH_ANY"; break; case AttributeFilter.Types.Operation.MATCH_ALL: str = "MATCH_ALL"; break; case AttributeFilter.Types.Operation.MATCH_ALL_MOST_SPECIFIC: str = "MATCH_ALL_MOST_SPECIFIC"; break; default: str = "UNKNOWN"; break; } text = text + "Operation: " + str + " "; text += "Attributes: ["; int attributeCount = filter.AttributeCount; for (int i = 0; i < attributeCount; i++) { bnet.protocol.attribute.Attribute attribute = filter.Attribute[i]; string text2 = text; text = string.Concat(new object[] { text2, "Name: ", attribute.Name, " Value: ", attribute.Value, " " }); } return(text + "] "); }
public void ConvertAttributeValueToJson() { var filter = new AttributeFilter { SchemaId = "1", AttributeValue = new AttributeValue { Name = "full-name", Value = "alice" } }; var json = filter.ToJson(); Assert.NotNull(json); Assert.Equal("{\"schema_id\":\"1\",\"attr::full-name::value\":\"alice\"}", json); }