public static String maskPassword(String password) {
		int lengthOfPassword = password.length();
		StringBuilder stringBuilder = new StringBuilder(lengthOfPassword);

		for (int i = 0; i < lengthOfPassword; i++) {
			stringBuilder.append('*');
		}

		return stringBuilder.toString();
	}
Simple method to replace characters in a String with asterisks to mask the password.

@param password The password to mask
spring-xd-shell/src/main/java/org/springframework/xd/shell/util/CommonUtils.java