Class TranslatorKeySettings

java.lang.Object
com.iizigo.translate.TranslatorKeySettings

public final class TranslatorKeySettings extends Object
The key of a translator in its settings container of the workspace settings (WorkspaceProperties, the file .iiziWorkSpace in the state location of the Designer plug-in). Every read, write and removal of a key goes through this class, so that no caller handles the two names a key has.

iiziGo v4 stores the key in plain text, as the StringProp key. This version stores it as a PasswordProp under the name key_, which v4 does not read, and leaves the name key to v4:

  • A read takes key_ first. When only key holds a key, the key is migrated: written as the PasswordProp key_, and key removed.
  • When both exist, key_ wins and is never overwritten from key; key is only removed (an iiziGo v4 started on the same workspace in between may have stored a key of its own there).
  • A write stores key_ and removes key; a removal removes both.

A PasswordProp is obfuscated in the file, not encrypted: its codec has no secret, so anyone with the code can read the key back. It keeps the key from a plain look at the file.

Author:
Christopher Mindus
  • Method Details

    • getKey

      public static String getKey(PropCnr settings)
      Gets the key of a translator, migrating a key stored by iiziGo v4 (see the class description).
      Parameters:
      settings - The settings container of the translator, null for none.
      Returns:
      The key, null when none is stored.
    • setKey

      public static void setKey(PropCnr settings, String key)
      Sets the key of a translator: stored as the PasswordProp key_, and the name key of iiziGo v4 removed.
      Parameters:
      settings - The settings container of the translator, null for none.
      key - The key, null or empty to remove the key.
    • removeKey

      public static void removeKey(PropCnr settings)
      Removes the key of a translator under both names.
      Parameters:
      settings - The settings container of the translator, null for none.
    • describe

      public static String describe(String key)
      Describes a key for a log line without revealing it: its length only, never one of its characters. A key is the developer's credential and belongs in no log line, exception message, dialog title or tooltip; the settings dialogs log that a translator was configured through this description.
      Parameters:
      key - The key, null for none.
      Returns:
      "no key" for null or an empty key, else the length as "<n> characters".