Skip to content

[#213] Read an entry's uid by the search's rule in authenticate, getObject, update and delete, so an empty own __UID__ falls back to the name - #220

Merged
maximthomas merged 5 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/213-xml-empty-own-uid
Nov 2, 2026
Merged

maximthomas merged 5 commits into
OpenIdentityPlatform:masterfrom
maximthomas:issues/213-xml-empty-own-uid

Conversation

@maximthomas

@maximthomas maximthomas commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #213.

The connector read an entry's uid in three ways:

  • The search (ConnectorObjectCreator) reads only elements whose first child is text. It took the last own __UID__ with a value and, without one, the last own __NAME__ with a value. So it reports the entry from the issue, with <icf:__UID__/>, under its name.
  • authenticate took the text of the first own __UID__ element, empty or not, and the first own __NAME__ only when there was no __UID__ element. On <icf:__UID__/> it called new Uid(""), which throws IllegalArgumentException: Uid value must not be blank!. On an entry with two __UID__ values it returned the first, while the search reports the last.
  • getObject, update and delete looked the uid up among __UID__ values only. For an entry without a __UID__ value, the uid the search reports is its name, and that lookup found nothing: getObject returned null, and update and delete threw UnknownUidException.

Now ConnectorObjectCreator.uidOf is the one rule, the search's: the last own __UID__ with a value, else the last own __NAME__ with a value, in any namespace. An element has a value if its first child is a text node. An empty __UID__ has none, and neither has one that held only whitespace, which loading the file empties. The search and authenticate use this rule.

A uid lookup (the __UID__ = v filter of getObject, update and delete) first takes the entries with a __UID__ of v, as before. Only if there are none, and only for a class with a __UID__, it takes the entries named v whose uidOf is v. Unless an entry has a __UID__ outside the ICF namespace, these are the entries without a __UID__ value whose last name is v. This fallback lives outside the index, so the index keeps agreeing with the XQuery path.

Changes in behaviour

  • authenticate returns the uid the search reports.
    • An entry with an empty or whitespace-only own __UID__ gets its name instead of an IllegalArgumentException.
    • An entry with two own __UID__ values gets the last, not the first.
    • An entry without a __UID__ value and with two names gets the last name, not the first.
  • getObject, update and delete find an __ACCOUNT__ without a __UID__ value by its name when no entry has that __UID__. This covers an empty element and no element at all. Through the facade, authenticate, getObject, update and delete now work on the entry from the issue.
  • update that renames an entry without a __UID__ value returns the new name as the uid, as it already did for __GROUP__, which has no __UID__. Before, it returned the old name, which no longer found the entry.
  • update refuses to rename an entry without a __UID__ value to a name that is another entry's __UID__. It throws AlreadyExistsException: Could not update entry. An entry with the __UID__ of <name> already exists. before any change. Otherwise the renamed entry's uid would be that name, and a lookup by it would find the other entry. An entry with a __UID__ value keeps its uid and may take such a name. The entry's own __UID__ element does not count: one that starts with a comment, such as <icf:__UID__><!--c-->v</icf:__UID__>, has no value, and the entry may be renamed to v.
  • On an entry without a __UID__ element whose __NAME__ starts with a comment, such as <icf:__NAME__><!--c-->bob</icf:__NAME__>, authenticate now throws IllegalArgumentException: Uid value must not be blank!. Before, it returned Uid("bob"). The search reads no value from such a __NAME__ and already threw on this entry on master.

Tests

The new tests are in XMLHandlerOwnElementsTests unless named otherwise.

authenticate and the search

  • authenticateReportsTheUidTheSearchReports replaces authenticateReadsTheFirstOwnPasswordAndUid.
    • Fixture: an entry with __UID__ values u40, u41 and passwords p40, p41.
    • p40 gives u41, and p41 gives null. On master p40 gives u40.
  • authenticateWithAnEmptyOwnUidReturnsItsName: <icf:__UID__/> and <icf:__UID__> </icf:__UID__> each give the entry's name, which is also the uid the search reports. On master: IllegalArgumentException.
  • aValuedUidBesideAnEmptyOneIsTheUid: a valued __UID__ before an empty one, and one after an empty one, is the uid in authenticate and in the search. On master: IllegalArgumentException where the empty one comes first.
  • authenticateReportsTheNameTheSearchReportsAsUid: an entry with an empty __UID__ and names name-a, name-b gets name-b. On master: IllegalArgumentException.
  • authenticateOnACommentFirstNameHasNoUid: an entry without a __UID__ element and with <icf:__NAME__><!--c-->bob</icf:__NAME__> gets IllegalArgumentException: Uid value must not be blank!. On master it gets Uid("bob").
  • aFullSearchReportsTheLastValuedUidOfTwo: the search reports u41 for the two-uid entry. Passes on master. Fails if uidOf takes the first value.

Uid lookup

  • uidLookupFindsAnEntryWithoutAUidByItsName: by the name, the __UID__ = emptyuid filter finds the entry, update changes it and delete removes it. The file is checked. On master the filter finds nothing.
  • uidLookupFindsAnEntryWithoutAUidElement: the same for an entry with no __UID__ element, under the ICF prefix x. On master: UnknownUidException.
  • uidLookupByNameSkipsEntriesWithAUid: two entries are named shared, one with __UID__ values u90 and u91. A lookup by shared finds only the other, and delete by shared removes only the other. On master the lookup finds nothing.
  • uidLookupByNameMatchesOnlyTheLastName: for the entry named name-a then name-b, name-a finds nothing and name-b finds it. update and delete by name-a throw UnknownUidException. On master name-b finds nothing.
  • uidLookupPrefersARealUid: an entry with __UID__ x wins over an entry without a uid named x, in the search and in update. Passes on master. Fails if the fallback adds to the real matches or replaces them.
  • eitherUidFindsAnEntryWithTwoForUpdateAndDelete: update by u40, then delete by u41. Passes on master. Fails if the lookup compares uidOf.

Rename

  • renamingAnEntryWithoutAUidReturnsTheNewName: the rename returns Uid("renamed"), and the __UID__ = renamed filter finds the entry. On master: UnknownUidException.
  • renamingAnEntryWithoutAUidToAnotherEntrysUidIsRefused:
    • It expects the refusal with its message, and all three entries unchanged.
    • An entry with a __UID__ renamed to another entry's uid keeps its own uid.
    • On master: UnknownUidException.
  • renamingToTheTextOfAnOwnUidWithoutAValueClashesOnlyWithAnotherEntry: two entries whose own __UID__ starts with a comment, <!--c-->v1 and <!--c-->v2, and a third with __UID__ v2.
    • Renaming the first to v1 returns Uid("v1"), and the __UID__ = v1 filter finds it.
    • Renaming the second to v2 is refused, because the third entry holds v2 too.
    • On master: UnknownUidException, since the lookup by the first entry's name finds nothing.
  • renamingAGroupIgnoresAStrayUid: a __GROUP__, which has no __UID__ in the XSD, renamed to the text of another group's stray __UID__ element returns the new name. Passes on master. Fails if the __UID__ clash check also runs for a class without a __UID__.

Facade and index

  • XMLConnectorTests#entryWithAnEmptyUidIsFoundByTheUidAuthenticateReturns runs, through the facade and on the entry from the issue: authenticate, getObject, update, getObject with the new value, delete, then getObject, which returns null. On master authenticate throws IllegalArgumentException.
  • XMLHandlerIndexTests.PROBES gets __UID__ = no-uid. index-fixture.xml has an account named no-uid with <icf:__UID__/>, and the index and the XQuery must both find nothing. This fails if the fallback moves into the index.

Run against master's main code, these tests give 13 failures, all of them with an "On master" result above. The module runs 402 tests with no failures; master runs 386.

Not covered

  • A filter on __UID__ with more than one part goes through XQuery, which does not find an entry by its name.
  • A __UID__ equal to the name of an entry without a __UID__ value wins. A lookup finds only the entry with the __UID__, and a full search reports both entries with the same uid.
  • The index keys __UID__ and __NAME__ in the ICF namespace only, while reads take them in any namespace. If an entry's last name is in another namespace, it reports a uid that no lookup finds.
  • A comment inside an identifier, as above, is read one way by the index and another by the search.
  • An entry with neither a __UID__ value nor a __NAME__ value gets IllegalArgumentException: Uid value must not be blank! from the search, as before. authenticate throws it too when it finds such an entry by name.
  • An entry with two __UID__ values:
    • update and delete find it by either value, and update returns the uid it was given.
    • Through the facade, getObject by the first value returns null, as on master: the facade drops a result whose uid is not the one asked for, and the search reports the last.
    • No write path creates two __UID__ elements.

…and authenticate, so an empty own __UID__ falls back to the name
… renames an entry without a __UID__ value, and refuse a name that is another entry's __UID__
@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 2, 2026
…own __UID__ that has no value; another holder still refuses it

update's __UID__ clash check asked the index whether any entry holds the new
name as __UID__. The index keys an own __UID__ that starts with a comment by its
text, while uidOf reads no value from it, so such an entry could not be renamed
to that text: it clashed with itself. The check now skips the entry itself, by
identity, and still refuses when another entry holds the name too.

Module 400/400.
…he comment-first name in authenticate and the __GROUP__ guard of the __UID__ clash check

- uidLookupByNameSkipsEntriesWithAUid and uidLookupByNameMatchesOnlyTheLastName
  also go through update and delete, so a getEntry that bypasses the uidOf
  filter fails.
- authenticateOnACommentFirstNameHasNoUid runs what the PR body only traced: an
  own __NAME__ that starts with a comment gives no uid, and authenticate throws
  IllegalArgumentException, as the search does.
- renamingAGroupIgnoresAStrayUid pins the isSupportUid guard of update's
  __UID__ clash check.
- The Javadoc of uidOf and entriesByUid says that the uid lookup takes its
  candidates from the index, which keys ICF elements by their whole text, and
  only then applies uidOf's rule; the comment in authenticate names the case in
  which an entry found by name has no uid.

Module 402/402.

@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 93d869c. I found no regressions.

The change addresses #213: authentication and search use the same UID selection rule, and a simple UID lookup finds entries with an empty or missing UID by their name. Renaming such an entry returns its new name as the UID and checks for another entry holding that UID before modifying the document.

I checked the discussion behind #213 and #209 against the implementation and tests. The real-UID precedence, compound-filter limitations, and namespace/comment edge cases are explicitly documented; I am not raising them again.

Validation: all 402 XML connector tests passed locally on JDK 21, with no failures, errors, or skips. The reactor package build passed with Javadoc generation skipped. GitHub CI is green.

@maximthomas
maximthomas merged commit 2187408 into OpenIdentityPlatform:master Nov 2, 2026
15 checks passed
@maximthomas
maximthomas deleted the issues/213-xml-empty-own-uid branch November 2, 2026 16: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: authenticate fails with IllegalArgumentException on an entry whose own __UID__ is empty

2 participants