Class CmsSecretUtil

java.lang.Object
org.opencms.util.CmsSecretUtil

public final class CmsSecretUtil extends Object
Utility methods for fetching secrets from the secret provider.
  • Constructor Details

  • Method Details

    • getSecret

      public static String getSecret(String key)
      Gets the secret for the exact given key.

      If no secret is found, null will be returned.

      Parameters:
      key - the key for a secret
      Returns:
      the secret
    • getSecretForUri

      public static String getSecretForUri(String prefix, CmsObject cms)
      Looks up a path dependent secret in the secret store for the current URI.

      This is done as follows:

      For the root path of each subsitemap we are in, in ascending order, the key (prefix + "." + path) is looked up. The first match will be returned. As a special case, the key for the site root is always looked up, even if it's not configured as a sitemap.

      Parameters:
      prefix - the key prefix
      cms - the OpenCms user context to use when resolving the secret
      Returns:
      the secret (or null, if nothing was found)
    • getSecretForUri

      public static String getSecretForUri(String prefix, CmsObject cms, String rootPath)
      Looks up a path dependent secret in the secret store for the given root path.

      This is done as follows:

      For the root path of each subsitemap we are in, in ascending order, the key (prefix + "." + path) is looked up. The first match will be returned. As a special case, the key for the site root is always looked up, even if it's not configured as a sitemap.

      Parameters:
      prefix - the key prefix
      cms - the OpenCms user context to use when resolving the secret
      rootPath - the root path for which the secret should be looked up
      Returns:
      the secret (or null, if nothing was found)