org.apache.hc.client5.http.impl

## Class DefaultUserTokenHandler

- java.lang.Object
- - org.apache.hc.client5.http.impl.DefaultUserTokenHandler

- All Implemented Interfaces:
    UserTokenHandler

      @Contract(threading=STATELESS)
      public class DefaultUserTokenHandler
      extends Object
      implements UserTokenHandler

  Default implementation of `UserTokenHandler`. This class will use an instance of `Principal` as a state object for HTTP connections, if it can be obtained from the given execution context. This helps ensure persistent connections created with a particular user identity within a particular security context can be reused by the same user only.

  DefaultUserTokenHandler will use the user principal of connection based authentication schemes such as NTLM or that of the SSL session with the client authentication turned on. If both are unavailable, `null` token will be returned.

  Since:
    4.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static DefaultUserTokenHandler` | `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultUserTokenHandler()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `getUserToken(HttpRoute route, org.apache.hc.core5.http.protocol.HttpContext context)` The token object returned by this method is expected to uniquely identify the current user if the context is user specific or to be `null` if it is not.
    `Object` | `getUserToken(HttpRoute route, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.protocol.HttpContext context)` The token object returned by this method is expected to uniquely identify the current user if the context is user specific or to be `null` if it is not.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final DefaultUserTokenHandler INSTANCE

  - ### Constructor Detail

    - #### DefaultUserTokenHandler

          public DefaultUserTokenHandler()

  - ### Method Detail

    - #### getUserToken

          public Object getUserToken(HttpRoute route,
                                     org.apache.hc.core5.http.protocol.HttpContext context)

      Description copied from interface: `UserTokenHandler`
      The token object returned by this method is expected to uniquely identify the current user if the context is user specific or to be `null` if it is not.
      Specified by:
        `getUserToken` in interface `UserTokenHandler`
      Parameters:
        `route` - HTTP route
        `context` - the execution context
      Returns:
        user token that uniquely identifies the user or `null` if the context is not user specific.

    - #### getUserToken

          public Object getUserToken(HttpRoute route,
                                     org.apache.hc.core5.http.HttpRequest request,
                                     org.apache.hc.core5.http.protocol.HttpContext context)

      Description copied from interface: `UserTokenHandler`
      The token object returned by this method is expected to uniquely identify the current user if the context is user specific or to be `null` if it is not.
      Specified by:
        `getUserToken` in interface `UserTokenHandler`
      Parameters:
        `route` - HTTP route
        `request` - HTTP request
        `context` - the execution context
      Returns:
        user token that uniquely identifies the user or `null` if the context is not user specific.

Copyright © 1999–2022 The Apache Software Foundation. All rights reserved.