File tree Expand file tree Collapse file tree
src/main/java/com/keybox/common/db Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,7 +65,24 @@ public void init(ServletConfig config) throws ServletException {
6565
6666 //if DB password is empty generate a random
6767 if (StringUtils .isEmpty (AppConfig .getProperty ("dbPassword" ))) {
68- AppConfig .encryptProperty ("dbPassword" , RandomStringUtils .randomAscii (32 ));
68+ String dbPassword = null ;
69+ String dbPasswordConfirm = null ;
70+ //prompt for password and confirmation
71+ while (dbPassword == null || !dbPassword .equals (dbPasswordConfirm )) {
72+ dbPassword = new String (System .console ().readPassword ("Please enter database password: " ));
73+ dbPasswordConfirm = new String (System .console ().readPassword ("Please confirm database password: " ));
74+ if (!dbPassword .equals (dbPasswordConfirm )) {
75+ System .out .println ("Passwords do not match" );
76+ }
77+ }
78+ //set password
79+ if (StringUtils .isNotEmpty (dbPassword )) {
80+ AppConfig .encryptProperty ("dbPassword" , dbPassword );
81+ //if password not set generate a random
82+ } else {
83+ System .out .println ("Generating random database password" );
84+ AppConfig .encryptProperty ("dbPassword" , RandomStringUtils .randomAscii (32 ));
85+ }
6986 //else encrypt password if plain-text
7087 } else if (!AppConfig .isPropertyEncrypted ("dbPassword" )) {
7188 AppConfig .encryptProperty ("dbPassword" , AppConfig .getProperty ("dbPassword" ));
You can’t perform that action at this time.
0 commit comments