Class ClientApplicationsResource

java.lang.Object
io.goobi.viewer.api.rest.v1.clients.ClientApplicationsResource

@Path("/clients") public class ClientApplicationsResource extends Object
REST resource for managing client application registrations and their access credentials.
Author:
Florian Alpers
  • Constructor Details

  • Method Details

    • register

      @POST @Path("/register") @Produces("application/json") public Response register() throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException, DAOException
      Registers the calling client application as a new, pending trusted client using the identifier sent in the request.

      The client identifier is read from the 'X-goobi-content-protection' request header. A new ClientApplication is persisted with access status REQUESTED and the caller's IP address; the registration must be approved separately (see setClient(String, ClientApplication)) before the client is granted access.

      Returns:
      the registration status as JSON
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if a client is already registered with this identifier
      DAOException - if the new client cannot be persisted
    • request

      @GET @Path("/request") @Produces("application/json") public String request() throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException, DAOException
      Requests access for a previously registered client application and reports its current access status.

      The client identifier is read from the 'X-goobi-content-protection' request header and must belong to a client already registered via register(). On success the client is stored in the current HTTP session for later access condition checks, and its last access date is updated in the database the first time this happens within the session.

      Returns:
      the access status as JSON
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException - if no client is registered with the given identifier
      DAOException - if the client's access record cannot be read or updated
    • setClient

      @PUT @Path("/{id}") @Produces("application/json") public ClientApplication setClient(@PathParam("id") String clientIdentifier, ClientApplication update) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
      Change properties of an existing ClientApplication.
      Parameters:
      clientIdentifier - unique identifier of the client to update
      update - client object carrying the new property values to apply
      Returns:
      ClientApplication
      Throws:
      DAOException - If an error occurs accessing the database
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException - If no 'id' or 'clientIdentier' values are given or if no matching client could be found
    • getAllClients

      @GET @Produces("application/json") public List<ClientApplication> getAllClients(@QueryParam("first") @DefaultValue("0") int first, @QueryParam("count") @DefaultValue("2147483647") int count) throws DAOException
      Lists all registered ClientApplications, optionally paginated.

      The default values keep the endpoint backwards-compatible with existing server-to-server consumers that fetched the unbounded list: when no parameters are supplied, the full list is returned. Clients that opt in by sending first / count get a paginated slice.

      Note: the pagination is currently applied in-memory after the DAO loads the full result set, so it limits the response payload but does not relieve the database/heap. A true DoS hardening would require a DAO method with SQL LIMIT/OFFSET.

      Parameters:
      first - zero-based index of the first entry to return; must be >= 0
      count - maximum number of entries to return; must be >= 0
      Returns:
      All clients from the DB, optionally paginated
      Throws:
      DAOException - If an error occurs accessing the database
    • getClient

      @GET @Path("/{id}") @Produces("application/json") public ClientApplication getClient(@PathParam("id") String clientIdentifier) throws DAOException, de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
      Lists all registered ClientApplications.
      Parameters:
      clientIdentifier - unique identifier of the client to retrieve
      Returns:
      Client with given clientIdentifier
      Throws:
      DAOException - If an error occurs accessing the database
      de.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException