Commit 8b2743f6 authored by Shawn Debnath's avatar Shawn Debnath

In setup, some of the host settings are loaded from XML properties specified...

In setup, some of the host settings are loaded from XML properties specified in openfire.xml, while others are incorrectly loaded from whats currently in JiveGlobals. Since we are in setup mode, JiveGlobals.getProperty returns null thereby ignoring any property overrides in openfire.xml specified by the user.

Changelog: 
1. Instead of just blindly setting anonymous auth to true, check if user has an override property in XML configuration, if not, default to true.
2. Call getXMLProperty to load user configuration override values and not what is currently in JiveGlobals. During setup mode, this is always null.
3. Instead of setting default values for auth, user, group, card, lockout, securityAudit and admin class names, check if the user has provided overrides for those properties, and if so, use those, otherwise use defaults.
4. Expose a method to retrieve XML property names, and then in finishSetup, go through the rest of the XML properties overridden by user that were not touched by setup and individually set those. This is particularly useful when users have to specify primary and secondary * hybrid providers.
parent fad60d88
......@@ -390,6 +390,14 @@ public class XMPPServer {
name = JiveGlobals.getProperty("xmpp.domain").toLowerCase();
xmppServerInfo.setXMPPDomain(name);
// Iterate through all the provided XML properties and set the ones that haven't
// already been touched by setup prior to this method being called.
for (String propName : (List<String>)JiveGlobals.getXMLPropertyNames()) {
if (JiveGlobals.getProperty(propName) == null) {
JiveGlobals.setProperty(propName, JiveGlobals.getXMLProperty(propName));
}
}
// Update certificates (if required)
try {
// Check if keystore already has certificates for current domain
......
......@@ -522,6 +522,24 @@ public class JiveGlobals {
return values;
}
/**
* Return all property names as a list of strings, or an empty list if jiveHome has not been loaded.
*
* @return all child property for the given parent.
*/
public static List<String> getXMLPropertyNames() {
if (openfireProperties == null) {
loadOpenfireProperties();
}
// jiveHome not loaded?
if (openfireProperties == null) {
return Collections.EMPTY_LIST;
}
return openfireProperties.getAllPropertyNames();
}
/**
* Deletes a locale property. If the property doesn't exist, the method
* does nothing.
......
......@@ -29,6 +29,7 @@
int embeddedPort = ParamUtils.getIntParameter(request, "embeddedPort", Integer.MIN_VALUE);
int securePort = ParamUtils.getIntParameter(request, "securePort", Integer.MIN_VALUE);
boolean sslEnabled = ParamUtils.getBooleanParameter(request, "sslEnabled", true);
boolean anonymousAuthentication = JiveGlobals.getXMLProperty("xmpp.auth.anonymous", true);
String encryptionAlgorithm = ParamUtils.getParameter(request, "encryptionAlgorithm");
String encryptionKey = ParamUtils.getParameter(request, "encryptionKey");
......@@ -75,7 +76,7 @@
xmppSettings.put("xmpp.domain", domain);
xmppSettings.put("xmpp.socket.ssl.active", "" + sslEnabled);
xmppSettings.put("xmpp.auth.anonymous", "true");
xmppSettings.put("xmpp.auth.anonymous", "" + anonymousAuthentication);
session.setAttribute("xmppSettings", xmppSettings);
Map<String, String> xmlSettings = new HashMap<String, String>();
......@@ -94,10 +95,10 @@
// Load the current values:
if (!doContinue) {
domain = JiveGlobals.getProperty("xmpp.domain");
domain = JiveGlobals.getXMLProperty("xmpp.domain");
embeddedPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090);
securePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091);
sslEnabled = JiveGlobals.getBooleanProperty("xmpp.socket.ssl.active", true);
sslEnabled = JiveGlobals.getXMLProperty("xmpp.socket.ssl.active", true);
// If the domain is still blank, guess at the value:
if (domain == null) {
......
......@@ -34,20 +34,22 @@
// Set to default providers by deleting any existing values.
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
xmppSettings.put("provider.auth.className",
org.jivesoftware.openfire.auth.DefaultAuthProvider.class.getName());
xmppSettings.put("provider.user.className",
org.jivesoftware.openfire.user.DefaultUserProvider.class.getName());
xmppSettings.put("provider.group.className",
org.jivesoftware.openfire.group.DefaultGroupProvider.class.getName());
xmppSettings.put("provider.vcard.className",
org.jivesoftware.openfire.vcard.DefaultVCardProvider.class.getName());
xmppSettings.put("provider.lockout.className",
org.jivesoftware.openfire.lockout.DefaultLockOutProvider.class.getName());
xmppSettings.put("provider.securityAudit.className",
org.jivesoftware.openfire.security.DefaultSecurityAuditProvider.class.getName());
xmppSettings.put("provider.admin.className",
org.jivesoftware.openfire.admin.DefaultAdminProvider.class.getName());
xmppSettings.put("provider.auth.className", JiveGlobals.getXMLProperty("provider.auth.className",
org.jivesoftware.openfire.auth.DefaultAuthProvider.class.getName()));
xmppSettings.put("provider.user.className", JiveGlobals.getXMLProperty("provider.user.className",
org.jivesoftware.openfire.user.DefaultUserProvider.class.getName()));
xmppSettings.put("provider.group.className", JiveGlobals.getXMLProperty("provider.group.className",
org.jivesoftware.openfire.group.DefaultGroupProvider.class.getName()));
xmppSettings.put("provider.vcard.className", JiveGlobals.getXMLProperty("provider.vcard.className",
org.jivesoftware.openfire.vcard.DefaultVCardProvider.class.getName()));
xmppSettings.put("provider.lockout.className", JiveGlobals.getXMLProperty("provider.lockout.className",
org.jivesoftware.openfire.lockout.DefaultLockOutProvider.class.getName()));
xmppSettings.put("provider.securityAudit.className", JiveGlobals.getXMLProperty("provider.securityAudit.className",
org.jivesoftware.openfire.security.DefaultSecurityAuditProvider.class.getName()));
xmppSettings.put("provider.admin.className", JiveGlobals.getXMLProperty("provider.admin.className",
org.jivesoftware.openfire.admin.DefaultAdminProvider.class.getName()));
// Redirect
response.sendRedirect("setup-admin-settings.jsp");
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment