Class DeviceInfoResolver

java.lang.Object
com.fayupable.logged.spring.security.DeviceInfoResolver

public final class DeviceInfoResolver extends Object
Turns a User-Agent header into a coarse "os / browser" description such as "Windows / Chrome 129", for @Logged(includeDevice = true).

The raw header is never returned. Every result is assembled only from a fixed set of names and at most 4 digits of a major version, so nothing the client controls (including CR/LF or fake log text) can ever reach a log line. Only major versions are kept: IP address plus browser plus full version comes close to a device fingerprint, which is personal data under GDPR / KVKK.

Detection order matters: Edge and Opera user agents also contain Chrome/, and Chrome's also contains Safari/, so the more specific tokens are checked first. Known limitation: iPadOS in desktop mode reports itself as macOS and is reported as such; no attempt is made to guess otherwise.

This class never throws: it only uses contains/indexOf lookups and bounds-checked substrings, so there is no failure path to guard. Any input it cannot make sense of resolves to "unknown".

  • Field Details

    • UNKNOWN

      public static final String UNKNOWN
      Placeholder for a missing, blank or unrecognized user agent.
      See Also:
  • Method Details

    • resolve

      public static String resolve(String userAgent)
      Resolves a coarse device description from a User-Agent header.
      Parameters:
      userAgent - the raw header value, may be null
      Returns:
      a value such as "iOS 17 / Safari", "curl", "Bot", or "unknown"; never null