java.lang.Object
com.irurueta.authserver.bff.infrastructure.resourceserver.RestDocumentGateway
All Implemented Interfaces:
DocumentGateway

@Component public class RestDocumentGateway extends Object implements 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 Details

    • documentsApi

      private final DocumentsApi documentsApi
      Documents client generated from the resource server's contract.
    • documentMapper

      private final DocumentMapper documentMapper
      Maps the generated model onto the domain.
    • stepUpChallengeMapper

      private final StepUpChallengeMapper stepUpChallengeMapper
      Reads the step-up challenge of a 401 answer.
  • Constructor Details

    • RestDocumentGateway

      public RestDocumentGateway()
  • Method Details

    • list

      public List<Document> list()
      Specified by:
      list in interface DocumentGateway
    • deleteById

      public void deleteById(String id)
      Specified by:
      deleteById in interface DocumentGateway
    • call

      private <T> T call(Supplier<T> operation)
      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

      private RuntimeException translate(org.springframework.web.client.RestClientResponseException e)
      Translates an error answer of the resource server.
      Parameters:
      e - the error answer.
      Returns:
      the domain exception that describes it.