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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MaskPasswordsConfig.VarMaskRegexEntry
-
Field Summary
Fields Modifier and Type Field Description List<MaskPasswordsBuildWrapper.VarMaskRegex>
globalVarMaskRegexes
Deprecated.HashMap<String,MaskPasswordsBuildWrapper.VarMaskRegex>
globalVarMaskRegexesMap
List<MaskPasswordsConfig.VarMaskRegexEntry>
globalVarMaskRegexesU
-
Constructor Summary
Constructors Constructor Description MaskPasswordsConfig()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addGlobalVarMaskRegex(MaskPasswordsBuildWrapper.VarMaskRegex varMaskRegex)
Adds a regex at the global level.void
addGlobalVarMaskRegex(String name, MaskPasswordsBuildWrapper.VarMaskRegex varMaskRegex)
void
addGlobalVarMaskRegex(String name, String regex)
void
addGlobalVarPasswordPair(MaskPasswordsBuildWrapper.VarPasswordPair varPasswordPair)
Adds a key/password pair at the global level.void
addMaskedPasswordParameterDefinition(String className)
void
clear()
void
clear(boolean doSave)
List<MaskPasswordsBuildWrapper.VarMaskRegex>
getGlobalVarMaskRegexesList()
Deprecated.HashMap<String,MaskPasswordsBuildWrapper.VarMaskRegex>
getGlobalVarMaskRegexesMap()
List<MaskPasswordsConfig.VarMaskRegexEntry>
getGlobalVarMaskRegexesU()
Returns the list of regexes defined at the global level.List<MaskPasswordsConfig.VarMaskRegexEntry>
getGlobalVarMaskRegexesUList()
List<MaskPasswordsBuildWrapper.VarPasswordPair>
getGlobalVarPasswordPairs()
Returns the list of key/password pairs defined at the global level.static MaskPasswordsConfig
getInstance()
static Map<String,String>
getParameterDefinitions()
Returns a map of allParameterDefinition
s that can be used in jobs.boolean
isEnabledGlobally()
Returns whether the plugin is enabled globally for ALL BUILDS.boolean
isMasked(ParameterValue value, String paramValueClassName)
Returns true if the specified parameter value class key corresponds to a parameter definition class key selected in Jenkins' main configuration screen.boolean
isMasked(String paramValueClassName)
Deprecated.There is a high risk of false-negatives.boolean
isSelected(String paramDefClassName)
Returns true if the specified parameter definition class key has been selected in Jenkins main configuration screen.static MaskPasswordsConfig
load()
void
removeGlobalVarMaskRegex(String name, String regex)
void
removeGlobalVarMaskRegexByName(String name)
void
reset()
Resets configuration to the default state.static void
save(MaskPasswordsConfig config)
void
setGlobalVarEnabledGlobally(boolean state)
String
toString()
-
-
-
Field Detail
-
globalVarMaskRegexes
@Deprecated public List<MaskPasswordsBuildWrapper.VarMaskRegex> globalVarMaskRegexes
Deprecated.Users can define regexes at the global level to mask in jobs.Never ever use this attribute directly: Use
getGlobalVarMaskRegexesMap()
to avoid potential NPEs.- Since:
- 2.9 Deprecated in favor of globalVarMaskRegexesMap which has label names mapped to value's for better identification
-
globalVarMaskRegexesU
public List<MaskPasswordsConfig.VarMaskRegexEntry> globalVarMaskRegexesU
-
globalVarMaskRegexesMap
public HashMap<String,MaskPasswordsBuildWrapper.VarMaskRegex> globalVarMaskRegexesMap
-
-
Method Detail
-
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, MaskPasswordsBuildWrapper.VarMaskRegex varMaskRegex)
-
removeGlobalVarMaskRegexByName
public void removeGlobalVarMaskRegexByName(@NonNull String name)
-
addMaskedPasswordParameterDefinition
public void addMaskedPasswordParameterDefinition(String className)
- Parameters:
className
- The class key of aParameterDefinition.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: WhenMaskPasswordsConfig.xml
is there but was created from version 2.8 (or older) of the plugin,globalVarPasswordPairs
can actually benull
==> 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 allParameterDefinition
s 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. UseisMasked(hudson.model.ParameterValue, java.lang.String)
at leastCheck if the parameter value class needs to be masked- Parameters:
paramValueClassName
- Class key of theParameterValue
- 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 theParameterValue
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 isnull
.- 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
-
-