Class UserResource
- java.lang.Object
-
- io.jans.configapi.core.rest.BaseResource
-
- io.jans.configapi.plugin.mgt.rest.UserResource
-
@Path("/configuser") @Produces("application/json") @Consumes("application/json") @ApplicationScoped public class UserResource extends io.jans.configapi.core.rest.BaseResource
-
-
Constructor Summary
Constructors Constructor Description UserResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description jakarta.ws.rs.core.ResponsecreateUser(@Valid CustomUser customUser, boolean removeNonLDAPAttributes)Create a new user from the provided CustomUser payload.jakarta.ws.rs.core.ResponsedeleteUser(@NotNull String inum)Delete a user identified by the given inum.jakarta.ws.rs.core.ResponsegetUserByInum(@NotNull String inum)Retrieve the user identified by its inum and return it as a CustomUser in the response.jakarta.ws.rs.core.ResponsegetUsers(int limit, String pattern, int startIndex, String sortBy, String sortOrder, String fieldValuePair)Retrieves a paged list of users matching the provided search, filter, and sort parameters.jakarta.ws.rs.core.ResponsepatchUser(@NotNull String inum, @NotNull UserPatchRequest userPatchRequest, boolean removeNonLDAPAttributes)Apply a user patch for the user identified by the given inum and return the patched CustomUser.CustomUsersetCustomUserAttributes(CustomUser customUser, io.jans.as.common.model.common.User user)CustomUsersetParentAttributes(CustomUser customUser, io.jans.as.common.model.common.User user, boolean removeNonLDAPAttributes)jakarta.ws.rs.core.ResponseupdateUser(@Valid CustomUser customUser, boolean removeNonLDAPAttributes)Update an existing user from the provided CustomUser payload.-
Methods inherited from class io.jans.configapi.core.rest.BaseResource
checkNotEmpty, checkNotEmpty, checkNotNull, checkNotNull, checkNotNull, checkResourceNotNull, createSearchRequest, findRootError, getBadRequestException, getBadRequestException, getBadRequestException, getHttpHeaders, getHttpRequest, getInternalServerException, getInternalServerException, getMissingAttributeError, getNotAcceptableException, getNotFoundError, getNotFoundError, getUriInfo, throwBadRequestException, throwBadRequestException, throwBadRequestException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwMissingAttributeError, throwNotFoundException, throwNotFoundException
-
-
-
-
Method Detail
-
getUsers
@GET public jakarta.ws.rs.core.Response getUsers(@DefaultValue("50") @QueryParam("limit") int limit, @DefaultValue("") @QueryParam("pattern") String pattern, @DefaultValue("0") @QueryParam("startIndex") int startIndex, @DefaultValue("inum") @QueryParam("sortBy") String sortBy, @DefaultValue("ascending") @QueryParam("sortOrder") String sortOrder, @DefaultValue("") @QueryParam("fieldValuePair") String fieldValuePair) throws IllegalAccessException, InvocationTargetExceptionRetrieves a paged list of users matching the provided search, filter, and sort parameters.- Parameters:
limit- maximum number of results to returnpattern- search pattern to match user entriesstartIndex- 1-based index of the first result to returnsortBy- attribute used to order the returned resultssortOrder- sort direction; allowed values are "ascending" and "descending"fieldValuePair- comma-separated field=value filters (e.g., "mail=abc@mail.com,jansStatus=true")- Returns:
- a paged result containing matching CustomUser entries and paging metadata
- Throws:
IllegalAccessException- if an error occurs accessing properties during conversionInvocationTargetException- if an invoked method or constructor during conversion throws an exception
-
getUserByInum
@GET @Path("{inum}") public jakarta.ws.rs.core.Response getUserByInum(@PathParam("inum") @NotNull @NotNull String inum) throws IllegalAccessException, InvocationTargetExceptionRetrieve the user identified by its inum and return it as a CustomUser in the response.- Parameters:
inum- the user's unique inum identifier- Returns:
- a Response whose entity is the matching CustomUser
- Throws:
IllegalAccessException- if a reflection access error occurs while converting the userInvocationTargetException- if a reflection invocation error occurs while converting the user
-
createUser
@POST public jakarta.ws.rs.core.Response createUser(@Valid @Valid CustomUser customUser, @DefaultValue("true") @QueryParam("removeNonLDAPAttributes") boolean removeNonLDAPAttributes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetExceptionCreate a new user from the provided CustomUser payload.- Parameters:
customUser- the CustomUser payload containing user attributes to persistremoveNonLDAPAttributes- if true, non‑LDAP attributes will be removed from the request before persisting- Returns:
- the created CustomUser populated with persisted attributes
- Throws:
NoSuchMethodException- if an expected method is not found during attribute mappingIllegalAccessException- if a reflective access error occurs while mapping attributesInvocationTargetException- if an invoked method throws an exception during attribute mapping
-
updateUser
@PUT public jakarta.ws.rs.core.Response updateUser(@Valid @Valid CustomUser customUser, @DefaultValue("true") @QueryParam("removeNonLDAPAttributes") boolean removeNonLDAPAttributes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetExceptionUpdate an existing user from the provided CustomUser payload. Applies validation, optional removal of non‑LDAP attributes, and persists the changes; the response contains the updated CustomUser.- Parameters:
customUser- the CustomUser representation containing updated user fieldsremoveNonLDAPAttributes- if true, remove attributes that are not mapped to LDAP before processing- Returns:
- a Response with status 200 OK containing the updated CustomUser as JSON
- Throws:
NoSuchMethodException- if a required accessor/mutator method is not found while mapping attributesIllegalAccessException- if a reflection access error occurs while mapping attributesInvocationTargetException- if an invoked method throws an exception while mapping attributes
-
patchUser
@PATCH @Path("{inum}") public jakarta.ws.rs.core.Response patchUser(@PathParam("inum") @NotNull @NotNull String inum, @NotNull @NotNull UserPatchRequest userPatchRequest, @DefaultValue("true") @QueryParam("removeNonLDAPAttributes") boolean removeNonLDAPAttributes) throws IllegalAccessException, InvocationTargetException, com.github.fge.jsonpatch.JsonPatchException, IOExceptionApply a user patch for the user identified by the given inum and return the patched CustomUser. Attempts to load the existing user, optionally removes non-LDAP attributes from the request, applies the provided patch, excludes configured attributes from the result, and converts the updated record to a CustomUser for the response.- Parameters:
inum- the identifier of the user to patchuserPatchRequest- the patch operations to apply to the userremoveNonLDAPAttributes- when true, remove attributes that are not stored in LDAP from the request before patching- Returns:
- the patched CustomUser
- Throws:
IllegalAccessException- if an access error occurs while reflecting or copying attributesInvocationTargetException- if an invoked method throws an exception during attribute handlingcom.github.fge.jsonpatch.JsonPatchException- if the patch payload is invalid or cannot be appliedIOException- if an I/O error occurs while processing the patch
-
deleteUser
@DELETE @Path("{inum}") public jakarta.ws.rs.core.Response deleteUser(@PathParam("inum") @NotNull @NotNull String inum)Delete a user identified by the given inum.- Parameters:
inum- the user's unique inum identifier- Returns:
- an HTTP 204 No Content response when the user is successfully deleted
-
setParentAttributes
public CustomUser setParentAttributes(CustomUser customUser, io.jans.as.common.model.common.User user, boolean removeNonLDAPAttributes)
-
setCustomUserAttributes
public CustomUser setCustomUserAttributes(CustomUser customUser, io.jans.as.common.model.common.User user)
-
-