Class ClientApplicationsResource
- Author:
- Florian Alpers
-
Constructor Summary
ConstructorsConstructorDescriptionClientApplicationsResource(IDAO dao, ClientApplicationManager clientManager) -
Method Summary
Modifier and TypeMethodDescriptiongetAllClients(int first, int count) Lists all registeredClientApplications, optionally paginated.Lists all registeredClientApplications.register()Registers the calling client application as a new, pending trusted client using the identifier sent in the request.request()Requests access for a previously registered client application and reports its current access status.setClient(String clientIdentifier, ClientApplication update) Change properties of an existingClientApplication.
-
Constructor Details
-
ClientApplicationsResource
- Throws:
DAOException
-
ClientApplicationsResource
-
-
Method Details
-
register
@POST @Path("/register") @Produces("application/json") public Response register() throws de.unigoettingen.sub.commons.contentlib.exceptions.ContentLibException, DAOExceptionRegisters 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
ClientApplicationis persisted with access statusREQUESTEDand the caller's IP address; the registration must be approved separately (seesetClient(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 identifierDAOException- 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, DAOExceptionRequests 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 identifierDAOException- 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 existingClientApplication.- Parameters:
clientIdentifier- unique identifier of the client to updateupdate- client object carrying the new property values to apply- Returns:
ClientApplication- Throws:
DAOException- If an error occurs accessing the databasede.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 registeredClientApplications, 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/countget 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>= 0count- 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 registeredClientApplications.- Parameters:
clientIdentifier- unique identifier of the client to retrieve- Returns:
- Client with given clientIdentifier
- Throws:
DAOException- If an error occurs accessing the databasede.unigoettingen.sub.commons.contentlib.exceptions.ContentNotFoundException
-