Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a322684
Add new resource for preferences API with POST method
raviendalpatadu Jun 11, 2026
71ade01
Add DefaultConfigResolver interface and implement default resource re…
raviendalpatadu Jun 15, 2026
8d34434
Implement DefaultConfigResolver registration and management in Config…
raviendalpatadu Jun 15, 2026
e7a1a5b
Add unit tests for DefaultConfigResolver in ConfigurationManagerTest
raviendalpatadu Jun 15, 2026
a07fd22
add comment to the getDefaultResource method
raviendalpatadu Jun 15, 2026
64d0a79
Merge remote-tracking branch 'upstream/master' into configs/preferenc…
raviendalpatadu Jun 17, 2026
bc7f851
Refactor ConfigurationManager to use ResourceIdentifier for DefaultCo…
raviendalpatadu Jun 17, 2026
ca5dca9
Add MaxDeviceLimitUpperBound configuration
raviendalpatadu Jun 17, 2026
ca3e0eb
Add Push Device Registration email template for authentication notifi…
raviendalpatadu Jun 17, 2026
b94035a
Update UNIQUE constraint in SQL files to include DEVICE_TOKEN and TEN…
raviendalpatadu Jun 17, 2026
0c7e849
Add DEVICE_MANAGEMENT resource type for tenant-level push authenticat…
raviendalpatadu Jun 17, 2026
ffbb833
Merge remote-tracking branch 'upstream/master' into configs/preferenc…
raviendalpatadu Jun 22, 2026
0fb18c6
Refactor ConfigurationManager to improve error handling and logging f…
raviendalpatadu Jun 22, 2026
de33c82
Enhance ConfigurationManager tests to utilize ResourceIdentifier for …
raviendalpatadu Jun 23, 2026
eb4459b
Merge remote-tracking branch 'upstream/master' into configs/preferenc…
raviendalpatadu Jun 24, 2026
bdd31dc
Update copyright years and enhance error messages for default config …
raviendalpatadu Jun 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,13 @@ default void deleteResourcesByType(String resourceType) throws ConfigurationMana

throw new NotImplementedException("This functionality is not implemented.");
}

/**
* Retrieves the default configuration for the given resource type and resource name, if it exists.
* @param resourceTypeName
* @param resourceName
* @return the resource object corresponding to the resource id with default configurations.
Comment thread
raviendalpatadu marked this conversation as resolved.
Outdated
* @throws ConfigurationManagementException
*/
Resource getDefaultResource(String resourceTypeName, String resourceName);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,15 @@ public Resources getResourcesByType(String resourceTypeName) throws Configuratio
return retrieveResourcesByType(getTenantId(), resourceTypeName);
}

private Resources retrieveResourcesByType(int tenantId, String resourceTypeName) throws ConfigurationManagementException {
private Resources retrieveResourcesByType(int tenantId, String resourceTypeName)
throws ConfigurationManagementException {

validateResourcesRetrieveRequest(resourceTypeName);
ResourceType resourceType = getResourceType(resourceTypeName);
List<Resource> resourceList;
try {
if (isInheritanceEnabled(resourceTypeName, IdentityTenantUtil.getTenantDomain(tenantId))) {
resourceList = getInheritedResourcesByType(tenantId, resourceType.getId());
resourceList = getInheritedResourcesByType(tenantId, resourceType.getId());
} else {
resourceList = this.getConfigurationDAO().getResourcesByType(tenantId, resourceType.getId());
}
Expand All @@ -229,10 +230,10 @@ private Resources retrieveResourcesByType(int tenantId, String resourceTypeName)
/**
* Method to get inherited resources by type.
*
* @param tenantId Tenant ID.
* @param tenantId Tenant ID.
* @param resourceTypeId Resource type ID.
* @return List of resources of the given type inherited from the organization hierarchy.
* @throws OrganizationManagementException If an error occurred when getting organization manager.
* @throws OrganizationManagementException If an error occurred when getting organization manager.
* @throws OrgResourceHierarchyTraverseException If an error occurred when traversing the resource hierarchy.
*/
private List<Resource> getInheritedResourcesByType(int tenantId, String resourceTypeId)
Expand All @@ -258,9 +259,9 @@ private List<Resource> getInheritedResourcesByType(int tenantId, String resource
*
* @param currentResourceList Current resources.
* @param parentResourceList Parent resources.
* @return Merged resources object.
* @return Merged resources object.
*/
private List<Resource> mergeResourceLists (List<Resource> currentResourceList, List<Resource> parentResourceList) {
private List<Resource> mergeResourceLists(List<Resource> currentResourceList, List<Resource> parentResourceList) {

Map<String, Resource> resourceMap = new HashMap<>();
for (Resource resource : currentResourceList) {
Expand All @@ -278,6 +279,7 @@ private List<Resource> mergeResourceLists (List<Resource> currentResourceList, L

/**
* {@inheritDoc}
*
* @deprecated Use {@link #getResource(String, String, boolean)} instead.
*/
@Deprecated
Expand Down Expand Up @@ -331,11 +333,11 @@ private Resource getResource(int tenantId, String resourceTypeName, String resou
/**
* Method to get inherited resource by resource and resource type name.
*
* @param tenantId Tenant ID.
* @param tenantId Tenant ID.
* @param resourceTypeId Resource type ID.
* @param resourceName Resource name.
* @param resourceName Resource name.
* @return Resource object of the given name inherited from the organization hierarchy.
* @throws OrganizationManagementException If an error occurred when getting organization manager.
* @throws OrganizationManagementException If an error occurred when getting organization manager.
* @throws OrgResourceHierarchyTraverseException If an error occurred when traversing the resource hierarchy.
*/
private Resource getInheritedResourceByName(int tenantId, String resourceTypeId, String resourceName)
Expand Down Expand Up @@ -598,6 +600,25 @@ public Attribute replaceAttribute(String resourceTypeName, String resourceName,
return attribute;
}

/**
* Resolve the default configurations for the given resource from the registered default config resolvers.
*
* @param resourceType Resource type name.
* @param resourceName Resource name.
* @return Default resource from the first resolver that can handle it.
Comment thread
raviendalpatadu marked this conversation as resolved.
Outdated
* @throws ConfigurationManagementException if no resolver can handle the given resource type and name
* (ERROR_CODE_RESOURCE_DOES_NOT_EXISTS).
*/
@Override
public Resource getDefaultResource(String resourceType, String resourceName) {

DefaultConfigResolver resolver = ConfigurationManagerComponentDataHolder.getInstance()
.getDefaultConfigResolver(resourceType, resourceName);

return resolver.getDefaultConfigs(resourceType, resourceName);

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}
Comment thread
raviendalpatadu marked this conversation as resolved.

private void validateSearchRequest(Condition condition) throws ConfigurationManagementClientException {

if (condition == null) {
Expand Down Expand Up @@ -1065,7 +1086,6 @@ private ConfigurationDAO getConfigurationDAO() throws ConfigurationManagementExc
}
}


@Override
public ResourceFile addFile(String resourceTypeName, String resourceName, String fileName, InputStream fileStream)
throws ConfigurationManagementException {
Expand Down Expand Up @@ -1290,7 +1310,8 @@ public void replaceResource(Resource resource) throws ConfigurationManagementExc
* @return True if inheritance is enabled, false otherwise.
* @throws OrganizationManagementException If an error occurs while checking inheritance status.
*/
private boolean isInheritanceEnabled(String resourceTypeName, String tenantDomain) throws OrganizationManagementException {
private boolean isInheritanceEnabled(String resourceTypeName, String tenantDomain)
throws OrganizationManagementException {

if (!OrganizationManagementUtil.isOrganization(tenantDomain)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.configuration.mgt.core;

import org.wso2.carbon.identity.configuration.mgt.core.model.Resource;
import org.wso2.carbon.identity.configuration.mgt.core.model.ResourceIdentifier;

/**
* Interface for resolving default configurations for a given resource type and name.
*/
public interface DefaultConfigResolver {

/**
* Get the resource identifier that this resolver can handle.
* @return ResourceIdentifier of the default configuration.
*/
ResourceIdentifier getResourceIdentifier();

/**
* Get the default configurations for the given resource type and name.
*
* @param resourceTypeName Name of the resource type.
* @param resourceName Name of the resource.
* @return Resource containing the default configurations.
*/
Resource getDefaultConfigs(String resourceTypeName, String resourceName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException;
import org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManager;
import org.wso2.carbon.identity.configuration.mgt.core.ConfigurationManagerImpl;
import org.wso2.carbon.identity.configuration.mgt.core.DefaultConfigResolver;
import org.wso2.carbon.identity.configuration.mgt.core.dao.ConfigurationDAO;
import org.wso2.carbon.identity.configuration.mgt.core.dao.impl.CachedBackedConfigurationDAO;
import org.wso2.carbon.identity.configuration.mgt.core.dao.impl.ConfigurationDAOImpl;
Expand Down Expand Up @@ -189,4 +190,27 @@ protected void unsetOrgResourceResolverService(OrgResourceResolverService orgRes

ConfigurationManagerComponentDataHolder.getInstance().setOrgResourceResolverService(null);
}

@Reference(
name = "default.config.resolver",
service = DefaultConfigResolver.class,
cardinality = ReferenceCardinality.MULTIPLE,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetDefaultConfigResolver"
)
protected void setDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {

if (log.isDebugEnabled()) {
log.debug("DefaultConfigResolver registered: " + defaultConfigResolver.getClass().getName());
}
ConfigurationManagerComponentDataHolder.getInstance().addDefaultConfigResolver(defaultConfigResolver);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 3

Suggested change
protected void setDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {
if (log.isDebugEnabled()) {
log.debug("DefaultConfigResolver registered: " + defaultConfigResolver.getClass().getName());
}
ConfigurationManagerComponentDataHolder.getInstance().addDefaultConfigResolver(defaultConfigResolver);
protected void setDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {
if (log.isDebugEnabled()) {
log.debug("DefaultConfigResolver registered: " + defaultConfigResolver.getClass().getName());
}
log.info("Registering DefaultConfigResolver: " + defaultConfigResolver.getClass().getSimpleName());
ConfigurationManagerComponentDataHolder.getInstance().addDefaultConfigResolver(defaultConfigResolver);

}

protected void unsetDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {

if (log.isDebugEnabled()) {
Comment thread
raviendalpatadu marked this conversation as resolved.
log.debug("DefaultConfigResolver unregistered: " + defaultConfigResolver.getClass().getName());
}
ConfigurationManagerComponentDataHolder.getInstance().removeDefaultConfigResolver(defaultConfigResolver);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 4

Suggested change
protected void unsetDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {
if (log.isDebugEnabled()) {
log.debug("DefaultConfigResolver unregistered: " + defaultConfigResolver.getClass().getName());
}
ConfigurationManagerComponentDataHolder.getInstance().removeDefaultConfigResolver(defaultConfigResolver);
protected void unsetDefaultConfigResolver(DefaultConfigResolver defaultConfigResolver) {
if (log.isDebugEnabled()) {
log.debug("DefaultConfigResolver unregistered: " + defaultConfigResolver.getClass().getName());
}
log.info("Unregistering DefaultConfigResolver: " + defaultConfigResolver.getClass().getSimpleName());
ConfigurationManagerComponentDataHolder.getInstance().removeDefaultConfigResolver(defaultConfigResolver);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

update license headers on changed files. check on all other places

package org.wso2.carbon.identity.configuration.mgt.core.internal;

import java.util.Map;
Comment thread
raviendalpatadu marked this conversation as resolved.
import java.util.concurrent.ConcurrentHashMap;
import org.wso2.carbon.identity.configuration.mgt.core.DefaultConfigResolver;
import org.wso2.carbon.identity.configuration.mgt.core.model.ResourceIdentifier;
import org.wso2.carbon.identity.organization.management.service.OrganizationManager;
import org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service.OrgResourceResolverService;
import org.wso2.carbon.user.core.service.RealmService;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
* A class to keep the data of the configuration manager component.
*/
Expand All @@ -32,6 +39,7 @@ public class ConfigurationManagerComponentDataHolder {
private RealmService realmService;
private OrganizationManager organizationManager;
private OrgResourceResolverService orgResourceResolverService;
private final Map<ResourceIdentifier, DefaultConfigResolver > defaultConfigResolvers = new ConcurrentHashMap<>();
Comment thread
raviendalpatadu marked this conversation as resolved.
Outdated

public static ConfigurationManagerComponentDataHolder getInstance() {

Expand Down Expand Up @@ -107,4 +115,36 @@ public void setOrgResourceResolverService(OrgResourceResolverService orgResource

this.orgResourceResolverService = orgResourceResolverService;
}

/**
* Add a DefaultConfigResolver. Called by the OSGi DS bind callback when a resolver service is registered.
Comment thread
raviendalpatadu marked this conversation as resolved.
Outdated
*
* @param resolver DefaultConfigResolver to add.
*/
public void addDefaultConfigResolver(DefaultConfigResolver resolver) {

defaultConfigResolvers.put(resolver.getResourceIdentifier(), resolver);
}
Comment on lines +124 to +136

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 5

Suggested change
*/
public void addDefaultConfigResolver(DefaultConfigResolver resolver) {
defaultConfigResolvers.add(resolver);
}
public void addDefaultConfigResolver(DefaultConfigResolver resolver) {
defaultConfigResolvers.add(resolver);
log.debug("DefaultConfigResolver added: " + resolver.getClass().getName());
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
* Remove a DefaultConfigResolver. Called by the OSGi DS unbind callback when a resolver service is
* unregistered.
*
* @param resolver DefaultConfigResolver to remove.
*/
public void removeDefaultConfigResolver(DefaultConfigResolver resolver) {

defaultConfigResolvers.remove(resolver.getResourceIdentifier());
}

/**
* Get the DefaultConfigResolver for the given resource type and name.
* @param resourceType
* @param resourceName
* @return
*/
public DefaultConfigResolver getDefaultConfigResolver(String resourceType, String resourceName){

return defaultConfigResolvers.get(new ResourceIdentifier(resourceType, resourceName));
}
}
Comment on lines +143 to 166

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 6

Suggested change
public void removeDefaultConfigResolver(DefaultConfigResolver resolver) {
defaultConfigResolvers.remove(resolver);
}
}
public void removeDefaultConfigResolver(DefaultConfigResolver resolver) {
defaultConfigResolvers.remove(resolver);
log.debug("DefaultConfigResolver removed: " + resolver.getClass().getName());
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (c) 2026, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.configuration.mgt.core.model;

import java.util.Objects;

public class ResourceIdentifier {

private String resourceType;
private String resourceName;

public ResourceIdentifier(String resourceType, String resourceName) {

this.resourceType = resourceType;
this.resourceName = resourceName;
}

public String getResourceType() {

return resourceType;
}

public void setResourceType(String resourceType) {

this.resourceType = resourceType;
}

public String getResourceName() {

return resourceName;
}

public void setResourceName(String resourceName) {

this.resourceName = resourceName;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

@Override
public boolean equals(Object o) {

if (!(o instanceof ResourceIdentifier that)) {
return false;
}
return Objects.equals(resourceType, that.resourceType) &&

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

check on this "That"

Objects.equals(resourceName, that.resourceName);
}

@Override
public int hashCode() {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

check on this


return Objects.hash(resourceType, resourceName);
}
}
Loading
Loading