Class SecretValue

java.lang.Object
org.cloudburstmc.netty.util.nethernet.SecretValue

public final class SecretValue extends Object
A secret a host configured, which may be the value itself or a file holding it.

A configuration file is read by anyone who can read the directory, gets copied between machines and ends up in support requests. A file reference keeps the secret out of it and leaves the protection to the filesystem.

  • Method Details

    • resolve

      public static String resolve(String value, Path directory) throws IOException
      Resolves a configured value, reading it from a file when it names one.

      A value is a file reference when it begins with file: or looks like a path. The file's trailing line terminator is dropped, because a file written by echo or an editor has one and it is never part of the secret.

      Parameters:
      value - The configured value, which may be empty
      directory - The directory a relative path is resolved against
      Returns:
      The secret itself, or the value unchanged when it names no file
      Throws:
      IOException - If the value names a file that cannot be read