Class BearerTokenAuthInterceptor

java.lang.Object
ca.uhn.fhir.rest.client.interceptor.BearerTokenAuthInterceptor
All Implemented Interfaces:
ca.uhn.fhir.rest.client.api.IClientInterceptor

public class BearerTokenAuthInterceptor extends Object implements ca.uhn.fhir.rest.client.api.IClientInterceptor
HTTP interceptor to be used for adding HTTP Authorization using "bearer tokens" to requests. Bearer tokens are used for protocols such as OAUTH2 (see the RFC 6750 specification on bearer token usage for more information).

This interceptor adds a header resembling the following:
   Authorization: Bearer dsfu9sd90fwp34.erw0-reu
where the token portion (at the end of the header) is supplied by the invoking code.

See the HAPI Documentation for information on how to use this class.

  • Constructor Details

    • BearerTokenAuthInterceptor

      Constructor. If this constructor is used, a token must be supplied later
    • BearerTokenAuthInterceptor

      Constructor
      Parameters:
      theToken - The bearer token to use (must not be null)
  • Method Details

    • getToken

      public String getToken()
      Returns the bearer token to use
    • interceptRequest

      public void interceptRequest(ca.uhn.fhir.rest.client.api.IHttpRequest theRequest)
      Specified by:
      interceptRequest in interface ca.uhn.fhir.rest.client.api.IClientInterceptor
    • interceptResponse

      public void interceptResponse(ca.uhn.fhir.rest.client.api.IHttpResponse theResponse)
      Specified by:
      interceptResponse in interface ca.uhn.fhir.rest.client.api.IClientInterceptor
    • setToken

      public void setToken(String theToken)
      Sets the bearer token to use