fix(KeyCloak): Organization Mapper missing in backend #3594
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the Organization Mapper feature to the Keycloak event listener module, enabling mapping of organization names from identity providers (Keycloak/LDAP) to SW360 internal organization names.
Changes Made
New Files:
OrganizationMapper.java - Core mapping logic with intelligent lazy loading and thread-safe initialization
orgmapping.properties - Externalized configuration file with documentation
OrganizationMapperTest.java - Unit tests covering initialization, thread safety, and edge cases
Sw360KeycloakUserEventServiceTest.java - Integration tests for organization mapping during user events
Modified Files:
Sw360KeycloakUserEventService.java - Integrated OrganizationMapper for department mapping during login
Issue:
#3581
Suggest Reviewer
How To Test?
Prerequisites
Test Configuration
Option 1: Using External Configuration (Recommended)
Place
orgmapping.propertiesin system config path:/etc/sw360/orgmapping.propertiesOption 2: Using Bundled Configuration
Modify
orgmapping.propertiesin source:keycloak/event-listeners/src/main/resources/orgmapping.propertiesTest Cases
TC1: Default Behavior (Custom Mapping Disabled)
Precondition:
enable.custom.mapping=falsein configurationsw360usersdatabasedepartment: "TestOrg"TC2: Custom Mapping Enabled (Exact Match)
Precondition:
enable.custom.mapping=truematch.prefix=falseExternal Company A→PARTNER_Adepartment: "PARTNER_A"TC3: Prefix Matching Enabled
Precondition:
enable.custom.mapping=truematch.prefix=trueDEPT_→DEPARTMENTTC4: External Configuration Override
Precondition:
enable.custom.mapping=false/etc/sw360/orgmapping.propertieshasenable.custom.mapping=trueTC5: Lazy Loading / Retry Mechanism
Precondition: Configuration file initially missing, then added
/etc/sw360/Notes