Package org.nuxeo.scim.v2.service
Class ScimV2MappingServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.scim.v2.service.ScimV2MappingServiceImpl
- All Implemented Interfaces:
Adaptable,Component,Extensible,TimestampedService,ScimV2MappingService
This service is used to register the SCIM v2 mapping class.
- Since:
- 2023.14
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Deque<ScimV2MappingDescriptor>static final Stringstatic final Stringprotected ScimV2MappingFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(ComponentContext context) Activates the component.protected voidaddMembersToNuxeoGroup(DocumentModel groupModel, List<com.unboundid.scim2.common.types.Member> members, boolean resetGroup) createNuxeoGroupFromGroupResource(com.unboundid.scim2.common.types.GroupResource group) Creates a Nuxeo group model according to the group resource.createNuxeoUserFromUserResource(com.unboundid.scim2.common.types.UserResource user) Creates a Nuxeo user model according to the user resource.voiddeactivate(ComponentContext context) Deactivates the component.protected StringgetAttribute(com.unboundid.scim2.common.filters.Filter filter) com.unboundid.scim2.common.types.GroupResourcegetGroupResourceFromNuxeoGroup(DocumentModel groupModel, String baseURL) Gets a group resource representation of a group model.Gets the contributed SCIM mapping.protected PredicategetPredicate(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, String> colMap) protected QueryBuildergetQueryBuilder(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) protected QueryBuildergetQueryBuilder(Integer startIndex, Integer count, String filterString, String sortBy, boolean descending, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) com.unboundid.scim2.common.types.UserResourcegetUserResourceFromNuxeoUser(DocumentModel groupModel, String baseURL) Gets a user resource representation of a user model.protected ObjectgetValue(com.unboundid.scim2.common.filters.Filter filter) protected voidhandleNoGroupMemberMatch(List<com.unboundid.scim2.common.types.Member> members, com.unboundid.scim2.common.messages.PatchOperation op) protected booleanisCaseSensitive(String attribute, ScimV2ResourceType type) protected StringmapGroupColumnName(String column, Object filterValue) protected StringmapGroupMemberAttributeName(String scimAttribute, Object filterValue) protected StringmapUserColumnName(String column, Object filterValue) protected StringmapUserMemberAttributeName(String scimAttribute, Object filterValue) protected PredicateparseFilters(String filterString, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) protected voidpatchGroup(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchRequest patch) Patches the given group model according to the given patch request, e.g.:protected voidpatchGroupJSONPatch(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) Patches the given group model according to the given patch operation using JSON patch.protected voidpatchGroupWithFilter(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op, com.unboundid.scim2.common.filters.Filter filter) Patches the given group model according to the given patch operation with a "path" attribute and a value filter specified, e.g.:protected voidpatchGroupWithoutFilter(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) Patches the given group model according to the given patch operation with a "path" attribute and no value filter specified, e.g.:protected voidpatchGroupWithoutPath(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) Patches the given group model according to the given patch operation without any "path" attribute, e.g.:protected voidpatchGroupWithPath(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) Patches the given group model according to the given patch operation with a "path" attribute, e.g.:voidpatchNuxeoGroup(String uid, com.unboundid.scim2.common.messages.PatchRequest patch) Patches a Nuxeo group model according to the patch request.patchNuxeoUser(String uid, com.unboundid.scim2.common.messages.PatchRequest patch) Patches a Nuxeo user model according to the patch request.protected com.unboundid.scim2.common.ScimResourcepatchScimResource(com.unboundid.scim2.common.ScimResource resource, com.unboundid.scim2.common.messages.PatchOperation patchOperation) protected com.unboundid.scim2.common.ScimResourcepatchScimResource(com.unboundid.scim2.common.ScimResource resource, com.unboundid.scim2.common.messages.PatchRequest patch) com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource>queryGroups(ScimV2QueryContext queryCtx) Searches for groups.protected com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource>queryResources(ScimV2QueryContext queryCtx, ScimV2ResourceType type) com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource>queryUsers(ScimV2QueryContext queryCtx) Searches for users.voidregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) protected voidremoveMembersFromNuxeoGroup(DocumentModel groupModel, List<com.unboundid.scim2.common.types.Member> members) protected voidresetGroupMembers(DocumentModel groupModel) protected List<com.unboundid.scim2.common.types.Member>searchGroupMembers(com.unboundid.scim2.common.filters.Filter filter) protected List<com.unboundid.scim2.common.types.Member>searchUserMembers(com.unboundid.scim2.common.filters.Filter filter) voidstart(ComponentContext context) Start the component.voidunregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) updateNuxeoGroupFromGroupResource(String uid, com.unboundid.scim2.common.types.GroupResource group) Updates a Nuxeo group model according to the group resource.updateNuxeoUserFromUserResource(String uid, com.unboundid.scim2.common.types.UserResource user) Updates a Nuxeo user model according to the user resource.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, stop, unregister, unregisterExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
GROUP_MEMBERS
- See Also:
-
GROUP_MEMBERS_TYPE
- See Also:
-
descriptors
-
groupCaseSensitiveFields
-
mapping
-
userCaseSensitiveFields
-
-
Constructor Details
-
ScimV2MappingServiceImpl
public ScimV2MappingServiceImpl()
-
-
Method Details
-
activate
Description copied from interface:ComponentActivates the component.This method is called by the runtime when a component is activated.
- Specified by:
activatein interfaceComponent- Overrides:
activatein classDefaultComponent- Parameters:
context- the runtime context
-
createNuxeoGroupFromGroupResource
public DocumentModel createNuxeoGroupFromGroupResource(com.unboundid.scim2.common.types.GroupResource group) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceCreates a Nuxeo group model according to the group resource.- Specified by:
createNuxeoGroupFromGroupResourcein interfaceScimV2MappingService- Parameters:
group- the group resource- Returns:
- the created group
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
createNuxeoUserFromUserResource
public DocumentModel createNuxeoUserFromUserResource(com.unboundid.scim2.common.types.UserResource user) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceCreates a Nuxeo user model according to the user resource.- Specified by:
createNuxeoUserFromUserResourcein interfaceScimV2MappingService- Parameters:
user- the user resource- Returns:
- the created user
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
deactivate
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
getGroupResourceFromNuxeoGroup
public com.unboundid.scim2.common.types.GroupResource getGroupResourceFromNuxeoGroup(DocumentModel groupModel, String baseURL) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceGets a group resource representation of a group model.- Specified by:
getGroupResourceFromNuxeoGroupin interfaceScimV2MappingService- Parameters:
groupModel- the group modelbaseURL- the location base URL of the SCIM group object- Returns:
- the group resource
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
getMapping
Description copied from interface:ScimV2MappingServiceGets the contributed SCIM mapping.- Specified by:
getMappingin interfaceScimV2MappingService- Returns:
- the contributed scim mapping
-
getUserResourceFromNuxeoUser
public com.unboundid.scim2.common.types.UserResource getUserResourceFromNuxeoUser(DocumentModel groupModel, String baseURL) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceGets a user resource representation of a user model.- Specified by:
getUserResourceFromNuxeoUserin interfaceScimV2MappingService- Parameters:
groupModel- the user modelbaseURL- the location base URL of the SCIM user object- Returns:
- the user resource
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
patchNuxeoGroup
public void patchNuxeoGroup(String uid, com.unboundid.scim2.common.messages.PatchRequest patch) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServicePatches a Nuxeo group model according to the patch request.- Specified by:
patchNuxeoGroupin interfaceScimV2MappingService- Parameters:
uid- the group uidpatch- the patch request- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
patchNuxeoUser
public DocumentModel patchNuxeoUser(String uid, com.unboundid.scim2.common.messages.PatchRequest patch) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServicePatches a Nuxeo user model according to the patch request.- Specified by:
patchNuxeoUserin interfaceScimV2MappingService- Parameters:
uid- the user uidpatch- the patch request- Returns:
- the patched user
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
queryGroups
public com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource> queryGroups(ScimV2QueryContext queryCtx) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceSearches for groups.- Specified by:
queryGroupsin interfaceScimV2MappingService- Parameters:
queryCtx- the query context- Returns:
- the query result
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
queryUsers
public com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource> queryUsers(ScimV2QueryContext queryCtx) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceSearches for users.- Specified by:
queryUsersin interfaceScimV2MappingService- Parameters:
queryCtx- the query context- Returns:
- the query result
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
registerContributionin classDefaultComponent
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContributionin classDefaultComponent
-
updateNuxeoGroupFromGroupResource
public DocumentModel updateNuxeoGroupFromGroupResource(String uid, com.unboundid.scim2.common.types.GroupResource group) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceUpdates a Nuxeo group model according to the group resource.- Specified by:
updateNuxeoGroupFromGroupResourcein interfaceScimV2MappingService- Parameters:
uid- the group uidgroup- the group resource- Returns:
- the updated group
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
updateNuxeoUserFromUserResource
public DocumentModel updateNuxeoUserFromUserResource(String uid, com.unboundid.scim2.common.types.UserResource user) throws com.unboundid.scim2.common.exceptions.ScimException Description copied from interface:ScimV2MappingServiceUpdates a Nuxeo user model according to the user resource.- Specified by:
updateNuxeoUserFromUserResourcein interfaceScimV2MappingService- Parameters:
uid- the user uiduser- the user resource- Returns:
- the updated user
- Throws:
com.unboundid.scim2.common.exceptions.ScimException- if an error occurred
-
addMembersToNuxeoGroup
protected void addMembersToNuxeoGroup(DocumentModel groupModel, List<com.unboundid.scim2.common.types.Member> members, boolean resetGroup) -
getAttribute
-
getPredicate
protected Predicate getPredicate(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, throws com.unboundid.scim2.common.exceptions.ScimExceptionString> colMap) - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
getQueryBuilder
protected QueryBuilder getQueryBuilder(Integer startIndex, Integer count, String filterString, String sortBy, boolean descending, ScimV2ResourceType type, BiFunction<String, Object, throws com.unboundid.scim2.common.exceptions.ScimExceptionString> columnMapper) - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
getQueryBuilder
protected QueryBuilder getQueryBuilder(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, throws com.unboundid.scim2.common.exceptions.ScimExceptionString> columnMapper) - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
getValue
-
handleNoGroupMemberMatch
protected void handleNoGroupMemberMatch(List<com.unboundid.scim2.common.types.Member> members, com.unboundid.scim2.common.messages.PatchOperation op) throws com.unboundid.scim2.common.exceptions.BadRequestException - Throws:
com.unboundid.scim2.common.exceptions.BadRequestException
-
isCaseSensitive
-
mapGroupColumnName
-
mapGroupMemberAttributeName
-
mapUserColumnName
-
mapUserMemberAttributeName
-
parseFilters
protected Predicate parseFilters(String filterString, ScimV2ResourceType type, BiFunction<String, Object, throws com.unboundid.scim2.common.exceptions.ScimExceptionString> columnMapper) - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroup
protected void patchGroup(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchRequest patch) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch request, e.g.:
The attributes other than "members", such as "displayName", are patched by using JSON patch, as provided by{ "schemas":["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "Operations":[ { "op":"replace", "path":"displayName", "value":"updatedDisplayName" }, { "op":"add", "path":"members", "value":[ { "value":"joe" }, { "value":"jack" } ] } ] }PatchOperation.apply(ObjectNode). The patch operation is applied to theGroupResourcerepresenting the group model. Then, the group model is updated following the mapping defined byScimV2Mapping.patchGroup(DocumentModel, GroupResource).The "members" attribute is patched by using directly the
UserManagerto update the "members" and "subGroups" properties of the given group model. Basically, we iterate on the member ids passed in the patch request ("value" sub-attribute) to incrementally add/remove/replace each user member (relying in its groups) or subgroup (relying on its parent groups).This allows to never fetch the Nuxeo group's members and subgroups. Thus, it avoids storing potentially large lists of users/group
DocumentModels in memory and the JSON serialization of such large lists.- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroupJSONPatch
protected void patchGroupJSONPatch(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch operation using JSON patch.- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroupWithoutPath
protected void patchGroupWithoutPath(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch operation without any "path" attribute, e.g.:{ "op":"add", "value":{ "displayName":"updatedDisplayName" "members":[ { "value":"joe" }, { "value":"jack" } ] } }- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroupWithPath
protected void patchGroupWithPath(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch operation with a "path" attribute, e.g.:{ "op":"add", "path":"members" "value":[ { "value":"joe" }, { "value":"jack" } ] }- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroupWithoutFilter
protected void patchGroupWithoutFilter(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch operation with a "path" attribute and no value filter specified, e.g.:{ "op":"remove", "path":"members" }- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchGroupWithFilter
protected void patchGroupWithFilter(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op, com.unboundid.scim2.common.filters.Filter filter) throws com.unboundid.scim2.common.exceptions.ScimException Patches the given group model according to the given patch operation with a "path" attribute and a value filter specified, e.g.:{ "op":"remove", "path":"members[value sw \"userIdPrefix\"]" }- Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchScimResource
protected com.unboundid.scim2.common.ScimResource patchScimResource(com.unboundid.scim2.common.ScimResource resource, com.unboundid.scim2.common.messages.PatchRequest patch) throws com.unboundid.scim2.common.exceptions.ScimException - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
patchScimResource
protected com.unboundid.scim2.common.ScimResource patchScimResource(com.unboundid.scim2.common.ScimResource resource, com.unboundid.scim2.common.messages.PatchOperation patchOperation) throws com.unboundid.scim2.common.exceptions.ScimException - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
queryResources
protected com.unboundid.scim2.common.messages.ListResponse<com.unboundid.scim2.common.ScimResource> queryResources(ScimV2QueryContext queryCtx, ScimV2ResourceType type) throws com.unboundid.scim2.common.exceptions.ScimException - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
removeMembersFromNuxeoGroup
protected void removeMembersFromNuxeoGroup(DocumentModel groupModel, List<com.unboundid.scim2.common.types.Member> members) -
resetGroupMembers
-
searchGroupMembers
protected List<com.unboundid.scim2.common.types.Member> searchGroupMembers(com.unboundid.scim2.common.filters.Filter filter) throws com.unboundid.scim2.common.exceptions.ScimException - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-
searchUserMembers
protected List<com.unboundid.scim2.common.types.Member> searchUserMembers(com.unboundid.scim2.common.filters.Filter filter) throws com.unboundid.scim2.common.exceptions.ScimException - Throws:
com.unboundid.scim2.common.exceptions.ScimException
-