java.lang.Object
org.sentrysoftware.metricshub.engine.common.helpers.MacrosUpdater

public class MacrosUpdater extends Object
Utility class for updating and replacing HTTP macros in a text string. This class handles various HTTP macros like username, password, authentication token, etc., and supports different encoding formats (e.g., base64, SHA256). Macros are case-insensitive and can be escaped using different types such as JSON, XML, URL, etc.
  • Constructor Details

    • MacrosUpdater

      public MacrosUpdater()
  • Method Details

    • update

      public static String update(String text, String username, char[] password, String authenticationToken, @NonNull @NonNull String hostname, boolean maskPasswords)
      Replaces each known macro in the given text with the corresponding values. Supported macros: %{USERNAME}, %{PASSWORD}, %{HOSTNAME}, %{AUTHENTICATIONTOKEN}, %{PASSWORD_BASE64}, %{BASIC_AUTH}, %{SHA256}, along with various escape formats like JSON, XML, URL, etc.
      Parameters:
      text - The text with macros to update.
      username - The HTTP username.
      password - The HTTP password.
      authenticationToken - The HTTP authentication token.
      hostname - The remote hostname.
      maskPasswords - Whether to mask passwords with "********".
      Returns:
      The updated string with replaced macros.