Class KerberosRestTemplate

java.lang.Object
org.springframework.http.client.support.HttpAccessor
org.springframework.http.client.support.InterceptingHttpAccessor
org.springframework.web.client.RestTemplate
org.springframework.security.kerberos.client.KerberosRestTemplate
All Implemented Interfaces:
org.springframework.web.client.RestOperations

public class KerberosRestTemplate extends org.springframework.web.client.RestTemplate
RestTemplate that is able to make kerberos SPNEGO authenticated REST requests. Under a hood this KerberosRestTemplate is using HttpClient to support Kerberos.

Generally this template can be configured in few different ways.

  • Leave keyTabLocation and userPrincipal empty if you want to use cached ticket
  • Use keyTabLocation and userPrincipal if you want to use keytab file
  • Use userPrincipal and password if you want to use user/password
  • Use loginOptions if you want to customise Krb5LoginModule options
  • Use a customised httpClient
  • Field Summary

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

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(String keyTabLocation, String userPrincipal)
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(String keyTabLocation, String userPrincipal, String password, Map<String,Object> loginOptions)
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(String keyTabLocation, String userPrincipal, Map<String,Object> loginOptions)
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(String keyTabLocation, String userPrincipal, org.apache.hc.client5.http.classic.HttpClient httpClient)
    Instantiates a new kerberos rest template.
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(Map<String,Object> loginOptions, org.apache.hc.client5.http.classic.HttpClient httpClient)
    Instantiates a new kerberos rest template.
    KerberosRestTemplate(org.apache.hc.client5.http.classic.HttpClient httpClient)
    Instantiates a new kerberos rest template.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final <T> T
    doExecute(URI url, String uriTemplate, org.springframework.http.HttpMethod method, org.springframework.web.client.RequestCallback requestCallback, org.springframework.web.client.ResponseExtractor<T> responseExtractor)
     

    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, getErrorHandler, getForEntity, getForEntity, getForEntity, getForObject, getForObject, getForObject, getMessageConverters, getObservationConvention, getObservationRegistry, 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, setObservationConvention, setObservationRegistry, 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

    createRequest, getClientHttpRequestInitializers, setClientHttpRequestInitializers

    Methods inherited from class java.lang.Object

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

    • KerberosRestTemplate

      public KerberosRestTemplate()
      Instantiates a new kerberos rest template.
    • KerberosRestTemplate

      public KerberosRestTemplate(org.apache.hc.client5.http.classic.HttpClient httpClient)
      Instantiates a new kerberos rest template.
      Parameters:
      httpClient - the http client
    • KerberosRestTemplate

      public KerberosRestTemplate(String keyTabLocation, String userPrincipal)
      Instantiates a new kerberos rest template.
      Parameters:
      keyTabLocation - the key tab location
      userPrincipal - the user principal
    • KerberosRestTemplate

      public KerberosRestTemplate(String keyTabLocation, String userPrincipal, org.apache.hc.client5.http.classic.HttpClient httpClient)
      Instantiates a new kerberos rest template.
      Parameters:
      keyTabLocation - the key tab location
      userPrincipal - the user principal
      httpClient - the http client
    • KerberosRestTemplate

      public KerberosRestTemplate(Map<String,Object> loginOptions)
      Instantiates a new kerberos rest template.
      Parameters:
      loginOptions - the login options
    • KerberosRestTemplate

      public KerberosRestTemplate(Map<String,Object> loginOptions, org.apache.hc.client5.http.classic.HttpClient httpClient)
      Instantiates a new kerberos rest template.
      Parameters:
      loginOptions - the login options
      httpClient - the http client
    • KerberosRestTemplate

      public KerberosRestTemplate(String keyTabLocation, String userPrincipal, Map<String,Object> loginOptions)
      Instantiates a new kerberos rest template.
      Parameters:
      keyTabLocation - the key tab location
      userPrincipal - the user principal
      loginOptions - the login options
    • KerberosRestTemplate

      public KerberosRestTemplate(String keyTabLocation, String userPrincipal, String password, Map<String,Object> loginOptions)
      Instantiates a new kerberos rest template.
      Parameters:
      keyTabLocation - the key tab location
      userPrincipal - the user principal
      password - the password
      loginOptions - the login options
  • Method Details

    • doExecute

      protected final <T> T doExecute(URI url, String uriTemplate, org.springframework.http.HttpMethod method, org.springframework.web.client.RequestCallback requestCallback, org.springframework.web.client.ResponseExtractor<T> responseExtractor) throws org.springframework.web.client.RestClientException
      Overrides:
      doExecute in class org.springframework.web.client.RestTemplate
      Throws:
      org.springframework.web.client.RestClientException