public static String maskPasswordsInDefinition(String definition) {

		Assert.hasText(definition, "definition must be neither empty nor null.");

		final StringBuffer output = new StringBuffer();
		final Matcher matcher = passwordParameterPattern.matcher(definition);
		while (matcher.find()) {
			final String passwordValue = matcher.group(3);
			final String maskedPasswordValue;
			if (passwordValue.startsWith("\"") && passwordValue.endsWith("\"")) {
				final String passwordValueWithoutQuotes = passwordValue.substring(1, passwordValue.length() - 1);
				maskedPasswordValue = "\"" + maskString(passwordValueWithoutQuotes) + "\"";
			}
			else {
				maskedPasswordValue = maskString(matcher.group(3));
			}
			matcher.appendReplacement(output, matcher.group(1) + maskedPasswordValue);
		}
		matcher.appendTail(output);
		return output.toString();
	}
This method takes a definition String as input parameter. The method
will filter out any parameters labeled {@code --password} and will masked them
using the {@code *} character.

@param definition Must not be empty
@return The definition string with masked passwords. Should never return null.
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/rest/PasswordUtils.java