Skip to content

Commit 3e6245d

Browse files
committed
OF-3276: Autosetup should not try to modify admin user unless instructed
Only try to update the admin user when there are actual autosetup values provided. This prevents warnings being logged when autosetup is using a configuration that does not use the default 'admin' user.
1 parent 2f680fa commit 3e6245d

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

xmppserver/src/main/java/org/jivesoftware/openfire/XMPPServer.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -516,19 +516,25 @@ void runAutoSetup() {
516516
JiveGlobals.setProperty("user.scramHashedPasswordOnly", "true");
517517
}
518518

519-
// steps from setup-admin-settings.jsp
520-
try {
521-
User adminUser = UserManager.getInstance().getUser("admin");
522-
adminUser.setPassword(JiveGlobals.getXMLProperty("autosetup.admin.password"));
523-
adminUser.setEmail(JiveGlobals.getXMLProperty("autosetup.admin.email"));
524-
Date now = new Date();
525-
adminUser.setCreationDate(now);
526-
adminUser.setModificationDate(now);
527-
} catch (Exception e) {
528-
e.printStackTrace();
529-
logger.warn("There was an unexpected error encountered when "
530-
+ "setting the new admin information. Please check your error "
531-
+ "logs and try to remedy the problem.");
519+
// steps from setup-admin-settings.jsp: change attributes of the default admin user
520+
if (JiveGlobals.getXMLProperty("autosetup.admin.password") != null || JiveGlobals.getXMLProperty("autosetup.admin.email") != null) {
521+
try {
522+
User adminUser = UserManager.getInstance().getUser("admin");
523+
if (JiveGlobals.getXMLProperty("autosetup.admin.password") != null) {
524+
adminUser.setPassword(JiveGlobals.getXMLProperty("autosetup.admin.password"));
525+
}
526+
if (JiveGlobals.getXMLProperty("autosetup.admin.email") != null) {
527+
adminUser.setEmail(JiveGlobals.getXMLProperty("autosetup.admin.email"));
528+
}
529+
Date now = new Date();
530+
adminUser.setCreationDate(now);
531+
adminUser.setModificationDate(now);
532+
} catch (Exception e) {
533+
e.printStackTrace();
534+
logger.warn("There was an unexpected error encountered when "
535+
+ "setting the new admin information. Please check your error "
536+
+ "logs and try to remedy the problem.");
537+
}
532538
}
533539

534540
// Import any provisioned users.

0 commit comments

Comments
 (0)