Class DocumentController
java.lang.Object
com.irurueta.authserver.resourceserver.api.web.documents.DocumentController
- All Implemented Interfaces:
DocumentsApi
Documents API, as the contract
apis/resource-server/rest-server/resource-server-api-v1.yaml describes it
through the generated DocumentsApi. Reading needs the documents.read scope (enforced by the filter
chain) and deleting the documents.delete scope (enforced by method security).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DeleteDocumentUseCaseUse case that deletes a document.private final DocumentDtoMapperMaps the documents onto the generated DTO.private final ListDocumentsUseCaseUse case that lists documents.static final StringBase path of the API, as declared by the contract.Fields inherited from interface com.irurueta.authserver.resourceserver.api.web.v1.generated.api.DocumentsApi
PATH_DELETE_DOCUMENT, PATH_LIST_DOCUMENTS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.springframework.security.core.Authenticationcaller()Returns the authenticated caller.org.springframework.http.ResponseEntity<Void> deleteDocument(String id) Deletes a document of the caller; an administrator (ROLE_ADMIN) may delete any document.org.springframework.http.ResponseEntity<List<DocumentResponse>> Lists the documents of the caller; an administrator (ROLE_ADMIN) sees every document.
-
Field Details
-
PATH
Base path of the API, as declared by the contract.- See Also:
-
listDocumentsUseCase
Use case that lists documents. -
deleteDocumentUseCase
Use case that deletes a document. -
documentDtoMapper
Maps the documents onto the generated DTO.
-
-
Constructor Details
-
DocumentController
public DocumentController()
-
-
Method Details
-
listDocuments
Lists the documents of the caller; an administrator (ROLE_ADMIN) sees every document.- Specified by:
listDocumentsin interfaceDocumentsApi- Returns:
- the documents.
-
deleteDocument
@PreAuthorize("hasAuthority(\'SCOPE_documents.delete\')") public org.springframework.http.ResponseEntity<Void> deleteDocument(String id) Deletes a document of the caller; an administrator (ROLE_ADMIN) may delete any document. Someone else's document is answered like a missing one, so the answer never reveals that it exists.- Specified by:
deleteDocumentin interfaceDocumentsApi- Parameters:
id- identifier of the document.- Returns:
- 204 when the document was deleted, 404 when it does not exist or belongs to someone else.
-
caller
private static org.springframework.security.core.Authentication caller()Returns the authenticated caller. The generated interface carries only the contract's parameters, so the bearer token's authentication is taken from the security context, which the filter chain has filled.- Returns:
- the authenticated caller.
- Throws:
org.springframework.security.authentication.AuthenticationCredentialsNotFoundException- if nobody is authenticated, answered 401 by the filter chain.
-