Class MaskPasswordsConfig

java.lang.Object
com.michelin.cio.hudson.plugins.maskpasswords.MaskPasswordsConfig

public class MaskPasswordsConfig extends Object
Singleton class to manage Mask Passwords global settings.
Since:
2.5
Author:
Romain Seguy (http://openromain.blogspot.com)
  • Field Details

  • Constructor Details

    • MaskPasswordsConfig

      public MaskPasswordsConfig()
  • Method Details

    • addGlobalVarPasswordPair

      public void addGlobalVarPasswordPair(MaskPasswordsBuildWrapper.VarPasswordPair varPasswordPair)
      Adds a key/password pair at the global level.

      If either key or password is blank (as defined per the Commons Lang library), then the pair is not added.

      Since:
      2.7
    • addGlobalVarMaskRegex

      public void addGlobalVarMaskRegex(MaskPasswordsBuildWrapper.VarMaskRegex varMaskRegex)
      Adds a regex at the global level.

      If regex is blank (as defined per the Commons Lang library), then the pair is not added.

      Since:
      2.9
    • addGlobalVarMaskRegex

      public void addGlobalVarMaskRegex(String name, String regex)
    • addGlobalVarMaskRegex

      public void addGlobalVarMaskRegex(String name, MaskPasswordsBuildWrapper.VarMaskRegex varMaskRegex)
    • removeGlobalVarMaskRegexByName

      public void removeGlobalVarMaskRegexByName(@NonNull String name)
    • removeGlobalVarMaskRegex

      public void removeGlobalVarMaskRegex(String name, String regex)
    • addMaskedPasswordParameterDefinition

      public void addMaskedPasswordParameterDefinition(String className)
      Parameters:
      className - The class key of a ParameterDefinition.ParameterDescriptor to be added to the list of parameters which will prevent the rebuild action to be enabled for a build
    • setGlobalVarEnabledGlobally

      public void setGlobalVarEnabledGlobally(boolean state)
    • reset

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void reset()
      Resets configuration to the default state.
    • clear

      public void clear()
    • clear

      public void clear(boolean doSave)
    • getInstance

      public static MaskPasswordsConfig getInstance()
    • getGlobalVarPasswordPairs

      public List<MaskPasswordsBuildWrapper.VarPasswordPair> getGlobalVarPasswordPairs()
      Returns the list of key/password pairs defined at the global level.

      Modifications broughts to the returned list has no impact on this configuration (the returned value is a copy). Also, the list can be empty but never null.

      Since:
      2.7
    • getGlobalVarMaskRegexesU

      public List<MaskPasswordsConfig.VarMaskRegexEntry> getGlobalVarMaskRegexesU()
      Returns the list of regexes defined at the global level.

      Modifications broughts to the returned list has no impact on this configuration (the returned value is a copy). Also, the list can be empty but never null.

      Since:
      2.9
    • getGlobalVarMaskRegexesList

      @Deprecated public List<MaskPasswordsBuildWrapper.VarMaskRegex> getGlobalVarMaskRegexesList()
      Deprecated.
      Fixes JENKINS-11514: When MaskPasswordsConfig.xml is there but was created from version 2.8 (or older) of the plugin, globalVarPasswordPairs can actually be null ==> Always use this getter to avoid NPEs.
      Since:
      2.9
    • getGlobalVarMaskRegexesUList

      public List<MaskPasswordsConfig.VarMaskRegexEntry> getGlobalVarMaskRegexesUList()
    • getGlobalVarMaskRegexesMap

      public HashMap<String,MaskPasswordsBuildWrapper.VarMaskRegex> getGlobalVarMaskRegexesMap()
    • getParameterDefinitions

      public static Map<String,String> getParameterDefinitions()
      Returns a map of all ParameterDefinitions that can be used in jobs.

      The key is the class key of the ParameterDefinition, the value is its display key.

    • isEnabledGlobally

      public boolean isEnabledGlobally()
      Returns whether the plugin is enabled globally for ALL BUILDS.
    • isMasked

      @Deprecated public boolean isMasked(@NonNull String paramValueClassName)
      Deprecated.
      There is a high risk of false-negatives. Use isMasked(hudson.model.ParameterValue, java.lang.String) at least
      Check if the parameter value class needs to be masked
      Parameters:
      paramValueClassName - Class key of the ParameterValue
      Returns:
      true if the parameter value should be masked. false if the plugin is not sure, may be false-negative
    • isMasked

      public boolean isMasked(@CheckForNull ParameterValue value, @NonNull String paramValueClassName)
      Returns true if the specified parameter value class key corresponds to a parameter definition class key selected in Jenkins' main configuration screen.
      Parameters:
      value - Parameter value. Without it there is a high risk of false negatives.
      paramValueClassName - Class key of the ParameterValue class implementation
      Returns:
      true if the parameter value should be masked. false if the plugin is not sure, may be false-negative especially if the value is null.
      Since:
      2.10
    • isSelected

      public boolean isSelected(String paramDefClassName)
      Returns true if the specified parameter definition class key has been selected in Jenkins main configuration screen.
    • load

      public static MaskPasswordsConfig load()
    • save

      public static void save(MaskPasswordsConfig config) throws IOException
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object