Class HttpRequestClientInfoAdapter

java.lang.Object
com.fayupable.logged.spring.security.HttpRequestClientInfoAdapter
All Implemented Interfaces:
IClientInfoPort

public class HttpRequestClientInfoAdapter extends Object implements IClientInfoPort
IClientInfoPort implementation that resolves the caller purely from the current HTTP request's client IP address, via RequestClientIpResolver.

Resolving a caller's IP address has nothing to do with Spring Security. This adapter exists for applications that carry Spring Web but not Spring Security at all — for example, an internal microservice behind a gateway that already authenticates the caller upstream. Such a service still benefits from knowing which address a call came from, even though it never performs authentication itself, so it should not be forced to fall back to "unknown" just because Spring Security is absent from its classpath.

LoggedAutoConfiguration only activates this adapter when SpringSecurityClientInfoAdapter itself is not active (Spring Security missing), so an application with Spring Security still gets the richer, authentication-aware resolution.

  • Constructor Details

    • HttpRequestClientInfoAdapter

      public HttpRequestClientInfoAdapter(boolean trustForwardedHeaders)
  • Method Details

    • resolveCallerIdentity

      public String resolveCallerIdentity()
      Description copied from interface: IClientInfoPort
      Resolves an identifier describing who triggered the current invocation.
      Specified by:
      resolveCallerIdentity in interface IClientInfoPort
      Returns:
      a caller identity such as "user:42" or "ip:203.0.113.10", or an implementation-defined placeholder such as "unknown" if no identity can be resolved