Class OAuthTokenRestTemplate

  • All Implemented Interfaces:
    org.springframework.web.client.RestOperations

    public class OAuthTokenRestTemplate
    extends org.springframework.web.client.RestTemplate
    Rest Template used to communicate with OAuth2 enabled REST APIs. Uses a RemoteAPITokenService to read OAuth2 tokens to use.
    • Field Summary

      • Fields inherited from class org.springframework.http.client.support.HttpAccessor

        logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.springframework.http.client.ClientHttpRequest createRequest​(java.net.URI uri, org.springframework.http.HttpMethod method)
      Add an OAuth token from the tokenRepository to the request
      org.springframework.web.client.ResponseErrorHandler getErrorHandler()  
      void setRemoteAPI​(RemoteAPI remoteAPI)
      Set the API this rest template will communicate with
      • Methods inherited from class org.springframework.web.client.RestTemplate

        acceptHeaderRequestCallback, delete, delete, delete, doExecute, exchange, exchange, exchange, exchange, exchange, exchange, exchange, exchange, execute, execute, execute, getForEntity, getForEntity, getForEntity, getForObject, getForObject, getForObject, getMessageConverters, getUriTemplateHandler, handleResponse, headersExtractor, headForHeaders, headForHeaders, headForHeaders, httpEntityCallback, httpEntityCallback, optionsForAllow, optionsForAllow, optionsForAllow, patchForObject, patchForObject, patchForObject, postForEntity, postForEntity, postForEntity, postForLocation, postForLocation, postForLocation, postForObject, postForObject, postForObject, put, put, put, responseEntityExtractor, setDefaultUriVariables, setErrorHandler, setMessageConverters, setUriTemplateHandler
      • Methods inherited from class org.springframework.http.client.support.InterceptingHttpAccessor

        getInterceptors, getRequestFactory, setInterceptors, setRequestFactory
      • Methods inherited from class org.springframework.http.client.support.HttpAccessor

        getClientHttpRequestInitializers, setClientHttpRequestInitializers
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OAuthTokenRestTemplate

        public OAuthTokenRestTemplate​(RemoteAPITokenService tokenService,
                                      RemoteAPI remoteAPI)
        Create a new OAuthTokenRestTemplate with the given RemoteAPITokenService and connecting to the given RemoteAPI
        Parameters:
        tokenService - the TokenService to get OAuth2 tokens from
        remoteAPI - the RemoteAPI this rest template will communicate with
    • Method Detail

      • createRequest

        protected org.springframework.http.client.ClientHttpRequest createRequest​(java.net.URI uri,
                                                                                  org.springframework.http.HttpMethod method)
                                                                           throws java.io.IOException
        Add an OAuth token from the tokenRepository to the request
        Overrides:
        createRequest in class org.springframework.http.client.support.HttpAccessor
        Throws:
        java.io.IOException
      • getErrorHandler

        public org.springframework.web.client.ResponseErrorHandler getErrorHandler()
        Overrides:
        getErrorHandler in class org.springframework.web.client.RestTemplate
      • setRemoteAPI

        public void setRemoteAPI​(RemoteAPI remoteAPI)
        Set the API this rest template will communicate with
        Parameters:
        remoteAPI - the RemoteAPI that this template communicates with.