Package com.atlassian.bamboo.util
Class PasswordMaskingUtils
- java.lang.Object
-
- com.atlassian.bamboo.util.PasswordMaskingUtils
-
public class PasswordMaskingUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
PASSWORD_FIELD_NAMES
List of fields which require masking/encrypting.static String
PASSWORD_MASK
static com.google.common.base.Predicate<VariableDefinitionContext>
SHOULD_VARIABLE_BE_MASKED
static Pattern
URL_PASSWORD_PATTERN
Regular expression for replacing passwords in URLs.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Iterable<String>
findPossiblePasswordValues(Collection<VariableDefinitionContext> variables)
static @Nullable String
getPasswordFromUrl(@NotNull String url)
static boolean
isMasked(@Nullable String value)
static String
mask(@NotNull String string, @Nullable Iterable<String> passwords)
Mask a password portion of a larger string.static String
mask(@NotNull String string, @Nullable String password)
Mask a password portion of a larger string.static <T extends VariableDefinitionContext>
Collection<? extends T>maskPasswordValues(@NotNull Collection<T> variables, @NotNull com.google.common.base.Function<? super T,? extends T> clone)
static String
maskPossiblePasswordValues(String text, VariableContext variableContext)
static @NotNull String
maskUrlPassword(@NotNull String url)
Masks password used in URL.static <T extends VariableDefinitionContext>
@NotNull Iterable<T>removePasswordVariableDefinitions(@NotNull Iterable<T> variables)
static @NotNull Iterable<String>
removePasswordVariables(@NotNull Iterable<String> variables)
static @NotNull Map<String,VariableDefinitionContext>
removePasswordVariables(@NotNull Map<String,VariableDefinitionContext> variables)
static boolean
shouldBeMasked(@NotNull VariableDefinition variableDefinition)
static boolean
shouldBeMasked(@NotNull VariableDefinitionContext variableDefinition)
static boolean
shouldBeMasked(@NotNull VariableSubstitutionContext variableSubstitutionContext)
static boolean
shouldBeMasked(@Nullable String variableName)
static boolean
shouldIgnoreValue(String key, String value)
-
-
-
Field Detail
-
PASSWORD_MASK
public static final String PASSWORD_MASK
- See Also:
- Constant Field Values
-
PASSWORD_FIELD_NAMES
public static final List<String> PASSWORD_FIELD_NAMES
List of fields which require masking/encrypting.Notice: updating this list will require re-encrypting of some data stored in Bamboo (e.g. variables and shared credentials).
-
URL_PASSWORD_PATTERN
public static final Pattern URL_PASSWORD_PATTERN
Regular expression for replacing passwords in URLs. Search for content between ':' and '@' after protocol declaration. Pattern: [protocol]://[user]:[password]@[remainingUri]
-
SHOULD_VARIABLE_BE_MASKED
public static com.google.common.base.Predicate<VariableDefinitionContext> SHOULD_VARIABLE_BE_MASKED
-
-
Method Detail
-
isMasked
public static boolean isMasked(@Nullable @Nullable String value)
-
shouldBeMasked
public static boolean shouldBeMasked(@Nullable @Nullable String variableName)
-
shouldBeMasked
public static boolean shouldBeMasked(@NotNull @NotNull VariableDefinition variableDefinition)
-
shouldBeMasked
public static boolean shouldBeMasked(@NotNull @NotNull VariableDefinitionContext variableDefinition)
-
shouldBeMasked
public static boolean shouldBeMasked(@NotNull @NotNull VariableSubstitutionContext variableSubstitutionContext)
-
maskPasswordValues
public static <T extends VariableDefinitionContext> Collection<? extends T> maskPasswordValues(@NotNull @NotNull Collection<T> variables, @NotNull @NotNull com.google.common.base.Function<? super T,? extends T> clone)
-
mask
public static String mask(@NotNull @NotNull String string, @Nullable @Nullable String password)
Mask a password portion of a larger string. e.g. passwords in git urls.- Parameters:
string
- to find and replace the password inpassword
- to find in the given string- Returns:
- string with the password replaced with a mask
-
mask
public static String mask(@NotNull @NotNull String string, @Nullable @Nullable Iterable<String> passwords)
Mask a password portion of a larger string. e.g. passwords in git urls.- Parameters:
string
- to find and replace the password inpasswords
- to find in the given string- Returns:
- string with the password replaced with a mask
-
findPossiblePasswordValues
public static Iterable<String> findPossiblePasswordValues(Collection<VariableDefinitionContext> variables)
-
maskPossiblePasswordValues
public static String maskPossiblePasswordValues(String text, VariableContext variableContext)
-
maskUrlPassword
@NotNull public static @NotNull String maskUrlPassword(@NotNull @NotNull String url)
Masks password used in URL. For example, forhttp://user:password@example.com
will returnhttp://user:********@example.com
.- Parameters:
url
- URL as string- Returns:
- URL with masked password if password was found, unmodified URL otherwise
-
getPasswordFromUrl
@Nullable public static @Nullable String getPasswordFromUrl(@NotNull @NotNull String url)
-
removePasswordVariables
@NotNull public static @NotNull Map<String,VariableDefinitionContext> removePasswordVariables(@NotNull @NotNull Map<String,VariableDefinitionContext> variables)
-
removePasswordVariables
@NotNull public static @NotNull Iterable<String> removePasswordVariables(@NotNull @NotNull Iterable<String> variables)
-
removePasswordVariableDefinitions
@NotNull public static <T extends VariableDefinitionContext> @NotNull Iterable<T> removePasswordVariableDefinitions(@NotNull @NotNull Iterable<T> variables)
-
-