Class LegacyServerId

java.lang.Object
com.ultikits.ultitools.utils.LegacyServerId

final class LegacyServerId extends Object
Normalises this server's stored install id (uuid in credentials.json) into the legacyServerUuid value of the device authorization request (attachToServerId is the panel's field on /v1/device/approve, never sent by the plugin).

There is no automatic migration of old servers (maintainer decision 31): the owner re-attaches this server's old record on the confirmation page, and UltiCloud finds that record by this value. canonical(String) must therefore equal the backend's canonicalLegacyUuid (backend schema decision 22) exactly; a change to either side is made on both.

The decision text lists "remove hyphens" before "the first 36 characters form a hyphenated UUID", which cannot both hold; this class applies the only order that makes sense -- cut a longer value to its leading 36-character UUID first, then remove the hyphens (Phase 22 decision S-41). The backend's golden fixture legacy-uuid-canonicalization.json (contract 2.0.0) confirms that order, and LegacyServerIdTest runs every one of its cases.

Since:
6.3.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
     
    private static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static String
    The backend's canonicalLegacyUuid rule: trim surrounding whitespace; if what remains is longer than 36 characters and its first 36 characters form a standard hyphenated UUID (8-4-4-4-12 hex digits, either case), keep only those 36; remove every -; lower-case ASCII A-F; return the result only if it is exactly 32 hex digits.
    private static boolean
    isAsciiHex(char c)
    ASCII only: Character.digit(char, int) would also accept non-ASCII digits.
    private static boolean
    isHex(String value)
     
    private static boolean
     
    private static String
    Lower-cases ASCII A-F only, as the rule says.

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • LegacyServerId

      private LegacyServerId()
  • Method Details

    • canonical

      static String canonical(String raw)
      The backend's canonicalLegacyUuid rule: trim surrounding whitespace; if what remains is longer than 36 characters and its first 36 characters form a standard hyphenated UUID (8-4-4-4-12 hex digits, either case), keep only those 36; remove every -; lower-case ASCII A-F; return the result only if it is exactly 32 hex digits. Trimming is String.trim() (U+0000..U+0020 only), as the backend fixture states.
      Parameters:
      raw - the stored value, or null
      Returns:
      32 lower-case hex digits, or null when raw does not normalise to them (the field is then omitted and the owner attaches the server by hand in the panel)
    • lowerAsciiHex

      private static String lowerAsciiHex(String value)
      Lower-cases ASCII A-F only, as the rule says. String.toLowerCase(java.util.Locale) would also map other characters, some to two chars, which could change the length the 32-digit check depends on.
    • isHyphenatedUuid

      private static boolean isHyphenatedUuid(String value)
      Returns:
      true for 8-4-4-4-12 ASCII hex digits separated by hyphens
    • isHex

      private static boolean isHex(String value)
    • isAsciiHex

      private static boolean isAsciiHex(char c)
      ASCII only: Character.digit(char, int) would also accept non-ASCII digits.