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
  • Field Summary

    Fields inherited from class io.jans.configapi.core.rest.BaseResource

    DEFAULT_SEARCH_PATTERN
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.ws.rs.core.Response
    createUser(@Valid CustomUser customUser, boolean removeNonLDAPAttributes)
    Create a new user from the provided CustomUser payload.
    jakarta.ws.rs.core.Response
    deleteUser(@NotNull String inum)
    Delete a user identified by the given inum.
    jakarta.ws.rs.core.Response
    getUserByInum(@NotNull String inum)
    Retrieve the user identified by its inum and return it as a CustomUser in the response.
    jakarta.ws.rs.core.Response
    getUsers(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.Response
    patchUser(@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.
    setCustomUserAttributes(CustomUser customUser, io.jans.as.common.model.common.User user)
     
    setParentAttributes(CustomUser customUser, io.jans.as.common.model.common.User user, boolean removeNonLDAPAttributes)
     
    jakarta.ws.rs.core.Response
    updateUser(@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, getRegexPattern, getUriInfo, throwBadRequestException, throwBadRequestException, throwBadRequestException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwMissingAttributeError, throwNotFoundException, throwNotFoundException

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UserResource

      public UserResource()
  • Method Details

    • 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, InvocationTargetException
      Retrieves a paged list of users matching the provided search, filter, and sort parameters.
      Parameters:
      limit - maximum number of results to return
      pattern - search pattern to match user entries
      startIndex - 1-based index of the first result to return
      sortBy - attribute used to order the returned results
      sortOrder - 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 conversion
      InvocationTargetException - 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, InvocationTargetException
      Retrieve 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 user
      InvocationTargetException - 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, InvocationTargetException
      Create a new user from the provided CustomUser payload.
      Parameters:
      customUser - the CustomUser payload containing user attributes to persist
      removeNonLDAPAttributes - 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 mapping
      IllegalAccessException - if a reflective access error occurs while mapping attributes
      InvocationTargetException - 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, InvocationTargetException
      Update 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 fields
      removeNonLDAPAttributes - 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 attributes
      IllegalAccessException - if a reflection access error occurs while mapping attributes
      InvocationTargetException - 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, IOException
      Apply 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 patch
      userPatchRequest - the patch operations to apply to the user
      removeNonLDAPAttributes - 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 attributes
      InvocationTargetException - if an invoked method throws an exception during attribute handling
      com.github.fge.jsonpatch.JsonPatchException - if the patch payload is invalid or cannot be applied
      IOException - 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)