diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/IdentityResourceTypeResourceManager.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/IdentityResourceTypeResourceManager.java index 0381d29a1..6e4b23c45 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/IdentityResourceTypeResourceManager.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/IdentityResourceTypeResourceManager.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.json.JSONObject; -import org.wso2.carbon.identity.scim2.common.handlers.SCIMClaimOperationEventHandler; import org.wso2.charon3.core.attributes.MultiValuedAttribute; import org.wso2.charon3.core.attributes.SimpleAttribute; import org.wso2.charon3.core.encoder.JSONDecoder; @@ -73,11 +72,8 @@ public SCIMResponse get(String id, UserManager userManager, String attributes, S */ private SCIMResponse getResourceType() { - JSONEncoder encoder = null; try { - //obtain the json encoder - encoder = getEncoder(); - //obtain the json decoder + JSONEncoder encoder = getEncoder(); JSONDecoder decoder = getDecoder(); // get the service provider config schema @@ -109,7 +105,7 @@ private SCIMResponse getResourceType() { groupResourceTypeObject); //encode the newly created SCIM Resource Type object. String encodedObject; - Map responseHeaders = new HashMap(); + Map responseHeaders = new HashMap<>(); if (resourceTypeObject != null) { //create a deep copy of the resource type object since we are going to change it. @@ -144,7 +140,6 @@ private SCIMResponse getResourceType() { * @param userObject * @param groupObject * @return - * @throws CharonException */ private AbstractSCIMObject buildCombinedResourceType(AbstractSCIMObject userObject, AbstractSCIMObject groupObject) throws CharonException { @@ -185,7 +180,7 @@ private String buildUserResourceTypeJsonBody() throws JSONException { userResourceTypeObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA, SCIMConstants.USER_CORE_SCHEMA_URI); - if (SCIMResourceSchemaManager.getInstance().isExtensionSet()) { + if (Boolean.TRUE.equals(SCIMResourceSchemaManager.getInstance().isExtensionSet())) { JSONObject extensionSchemaObject = new JSONObject(); extensionSchemaObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA_EXTENSIONS_SCHEMA, SCIMResourceSchemaManager.getInstance().getExtensionURI()); @@ -194,6 +189,15 @@ private String buildUserResourceTypeJsonBody() throws JSONException { userResourceTypeObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA_EXTENSIONS, extensionSchemaObject); + + JSONObject systemSchemaObject = new JSONObject(); + systemSchemaObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA_EXTENSIONS_SCHEMA, + SCIMResourceSchemaManager.getInstance().getSystemSchemaExtensionURI()); + systemSchemaObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA_EXTENSIONS_REQUIRED, + SCIMResourceSchemaManager.getInstance().getSystemSchemaExtensionRequired()); + + userResourceTypeObject.put(SCIMConstants.ResourceTypeSchemaConstants.SCHEMA_EXTENSIONS, + systemSchemaObject); } return userResourceTypeObject.toString(); } diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java index 0f686bb72..b77709359 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManager.java @@ -86,6 +86,7 @@ import org.wso2.charon3.core.attributes.MultiValuedAttribute; import org.wso2.charon3.core.attributes.SimpleAttribute; import org.wso2.charon3.core.config.SCIMConfigConstants; +import org.wso2.charon3.core.config.SCIMSystemSchemaExtensionBuilder; import org.wso2.charon3.core.config.SCIMUserSchemaExtensionBuilder; import org.wso2.charon3.core.exceptions.BadRequestException; import org.wso2.charon3.core.exceptions.CharonException; @@ -368,11 +369,11 @@ public User createUser(User user, Map requiredAttributes) throw new BadRequestException(errorMessage, ResponseCodeConstants.INVALID_VALUE); } catch (UserStoreException e) { // Sometimes client exceptions are wrapped in the super class. - // Therefore checking for possible client exception. + // Therefore, checking for possible client exception. Throwable ex = ExceptionUtils.getRootCause(e); if (ex instanceof UserStoreClientException) { - String errorMessage = String.format("Error in adding the user: " + maskIfRequired(user.getUserName()) - + ". %s", ex.getMessage()); + String errorMessage = String.format("Error in adding the user: %s. %s", + maskIfRequired(user.getUserName()), ex.getMessage()); if (log.isDebugEnabled()) { log.debug(errorMessage, ex); } @@ -520,9 +521,9 @@ public void deleteUser(String userId) throws NotFoundException, CharonException, if (log.isDebugEnabled()) { log.debug("Deleting user: " + userId); } - //get the user name of the user with this id + // Get the username of the user with this id. org.wso2.carbon.user.core.common.User coreUser = null; - String userName = null; + String userName; try { // Set thread local property to signal the downstream SCIMUserOperationListener @@ -2365,6 +2366,10 @@ private Map getAllAttributes(String domainName) throws CharonExc String extensionURI = SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI(); attributes.putAll(getMappedAttributes(extensionURI, domainName)); } + if (SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema() != null) { + String extensionURI = SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI(); + attributes.putAll(getMappedAttributes(extensionURI, domainName)); + } attributes.putAll(getMappedAttributes(getCustomSchemaURI(), domainName)); } else { @@ -2372,6 +2377,7 @@ private Map getAllAttributes(String domainName) throws CharonExc ClaimMapping[] userClaims; ClaimMapping[] coreClaims; ClaimMapping[] extensionClaims = null; + ClaimMapping[] systemClaims = null; ClaimMapping[] customClaims = null; coreClaims = carbonClaimManager.getAllClaimMappings(SCIMCommonConstants.SCIM_CORE_CLAIM_DIALECT); @@ -2380,6 +2386,10 @@ private Map getAllAttributes(String domainName) throws CharonExc extensionClaims = carbonClaimManager.getAllClaimMappings( SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI()); } + if (SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema() != null) { + systemClaims = carbonClaimManager.getAllClaimMappings( + SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI()); + } customClaims = carbonClaimManager.getAllClaimMappings(getCustomSchemaURI()); for (ClaimMapping claim : coreClaims) { @@ -2393,6 +2403,11 @@ private Map getAllAttributes(String domainName) throws CharonExc attributes.put(claim.getClaim().getClaimUri(), claim.getMappedAttribute(domainName)); } } + if (systemClaims != null) { + for (ClaimMapping claim : systemClaims) { + attributes.put(claim.getClaim().getClaimUri(), claim.getMappedAttribute(domainName)); + } + } if (ArrayUtils.isNotEmpty(customClaims)) { for (ClaimMapping claim : customClaims) { attributes.put(claim.getClaim().getClaimUri(), claim.getMappedAttribute(domainName)); @@ -5726,7 +5741,7 @@ public List getEnterpriseUserSchema() throws CharonException { Map filteredAttributeMap = getFilteredSchemaAttributes(scimClaimToLocalClaimMap); Map hierarchicalAttributeMap = - buildHierarchicalAttributeMapForEnterpriseSchema(filteredAttributeMap); + buildHierarchicalAttributeMapForEnterpriseSchema(filteredAttributeMap, true, false); enterpriseUserSchemaAttributesList = new ArrayList(hierarchicalAttributeMap.values()); @@ -5741,6 +5756,38 @@ public List getEnterpriseUserSchema() throws CharonException { return enterpriseUserSchemaAttributesList; } + /** + * Returns the schema of the system user extension in SCIM 2.0. + * + * @return List of attributes of system user extension + * @throws CharonException Error while retrieving schema attribute details. + */ + @Override + public List getSystemUserSchema() throws CharonException { + + List systemUserSchemaAttributesList = null; + + // We are using the same configuration to enable/disable system user schema as the enterprise user schema. + if (SCIMCommonUtils.isEnterpriseUserExtensionEnabled()) { + Map scimClaimToLocalClaimMap = + getMappedLocalClaimsForDialect(SCIMCommonConstants.SCIM_SYSTEM_USER_CLAIM_DIALECT, tenantDomain); + + Map filteredAttributeMap = + getFilteredSchemaAttributes(scimClaimToLocalClaimMap); + Map hierarchicalAttributeMap = + buildHierarchicalAttributeMapForEnterpriseSchema(filteredAttributeMap, false, true); + + systemUserSchemaAttributesList = new ArrayList(hierarchicalAttributeMap.values()); + + if (log.isDebugEnabled()) { + logSchemaAttributes(systemUserSchemaAttributesList); + } + } else { + log.debug("System user schema support disabled."); + } + return systemUserSchemaAttributesList; + } + /** * Get mapped local claims for the claims in specified external claim dialect. * @@ -5810,7 +5857,7 @@ private Map getFilteredUserSchemaAttributes(Map getFilteredSchemaAttributes(Map isSupportedByDefault(entry.getValue())) - .map(e -> getSchemaAttributes(e.getKey(), e.getValue(), true)) - .collect(Collectors.toMap(attr -> attr.getName(), Function.identity())); + .map(e -> getSchemaAttributes(e.getKey(), e.getValue())) + .collect(Collectors.toMap(Attribute::getName, Function.identity())); } private boolean isSupportedByDefault(LocalClaim mappedLocalClaim) { @@ -5851,15 +5898,26 @@ private boolean isUsernameClaim(ExternalClaim scimClaim) { * @param mappedLocalClaim * @return */ - private Attribute getSchemaAttributes(ExternalClaim scimClaim, LocalClaim mappedLocalClaim, - boolean isExtensionAttr) { + private Attribute getSchemaAttributes(ExternalClaim scimClaim, LocalClaim mappedLocalClaim) { String name = scimClaim.getClaimURI(); - String claimDielectURI = scimClaim.getClaimDialectURI(); + String claimDialectURI = scimClaim.getClaimDialectURI(); + boolean isExtensionAttr = false; + boolean isSystemSchemaAttr = false; boolean isCustomSchemaAttr = false; boolean isComplexCustomAttr = false; + + if (SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema() != null + && SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI().equals(claimDialectURI)) { + isExtensionAttr = true; + } + if (SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema() != null + && SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema().getURI() + .equals(claimDialectURI)) { + isSystemSchemaAttr = true; + } if (getCustomSchemaURI() != null) { - isCustomSchemaAttr = getCustomSchemaURI().equalsIgnoreCase(claimDielectURI); + isCustomSchemaAttr = getCustomSchemaURI().equalsIgnoreCase(claimDialectURI); } if (mappedLocalClaim != null && mappedLocalClaim.getClaimProperties() != null) { for (Map.Entry claimProperty : mappedLocalClaim.getClaimProperties().entrySet()) { @@ -5882,7 +5940,7 @@ private Attribute getSchemaAttributes(ExternalClaim scimClaim, LocalClaim mapped attribute = new SimpleAttribute(name, null); } - populateBasicAttributes(mappedLocalClaim, attribute, isExtensionAttr, isCustomSchemaAttr); + populateBasicAttributes(mappedLocalClaim, attribute, isExtensionAttr, isSystemSchemaAttr, isCustomSchemaAttr); return attribute; } @@ -5956,11 +6014,11 @@ private SCIMDefinitions.DataType getCustomAttrDataType(String dataType) { /** * Populates basic Charon Attributes details using the claim metadata. * - * @param mappedLocalClaim - * @param attribute + * @param mappedLocalClaim Mapped local claim. + * @param attribute Charon Attribute. */ private void populateBasicAttributes(LocalClaim mappedLocalClaim, AbstractAttribute attribute, boolean - isEnterpriseExtensionAttr, boolean isCustomSchemaAttr) { + isEnterpriseExtensionAttr, boolean isSystemSchemaAttr, boolean isCustomSchemaAttr) { boolean isMultivaluedCustomAttr = false; String customAttrDataType = null; @@ -5996,9 +6054,12 @@ private void populateBasicAttributes(LocalClaim mappedLocalClaim, AbstractAttrib attribute.setType(SCIMDefinitions.DataType.COMPLEX); } else if (customAttrDataType != null) { attribute.setType(getCustomAttrDataType(customAttrDataType)); - } else if (isEnterpriseExtensionAttr) { - AttributeSchema attributeSchema = SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema() - .getSubAttributeSchema(attribute.getName()); + } else if (isEnterpriseExtensionAttr || isSystemSchemaAttr) { + AttributeSchema attributeSchema = isEnterpriseExtensionAttr + ? SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema() + .getSubAttributeSchema(attribute.getName()) + : SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema() + .getSubAttributeSchema(attribute.getName()); if (attributeSchema != null && attributeSchema.getType() != null) { attribute.setType(attributeSchema.getType()); } else { @@ -6050,11 +6111,11 @@ private void populateBasicAttributes(LocalClaim mappedLocalClaim, AbstractAttrib * @param filteredFlatAttributeMap * @return */ - private Map buildHierarchicalAttributeMapForEnterpriseSchema(Map - filteredFlatAttributeMap) - throws CharonException { + private Map buildHierarchicalAttributeMapForEnterpriseSchema( + Map filteredFlatAttributeMap, boolean isEnterpriseExtensionAttr, + boolean isSystemExtensionAttr) throws CharonException { - return buildHierarchicalAttributeMap(filteredFlatAttributeMap, true); + return buildHierarchicalAttributeMap(filteredFlatAttributeMap, isEnterpriseExtensionAttr, isSystemExtensionAttr); } /** @@ -6068,7 +6129,7 @@ private Map buildHierarchicalAttributeMapForStandardSchema(Ma filteredFlatAttributeMap) throws CharonException { - return buildHierarchicalAttributeMap(filteredFlatAttributeMap, false); + return buildHierarchicalAttributeMap(filteredFlatAttributeMap, false, false); } /** @@ -6078,7 +6139,7 @@ private Map buildHierarchicalAttributeMapForStandardSchema(Ma * @return */ private Map buildHierarchicalAttributeMap(Map filteredFlatAttributeMap, - boolean isEnterpriseExtensionAttr) + boolean isEnterpriseExtensionAttr, boolean isSystemSchemaAttr) throws CharonException { Map simpleAttributeMap = new HashMap<>(); @@ -6090,7 +6151,7 @@ private Map buildHierarchicalAttributeMap(Map buildHierarchicalAttributeMap(Map flatAttributeMap, Map complexAttributeMap, - boolean isEnterpriseExtensionAttr) + boolean isEnterpriseExtensionAttr, boolean isSystemSchemaAttr) throws CharonException { String attributeName = attribute.getName(); @@ -6126,7 +6187,8 @@ private ComplexAttribute handleSubAttribute(Attribute attribute, Map getCustomUserSchemaAttributes() throws CharonException { Map filteredAttributeMap = getFilteredSchemaAttributes(scimClaimToLocalClaimMap); Map hierarchicalAttributeMap = - buildHierarchicalAttributeMapForEnterpriseSchema(filteredAttributeMap); + buildHierarchicalAttributeMapForEnterpriseSchema(filteredAttributeMap, false, false); customUserSchemaAttributesList = new ArrayList(hierarchicalAttributeMap.values()); @@ -6402,7 +6464,7 @@ public List getCustomUserSchemaAttributes() throws CharonException { * Returns SCIM2 custom AttributeSchema of the tenant. * * @return Returns scim2 custom schema - * @throws CharonException + * @throws CharonException CharonException */ @Override public AttributeSchema getCustomUserSchemaExtension() throws CharonException { diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/internal/SCIMCommonComponent.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/internal/SCIMCommonComponent.java index 9994a8dd8..4e7df27fa 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/internal/SCIMCommonComponent.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/internal/SCIMCommonComponent.java @@ -55,6 +55,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.charon3.core.config.SCIMConfigConstants; import org.wso2.charon3.core.config.SCIMCustomSchemaExtensionBuilder; +import org.wso2.charon3.core.config.SCIMSystemSchemaExtensionBuilder; import org.wso2.charon3.core.config.SCIMUserSchemaExtensionBuilder; import org.wso2.charon3.core.exceptions.CharonException; import org.wso2.charon3.core.exceptions.InternalErrorException; @@ -83,12 +84,13 @@ protected void activate(ComponentContext ctx) { SCIMConfigProcessor scimConfigProcessor = SCIMConfigProcessor.getInstance(); scimConfigProcessor.buildConfigFromFile(filePath); - // reading user schema extension + // Reading user schema extensions. if (Boolean.parseBoolean(scimConfigProcessor.getProperty("user-schema-extension-enabled"))) { String schemaFilePath = CarbonUtils.getCarbonConfigDirPath() + File.separator + SCIMConfigConstants.SCIM_SCHEMA_EXTENSION_CONFIG; SCIMUserSchemaExtensionBuilder.getInstance().buildUserSchemaExtension(schemaFilePath); + SCIMSystemSchemaExtensionBuilder.getInstance().buildSystemSchemaExtension(schemaFilePath); } // If custom schema is enabled, read it root attribute URI from the file config if it is configured. if (SCIMCommonUtils.isCustomSchemaEnabled()) { diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonConstants.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonConstants.java index d74f5bf05..ad51c9959 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonConstants.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonConstants.java @@ -47,6 +47,7 @@ public class SCIMCommonConstants { public static final String SCIM_USER_CLAIM_DIALECT = "urn:ietf:params:scim:schemas:core:2.0:User"; public static final String SCIM_ENTERPRISE_USER_CLAIM_DIALECT = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"; + public static final String SCIM_SYSTEM_USER_CLAIM_DIALECT = "urn:scim:wso2:schema"; public static final String EQ = "eq"; public static final String NE = "ne"; diff --git a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java index 3de18a22d..034a66bc6 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/main/java/org/wso2/carbon/identity/scim2/common/utils/SCIMCommonUtils.java @@ -49,6 +49,7 @@ import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import org.wso2.charon3.core.attributes.SCIMCustomAttribute; import org.wso2.charon3.core.config.SCIMCustomSchemaExtensionBuilder; +import org.wso2.charon3.core.config.SCIMSystemSchemaExtensionBuilder; import org.wso2.charon3.core.config.SCIMUserSchemaExtensionBuilder; import org.wso2.charon3.core.exceptions.CharonException; import org.wso2.charon3.core.exceptions.InternalErrorException; @@ -451,10 +452,16 @@ public static Map getSCIMtoLocalMappings() throws UserStoreExcep // Get the extension claims, if there are any extensions enabled. if (SCIMUserSchemaExtensionBuilder.getInstance().getExtensionSchema() != null) { - Map extensionClaims = ClaimMetadataHandler.getInstance() + Map enterpriseExtensionClaims = ClaimMetadataHandler.getInstance() .getMappingsMapFromOtherDialectToCarbon(SCIMUserSchemaExtensionBuilder.getInstance() .getExtensionSchema().getURI(), null, tenantDomain, false); - scimToLocalClaimMap.putAll(extensionClaims); + scimToLocalClaimMap.putAll(enterpriseExtensionClaims); + } + if (SCIMSystemSchemaExtensionBuilder.getInstance().getExtensionSchema() != null) { + Map systemExtensionClaims = ClaimMetadataHandler.getInstance() + .getMappingsMapFromOtherDialectToCarbon(SCIMSystemSchemaExtensionBuilder.getInstance() + .getExtensionSchema().getURI(), null, tenantDomain, false); + scimToLocalClaimMap.putAll(systemExtensionClaims); } String userTenantDomain = getTenantDomain(); diff --git a/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java b/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java index 649a2686c..1c817ccbb 100644 --- a/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java +++ b/components/org.wso2.carbon.identity.scim2.common/src/test/java/org/wso2/carbon/identity/scim2/common/impl/SCIMUserManagerTest.java @@ -50,6 +50,7 @@ import org.wso2.carbon.user.core.UserStoreClientException; import org.wso2.carbon.user.core.common.PaginatedUserResponse; import org.wso2.carbon.user.core.model.UniqueIDUserClaimSearchEntry; +import org.wso2.charon3.core.config.SCIMSystemSchemaExtensionBuilder; import org.wso2.charon3.core.exceptions.NotImplementedException; import org.wso2.charon3.core.extensions.UserManager; import org.wso2.charon3.core.objects.plainobjects.UsersGetResponse; @@ -128,6 +129,8 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import static org.wso2.charon3.core.schema.SCIMConstants.CUSTOM_USER_SCHEMA_URI; +import static org.wso2.charon3.core.schema.SCIMConstants.ENTERPRISE_USER_SCHEMA_URI; /* * Unit tests for SCIMUserManager @@ -207,6 +210,7 @@ public class SCIMUserManagerTest { @Mock private RolePermissionManagementService mockedRolePermissionManagementService; private MockedStatic scimUserSchemaExtensionBuilder; + private MockedStatic scimSystemSchemaExtensionBuilder; private MockedStatic identityUtil; private MockedStatic scimCommonUtils; private MockedStatic attributeMapper; @@ -228,11 +232,17 @@ public void setUpMethod() { applicationManagementServiceMockedStatic = mockStatic(ApplicationManagementService.class); scimCommonComponentHolder = mockStatic(SCIMCommonComponentHolder.class); scimUserSchemaExtensionBuilder = mockStatic(SCIMUserSchemaExtensionBuilder.class); + scimSystemSchemaExtensionBuilder = mockStatic(SCIMSystemSchemaExtensionBuilder.class); claimMetadataHandler = mockStatic(ClaimMetadataHandler.class); resourceManagerUtil = mockStatic(ResourceManagerUtil.class); SCIMUserSchemaExtensionBuilder mockSCIMUserSchemaExtensionBuilder = mock(SCIMUserSchemaExtensionBuilder.class); + SCIMSystemSchemaExtensionBuilder mockSCIMSystemSchemaExtensionBuilder = mock(SCIMSystemSchemaExtensionBuilder.class); scimUserSchemaExtensionBuilder.when(SCIMUserSchemaExtensionBuilder::getInstance).thenReturn(mockSCIMUserSchemaExtensionBuilder); when(mockSCIMUserSchemaExtensionBuilder.getExtensionSchema()).thenReturn(mockedSCIMAttributeSchema); + when(mockedSCIMAttributeSchema.getURI()).thenReturn(ENTERPRISE_USER_SCHEMA_URI) + .thenReturn(CUSTOM_USER_SCHEMA_URI); + scimSystemSchemaExtensionBuilder.when(SCIMSystemSchemaExtensionBuilder::getInstance).thenReturn(mockSCIMSystemSchemaExtensionBuilder); + when(mockSCIMSystemSchemaExtensionBuilder.getExtensionSchema()).thenReturn(mockedSCIMAttributeSchema); } @AfterMethod @@ -244,6 +254,7 @@ public void tearDown() { applicationManagementServiceMockedStatic.close(); scimCommonComponentHolder.close(); scimUserSchemaExtensionBuilder.close(); + scimSystemSchemaExtensionBuilder.close(); claimMetadataHandler.close(); resourceManagerUtil.close(); } diff --git a/features/org.wso2.carbon.identity.scim2.common.feature/resources/charon-config.xml b/features/org.wso2.carbon.identity.scim2.common.feature/resources/charon-config.xml index 10a31a5d7..350f2445b 100644 --- a/features/org.wso2.carbon.identity.scim2.common.feature/resources/charon-config.xml +++ b/features/org.wso2.carbon.identity.scim2.common.feature/resources/charon-config.xml @@ -19,7 +19,7 @@ true true - urn:scim:wso2:schema + urn:scim:schemas:extension:custom:User true http://example.com/help/scim.html true diff --git a/features/org.wso2.carbon.identity.scim2.common.feature/resources/org.wso2.carbon.identity.scim2.common.feature.default.json b/features/org.wso2.carbon.identity.scim2.common.feature/resources/org.wso2.carbon.identity.scim2.common.feature.default.json index 9c0eb384b..036bb92c2 100644 --- a/features/org.wso2.carbon.identity.scim2.common.feature/resources/org.wso2.carbon.identity.scim2.common.feature.default.json +++ b/features/org.wso2.carbon.identity.scim2.common.feature/resources/org.wso2.carbon.identity.scim2.common.feature.default.json @@ -1,7 +1,7 @@ { "scim2.enable_schema_extension": true, "scim2.enable_custom_schema_extension": true, - "scim2.custom_user_schema_uri": "urn:scim:wso2:schema", + "scim2.custom_user_schema_uri": "urn:scim:schemas:extension:custom:User", "scim2.max_bulk_operations": "1000", "scim2.max_bulk_payload": "1048576", "scim2.documentation_uri": "https://is.docs.wso2.com/en/latest/apis/scim2/",