Update identity provider listeners in IDP manager#8208
Conversation
📝 WalkthroughWalkthroughChangesShared identity providers now expose shared-state detection and support resolution-aware retrieval through manager APIs and post-get listeners. Updates use raw provider data, new management error codes are defined, and connection-sharing configuration adds a PRIMARY provisioning user-store fallback. Shared Identity Provider Resolution
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java`:
- Around line 996-1008: Add Javadoc to the public isShared() method describing
its return value, and make the property-name comparison null-safe by invoking
equals on the constant "isShared" rather than on idpProperty.getName(). Preserve
the existing false fallback behavior.
- Around line 996-1008: Add Javadoc to the public isShared() method, and make
the property-name comparison null-safe by invoking equals on the constant
"isShared" rather than on idpProperty.getName().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 211b3fb2-b84a-4c37-83f0-445ccb201e45
📒 Files selected for processing (8)
components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.javacomponents/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdentityProviderManager.javacomponents/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/IdpManager.javacomponents/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/listener/IdentityProviderMgtListener.javacomponents/idp-mgt/org.wso2.carbon.idp.mgt/src/main/java/org/wso2/carbon/idp/mgt/util/IdPManagementConstants.javafeatures/identity-core/org.wso2.carbon.identity.core.server.feature/resources/identity.xmlfeatures/identity-core/org.wso2.carbon.identity.core.server.feature/resources/identity.xml.j2features/identity-core/org.wso2.carbon.identity.core.server.feature/resources/org.wso2.carbon.identity.core.server.feature.default.json
| public boolean isShared() { | ||
|
|
||
| IdentityProviderProperty[] idpProperties = getIdpProperties(); | ||
| if (idpProperties == null) { | ||
| return false; | ||
| } | ||
| for (IdentityProviderProperty idpProperty : idpProperties) { | ||
| if (idpProperty.getName().equals("isShared")) { | ||
| return Boolean.parseBoolean(idpProperty.getValue()); | ||
| } | ||
| } | ||
| return false; | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Prevent NullPointerException and add missing Javadoc.
As per coding guidelines, all public methods should have a docstring. Additionally, swapping the string comparison prevents a potential NullPointerException if idpProperty.getName() evaluates to null.
♻️ Proposed fix
+ /**
+ * Checks if the identity provider is shared.
+ *
+ * `@return` True if the identity provider is shared, false otherwise.
+ */
public boolean isShared() {
IdentityProviderProperty[] idpProperties = getIdpProperties();
if (idpProperties == null) {
return false;
}
for (IdentityProviderProperty idpProperty : idpProperties) {
- if (idpProperty.getName().equals("isShared")) {
+ if ("isShared".equals(idpProperty.getName())) {
return Boolean.parseBoolean(idpProperty.getValue());
}
}
return false;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public boolean isShared() { | |
| IdentityProviderProperty[] idpProperties = getIdpProperties(); | |
| if (idpProperties == null) { | |
| return false; | |
| } | |
| for (IdentityProviderProperty idpProperty : idpProperties) { | |
| if (idpProperty.getName().equals("isShared")) { | |
| return Boolean.parseBoolean(idpProperty.getValue()); | |
| } | |
| } | |
| return false; | |
| } | |
| /** | |
| * Checks if the identity provider is shared. | |
| * | |
| * `@return` True if the identity provider is shared, false otherwise. | |
| */ | |
| public boolean isShared() { | |
| IdentityProviderProperty[] idpProperties = getIdpProperties(); | |
| if (idpProperties == null) { | |
| return false; | |
| } | |
| for (IdentityProviderProperty idpProperty : idpProperties) { | |
| if ("isShared".equals(idpProperty.getName())) { | |
| return Boolean.parseBoolean(idpProperty.getValue()); | |
| } | |
| } | |
| return false; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java`
around lines 996 - 1008, Add Javadoc to the public isShared() method describing
its return value, and make the property-name comparison null-safe by invoking
equals on the constant "isShared" rather than on idpProperty.getName(). Preserve
the existing false fallback behavior.
Source: Coding guidelines
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Prevent NullPointerException and add missing Javadoc.
As per coding guidelines, all public methods should have a docstring. Additionally, swapping the string comparison prevents a potential NullPointerException if idpProperty.getName() evaluates to null.
♻️ Proposed fix
+ /**
+ * Checks if the identity provider is shared.
+ *
+ * `@return` True if the identity provider is shared, false otherwise.
+ */
public boolean isShared() {
IdentityProviderProperty[] idpProperties = getIdpProperties();
if (idpProperties == null) {
return false;
}
for (IdentityProviderProperty idpProperty : idpProperties) {
- if (idpProperty.getName().equals("isShared")) {
+ if ("isShared".equals(idpProperty.getName())) {
return Boolean.parseBoolean(idpProperty.getValue());
}
}
return false;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public boolean isShared() { | |
| IdentityProviderProperty[] idpProperties = getIdpProperties(); | |
| if (idpProperties == null) { | |
| return false; | |
| } | |
| for (IdentityProviderProperty idpProperty : idpProperties) { | |
| if (idpProperty.getName().equals("isShared")) { | |
| return Boolean.parseBoolean(idpProperty.getValue()); | |
| } | |
| } | |
| return false; | |
| } | |
| /** | |
| * Checks if the identity provider is shared. | |
| * | |
| * `@return` True if the identity provider is shared, false otherwise. | |
| */ | |
| public boolean isShared() { | |
| IdentityProviderProperty[] idpProperties = getIdpProperties(); | |
| if (idpProperties == null) { | |
| return false; | |
| } | |
| for (IdentityProviderProperty idpProperty : idpProperties) { | |
| if ("isShared".equals(idpProperty.getName())) { | |
| return Boolean.parseBoolean(idpProperty.getValue()); | |
| } | |
| } | |
| return false; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/IdentityProvider.java`
around lines 996 - 1008, Add Javadoc to the public isShared() method, and make
the property-name comparison null-safe by invoking equals on the constant
"isShared" rather than on idpProperty.getName().
Source: Coding guidelines
Proposed changes in this pull request