Class ExampleUtil

Object
ExampleUtil

public final class ExampleUtil extends Object
General helper utilities for example scenarios:
  • Configuration loading
  • Authentication
  • JSON serialization (with Java Time support)
  • Cryptographic helpers
  • Error handling
  • Method Details

    • loadProperties

      public static Properties loadProperties()
      Load CLI configuration in order: 1. ./cli.properties 2. System property -Dcli.config 3. Classpath resource /cli.properties
      Returns:
      loaded Properties
      Throws:
      UncheckedIOException - on I/O failure
    • authenticate

      public static AnkaSecureSdk authenticate(Properties props)
      Authenticate application using encrypted credentials in props. Exits the JVM on failure.
      Parameters:
      props - Properties from loadProperties()
      Returns:
      an authenticated AnkaSecureSdk instance
    • toJson

      public static String toJson(Object o)
      Serialize any object to pretty-printed JSON, including ZonedDateTime.
      Parameters:
      o - object to serialize
      Returns:
      JSON string
      Throws:
      UncheckedIOException - on serialization failure
    • ensureTempDir

      public static void ensureTempDir(Path dir)
      Ensures the given directory exists. Creates it (and any parents) if needed. Exits the JVM on failure.
      Parameters:
      dir - path to ensure
    • fatal

      public static void fatal(String msg, Throwable t)
      Print an error message and terminate the JVM.
      Parameters:
      msg - error message
      t - optional throwable