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
Modifier and TypeFieldDescriptionprotected Deque<ScimV2MappingDescriptor>
static final String
static final String
protected ScimV2Mapping
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.protected void
addMembersToNuxeoGroup
(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.void
deactivate
(ComponentContext context) Deactivates the component.protected String
getAttribute
(com.unboundid.scim2.common.filters.Filter filter) com.unboundid.scim2.common.types.GroupResource
getGroupResourceFromNuxeoGroup
(DocumentModel groupModel, String baseURL) Gets a group resource representation of a group model.Gets the contributed SCIM mapping.protected Predicate
getPredicate
(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, String> colMap) protected QueryBuilder
getQueryBuilder
(com.unboundid.scim2.common.filters.Filter filter, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) protected QueryBuilder
getQueryBuilder
(Integer startIndex, Integer count, String filterString, String sortBy, boolean descending, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) com.unboundid.scim2.common.types.UserResource
getUserResourceFromNuxeoUser
(DocumentModel groupModel, String baseURL) Gets a user resource representation of a user model.protected Object
getValue
(com.unboundid.scim2.common.filters.Filter filter) protected void
handleNoGroupMemberMatch
(List<com.unboundid.scim2.common.types.Member> members, com.unboundid.scim2.common.messages.PatchOperation op) protected boolean
isCaseSensitive
(String attribute, ScimV2ResourceType type) protected String
mapGroupColumnName
(String column, Object filterValue) protected String
mapGroupMemberAttributeName
(String scimAttribute, Object filterValue) protected String
mapUserColumnName
(String column, Object filterValue) protected String
mapUserMemberAttributeName
(String scimAttribute, Object filterValue) protected Predicate
parseFilters
(String filterString, ScimV2ResourceType type, BiFunction<String, Object, String> columnMapper) protected void
patchGroup
(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchRequest patch) Patches the given group model according to the given patch request, e.g.:protected void
patchGroupJSONPatch
(DocumentModel groupModel, com.unboundid.scim2.common.messages.PatchOperation op) Patches the given group model according to the given patch operation using JSON patch.protected void
patchGroupWithFilter
(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 void
patchGroupWithoutFilter
(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 void
patchGroupWithoutPath
(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 void
patchGroupWithPath
(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.:void
patchNuxeoGroup
(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.ScimResource
patchScimResource
(com.unboundid.scim2.common.ScimResource resource, com.unboundid.scim2.common.messages.PatchOperation patchOperation) protected com.unboundid.scim2.common.ScimResource
patchScimResource
(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.void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) protected void
removeMembersFromNuxeoGroup
(DocumentModel groupModel, List<com.unboundid.scim2.common.types.Member> members) protected void
resetGroupMembers
(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) void
start
(ComponentContext context) Start the component.void
unregisterContribution
(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, unregisterExtension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in 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:ScimV2MappingService
Creates a Nuxeo group model according to the group resource.- Specified by:
createNuxeoGroupFromGroupResource
in 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:ScimV2MappingService
Creates a Nuxeo user model according to the user resource.- Specified by:
createNuxeoUserFromUserResource
in 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:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in 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:ScimV2MappingService
Gets a group resource representation of a group model.- Specified by:
getGroupResourceFromNuxeoGroup
in 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:ScimV2MappingService
Gets the contributed SCIM mapping.- Specified by:
getMapping
in 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:ScimV2MappingService
Gets a user resource representation of a user model.- Specified by:
getUserResourceFromNuxeoUser
in 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:ScimV2MappingService
Patches a Nuxeo group model according to the patch request.- Specified by:
patchNuxeoGroup
in 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:ScimV2MappingService
Patches a Nuxeo user model according to the patch request.- Specified by:
patchNuxeoUser
in 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:ScimV2MappingService
Searches for groups.- Specified by:
queryGroups
in 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:ScimV2MappingService
Searches for users.- Specified by:
queryUsers
in 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:
registerContribution
in classDefaultComponent
-
start
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContribution
in 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:ScimV2MappingService
Updates a Nuxeo group model according to the group resource.- Specified by:
updateNuxeoGroupFromGroupResource
in 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:ScimV2MappingService
Updates a Nuxeo user model according to the user resource.- Specified by:
updateNuxeoUserFromUserResource
in 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 theGroupResource
representing 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
UserManager
to 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
DocumentModel
s 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
-