Class RestDocumentGateway
java.lang.Object
com.irurueta.authserver.bff.infrastructure.resourceserver.RestDocumentGateway
- All Implemented Interfaces:
DocumentGateway
Implements the documents port with the client generated from the resource server's contract. The call runs on behalf
of the signed-in user (the REST client adds the user's access token) and every failure becomes a domain exception:
a missing or unrenewable token and a
401 are unauthorized, except a 401 carrying a step-up challenge
(RFC 9470), which asks for a stronger or more recent authentication; a 403 is forbidden, a 404 not
found, and an unreachable resource server or any other answer unavailable. No token is ever logged.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DocumentMapperMaps the generated model onto the domain.private final DocumentsApiDocuments client generated from the resource server's contract.private final StepUpChallengeMapperReads the step-up challenge of a401answer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> TCalls the resource server and translates its failures into domain exceptions.voiddeleteById(String id) Deletes one document of the signed-in user.list()Lists the documents the signed-in user may see.private RuntimeExceptiontranslate(org.springframework.web.client.RestClientResponseException e) Translates an error answer of the resource server.
-
Field Details
-
documentsApi
Documents client generated from the resource server's contract. -
documentMapper
Maps the generated model onto the domain. -
stepUpChallengeMapper
Reads the step-up challenge of a401answer.
-
-
Constructor Details
-
RestDocumentGateway
public RestDocumentGateway()
-
-
Method Details
-
list
Description copied from interface:DocumentGatewayLists the documents the signed-in user may see.- Specified by:
listin interfaceDocumentGateway- Returns:
- the documents, empty when there are none.
-
deleteById
Description copied from interface:DocumentGatewayDeletes one document of the signed-in user.- Specified by:
deleteByIdin interfaceDocumentGateway- Parameters:
id- identifier of the document.
-
call
Calls the resource server and translates its failures into domain exceptions.- Type Parameters:
T- type of the answer.- Parameters:
operation- the call.- Returns:
- the answer of the resource server.
-
translate
Translates an error answer of the resource server.- Parameters:
e- the error answer.- Returns:
- the domain exception that describes it.
-