Skip to content

[#218] Name the element a filter compares as the schema spells the attribute, so a filter in another case finds the entry - #222

Merged
maximthomas merged 4 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/218-xml-filter-name-case
Nov 3, 2026
Merged

maximthomas merged 4 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/218-xml-filter-name-case

Conversation

@maximthomas

@maximthomas maximthomas commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #218.

Since #212, create and update name an attribute as the schema spells it: they look the given name up exactly first, then without regard to case. The filter translator still named the element it compares by the filter's spelling, and looked its icf/ri prefix up by that spelling too, exactly. So LastName=M compared $x/ri:LastName and found nothing, and __name__=a1 compared $x/ri:__name__: it found nothing and did not reach the EntryIndex. __uid__=x was the same.

  • XMLHandler.schemaAttributeName(ObjectClass, String) gives the schema's spelling by the lookup checkAttribute uses; the two share schemaAttribute and exactAttributes. For a class or a name the schema does not have, it gives the name as given. It is a default method that returns the name as given, so other implementations keep compiling. XMLHandlerImpl overrides it. ConcurrentXMLHandler, the connector's handler, delegates without the lock, as isSupportUid does: the schema is set when the handler is made.
  • XMLFilterTranslator gets a constructor (boolean preferUidOverName, UnaryOperator<String> schemaName), and XMLConnector.createFilterTranslator passes name -> handler.schemaAttributeName(objClass, name). getAttributeName, which every expression takes its name from, maps a uid in any case to __UID__ without the schema and any other name through schemaName, then applies elementName as before. The prefix is looked up from the result, so __name__ becomes icf:__NAME__.
  • A uid keeps __UID__ whatever the schema spells it: the handler looks entries up by exactly that name (getEntry, EntryIndex), and the framework's getObject filters by it. Through the schema, an XSD that spells the uid __uid__ would turn getObject's filter into ri:__uid__. On a class without __UID__ in the schema, such as __GROUP__, __uid__=x searches by __NAME__, as __UID__=x does.
  • The (boolean) constructor stays. It names attributes as given, apart from the uid.

Changes in behaviour

  • A filter on an attribute name in another case than the schema's finds what the same filter in the schema's case finds: equalTo, startsWith, endsWith, contains, the orderings and containsAllValues. Before, it found nothing.
  • __name__=x and __uid__=x go to the index, as __NAME__=x and __UID__=x do.
  • At the connector level, LastName=X no longer matches the stray <ri:LastName> elements that update appended before XML connector: create and update accept an attribute name in another case, then lose its value #212; it compares <ri:lastname>. Reads skip the stray elements, so the framework's filter dropped such matches unless lastname held X as well.
  • containsAllValues on __password__ or __current_password__ now throws IllegalArgumentException for any value, a GuardedString included, as it does on __PASSWORD__ and __CURRENT_PASSWORD__, when the class searched has that attribute in its schema. The translator rebuilds each value with toString() into an EqualsFilter under the schema's name, and AttributeBuilder accepts only a GuardedString under either name. Before, it compared ri:__password__ (ri:__current_password__) and found nothing.

Tests

  • XMLHandlerIndexTests#schemaAttributeNameIsTheSchemasSpelling:
    • LastName, LASTNAME and lastname give lastname, and __name__ gives __NAME__.
    • An unknown name, __uid__ on __GROUP__ and an unknown class give the name as given.
    • The same lookup goes through new ConcurrentXMLHandler(handler).
    • It fails without the override in ConcurrentXMLHandler.
  • XMLHandlerIndexTests#schemaAttributeNameTakesTheExactSpellingFirst:
    • On the case-pair XSD, LastName gives LastName and lastname gives lastname.
    • It fails if the override skips the exact map.
    • The XSD is now written by writeCasePairXsd, shared with attributesWhoseNamesDifferOnlyInCaseAreWrittenApart.
  • XMLFilterSearchTests#filters gets eight rows, searched through the facade with the framework's filtering off. Each expects what the same filter finds in the schema's case:
    • the rows: LastName=M, startsWith(EMAIL, y), endsWith(Email, 3), contains(FirstName, '), greaterThan(AGE, 9), containsAllValues(Age, 9), __name__=a1 and __uid__=uid-a1;
    • giving an expression method the name as given fails its rows, except in containsAllValues, where only containsAllValuesOnThePasswordInAnotherCaseThrows fails: the EqualsFilters it builds pass through createEqualsExpression, which maps the name again;
    • wiring XMLConnector with the (boolean) constructor fails seven of them, all but __uid__.
  • XMLFilterSearchTests#filters also gets a row for a stray element:
  • XMLFilterSearchTests#containsAllValuesOnThePasswordInAnotherCaseThrows:
    • containsAllValues on __password__ with a GuardedString throws IllegalArgumentException through the facade.
    • It fails if createContainsAllValuesExpression builds its EqualsFilters under the name as given.
    • No test XSD references __CURRENT_PASSWORD__, so that name is not tested.
  • XMLFilterSearchTests#uidFilterInAnotherCaseFindsTheNameOnAClassWithoutUid:
    • Two __GROUP__ entries are added to the fixture.
    • __uid__=g1 and Uid("g1") both find g1.
    • It fails if the uid goes through schemaName.
  • XMLFilterSearchTests#filterInAnotherCaseNamesTheAttributeByTheSearchedClass:
    • __short_name__=g1 on __GROUP__ finds g1.
    • It fails if XMLConnector maps names by __ACCOUNT__'s schema, which has no __SHORT_NAME__.
  • XMLHandlerIndexTests#anotherCaseIdentifierGoesToTheIndexUnderTheSchemasName: with the connector's mapping, __name__=x and __uid__=x give identifierField __NAME__ and __UID__.
  • XMLHandlerIndexTests#uidFilterKeepsTheUidWhateverTheSchemaSpellsIt:
    • String::toLowerCase stands for an XSD that declares __uid__.
    • Uid("x") still gives __UID__.
    • It passes before the change and fails if the uid goes through schemaName.

With master's getAttributeName, 13 of the runs above fail: the eight rows, the stray-element row, containsAllValuesOnThePasswordInAnotherCaseThrows, uidFilterInAnotherCaseFindsTheNameOnAClassWithoutUid, filterInAnotherCaseNamesTheAttributeByTheSearchedClass and anotherCaseIdentifierGoesToTheIndexUnderTheSchemasName. The module runs 418 tests with no failures, against 402 on master.

Not covered

  • Elements such as <ri:LastName> that the old update wrote into existing files stay there, and a filter in any case no longer finds an entry by them.
  • On an XSD with two attribute names that differ only in case, a third spelling, such as LASTNAME next to lastname and LastName, goes to whichever of the two the framework's case-insensitive map holds, as in create and update.
  • containsAllValues compares a GuardedString by its toString(), as before.

… name from the XML handler, by the lookup create and update use
…schema spells the attribute, so a filter in another case finds the entry
@maximthomas maximthomas added bug Something isn't working java Pull requests that update java code tests Test additions or fixes connector:xml XML connector labels Nov 3, 2026
… outside the schema, and that containsAllValues on __password__ throws

Account a2 gets a <ri:LastName> beside its <ri:lastname>, as update wrote
such elements before OpenIdentityPlatform#212, and LastName=S finds nothing. It fails with
master's getAttributeName and if createEqualsExpression compares the name
as given as well as the schema's.

containsAllValuesOnThePasswordInAnotherCaseThrows fails if
createContainsAllValuesExpression builds its EqualsFilters under the name
as given; until now that mapping had no test.
@maximthomas
maximthomas marked this pull request as ready for review November 3, 2026 12:30
@maximthomas
maximthomas requested a review from vharseko November 3, 2026 12:30

@vharseko vharseko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at b938289. I found no new issues in the changes.

The filter translator now resolves attribute names using the same exact-first, case-insensitive-fallback lookup as create and update, using the schema of the searched object class. Namespace selection follows the resolved name. The UID special case preserves identifier lookup and the name fallback for classes without UID support, and ConcurrentXMLHandler delegates the new lookup correctly.

The treatment of legacy elements, ambiguous case-pair names, and containsAllValues on password attributes is explicitly documented in the PR description.

Local validation on JDK 21: the Maven reactor package build succeeded; all 418 XML connector unit tests passed, with no failures, errors, or skips. CodeQL passed. The Maven CI matrix was still pending or running when I checked.

@maximthomas
maximthomas merged commit f2883a4 into OpenIdentityPlatform:master Nov 3, 2026
15 checks passed
@maximthomas
maximthomas deleted the issues/218-xml-filter-name-case branch November 3, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connector:xml XML connector java Pull requests that update java code tests Test additions or fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML connector: a filter on an attribute name in another case than the schema's finds nothing

2 participants