Commit 43a7bcd7 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-1277] Configuration that can be stored in the DB is now stored in the DB...

[JM-1277] Configuration that can be stored in the DB is now stored in the DB (providers, etc).  Reviewer: Gabriel

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@10181 b35dd754-fafc-0310-a699-88a17e54d16e
parent ff23f036
...@@ -25,7 +25,7 @@ import java.util.Iterator; ...@@ -25,7 +25,7 @@ import java.util.Iterator;
/** /**
* Bean that stores the vcard mapping. It is also responsible for saving the mapping * Bean that stores the vcard mapping. It is also responsible for saving the mapping
* as an XML property and retrieving it. * as a system property and retrieving it.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
...@@ -497,10 +497,10 @@ public class LdapUserProfile { ...@@ -497,10 +497,10 @@ public class LdapUserProfile {
StringBuilder sb = new StringBuilder(vcardXML.length()); StringBuilder sb = new StringBuilder(vcardXML.length());
sb.append("<![CDATA[").append(vcardXML).append("]]>"); sb.append("<![CDATA[").append(vcardXML).append("]]>");
// Save mapping as an XML property // Save mapping as an XML property
JiveGlobals.setXMLProperty("ldap.vcard-mapping", sb.toString()); JiveGlobals.setProperty("ldap.vcard-mapping", sb.toString());
// Set that the vcard provider is LdapVCardProvider // Set that the vcard provider is LdapVCardProvider
JiveGlobals.setXMLProperty("provider.vcard.className", LdapVCardProvider.class.getName()); JiveGlobals.setProperty("provider.vcard.className", LdapVCardProvider.class.getName());
// Save duplicated fields in LdapManager (should be removed in the future) // Save duplicated fields in LdapManager (should be removed in the future)
LdapManager.getInstance().setNameField(name.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2")); LdapManager.getInstance().setNameField(name.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2"));
...@@ -517,7 +517,7 @@ public class LdapUserProfile { ...@@ -517,7 +517,7 @@ public class LdapUserProfile {
* @return true if mappings where loaded from saved property. * @return true if mappings where loaded from saved property.
*/ */
public boolean loadFromProperties() { public boolean loadFromProperties() {
String xmlProperty = JiveGlobals.getXMLProperty("ldap.vcard-mapping"); String xmlProperty = JiveGlobals.getProperty("ldap.vcard-mapping");
if (xmlProperty == null || xmlProperty.trim().length() == 0) { if (xmlProperty == null || xmlProperty.trim().length() == 0) {
return false; return false;
} }
......
...@@ -20,14 +20,11 @@ import java.util.*; ...@@ -20,14 +20,11 @@ import java.util.*;
* accounts with admin permissions, and provides a single point of entry for handling * accounts with admin permissions, and provides a single point of entry for handling
* getting and setting administrative accounts. * getting and setting administrative accounts.
* *
* The provider can be specified in <tt>openfire.xml</tt> by adding: * The provider can be specified using the system property:
* ... *
* <provider> * <ul>
* <admin> * <li><tt>provider.admin.className = my.admin.provider</tt></li>
* <className>my.admin.provider</className> * </ul>
* </admin>
* </provider>
* ...
* *
* @author Daniel Henninger * @author Daniel Henninger
*/ */
...@@ -73,7 +70,9 @@ public class AdminManager { ...@@ -73,7 +70,9 @@ public class AdminManager {
// Detect when a new admin provider class is set // Detect when a new admin provider class is set
PropertyEventListener propListener = new PropertyEventListener() { PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) { public void propertySet(String property, Map params) {
//Ignore if ("provider.admin.className".equals(property)) {
initProvider();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -81,9 +80,7 @@ public class AdminManager { ...@@ -81,9 +80,7 @@ public class AdminManager {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("provider.admin.className".equals(property)) { //Ignore
initProvider();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
...@@ -101,7 +98,10 @@ public class AdminManager { ...@@ -101,7 +98,10 @@ public class AdminManager {
* DefaultAdminProvider if the specified provider is not valid or not specified. * DefaultAdminProvider if the specified provider is not valid or not specified.
*/ */
private void initProvider() { private void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.admin.className", // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.admin.className");
String className = JiveGlobals.getProperty("provider.admin.className",
"org.jivesoftware.openfire.admin.DefaultAdminProvider"); "org.jivesoftware.openfire.admin.DefaultAdminProvider");
// Check if we need to reset the provider class // Check if we need to reset the provider class
if (provider == null || !className.equals(provider.getClass().getName())) { if (provider == null || !className.equals(provider.getClass().getName())) {
......
...@@ -22,9 +22,9 @@ import java.util.Map; ...@@ -22,9 +22,9 @@ import java.util.Map;
/** /**
* Pluggable authentication service. Users of Openfire that wish to change the AuthProvider * Pluggable authentication service. Users of Openfire that wish to change the AuthProvider
* implementation used to authenticate users can set the <code>AuthProvider.className</code> * implementation used to authenticate users can set the <code>AuthProvider.className</code>
* XML property. For example, if you have configured Openfire to use LDAP for user information, * system property. For example, if you have configured Openfire to use LDAP for user information,
* you'd want to send a custom implementation of AuthFactory to make LDAP auth queries. * you'd want to send a custom implementation of AuthFactory to make LDAP auth queries.
* After changing the <code>AuthProvider.className</code> XML property, you must restart your * After changing the <code>AuthProvider.className</code> system property, you must restart your
* application server. * application server.
* *
* @author Matt Tucker * @author Matt Tucker
...@@ -50,7 +50,9 @@ public class AuthFactory { ...@@ -50,7 +50,9 @@ public class AuthFactory {
// Detect when a new auth provider class is set // Detect when a new auth provider class is set
PropertyEventListener propListener = new PropertyEventListener() { PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) { public void propertySet(String property, Map params) {
//Ignore if ("provider.auth.className".equals(property)) {
initProvider();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -58,9 +60,7 @@ public class AuthFactory { ...@@ -58,9 +60,7 @@ public class AuthFactory {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("provider.auth.className".equals(property)) { //Ignore
initProvider();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
...@@ -71,7 +71,10 @@ public class AuthFactory { ...@@ -71,7 +71,10 @@ public class AuthFactory {
} }
private static void initProvider() { private static void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.auth.className", // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.auth.className");
String className = JiveGlobals.getProperty("provider.auth.className",
"org.jivesoftware.openfire.auth.DefaultAuthProvider"); "org.jivesoftware.openfire.auth.DefaultAuthProvider");
// Check if we need to reset the auth provider class // Check if we need to reset the auth provider class
if (authProvider == null || !className.equals(authProvider.getClass().getName())) { if (authProvider == null || !className.equals(authProvider.getClass().getName())) {
......
...@@ -51,7 +51,13 @@ public class AuthorizationManager { ...@@ -51,7 +51,13 @@ public class AuthorizationManager {
private static AuthorizationManager instance = new AuthorizationManager(); private static AuthorizationManager instance = new AuthorizationManager();
static { static {
String classList = JiveGlobals.getXMLProperty("provider.authorization.classList"); // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.authorization.classList");
JiveGlobals.migrateProperty("provider.authorizationMapping.classList");
JiveGlobals.migrateProperty("sasl.approvedRealms");
JiveGlobals.migrateProperty("sasl.realm");
String classList = JiveGlobals.getProperty("provider.authorization.classList");
if (classList != null) { if (classList != null) {
StringTokenizer st = new StringTokenizer(classList, " ,\t\n\r\f"); StringTokenizer st = new StringTokenizer(classList, " ,\t\n\r\f");
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
...@@ -72,10 +78,8 @@ public class AuthorizationManager { ...@@ -72,10 +78,8 @@ public class AuthorizationManager {
Log.debug("AuthorizationManager: No AuthorizationProvider's found. Loading DefaultAuthorizationPolicy"); Log.debug("AuthorizationManager: No AuthorizationProvider's found. Loading DefaultAuthorizationPolicy");
authorizationPolicies.add(new DefaultAuthorizationPolicy()); authorizationPolicies.add(new DefaultAuthorizationPolicy());
} }
classList = null;
classList = JiveGlobals.getXMLProperty("provider.authorizationMapping.classList");
classList = JiveGlobals.getProperty("provider.authorizationMapping.classList");
if (classList != null) { if (classList != null) {
StringTokenizer st = new StringTokenizer(classList, " ,\t\n\r\f"); StringTokenizer st = new StringTokenizer(classList, " ,\t\n\r\f");
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
...@@ -97,7 +101,7 @@ public class AuthorizationManager { ...@@ -97,7 +101,7 @@ public class AuthorizationManager {
} }
if (authorizationMapping.isEmpty()) { if (authorizationMapping.isEmpty()) {
Log.debug("AuthorizationManager: No AuthorizationMapping's found. Loading DefaultAuthorizationMapping"); Log.debug("AuthorizationManager: No AuthorizationMapping's found. Loading DefaultAuthorizationMapping");
authorizationMapping.add((AuthorizationMapping)new DefaultAuthorizationMapping()); authorizationMapping.add(new DefaultAuthorizationMapping());
} }
} }
......
...@@ -17,7 +17,7 @@ import org.jivesoftware.util.JiveGlobals; ...@@ -17,7 +17,7 @@ import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
/** /**
* This is the interface the used to provide default defualt authorization * This is the interface the used to provide default default authorization
* ID's when none was selected by the client. * ID's when none was selected by the client.
* This class simply removes the realm (if any) from the principal if and only if * This class simply removes the realm (if any) from the principal if and only if
* the realm matches the server's realm, the server's xmpp domain name, or * the realm matches the server's realm, the server's xmpp domain name, or
...@@ -31,7 +31,7 @@ public class DefaultAuthorizationMapping implements AuthorizationMapping { ...@@ -31,7 +31,7 @@ public class DefaultAuthorizationMapping implements AuthorizationMapping {
public DefaultAuthorizationMapping() { public DefaultAuthorizationMapping() {
approvedRealms = new Vector<String>(); approvedRealms = new Vector<String>();
String realmList = JiveGlobals.getXMLProperty("sasl.approvedRealms"); String realmList = JiveGlobals.getProperty("sasl.approvedRealms");
if(realmList != null) { if(realmList != null) {
StringTokenizer st = new StringTokenizer(realmList, " ,\t\n\r\f"); StringTokenizer st = new StringTokenizer(realmList, " ,\t\n\r\f");
while(st.hasMoreTokens()) { while(st.hasMoreTokens()) {
...@@ -55,7 +55,7 @@ public class DefaultAuthorizationMapping implements AuthorizationMapping { ...@@ -55,7 +55,7 @@ public class DefaultAuthorizationMapping implements AuthorizationMapping {
if(realm.equals(JiveGlobals.getProperty("xmpp.domain"))) { if(realm.equals(JiveGlobals.getProperty("xmpp.domain"))) {
Log.debug("DefaultAuthorizationMapping: realm = xmpp.domain"); Log.debug("DefaultAuthorizationMapping: realm = xmpp.domain");
return username; return username;
} else if(realm.equals(JiveGlobals.getXMLProperty("sasl.realm"))) { } else if(realm.equals(JiveGlobals.getProperty("sasl.realm"))) {
Log.debug("DefaultAuthorizationMapping: ream = sasl.realm"); Log.debug("DefaultAuthorizationMapping: ream = sasl.realm");
return username; return username;
} else { } else {
......
...@@ -37,7 +37,7 @@ import java.util.Vector; ...@@ -37,7 +37,7 @@ import java.util.Vector;
* <li>The SASL realm of the server * <li>The SASL realm of the server
* <li>Be in the list of acceptable realms * <li>Be in the list of acceptable realms
* </ul> * </ul>
* <li>If the requested username contains an '@' then the porotion before the * <li>If the requested username contains an '@' then the portion before the
* '@' will be considered the requested username only if the portion after * '@' will be considered the requested username only if the portion after
* the '@' matches the XMPP domain of the server or the portion after the * the '@' matches the XMPP domain of the server or the portion after the
* '@' in the authenticated ID, if any. * '@' in the authenticated ID, if any.
...@@ -54,7 +54,7 @@ public class DefaultAuthorizationPolicy implements AuthorizationPolicy { ...@@ -54,7 +54,7 @@ public class DefaultAuthorizationPolicy implements AuthorizationPolicy {
public DefaultAuthorizationPolicy() { public DefaultAuthorizationPolicy() {
approvedRealms = new Vector<String>(); approvedRealms = new Vector<String>();
String realmList = JiveGlobals.getXMLProperty("sasl.approvedRealms"); String realmList = JiveGlobals.getProperty("sasl.approvedRealms");
if(realmList != null) { if(realmList != null) {
StringTokenizer st = new StringTokenizer(realmList, " ,\t\n\r\f"); StringTokenizer st = new StringTokenizer(realmList, " ,\t\n\r\f");
while(st.hasMoreTokens()) { while(st.hasMoreTokens()) {
...@@ -108,7 +108,7 @@ public class DefaultAuthorizationPolicy implements AuthorizationPolicy { ...@@ -108,7 +108,7 @@ public class DefaultAuthorizationPolicy implements AuthorizationPolicy {
if(authenRealm.equals(JiveGlobals.getProperty("xmpp.domain"))) { if(authenRealm.equals(JiveGlobals.getProperty("xmpp.domain"))) {
Log.debug("DefaultAuthorizationPolicy: authenRealm = xmpp.domain"); Log.debug("DefaultAuthorizationPolicy: authenRealm = xmpp.domain");
authorized = true; authorized = true;
} else if(authenRealm.equals(JiveGlobals.getXMLProperty("sasl.realm"))) { } else if(authenRealm.equals(JiveGlobals.getProperty("sasl.realm"))) {
Log.debug("DefaultAuthorizationPolicy: authenRealm = sasl.realm"); Log.debug("DefaultAuthorizationPolicy: authenRealm = sasl.realm");
authorized = true; authorized = true;
} else { } else {
......
...@@ -29,28 +29,16 @@ import java.util.HashSet; ...@@ -29,28 +29,16 @@ import java.util.HashSet;
* <li>If the tertiary provider is defined, attempt authentication. * <li>If the tertiary provider is defined, attempt authentication.
* </ol> * </ol>
* *
* To enable this provider, set the following in the XML configuration file: * To enable this provider, set the <tt>provider.auth.className</tt> system property to
* <tt>org.jivesoftware.openfire.auth.HybridAuthProvider</tt>.
* *
* <pre> * The primary, secondary, and tertiary providers are configured be setting system properties similar to
* &lt;provider&gt; * the following:
* &lt;auth&gt;
* &lt;className&gt;org.jivesoftware.openfire.auth.HybridAuthProvider&lt;/className&gt;
* &lt;/auth&gt;
* &lt;/provider&gt;
* </pre>
* *
* The primary, secondary, and tertiary providers are configured as in the following example: * <ul>
* * <li><tt>hybridAuthProvider.primaryProvider = org.jivesoftware.openfire.auth.DefaultAuthProvider</tt></li>
* <pre> * <li><tt>hybrodAuthProvider.secondaryProvider = org.jivesoftware.openfire.auth.NativeAuthProvider</tt></li>
* &lt;hybridAuthProvider&gt; * </ul>
* &lt;primaryProvider&gt;
* &lt;className&gt;org.jivesoftware.openfire.auth.DefaultAuthProvider&lt;className&gt;
* &lt;/primaryProvider&gt;
* &lt;secondaryProvider&gt;
* &lt;className&gt;org.jivesoftware.openfire.auth.NativeAuthProvider&lt;/className&gt;
* &lt;/secondaryProvider&gt;
* &lt;/hybridAuthProvider&gt;
* </pre>
* *
* Each of the chained providers can have a list of override users. If a user is in * Each of the chained providers can have a list of override users. If a user is in
* an override list, authentication will only be attempted with the associated provider * an override list, authentication will only be attempted with the associated provider
...@@ -88,8 +76,17 @@ public class HybridAuthProvider implements AuthProvider { ...@@ -88,8 +76,17 @@ public class HybridAuthProvider implements AuthProvider {
private Set<String> tertiaryOverrides = new HashSet<String>(); private Set<String> tertiaryOverrides = new HashSet<String>();
public HybridAuthProvider() { public HybridAuthProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("hybridAuthProvider.primaryProvider.className");
JiveGlobals.migrateProperty("hybridAuthProvider.primaryProvider.className");
JiveGlobals.migrateProperty("hybridAuthProvider.secondaryProvider.className");
JiveGlobals.migrateProperty("hybridAuthProvider.tertiaryProvider.className");
JiveGlobals.migrateProperty("hybridAuthProvider.primaryProvider.overrideList");
JiveGlobals.migrateProperty("hybridAuthProvider.secondaryProvider.overrideList");
JiveGlobals.migrateProperty("hybridAuthProvider.tertiaryProvider.overrideList");
// Load primary, secondary, and tertiary auth providers. // Load primary, secondary, and tertiary auth providers.
String primaryClass = JiveGlobals.getXMLProperty( String primaryClass = JiveGlobals.getProperty(
"hybridAuthProvider.primaryProvider.className"); "hybridAuthProvider.primaryProvider.className");
if (primaryClass == null) { if (primaryClass == null) {
Log.error("A primary AuthProvider must be specified. Authentication will be disabled."); Log.error("A primary AuthProvider must be specified. Authentication will be disabled.");
...@@ -113,7 +110,7 @@ public class HybridAuthProvider implements AuthProvider { ...@@ -113,7 +110,7 @@ public class HybridAuthProvider implements AuthProvider {
return; return;
} }
String secondaryClass = JiveGlobals.getXMLProperty( String secondaryClass = JiveGlobals.getProperty(
"hybridAuthProvider.secondaryProvider.className"); "hybridAuthProvider.secondaryProvider.className");
if (secondaryClass != null) { if (secondaryClass != null) {
try { try {
...@@ -134,7 +131,7 @@ public class HybridAuthProvider implements AuthProvider { ...@@ -134,7 +131,7 @@ public class HybridAuthProvider implements AuthProvider {
} }
} }
String tertiaryClass = JiveGlobals.getXMLProperty( String tertiaryClass = JiveGlobals.getProperty(
"hybridAuthProvider.tertiaryProvider.className"); "hybridAuthProvider.tertiaryProvider.className");
if (tertiaryClass != null) { if (tertiaryClass != null) {
try { try {
...@@ -157,14 +154,14 @@ public class HybridAuthProvider implements AuthProvider { ...@@ -157,14 +154,14 @@ public class HybridAuthProvider implements AuthProvider {
} }
// Now, load any overrides. // Now, load any overrides.
String overrideList = JiveGlobals.getXMLProperty( String overrideList = JiveGlobals.getProperty(
"hybridAuthProvider.primaryProvider.overrideList", ""); "hybridAuthProvider.primaryProvider.overrideList", "");
for (String user: overrideList.split(",")) { for (String user: overrideList.split(",")) {
primaryOverrides.add(user.trim().toLowerCase()); primaryOverrides.add(user.trim().toLowerCase());
} }
if (secondaryProvider != null) { if (secondaryProvider != null) {
overrideList = JiveGlobals.getXMLProperty( overrideList = JiveGlobals.getProperty(
"hybridAuthProvider.secondaryProvider.overrideList", ""); "hybridAuthProvider.secondaryProvider.overrideList", "");
for (String user: overrideList.split(",")) { for (String user: overrideList.split(",")) {
secondaryOverrides.add(user.trim().toLowerCase()); secondaryOverrides.add(user.trim().toLowerCase());
...@@ -172,7 +169,7 @@ public class HybridAuthProvider implements AuthProvider { ...@@ -172,7 +169,7 @@ public class HybridAuthProvider implements AuthProvider {
} }
if (tertiaryProvider != null) { if (tertiaryProvider != null) {
overrideList = JiveGlobals.getXMLProperty( overrideList = JiveGlobals.getProperty(
"hybridAuthProvider.tertiaryProvider.overrideList", ""); "hybridAuthProvider.tertiaryProvider.overrideList", "");
for (String user: overrideList.split(",")) { for (String user: overrideList.split(",")) {
tertiaryOverrides.add(user.trim().toLowerCase()); tertiaryOverrides.add(user.trim().toLowerCase());
......
...@@ -27,28 +27,19 @@ import java.sql.*; ...@@ -27,28 +27,19 @@ import java.sql.*;
* {@link HybridAuthProvider hybrid} auth provider, so that you can also have * {@link HybridAuthProvider hybrid} auth provider, so that you can also have
* XMPP-only users that won't pollute your external data.<p> * XMPP-only users that won't pollute your external data.<p>
* *
* To enable this provider, set the following in the XML configuration file: * To enable this provider, set the following in the system properties:
* * <ul>
* <pre> * <li><tt>provider.auth.className = org.jivesoftware.openfire.auth.JDBCAuthProvider</tt></li>
* &lt;provider&gt; * </ul>
* &lt;auth&gt;
* &lt;className&gt;org.jivesoftware.openfire.auth.JDBCAuthProvider&lt;/className&gt;
* &lt;/auth&gt;
* &lt;/provider&gt;
* </pre>
* *
* You'll also need to set your JDBC driver, connection string, and SQL statements: * You'll also need to set your JDBC driver, connection string, and SQL statements:
* *
* <pre> * <ul>
* &lt;jdbcProvider&gt; * <li><tt>jdbcProvider.driver = com.mysql.jdbc.Driver</tt></li>
* &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt; * <li><tt>jdbcProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&amp;password=secret</tt></li>
* &lt;connectionString&gt;jdbc:mysql://localhost/dbname?user=username&amp;password=secret&lt;/connectionString&gt; * <li><tt>jdbcAuthProvider.passwordSQL = SELECT password FROM user_account WHERE username=?</tt></li>
* &lt;/jdbcProvider&gt; * <li><tt>jdbcAuthProvider.passwordType = plain</tt></li>
* * </ul>
* &lt;jdbcAuthProvider&gt;
* &lt;passwordSQL&gt;SELECT password FROM user_account WHERE username=?&lt;/passwordSQL&gt;
* &lt;passwordType&gt;plain&lt;/passwordType&gt;
* &lt;/jdbcAuthProvider&gt;</pre>
* *
* The passwordType setting tells Openfire how the password is stored. Setting the value * The passwordType setting tells Openfire how the password is stored. Setting the value
* is optional (when not set, it defaults to "plain"). The valid values are:<ul> * is optional (when not set, it defaults to "plain"). The valid values are:<ul>
...@@ -70,8 +61,14 @@ public class JDBCAuthProvider implements AuthProvider { ...@@ -70,8 +61,14 @@ public class JDBCAuthProvider implements AuthProvider {
* Constructs a new JDBC authentication provider. * Constructs a new JDBC authentication provider.
*/ */
public JDBCAuthProvider() { public JDBCAuthProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("jdbcProvider.driver");
JiveGlobals.migrateProperty("jdbcProvider.connectionString");
JiveGlobals.migrateProperty("jdbcAuthProvider.passwordSQL");
JiveGlobals.migrateProperty("jdbcAuthProvider.passwordType");
// Load the JDBC driver and connection string. // Load the JDBC driver and connection string.
String jdbcDriver = JiveGlobals.getXMLProperty("jdbcProvider.driver"); String jdbcDriver = JiveGlobals.getProperty("jdbcProvider.driver");
try { try {
Class.forName(jdbcDriver).newInstance(); Class.forName(jdbcDriver).newInstance();
} }
...@@ -79,14 +76,14 @@ public class JDBCAuthProvider implements AuthProvider { ...@@ -79,14 +76,14 @@ public class JDBCAuthProvider implements AuthProvider {
Log.error("Unable to load JDBC driver: " + jdbcDriver, e); Log.error("Unable to load JDBC driver: " + jdbcDriver, e);
return; return;
} }
connectionString = JiveGlobals.getXMLProperty("jdbcProvider.connectionString"); connectionString = JiveGlobals.getProperty("jdbcProvider.connectionString");
// Load SQL statements. // Load SQL statements.
passwordSQL = JiveGlobals.getXMLProperty("jdbcAuthProvider.passwordSQL"); passwordSQL = JiveGlobals.getProperty("jdbcAuthProvider.passwordSQL");
passwordType = PasswordType.plain; passwordType = PasswordType.plain;
try { try {
passwordType = PasswordType.valueOf( passwordType = PasswordType.valueOf(
JiveGlobals.getXMLProperty("jdbcAuthProvider.passwordType", "plain")); JiveGlobals.getProperty("jdbcAuthProvider.passwordType", "plain"));
} }
catch (IllegalArgumentException iae) { catch (IllegalArgumentException iae) {
Log.error(iae); Log.error(iae);
...@@ -215,6 +212,7 @@ public class JDBCAuthProvider implements AuthProvider { ...@@ -215,6 +212,7 @@ public class JDBCAuthProvider implements AuthProvider {
* Returns the value of the password field. It will be in plain text or hashed * Returns the value of the password field. It will be in plain text or hashed
* format, depending on the password type. * format, depending on the password type.
* *
* @param username user to retrieve the password field for
* @return the password value. * @return the password value.
* @throws UserNotFoundException if the given user could not be loaded. * @throws UserNotFoundException if the given user could not be loaded.
*/ */
......
...@@ -32,18 +32,12 @@ import java.lang.reflect.Field; ...@@ -32,18 +32,12 @@ import java.lang.reflect.Field;
* The appropriate native library must be manually moved from the resources/nativeAuth * The appropriate native library must be manually moved from the resources/nativeAuth
* directory to the lib directory.<p> * directory to the lib directory.<p>
* *
* To enable this provider, set the following in the XML configuration file: * To enable this provider, set the following in the system properties:
* *
* <pre> * <ul>
* &lt;provider&gt; * <li><tt>provider.auth.className = org.jivesoftware.openfire.auth.NativeAuthProvider</tt></li>
* &lt;auth&gt; * <li><tt>provider.user.className = org.jivesoftware.openfire.user.NativeUserProvider</tt></li>
* &lt;className&gt;org.jivesoftware.openfire.auth.NativeAuthProvider&lt;/className&gt; * </ul>
* &lt;/auth&gt;
* &lt;user&gt;
* &lt;className&gt;org.jivesoftware.openfire.user.NativeUserProvider&lt;/className&gt;
* &lt;/user&gt;
* &lt;/provider&gt;
* </pre>
* *
* The properties to configure the provider are as follows: * The properties to configure the provider are as follows:
* *
...@@ -66,7 +60,10 @@ public class NativeAuthProvider implements AuthProvider { ...@@ -66,7 +60,10 @@ public class NativeAuthProvider implements AuthProvider {
private String domain; private String domain;
public NativeAuthProvider() { public NativeAuthProvider() {
this.domain = JiveGlobals.getXMLProperty("nativeAuth.domain"); // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("nativeAuth.domain");
this.domain = JiveGlobals.getProperty("nativeAuth.domain");
// Configure the library path so that we can load the shaj native library // Configure the library path so that we can load the shaj native library
// from the Openfire lib directory. // from the Openfire lib directory.
......
...@@ -26,19 +26,12 @@ import java.util.Properties; ...@@ -26,19 +26,12 @@ import java.util.Properties;
/** /**
* An AuthProvider that authenticates using a POP3 server. It will automatically create * An AuthProvider that authenticates using a POP3 server. It will automatically create
* local user accounts as needed. To enable this provider, edit the XML config file * local user accounts as needed. To enable this provider, set system properties as follows:
* file and set:
* *
* <pre> * <ul>
* &lt;provider&gt; * <li><tt>provider.auth.className = org.jivesoftware.openfire.auth.POP3AuthProvider</tt></li>
* &lt;auth&gt; * <li><tt>provider.user.className = org.jivesoftware.openfire.user.POP3UserProvider</tt></li>
* &lt;className&gt;org.jivesoftware.openfire.auth.POP3AuthProvider&lt;/className&gt; * </ul>
* &lt;/auth&gt;
* &lt;user&gt;
* &lt;className&gt;org.jivesoftware.openfire.user.POP3UserProvider&lt;/className&gt;
* &lt;/user&gt;
* &lt;/provider&gt;
* </pre>
* *
* The properties to configure the provider are as follows: * The properties to configure the provider are as follows:
* *
...@@ -79,24 +72,33 @@ public class POP3AuthProvider implements AuthProvider { ...@@ -79,24 +72,33 @@ public class POP3AuthProvider implements AuthProvider {
* Initialiazes the POP3AuthProvider with values from the global config file. * Initialiazes the POP3AuthProvider with values from the global config file.
*/ */
public POP3AuthProvider() { public POP3AuthProvider() {
if (Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authCache.enabled"))) { // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("pop3.authCache.enabled");
JiveGlobals.migrateProperty("pop3.ssl");
JiveGlobals.migrateProperty("pop3.authRequiresDomain");
JiveGlobals.migrateProperty("pop3.host");
JiveGlobals.migrateProperty("pop3.debug");
JiveGlobals.migrateProperty("pop3.domain");
JiveGlobals.migrateProperty("pop3.port");
if (Boolean.valueOf(JiveGlobals.getProperty("pop3.authCache.enabled"))) {
String cacheName = "POP3 Authentication"; String cacheName = "POP3 Authentication";
authCache = CacheFactory.createCache(cacheName); authCache = CacheFactory.createCache(cacheName);
} }
useSSL = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.ssl")); useSSL = Boolean.valueOf(JiveGlobals.getProperty("pop3.ssl"));
authRequiresDomain = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.authRequiresDomain")); authRequiresDomain = Boolean.valueOf(JiveGlobals.getProperty("pop3.authRequiresDomain"));
host = JiveGlobals.getXMLProperty("pop3.host"); host = JiveGlobals.getProperty("pop3.host");
if (host == null || host.length() < 1) { if (host == null || host.length() < 1) {
throw new IllegalArgumentException("pop3.host is null or empty"); throw new IllegalArgumentException("pop3.host is null or empty");
} }
debugEnabled = Boolean.valueOf(JiveGlobals.getXMLProperty("pop3.debug")); debugEnabled = Boolean.valueOf(JiveGlobals.getProperty("pop3.debug"));
domain = JiveGlobals.getXMLProperty("pop3.domain"); domain = JiveGlobals.getProperty("pop3.domain");
port = JiveGlobals.getXMLProperty("pop3.port", useSSL ? 995 : 110); port = JiveGlobals.getIntProperty("pop3.port", useSSL ? 995 : 110);
if (Log.isDebugEnabled()) { if (Log.isDebugEnabled()) {
Log.debug("POP3AuthProvider: Created new POP3AuthProvider instance, fields:"); Log.debug("POP3AuthProvider: Created new POP3AuthProvider instance, fields:");
......
...@@ -166,17 +166,17 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -166,17 +166,17 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
this.properties = new Map<String, String>() { this.properties = new Map<String, String>() {
public String get(Object key) { public String get(Object key) {
return JiveGlobals.getXMLProperty((String) key); return JiveGlobals.getProperty((String) key);
} }
public String put(String key, String value) { public String put(String key, String value) {
JiveGlobals.setXMLProperty(key, value); JiveGlobals.setProperty(key, value);
// Always return null since XMLProperties doesn't support the normal semantics. // Always return null since XMLProperties doesn't support the normal semantics.
return null; return null;
} }
public String remove(Object key) { public String remove(Object key) {
JiveGlobals.deleteXMLProperty((String) key); JiveGlobals.deleteProperty((String) key);
// Always return null since XMLProperties doesn't support the normal semantics. // Always return null since XMLProperties doesn't support the normal semantics.
return null; return null;
} }
...@@ -222,6 +222,40 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM ...@@ -222,6 +222,40 @@ public class ClearspaceManager extends BasicModule implements ExternalComponentM
} }
private void init() { private void init() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("clearspace.uri");
JiveGlobals.migrateProperty("clearspace.sharedSecret");
// Make sure that all Clearspace components are set up, unless they were overridden
// Note that the auth provider is our way of knowing that we are set up with Clearspace,
// so don't bother checking to set it.
if (isEnabled()) {
if (JiveGlobals.getProperty("provider.user.className") == null) {
JiveGlobals.setProperty("provider.user.className",
"org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
}
if (JiveGlobals.getProperty("provider.group.className") == null) {
JiveGlobals.setProperty("provider.group.className",
"org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
}
if (JiveGlobals.getProperty("provider.vcard.className") == null) {
JiveGlobals.setProperty("provider.vcard.className",
"org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
}
if (JiveGlobals.getProperty("provider.lockout.className") == null) {
JiveGlobals.setProperty("provider.lockout.className",
"org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
}
if (JiveGlobals.getProperty("provider.securityAudit.className") == null) {
JiveGlobals.setProperty("provider.securityAudit.className",
"org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
}
if (JiveGlobals.getProperty("provider.admin.className") == null) {
JiveGlobals.setProperty("provider.admin.className",
"org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider");
}
}
this.uri = properties.get("clearspace.uri"); this.uri = properties.get("clearspace.uri");
if (uri != null) { if (uri != null) {
if (!this.uri.endsWith("/")) { if (!this.uri.endsWith("/")) {
......
...@@ -19,10 +19,7 @@ import org.jivesoftware.openfire.event.UserEventListener; ...@@ -19,10 +19,7 @@ import org.jivesoftware.openfire.event.UserEventListener;
import org.jivesoftware.openfire.user.User; import org.jivesoftware.openfire.user.User;
import org.jivesoftware.openfire.user.UserManager; import org.jivesoftware.openfire.user.UserManager;
import org.jivesoftware.openfire.user.UserNotFoundException; import org.jivesoftware.openfire.user.UserNotFoundException;
import org.jivesoftware.util.ClassUtils; import org.jivesoftware.util.*;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.TaskEngine;
import org.jivesoftware.util.cache.Cache; import org.jivesoftware.util.cache.Cache;
import org.jivesoftware.util.cache.CacheFactory; import org.jivesoftware.util.cache.CacheFactory;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -68,17 +65,7 @@ public class GroupManager { ...@@ -68,17 +65,7 @@ public class GroupManager {
// a particular user // a particular user
groupMetaCache = CacheFactory.createCache("Group Metadata Cache"); groupMetaCache = CacheFactory.createCache("Group Metadata Cache");
// Load a group provider. initProvider();
String className = JiveGlobals.getXMLProperty("provider.group.className",
"org.jivesoftware.openfire.group.DefaultGroupProvider");
try {
Class c = ClassUtils.forName(className);
provider = (GroupProvider) c.newInstance();
}
catch (Exception e) {
Log.error("Error loading group provider: " + className, e);
provider = new DefaultGroupProvider();
}
GroupEventDispatcher.addListener(new GroupEventListener() { GroupEventDispatcher.addListener(new GroupEventListener() {
public void groupCreated(Group group, Map params) { public void groupCreated(Group group, Map params) {
...@@ -156,6 +143,28 @@ public class GroupManager { ...@@ -156,6 +143,28 @@ public class GroupManager {
} }
}); });
// Detect when a new auth provider class is set
PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) {
if ("provider.group.className".equals(property)) {
initProvider();
}
}
public void propertyDeleted(String property, Map params) {
//Ignore
}
public void xmlPropertySet(String property, Map params) {
//Ignore
}
public void xmlPropertyDeleted(String property, Map params) {
//Ignore
}
};
PropertyEventDispatcher.addListener(propListener);
// Pre-load shared groups. This will provide a faster response // Pre-load shared groups. This will provide a faster response
// time to the first client that logs in. // time to the first client that logs in.
Runnable task = new Runnable() { Runnable task = new Runnable() {
...@@ -180,6 +189,23 @@ public class GroupManager { ...@@ -180,6 +189,23 @@ public class GroupManager {
TaskEngine.getInstance().submit(task); TaskEngine.getInstance().submit(task);
} }
private void initProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.group.className");
// Load a group provider.
String className = JiveGlobals.getProperty("provider.group.className",
"org.jivesoftware.openfire.group.DefaultGroupProvider");
try {
Class c = ClassUtils.forName(className);
provider = (GroupProvider) c.newInstance();
}
catch (Exception e) {
Log.error("Error loading group provider: " + className, e);
provider = new DefaultGroupProvider();
}
}
/** /**
* Factory method for creating a new Group. A unique name is the only required field. * Factory method for creating a new Group. A unique name is the only required field.
* *
......
...@@ -27,37 +27,24 @@ import java.util.List; ...@@ -27,37 +27,24 @@ import java.util.List;
* It is best used with the JDBCAuthProvider to provide integration between your external system and * It is best used with the JDBCAuthProvider to provide integration between your external system and
* Openfire. All data is treated as read-only so any set operations will result in an exception. * Openfire. All data is treated as read-only so any set operations will result in an exception.
* *
* To enable this provider, set the following in the XML configuration file: * To enable this provider, set the following in the system properties:
* *
* <pre> * <ul>
* &lt;provider&gt; * <li><tt>provider.group.className = org.jivesoftware.openfire.group.JDBCGroupProvider</tt></li>
* &lt;group&gt; * </ul>
* &lt;className&gt;org.jivesoftware.openfire.group.JDBCGroupProvider&lt;/className&gt;
* &lt;/group&gt;
* &lt;/provider&gt;
* </pre>
* *
* Then you need to set your driver, connection string and SQL statements: * Then you need to set your driver, connection string and SQL statements:
* *
* <pre> * <ul>
* &lt;jdbcProvider&gt; * <li><tt>jdbcProvider.driver = com.mysql.jdbc.Driver</tt></li>
* &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt; * <li><tt>jdbcProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&amp;password=secret</tt></li>
* &lt;connectionString&gt;jdbc:mysql://localhost/dbname?user=username&amp;password=secret&lt;/connectionString&gt; * <li><tt>jdbcGroupProvider.groupCountSQL = SELECT count(*) FROM myGroups</tt></li>
* &lt;/jdbcProvider&gt; * <li><tt>jdbcGroupProvider.allGroupsSQL = SELECT groupName FROM myGroups</tt></li>
* * <li><tt>jdbcGroupProvider.userGroupsSQL = SELECT groupName FORM myGroupUsers WHERE username=?</tt></li>
* &lt;jdbcGroupProvider&gt; * <li><tt>jdbcGroupProvider.descriptionSQL = SELECT groupDescription FROM myGroups WHERE groupName=?</tt></li>
* &lt;groupCountSQL&gt;SELECT count(*) FROM myGroups&lt;/groupCountSQL&gt; * <li><tt>jdbcGroupProvider.loadMembersSQL = SELECT username FORM myGroupUsers WHERE groupName=? AND isAdmin='N'</tt></li>
* &lt;allGroupsSQL&gt;SELECT groupName FROM myGroups&lt;/allGroupsSQL&gt; * <li><tt>jdbcGroupProvider.loadAdminsSQL = SELECT username FORM myGroupUsers WHERE groupName=? AND isAdmin='Y'</tt></li>
* &lt;userGroupsSQL&gt;SELECT groupName FORM myGroupUsers WHERE * </ul>
* username=?&lt;/userGroupsSQL&gt;
* &lt;descriptionSQL&gt;SELECT groupDescription FROM myGroups WHERE
* groupName=?&lt;/descriptionSQL&gt;
* &lt;loadMembersSQL&gt;SELECT username FORM myGroupUsers WHERE groupName=? AND
* isAdmin='N'&lt;/loadMembersSQL&gt;
* &lt;loadAdminsSQL&gt;SELECT username FORM myGroupUsers WHERE groupName=? AND
* isAdmin='Y'&lt;/loadAdminsSQL&gt;
* &lt;/jdbcGroupProvider&gt;
* </pre>
* *
* @author David Snopek * @author David Snopek
*/ */
...@@ -78,8 +65,18 @@ public class JDBCGroupProvider implements GroupProvider { ...@@ -78,8 +65,18 @@ public class JDBCGroupProvider implements GroupProvider {
* Constructor of the JDBCGroupProvider class. * Constructor of the JDBCGroupProvider class.
*/ */
public JDBCGroupProvider() { public JDBCGroupProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("jdbcProvider.driver");
JiveGlobals.migrateProperty("jdbcProvider.connectionString");
JiveGlobals.migrateProperty("jdbcGroupProvider.groupCountSQL");
JiveGlobals.migrateProperty("jdbcGroupProvider.allGroupsSQL");
JiveGlobals.migrateProperty("jdbcGroupProvider.userGroupsSQL");
JiveGlobals.migrateProperty("jdbcGroupProvider.descriptionSQL");
JiveGlobals.migrateProperty("jdbcGroupProvider.loadMembersSQL");
JiveGlobals.migrateProperty("jdbcGroupProvider.loadAdminsSQL");
// Load the JDBC driver and connection string. // Load the JDBC driver and connection string.
String jdbcDriver = JiveGlobals.getXMLProperty("jdbcProvider.driver"); String jdbcDriver = JiveGlobals.getProperty("jdbcProvider.driver");
try { try {
Class.forName(jdbcDriver).newInstance(); Class.forName(jdbcDriver).newInstance();
} }
...@@ -87,15 +84,15 @@ public class JDBCGroupProvider implements GroupProvider { ...@@ -87,15 +84,15 @@ public class JDBCGroupProvider implements GroupProvider {
Log.error("Unable to load JDBC driver: " + jdbcDriver, e); Log.error("Unable to load JDBC driver: " + jdbcDriver, e);
return; return;
} }
connectionString = JiveGlobals.getXMLProperty("jdbcProvider.connectionString"); connectionString = JiveGlobals.getProperty("jdbcProvider.connectionString");
// Load SQL statements // Load SQL statements
groupCountSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.groupCountSQL"); groupCountSQL = JiveGlobals.getProperty("jdbcGroupProvider.groupCountSQL");
allGroupsSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.allGroupsSQL"); allGroupsSQL = JiveGlobals.getProperty("jdbcGroupProvider.allGroupsSQL");
userGroupsSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.userGroupsSQL"); userGroupsSQL = JiveGlobals.getProperty("jdbcGroupProvider.userGroupsSQL");
descriptionSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.descriptionSQL"); descriptionSQL = JiveGlobals.getProperty("jdbcGroupProvider.descriptionSQL");
loadMembersSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.loadMembersSQL"); loadMembersSQL = JiveGlobals.getProperty("jdbcGroupProvider.loadMembersSQL");
loadAdminsSQL = JiveGlobals.getXMLProperty("jdbcGroupProvider.loadAdminsSQL"); loadAdminsSQL = JiveGlobals.getProperty("jdbcGroupProvider.loadAdminsSQL");
} }
/** /**
......
...@@ -35,11 +35,11 @@ import javax.naming.CommunicationException; ...@@ -35,11 +35,11 @@ import javax.naming.CommunicationException;
* *
* <li><tt>ldap.authCache.enabled</tt> -- true to enable the auth cache.</li> * <li><tt>ldap.authCache.enabled</tt> -- true to enable the auth cache.</li>
* <li><tt>ldap.authCache.size</tt> -- size in bytes of the auth cache. If property is * <li><tt>ldap.authCache.size</tt> -- size in bytes of the auth cache. If property is
* not set, the default value is 524288 (512 K). * not set, the default value is 524288 (512 K).</li>
* <li><tt>ldap.authCache.maxLifetime</tt> -- maximum amount of time a hashed password * <li><tt>ldap.authCache.maxLifetime</tt> -- maximum amount of time a hashed password
* can be cached in milleseconds. If property is not set, the default value is * can be cached in milleseconds. If property is not set, the default value is
* 7200000 (2 hours). * 7200000 (2 hours).</li>
* </tt> * </ul>
* *
* @author Matt Tucker * @author Matt Tucker
*/ */
...@@ -49,8 +49,11 @@ public class LdapAuthProvider implements AuthProvider { ...@@ -49,8 +49,11 @@ public class LdapAuthProvider implements AuthProvider {
private Cache<String, String> authCache = null; private Cache<String, String> authCache = null;
public LdapAuthProvider() { public LdapAuthProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.authCache.enabled");
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
if (JiveGlobals.getXMLProperty("ldap.authCache.enabled", false)) { if (JiveGlobals.getBooleanProperty("ldap.authCache.enabled", false)) {
String cacheName = "LDAP Authentication"; String cacheName = "LDAP Authentication";
authCache = CacheFactory.createCache(cacheName); authCache = CacheFactory.createCache(cacheName);
} }
......
...@@ -28,14 +28,13 @@ import javax.naming.directory.SearchResult; ...@@ -28,14 +28,13 @@ import javax.naming.directory.SearchResult;
/** /**
* Provider for authorization mapping using LDAP. If the authenticated * Provider for authorization mapping using LDAP. If the authenticated
* principal did not request a username, provide one via LDAP. Specify the * principal did not request a username, provide one via LDAP. Specify the
* lookup field in the <tt>openfire.xml</tt> file. An entry in that file would * lookup field in the system properties. An entry in that file would
* look like the following: * look like the following:
* <p/> *
* <pre> * <ul>
* &lt;ldap&gt; * <li><tt>ldap.princField = k5login</tt></li>
* &lt;princField&gt; k5login &lt;/princField&gt; * <li><tt>ldap.princSearchFilter = princField={0}</tt></li>
* &lt;princSearchFilter&gt; princField={0} &lt;/princSearchFilter&gt; * </ul>
* &lt;/ldap&gt;</pre>
* <p/> * <p/>
* Each ldap object that represents a user is expcted to have exactly one of * Each ldap object that represents a user is expcted to have exactly one of
* ldap.usernameField and ldap.princField, and they are both expected to be unique * ldap.usernameField and ldap.princField, and they are both expected to be unique
...@@ -59,10 +58,14 @@ public class LdapAuthorizationMapping implements AuthorizationMapping { ...@@ -59,10 +58,14 @@ public class LdapAuthorizationMapping implements AuthorizationMapping {
private String princSearchFilter; private String princSearchFilter;
public LdapAuthorizationMapping() { public LdapAuthorizationMapping() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.princField");
JiveGlobals.migrateProperty("ldap.princSearchFilter");
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
usernameField = manager.getUsernameField(); usernameField = manager.getUsernameField();
princField = JiveGlobals.getXMLProperty("ldap.princField", "k5login"); princField = JiveGlobals.getProperty("ldap.princField", "k5login");
princSearchFilter = JiveGlobals.getXMLProperty("ldap.princSearchFilter"); princSearchFilter = JiveGlobals.getProperty("ldap.princSearchFilter");
StringBuilder filter = new StringBuilder(); StringBuilder filter = new StringBuilder();
if(princSearchFilter == null) { if(princSearchFilter == null) {
filter.append("(").append(princField).append("={0})"); filter.append("(").append(princField).append("={0})");
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
package org.jivesoftware.openfire.ldap; package org.jivesoftware.openfire.ldap;
import org.jivesoftware.openfire.ldap.LdapManager;
import org.jivesoftware.openfire.auth.AuthorizationPolicy; import org.jivesoftware.openfire.auth.AuthorizationPolicy;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -27,14 +26,13 @@ import java.util.Enumeration; ...@@ -27,14 +26,13 @@ import java.util.Enumeration;
/** /**
* Provider for authorization using LDAP. Checks if the authenticated * Provider for authorization using LDAP. Checks if the authenticated
* principal is in the user's LDAP object using the authorizeField * principal is in the user's LDAP object using the authorizeField
* from the <tt>openfire.xml</tt> file. An entry in that file would * from the system properties. An entry in that file would
* look like the following: * look like the following:
* <p/> *
* <pre> * <ul>
* &lt;ldap&gt; * <li><tt>ldap.authorizeField = k5login</tt></li>
* &lt;authorizeField&gt; k5login &lt;/authorizeField&gt; * </ul>
* &lt;/ldap&gt;</pre> *
* <p/>
* This implementation requires that LDAP be configured, obviously. * This implementation requires that LDAP be configured, obviously.
* *
* @author Jay Kline * @author Jay Kline
...@@ -46,9 +44,12 @@ public class LdapAuthorizationPolicy implements AuthorizationPolicy { ...@@ -46,9 +44,12 @@ public class LdapAuthorizationPolicy implements AuthorizationPolicy {
private String authorizeField; private String authorizeField;
public LdapAuthorizationPolicy() { public LdapAuthorizationPolicy() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.authorizeField");
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
usernameField = manager.getUsernameField(); usernameField = manager.getUsernameField();
authorizeField = JiveGlobals.getXMLProperty("ldap.authorizeField", "k5login"); authorizeField = JiveGlobals.getProperty("ldap.authorizeField", "k5login");
} }
/** /**
......
...@@ -75,17 +75,17 @@ public class LdapManager { ...@@ -75,17 +75,17 @@ public class LdapManager {
Map<String, String> properties = new Map<String, String>() { Map<String, String> properties = new Map<String, String>() {
public String get(Object key) { public String get(Object key) {
return JiveGlobals.getXMLProperty((String)key); return JiveGlobals.getProperty((String)key);
} }
public String put(String key, String value) { public String put(String key, String value) {
JiveGlobals.setXMLProperty(key, value); JiveGlobals.setProperty(key, value);
// Always return null since XMLProperties doesn't support the normal semantics. // Always return null since XMLProperties doesn't support the normal semantics.
return null; return null;
} }
public String remove(Object key) { public String remove(Object key) {
JiveGlobals.deleteXMLProperty((String)key); JiveGlobals.deleteProperty((String)key);
// Always return null since XMLProperties doesn't support the normal semantics. // Always return null since XMLProperties doesn't support the normal semantics.
return null; return null;
} }
...@@ -181,6 +181,37 @@ public class LdapManager { ...@@ -181,6 +181,37 @@ public class LdapManager {
*/ */
public LdapManager(Map<String, String> properties) { public LdapManager(Map<String, String> properties) {
this.properties = properties; this.properties = properties;
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.host");
JiveGlobals.migrateProperty("ldap.port");
JiveGlobals.migrateProperty("ldap.readTimeout");
JiveGlobals.migrateProperty("ldap.usernameField");
JiveGlobals.migrateProperty("ldap.usernameSuffix");
JiveGlobals.migrateProperty("ldap.baseDN");
JiveGlobals.migrateProperty("ldap.alternateBaseDN");
JiveGlobals.migrateProperty("ldap.nameField");
JiveGlobals.migrateProperty("ldap.emailField");
JiveGlobals.migrateProperty("ldap.connectionPoolEnabled");
JiveGlobals.migrateProperty("ldap.searchFilter");
JiveGlobals.migrateProperty("ldap.subTreeSearch");
JiveGlobals.migrateProperty("ldap.groupNameField");
JiveGlobals.migrateProperty("ldap.groupMemberField");
JiveGlobals.migrateProperty("ldap.groupDescriptionField");
JiveGlobals.migrateProperty("ldap.posixMode");
JiveGlobals.migrateProperty("ldap.groupSearchFilter");
JiveGlobals.migrateProperty("ldap.adminDN");
JiveGlobals.migrateProperty("ldap.adminPassword");
JiveGlobals.migrateProperty("ldap.debugEnabled");
JiveGlobals.migrateProperty("ldap.sslEnabled");
JiveGlobals.migrateProperty("ldap.autoFollowReferrals");
JiveGlobals.migrateProperty("ldap.autoFollowAliasReferrals");
JiveGlobals.migrateProperty("ldap.encloseUserDN");
JiveGlobals.migrateProperty("ldap.encloseGroupDN");
JiveGlobals.migrateProperty("ldap.initialContextFactory");
JiveGlobals.migrateProperty("ldap.pagedResultsSize");
JiveGlobals.migrateProperty("ldap.clientSideSorting");
JiveGlobals.migrateProperty("ldap.ldapDebugEnabled");
String host = properties.get("ldap.host"); String host = properties.get("ldap.host");
if (host != null) { if (host != null) {
...@@ -1485,8 +1516,12 @@ public class LdapManager { ...@@ -1485,8 +1516,12 @@ public class LdapManager {
*/ */
public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim) { public List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim) {
List<String> results = new ArrayList<String>(); List<String> results = new ArrayList<String>();
int pageSize = JiveGlobals.getXMLProperty("ldap.pagedResultsSize", -1); int pageSize = -1;
Boolean clientSideSort = JiveGlobals.getXMLProperty("ldap.clientSideSorting", false); String pageSizeStr = properties.get("ldap.pagedResultsSize");
if (pageSizeStr != null) pageSize = Integer.parseInt(pageSizeStr, -1);
Boolean clientSideSort = false;
String clientSideSortStr = properties.get("ldap.clientSideSorting");
if (clientSideSortStr != null) clientSideSort = Boolean.valueOf(clientSideSortStr);
LdapContext ctx = null; LdapContext ctx = null;
LdapContext ctx2 = null; LdapContext ctx2 = null;
try { try {
...@@ -1688,7 +1723,9 @@ public class LdapManager { ...@@ -1688,7 +1723,9 @@ public class LdapManager {
* @return The number of entries that match the filter. * @return The number of entries that match the filter.
*/ */
public Integer retrieveListCount(String attribute, String searchFilter) { public Integer retrieveListCount(String attribute, String searchFilter) {
int pageSize = JiveGlobals.getXMLProperty("ldap.pagedResultsSize", -1); int pageSize = -1;
String pageSizeStr = properties.get("ldap.pagedResultsSize");
if (pageSizeStr != null) pageSize = Integer.parseInt(pageSizeStr, -1);
LdapContext ctx = null; LdapContext ctx = null;
LdapContext ctx2 = null; LdapContext ctx2 = null;
Integer count = 0; Integer count = 0;
......
...@@ -40,9 +40,12 @@ public class LdapUserProvider implements UserProvider { ...@@ -40,9 +40,12 @@ public class LdapUserProvider implements UserProvider {
private long expiresStamp = System.currentTimeMillis(); private long expiresStamp = System.currentTimeMillis();
public LdapUserProvider() { public LdapUserProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.searchFields");
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
searchFields = new LinkedHashMap<String,String>(); searchFields = new LinkedHashMap<String,String>();
String fieldList = JiveGlobals.getXMLProperty("ldap.searchFields"); String fieldList = JiveGlobals.getProperty("ldap.searchFields");
// If the value isn't present, default to to username, name, and email. // If the value isn't present, default to to username, name, and email.
if (fieldList == null) { if (fieldList == null) {
searchFields.put("Username", manager.getUsernameField()); searchFields.put("Username", manager.getUsernameField());
...@@ -207,7 +210,7 @@ public class LdapUserProvider implements UserProvider { ...@@ -207,7 +210,7 @@ public class LdapUserProvider implements UserProvider {
Log.error("Error parsing LDAP search fields: " + fieldList, e); Log.error("Error parsing LDAP search fields: " + fieldList, e);
} }
} }
JiveGlobals.setXMLProperty("ldap.searchFields", fieldList); JiveGlobals.setProperty("ldap.searchFields", fieldList);
} }
public Collection<User> findUsers(Set<String> fields, String query) public Collection<User> findUsers(Set<String> fields, String query)
......
...@@ -27,15 +27,9 @@ import java.util.*; ...@@ -27,15 +27,9 @@ import java.util.*;
/** /**
* Read-only LDAP provider for vCards.Configuration consists of adding a provider:<p/> * Read-only LDAP provider for vCards.Configuration consists of adding a provider:<p/>
* *
* <pre> * <tt>provider.vcard.className = org.jivesoftware.openfire.ldap.LdapVCardProvider</tt>
* &lt;provider&gt;
* &lt;vcard&gt;
* &lt;className&gt;org.jivesoftware.openfire.ldap.LdapVCardProvider&lt;/className&gt;
* &lt;/vcard&gt;
* &lt;/provider&gt;
* </pre><p/>
* *
* and an xml vcard-mapping to openfire.xml.<p/> * and an xml vcard-mapping in the system properties.<p/>
* *
* The vcard attributes can be configured by adding an <code>attrs="attr1,attr2"</code> * The vcard attributes can be configured by adding an <code>attrs="attr1,attr2"</code>
* attribute to the vcard elements.<p/> * attribute to the vcard elements.<p/>
...@@ -49,9 +43,8 @@ import java.util.*; ...@@ -49,9 +43,8 @@ import java.util.*;
* XML this provider will send to a client after after stripping <code>attr</code> attributes * XML this provider will send to a client after after stripping <code>attr</code> attributes
* and populating the placeholders with the data retrieved from LDAP. This system should * and populating the placeholders with the data retrieved from LDAP. This system should
* be flexible enough to handle any client's vCard format. An example mapping follows.<br> * be flexible enough to handle any client's vCard format. An example mapping follows.<br>
* <pre> *
* &lt;ldap&gt; * <tt>ldap.vcard-mapping =
* &lt;vcard-mapping&gt;
* &lt;![CDATA[ * &lt;![CDATA[
* &lt;vCard xmlns='vcard-temp'&gt; * &lt;vCard xmlns='vcard-temp'&gt;
* &lt;FN attrs=&quot;displayName&quot;&gt;{0}&lt;/FN&gt; * &lt;FN attrs=&quot;displayName&quot;&gt;{0}&lt;/FN&gt;
...@@ -87,9 +80,7 @@ import java.util.*; ...@@ -87,9 +80,7 @@ import java.util.*;
* &lt;/DESC&gt; * &lt;/DESC&gt;
* &lt;/vCard&gt; * &lt;/vCard&gt;
* ]]&gt; * ]]&gt;
* &lt;/vcard-mapping&gt; * </tt>
* &lt;/ldap&gt;
* </pre><p>
* <p/> * <p/>
* An easy way to get the vcard format your client needs, assuming you've been * An easy way to get the vcard format your client needs, assuming you've been
* using the database store, is to do a <code>SELECT value FROM ofVCard WHERE * using the database store, is to do a <code>SELECT value FROM ofVCard WHERE
...@@ -113,6 +104,9 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener { ...@@ -113,6 +104,9 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener {
private DefaultVCardProvider defaultProvider = null; private DefaultVCardProvider defaultProvider = null;
public LdapVCardProvider() { public LdapVCardProvider() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("ldap.vcard-mapping");
manager = LdapManager.getInstance(); manager = LdapManager.getInstance();
initTemplate(); initTemplate();
// Listen to property events so that the template is always up to date // Listen to property events so that the template is always up to date
...@@ -127,7 +121,7 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener { ...@@ -127,7 +121,7 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener {
* Initializes the VCard template as set by the administrator. * Initializes the VCard template as set by the administrator.
*/ */
private void initTemplate() { private void initTemplate() {
String property = JiveGlobals.getXMLProperty("ldap.vcard-mapping"); String property = JiveGlobals.getProperty("ldap.vcard-mapping");
Log.debug("LdapVCardProvider: Found vcard mapping: '" + property); Log.debug("LdapVCardProvider: Found vcard mapping: '" + property);
try { try {
// Remove CDATA wrapping element // Remove CDATA wrapping element
...@@ -416,6 +410,11 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener { ...@@ -416,6 +410,11 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener {
if ("ldap.override.avatar".equals(property)) { if ("ldap.override.avatar".equals(property)) {
dbStorageEnabled = Boolean.parseBoolean((String)params.get("value")); dbStorageEnabled = Boolean.parseBoolean((String)params.get("value"));
} }
else if ("ldap.vcard-mapping".equals(property)) {
initTemplate();
// Reset cache of vCards
VCardManager.getInstance().reset();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -425,11 +424,7 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener { ...@@ -425,11 +424,7 @@ public class LdapVCardProvider implements VCardProvider, PropertyEventListener {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("ldap.vcard-mapping".equals(property)) { //Ignore
initTemplate();
// Reset cache of vCards
VCardManager.getInstance().reset();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
......
...@@ -21,14 +21,11 @@ import java.util.Map; ...@@ -21,14 +21,11 @@ import java.util.Map;
* whether accounts are disabled or enabled, and provides a single point of entry for handling * whether accounts are disabled or enabled, and provides a single point of entry for handling
* locked/disabled accounts. * locked/disabled accounts.
* *
* The provider can be specified in <tt>openfire.xml</tt> by adding: * The provider can be specified in system properties by adding:
* ... *
* <provider> * <ul>
* <lockout> * <li><tt>provider.lockout.className = my.lock.out.provider</tt></li>
* <className>my.lock.out.provider</className> * </ul>
* </lockout>
* </provider>
* ...
* *
* @author Daniel Henninger * @author Daniel Henninger
*/ */
...@@ -77,7 +74,9 @@ public class LockOutManager { ...@@ -77,7 +74,9 @@ public class LockOutManager {
// Detect when a new lockout provider class is set // Detect when a new lockout provider class is set
PropertyEventListener propListener = new PropertyEventListener() { PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) { public void propertySet(String property, Map params) {
//Ignore if ("provider.lockout.className".equals(property)) {
initProvider();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -85,9 +84,7 @@ public class LockOutManager { ...@@ -85,9 +84,7 @@ public class LockOutManager {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("provider.lockout.className".equals(property)) { //Ignore
initProvider();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
...@@ -102,7 +99,10 @@ public class LockOutManager { ...@@ -102,7 +99,10 @@ public class LockOutManager {
* DefaultLockOutProvider if the specified provider is not valid or not specified. * DefaultLockOutProvider if the specified provider is not valid or not specified.
*/ */
private void initProvider() { private void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.lockout.className", // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.lockout.className");
String className = JiveGlobals.getProperty("provider.lockout.className",
"org.jivesoftware.openfire.lockout.DefaultLockOutProvider"); "org.jivesoftware.openfire.lockout.DefaultLockOutProvider");
// Check if we need to reset the provider class // Check if we need to reset the provider class
if (provider == null || !className.equals(provider.getClass().getName())) { if (provider == null || !className.equals(provider.getClass().getName())) {
......
...@@ -662,8 +662,14 @@ public class SASLAuthentication { ...@@ -662,8 +662,14 @@ public class SASLAuthentication {
} }
private static void initMechanisms() { private static void initMechanisms() {
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("sasl.mechs");
JiveGlobals.migrateProperty("sasl.gssapi.debug");
JiveGlobals.migrateProperty("sasl.gssapi.config");
JiveGlobals.migrateProperty("sasl.gssapi.useSubjectCredsOnly");
mechanisms = new HashSet<String>(); mechanisms = new HashSet<String>();
String available = JiveGlobals.getXMLProperty("sasl.mechs"); String available = JiveGlobals.getProperty("sasl.mechs");
if (available == null) { if (available == null) {
mechanisms.add("ANONYMOUS"); mechanisms.add("ANONYMOUS");
mechanisms.add("PLAIN"); mechanisms.add("PLAIN");
...@@ -690,13 +696,13 @@ public class SASLAuthentication { ...@@ -690,13 +696,13 @@ public class SASLAuthentication {
} }
if (mechanisms.contains("GSSAPI")) { if (mechanisms.contains("GSSAPI")) {
if (JiveGlobals.getXMLProperty("sasl.gssapi.config") != null) { if (JiveGlobals.getProperty("sasl.gssapi.config") != null) {
System.setProperty("java.security.krb5.debug", System.setProperty("java.security.krb5.debug",
JiveGlobals.getXMLProperty("sasl.gssapi.debug", "false")); JiveGlobals.getProperty("sasl.gssapi.debug", "false"));
System.setProperty("java.security.auth.login.config", System.setProperty("java.security.auth.login.config",
JiveGlobals.getXMLProperty("sasl.gssapi.config")); JiveGlobals.getProperty("sasl.gssapi.config"));
System.setProperty("javax.security.auth.useSubjectCredsOnly", System.setProperty("javax.security.auth.useSubjectCredsOnly",
JiveGlobals.getXMLProperty("sasl.gssapi.useSubjectCredsOnly", "false")); JiveGlobals.getProperty("sasl.gssapi.useSubjectCredsOnly", "false"));
} }
else { else {
//Not configured, remove the option. //Not configured, remove the option.
......
...@@ -20,14 +20,11 @@ import java.util.Date; ...@@ -20,14 +20,11 @@ import java.util.Date;
* a proper conduit for making security log entries and looking them up. Ideally there is no reason * a proper conduit for making security log entries and looking them up. Ideally there is no reason
* for outside classes to interact directly with a provider. * for outside classes to interact directly with a provider.
* *
* The provider can be specified in <tt>openfire.xml</tt> by adding: * The provider can be specified in system properties by adding:
* ... *
* <provider> * <ul>
* <securityAudit> * <li><tt>provider.securityAudit.className = my.security.audit.provider</tt></li>
* <className>my.security.audit.provider</className> * </ul>
* </securityAudit>
* </provider>
* ...
* *
* @author Daniel Henninger * @author Daniel Henninger
*/ */
...@@ -71,7 +68,9 @@ public class SecurityAuditManager { ...@@ -71,7 +68,9 @@ public class SecurityAuditManager {
// Detect when a new security audit provider class is set // Detect when a new security audit provider class is set
PropertyEventListener propListener = new PropertyEventListener() { PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) { public void propertySet(String property, Map params) {
//Ignore if ("provider.securityAudit.className".equals(property)) {
initProvider();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -79,9 +78,7 @@ public class SecurityAuditManager { ...@@ -79,9 +78,7 @@ public class SecurityAuditManager {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("provider.securityAudit.className".equals(property)) { //Ignore
initProvider();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
...@@ -96,7 +93,10 @@ public class SecurityAuditManager { ...@@ -96,7 +93,10 @@ public class SecurityAuditManager {
* DefaultSecurityAuditProvider if the specified provider is not valid or not specified. * DefaultSecurityAuditProvider if the specified provider is not valid or not specified.
*/ */
private void initProvider() { private void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.securityAudit.className", // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.securityAudit.className");
String className = JiveGlobals.getProperty("provider.securityAudit.className",
"org.jivesoftware.openfire.security.DefaultSecurityAuditProvider"); "org.jivesoftware.openfire.security.DefaultSecurityAuditProvider");
// Check if we need to reset the provider class // Check if we need to reset the provider class
if (provider == null || !className.equals(provider.getClass().getName())) { if (provider == null || !className.equals(provider.getClass().getName())) {
......
...@@ -31,33 +31,25 @@ import java.util.Date; ...@@ -31,33 +31,25 @@ import java.util.Date;
* section below, as well as the <i>usernameField</i>, the <i>nameField</i> and the * section below, as well as the <i>usernameField</i>, the <i>nameField</i> and the
* <i>emailField</i>.<p/> * <i>emailField</i>.<p/>
* *
* To enable this provider, set the following in the XML configuration file:<p/> * To enable this provider, set the following in the system properties:<p/>
* <pre> *
* &lt;provider&gt; * <ul>
* &lt;user&gt; * <li><tt>provider.user.className = org.jivesoftware.openfire.user.JDBCUserProvider</tt></li>
* &lt;className&gt;org.jivesoftware.openfire.user.JDBCUserProvider&lt;/className&gt; * </ul>
* &lt;/user&gt;
* &lt;/provider&gt;
* </pre><p/>
* *
* Then you need to set your driver, connection string and SQL statements: * Then you need to set your driver, connection string and SQL statements:
* <p/> * <p/>
* <pre> * <ul>
* &lt;jdbcProvider&gt; * <li><tt>jdbcProvider.driver = com.mysql.jdbc.Driver</tt></li>
* &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt; * <li><tt>jdbcProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&amp;password=secret</tt></li>
* &lt;connectionString&gt;jdbc:mysql://localhost/dbname?user=username&amp;password=secret&lt;/connectionString&gt; * <li><tt>jdbcUserProvider.loadUserSQL = SELECT name,email FROM myUser WHERE user = ?</tt></li>
* &lt;/jdbcProvider&gt; * <li><tt>jdbcUserProvider.userCountSQL = SELECT COUNT(*) FROM myUser</tt></li>
* * <li><tt>jdbcUserProvider.allUsersSQL = SELECT user FROM myUser</tt></li>
* &lt;jdbcUserProvider&gt; * <li><tt>jdbcUserProvider.searchSQL = SELECT user FROM myUser WHERE</tt></li>
* &lt;loadUserSQL&gt;SELECT name,email FROM myUser WHERE user = ?&lt;/loadUserSQL&gt; * <li><tt>jdbcUserProvider.usernameField = myUsernameField</tt></li>
* &lt;userCountSQL&gt;SELECT COUNT(*) FROM myUser&lt;/userCountSQL&gt; * <li><tt>jdbcUserProvider.nameField = myNameField</tt></li>
* &lt;allUsersSQL&gt;SELECT user FROM myUser&lt;/allUsersSQL&gt; * <li><tt>jdbcUserProvider.emailField = mymailField</tt></li>
* &lt;searchSQL&gt;SELECT user FROM myUser WHERE&lt;/searchSQL&gt; * </ul>
* &lt;usernameField&gt;myUsernameField&lt;/usernameField&gt;
* &lt;nameField&gt;myNameField&lt;/nameField&gt;
* &lt;emailField&gt;mymailField&lt;/emailField&gt;
* &lt;/jdbcUserProvider&gt;
* </pre>
* *
* @author Huw Richards huw.richards@gmail.com * @author Huw Richards huw.richards@gmail.com
*/ */
...@@ -77,8 +69,19 @@ public class JDBCUserProvider implements UserProvider { ...@@ -77,8 +69,19 @@ public class JDBCUserProvider implements UserProvider {
* Constructs a new JDBC user provider. * Constructs a new JDBC user provider.
*/ */
public JDBCUserProvider() { public JDBCUserProvider() {
// Load the JDBC driver and connection string. // Convert XML based provider setup to Database based
String jdbcDriver = JiveGlobals.getXMLProperty("jdbcProvider.driver"); JiveGlobals.migrateProperty("jdbcProvider.driver");
JiveGlobals.migrateProperty("jdbcProvider.connectionString");
JiveGlobals.migrateProperty("jdbcUserProvider.loadUserSQL");
JiveGlobals.migrateProperty("jdbcUserProvider.userCountSQL");
JiveGlobals.migrateProperty("jdbcUserProvider.allUsersSQL");
JiveGlobals.migrateProperty("jdbcUserProvider.searchSQL");
JiveGlobals.migrateProperty("jdbcUserProvider.usernameField");
JiveGlobals.migrateProperty("jdbcUserProvider.nameField");
JiveGlobals.migrateProperty("jdbcUserProvider.emailField");
// Load the JDBC driver and connection string.
String jdbcDriver = JiveGlobals.getProperty("jdbcProvider.driver");
try { try {
Class.forName(jdbcDriver).newInstance(); Class.forName(jdbcDriver).newInstance();
} }
...@@ -86,16 +89,16 @@ public class JDBCUserProvider implements UserProvider { ...@@ -86,16 +89,16 @@ public class JDBCUserProvider implements UserProvider {
Log.error("Unable to load JDBC driver: " + jdbcDriver, e); Log.error("Unable to load JDBC driver: " + jdbcDriver, e);
return; return;
} }
connectionString = JiveGlobals.getXMLProperty("jdbcProvider.connectionString"); connectionString = JiveGlobals.getProperty("jdbcProvider.connectionString");
// Load database statements for user data. // Load database statements for user data.
loadUserSQL = JiveGlobals.getXMLProperty("jdbcUserProvider.loadUserSQL"); loadUserSQL = JiveGlobals.getProperty("jdbcUserProvider.loadUserSQL");
userCountSQL = JiveGlobals.getXMLProperty("jdbcUserProvider.userCountSQL"); userCountSQL = JiveGlobals.getProperty("jdbcUserProvider.userCountSQL");
allUsersSQL = JiveGlobals.getXMLProperty("jdbcUserProvider.allUsersSQL"); allUsersSQL = JiveGlobals.getProperty("jdbcUserProvider.allUsersSQL");
searchSQL = JiveGlobals.getXMLProperty("jdbcUserProvider.searchSQL"); searchSQL = JiveGlobals.getProperty("jdbcUserProvider.searchSQL");
usernameField = JiveGlobals.getXMLProperty("jdbcUserProvider.usernameField"); usernameField = JiveGlobals.getProperty("jdbcUserProvider.usernameField");
nameField = JiveGlobals.getXMLProperty("jdbcUserProvider.nameField"); nameField = JiveGlobals.getProperty("jdbcUserProvider.nameField");
emailField = JiveGlobals.getXMLProperty("jdbcUserProvider.emailField"); emailField = JiveGlobals.getProperty("jdbcUserProvider.emailField");
} }
public User loadUser(String username) throws UserNotFoundException { public User loadUser(String username) throws UserNotFoundException {
......
...@@ -77,7 +77,9 @@ public class UserManager implements IQResultListener { ...@@ -77,7 +77,9 @@ public class UserManager implements IQResultListener {
// Detect when a new auth provider class is set // Detect when a new auth provider class is set
PropertyEventListener propListener = new PropertyEventListener() { PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) { public void propertySet(String property, Map params) {
//Ignore if ("provider.user.className".equals(property)) {
initProvider();
}
} }
public void propertyDeleted(String property, Map params) { public void propertyDeleted(String property, Map params) {
...@@ -85,9 +87,7 @@ public class UserManager implements IQResultListener { ...@@ -85,9 +87,7 @@ public class UserManager implements IQResultListener {
} }
public void xmlPropertySet(String property, Map params) { public void xmlPropertySet(String property, Map params) {
if ("provider.user.className".equals(property)) { //Ignore
initProvider();
}
} }
public void xmlPropertyDeleted(String property, Map params) { public void xmlPropertyDeleted(String property, Map params) {
...@@ -410,7 +410,10 @@ public class UserManager implements IQResultListener { ...@@ -410,7 +410,10 @@ public class UserManager implements IQResultListener {
} }
private void initProvider() { private void initProvider() {
String className = JiveGlobals.getXMLProperty("provider.user.className", // Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.user.className");
String className = JiveGlobals.getProperty("provider.user.className",
"org.jivesoftware.openfire.user.DefaultUserProvider"); "org.jivesoftware.openfire.user.DefaultUserProvider");
// Check if we need to reset the provider class // Check if we need to reset the provider class
if (provider == null || !className.equals(provider.getClass().getName())) { if (provider == null || !className.equals(provider.getClass().getName())) {
......
...@@ -62,7 +62,6 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider ...@@ -62,7 +62,6 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider
vcardCache = CacheFactory.createCache(cacheName); vcardCache = CacheFactory.createCache(cacheName);
this.eventHandler = new EventHandler(); this.eventHandler = new EventHandler();
// Keeps the cache updated in case the vCard action was not performed by VCardManager // Keeps the cache updated in case the vCard action was not performed by VCardManager
VCardEventDispatcher.addListener(new VCardListener() { VCardEventDispatcher.addListener(new VCardListener() {
public void vCardCreated(String username, Element vCard) { public void vCardCreated(String username, Element vCard) {
...@@ -230,8 +229,11 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider ...@@ -230,8 +229,11 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider
public void initialize(XMPPServer server) { public void initialize(XMPPServer server) {
instance = this; instance = this;
// Convert XML based provider setup to Database based
JiveGlobals.migrateProperty("provider.vcard.className");
// Load a VCard provider. // Load a VCard provider.
String className = JiveGlobals.getXMLProperty("provider.vcard.className", String className = JiveGlobals.getProperty("provider.vcard.className",
DefaultVCardProvider.class.getName()); DefaultVCardProvider.class.getName());
try { try {
Class c = ClassUtils.forName(className); Class c = ClassUtils.forName(className);
...@@ -249,6 +251,28 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider ...@@ -249,6 +251,28 @@ public class VCardManager extends BasicModule implements ServerFeaturesProvider
if (!provider.isReadOnly()) { if (!provider.isReadOnly()) {
UserEventDispatcher.addListener(eventHandler); UserEventDispatcher.addListener(eventHandler);
} }
// Detect when a new vcard provider class is set
PropertyEventListener propListener = new PropertyEventListener() {
public void propertySet(String property, Map params) {
if ("provider.vcard.className".equals(property)) {
initialize(XMPPServer.getInstance());
}
}
public void propertyDeleted(String property, Map params) {
//Ignore
}
public void xmlPropertySet(String property, Map params) {
//Ignore
}
public void xmlPropertyDeleted(String property, Map params) {
//Ignore
}
};
PropertyEventDispatcher.addListener(propListener);
} }
public void stop() { public void stop() {
......
...@@ -138,6 +138,8 @@ public class JiveGlobals { ...@@ -138,6 +138,8 @@ public class JiveGlobals {
/** /**
* Sets the global time zone used by Jive. The default time zone is the VM's * Sets the global time zone used by Jive. The default time zone is the VM's
* time zone. * time zone.
*
* @param newTimeZone Time zone to set.
*/ */
public static void setTimeZone(TimeZone newTimeZone) { public static void setTimeZone(TimeZone newTimeZone) {
timeZone = newTimeZone; timeZone = newTimeZone;
...@@ -616,6 +618,7 @@ public class JiveGlobals { ...@@ -616,6 +618,7 @@ public class JiveGlobals {
* the immediate child properties of <tt>X.Y</tt> are <tt>A</tt>, <tt>B</tt>, and * the immediate child properties of <tt>X.Y</tt> are <tt>A</tt>, <tt>B</tt>, and
* <tt>C</tt> (<tt>C.D</tt> would not be returned using this method).<p> * <tt>C</tt> (<tt>C.D</tt> would not be returned using this method).<p>
* *
* @param parent Parent "node" to find the children of.
* @return a List of all immediate children property names (Strings). * @return a List of all immediate children property names (Strings).
*/ */
public static List<String> getPropertyNames(String parent) { public static List<String> getPropertyNames(String parent) {
...@@ -723,6 +726,33 @@ public class JiveGlobals { ...@@ -723,6 +726,33 @@ public class JiveGlobals {
properties.remove(name); properties.remove(name);
} }
/**
* Convenience routine to migrate an XML property into the database
* storage method. Will check for the XML property being null before
* migrating.
*
* @param name the name of the property to migrate.
*/
public static void migrateProperty(String name) {
if (isSetupMode()) {
return;
}
if (getXMLProperty(name) != null) {
if (getProperty(name) == null) {
Log.debug("JiveGlobals: Migrating XML property '"+name+"' into database.");
setProperty(name, getXMLProperty(name));
deleteXMLProperty(name);
}
else if (getProperty(name).equals(getXMLProperty(name))) {
Log.debug("JiveGlobals: Deleting duplicate XML property '"+name+"' that is already in database.");
deleteXMLProperty(name);
}
else if (!getProperty(name).equals(getXMLProperty(name))) {
Log.warn("Property '"+name+"' as specified in openfire.xml differs from what is stored in the database. Please make property changes in the database instead of openfire.xml.");
}
}
}
/** /**
* Allows the name of the local config file name to be changed. The * Allows the name of the local config file name to be changed. The
* default is "openfire.xml". * default is "openfire.xml".
......
...@@ -195,8 +195,12 @@ public class JiveProperties implements Map<String, String> { ...@@ -195,8 +195,12 @@ public class JiveProperties implements Map<String, String> {
} }
public String put(String key, String value) { public String put(String key, String value) {
if (key == null || value == null) { if (value == null) {
throw new NullPointerException("Key or value cannot be null. Key=" + // This is the same as deleting, so remove it.
return remove(key);
}
if (key == null) {
throw new NullPointerException("Key cannot be null. Key=" +
key + ", value=" + value); key + ", value=" + value);
} }
if (key.endsWith(".")) { if (key.endsWith(".")) {
......
...@@ -37,9 +37,9 @@ ...@@ -37,9 +37,9 @@
<body> <body>
<% <%
boolean isLDAP = "org.jivesoftware.openfire.ldap.LdapAuthProvider".equals( boolean isLDAP = "org.jivesoftware.openfire.ldap.LdapAuthProvider".equals(
JiveGlobals.getXMLProperty("provider.auth.className")); JiveGlobals.getProperty("provider.auth.className"));
boolean isCLEARSPACE = "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider".equals( boolean isCLEARSPACE = "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider".equals(
JiveGlobals.getXMLProperty("provider.auth.className")); JiveGlobals.getProperty("provider.auth.className"));
%> %>
<p> <p>
<fmt:message key="profile-settings.info"/> <fmt:message key="profile-settings.info"/>
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
// Get parameters // Get parameters
boolean save = request.getParameter("save") != null; boolean save = request.getParameter("save") != null;
boolean test = request.getParameter("test") != null; boolean test = request.getParameter("test") != null;
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
ClearspaceManager manager = null; ClearspaceManager manager = null;
if (ClearspaceManager.getInstance() != null) { if (ClearspaceManager.getInstance() != null) {
...@@ -46,22 +48,43 @@ ...@@ -46,22 +48,43 @@
manager.setConnectionURI(uri); manager.setConnectionURI(uri);
manager.setSharedSecret(sharedSecret); manager.setSharedSecret(sharedSecret);
// Enable the Clearspace user, auth, group, and vcard providers. // Enable the Clearspace auth, user, group, vcard, lockout, security audit, and admin providers.
JiveGlobals.setXMLProperty("provider.user.className", JiveGlobals.setProperty("provider.auth.className",
"org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
JiveGlobals.setXMLProperty("provider.auth.className",
"org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider");
JiveGlobals.setXMLProperty("provider.group.className", JiveGlobals.setProperty("provider.user.className",
"org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
JiveGlobals.setProperty("provider.group.className",
"org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
JiveGlobals.setXMLProperty("provider.vcard.className", JiveGlobals.setProperty("provider.vcard.className",
"org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
JiveGlobals.setXMLProperty("provider.lockout.className", JiveGlobals.setProperty("provider.lockout.className",
"org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
JiveGlobals.setXMLProperty("provider.securityAudit.className", JiveGlobals.setProperty("provider.securityAudit.className",
"org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
JiveGlobals.setXMLProperty("provider.admin.className", JiveGlobals.setProperty("provider.admin.className",
"org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider"); "org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider");
// Save the settings for later, if we're in setup
if (xmppSettings != null) {
xmppSettings.put("provider.auth.className",
"org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider");
xmppSettings.put("provider.user.className",
"org.jivesoftware.openfire.clearspace.ClearspaceUserProvider");
xmppSettings.put("provider.group.className",
"org.jivesoftware.openfire.clearspace.ClearspaceGroupProvider");
xmppSettings.put("provider.vcard.className",
"org.jivesoftware.openfire.clearspace.ClearspaceVCardProvider");
xmppSettings.put("provider.lockout.className",
"org.jivesoftware.openfire.clearspace.ClearspaceLockOutProvider");
xmppSettings.put("provider.securityAudit.className",
"org.jivesoftware.openfire.clearspace.ClearspaceSecurityAuditProvider");
xmppSettings.put("provider.admin.className",
"org.jivesoftware.openfire.clearspace.ClearspaceAdminProvider");
xmppSettings.put("clearspace.uri", uri);
xmppSettings.put("clearspace.sharedSecret", sharedSecret);
session.setAttribute("xmppSettings", xmppSettings);
}
// Redirect to next step. // Redirect to next step.
response.sendRedirect(nextPage); response.sendRedirect(nextPage);
return; return;
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
<% <%
// Get parameters // Get parameters
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
String serverType = ParamUtils.getParameter(request, "serverType"); String serverType = ParamUtils.getParameter(request, "serverType");
// Server type should never be null, but if it is, assume "other" // Server type should never be null, but if it is, assume "other"
...@@ -19,12 +21,12 @@ ...@@ -19,12 +21,12 @@
LdapManager manager = LdapManager.getInstance(); LdapManager manager = LdapManager.getInstance();
// Determine the right default values based on the the server type. // Determine the right default values based on the the server type.
String defaultGroupNameField = JiveGlobals.getXMLProperty("ldap.groupNameField"); String defaultGroupNameField = JiveGlobals.getProperty("ldap.groupNameField");
String defaultGroupMemberField = JiveGlobals.getXMLProperty("ldap.groupMemberField"); String defaultGroupMemberField = JiveGlobals.getProperty("ldap.groupMemberField");
String defaultGroupDescriptionField = JiveGlobals.getXMLProperty("ldap.groupDescriptionField"); String defaultGroupDescriptionField = JiveGlobals.getProperty("ldap.groupDescriptionField");
String posixModeString = JiveGlobals.getXMLProperty("ldap.posixMode"); String posixModeString = JiveGlobals.getProperty("ldap.posixMode");
boolean defaultPosixMode = Boolean.parseBoolean(posixModeString); boolean defaultPosixMode = Boolean.parseBoolean(posixModeString);
String defaultGroupSearchFilter = JiveGlobals.getXMLProperty("ldap.groupSearchFilter"); String defaultGroupSearchFilter = JiveGlobals.getProperty("ldap.groupSearchFilter");
if (serverType.equals("activedirectory")) { if (serverType.equals("activedirectory")) {
if (defaultGroupNameField == null) { if (defaultGroupNameField == null) {
...@@ -109,9 +111,21 @@ ...@@ -109,9 +111,21 @@
} }
// Enable the LDAP auth provider. The LDAP user provider will be enabled on the next step. // Enable the LDAP auth provider. The LDAP user provider will be enabled on the next step.
JiveGlobals.setXMLProperty("provider.group.className", JiveGlobals.setProperty("provider.group.className",
"org.jivesoftware.openfire.ldap.LdapGroupProvider"); "org.jivesoftware.openfire.ldap.LdapGroupProvider");
// Save the settings for later, if we're in setup
if (xmppSettings != null) {
xmppSettings.put("provider.group.className",
"org.jivesoftware.openfire.ldap.LdapGroupProvider");
xmppSettings.put("ldap.groupNameField", groupNameField);
xmppSettings.put("ldap.groupMemberField", groupMemberField);
xmppSettings.put("ldap.groupDescriptionField", groupDescriptionField);
xmppSettings.put("ldap.posixMode", Boolean.toString(posixMode));
xmppSettings.put("ldap.groupSearchFilter", groupSearchFilter);
session.setAttribute("xmppSettings", xmppSettings);
}
// Redirect // Redirect
response.sendRedirect(nextPage); response.sendRedirect(nextPage);
return; return;
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
boolean referralsEnabled = false; boolean referralsEnabled = false;
boolean aliasReferralsEnabled = true; boolean aliasReferralsEnabled = true;
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
// Get parameters // Get parameters
boolean save = request.getParameter("save") != null; boolean save = request.getParameter("save") != null;
boolean test = request.getParameter("test") != null; boolean test = request.getParameter("test") != null;
...@@ -53,8 +56,12 @@ ...@@ -53,8 +56,12 @@
settings.put("ldap.host", host); settings.put("ldap.host", host);
settings.put("ldap.port", Integer.toString(port)); settings.put("ldap.port", Integer.toString(port));
settings.put("ldap.baseDN", baseDN); settings.put("ldap.baseDN", baseDN);
settings.put("ldap.adminDN", adminDN); if (adminDN != null) {
settings.put("ldap.adminPassword", adminPassword); settings.put("ldap.adminDN", adminDN);
}
if (adminPassword != null) {
settings.put("ldap.adminPassword", adminPassword);
}
settings.put("ldap.connectionPoolEnabled", settings.put("ldap.connectionPoolEnabled",
Boolean.toString(connectionPoolEnabled)); Boolean.toString(connectionPoolEnabled));
settings.put("ldap.sslEnabled", Boolean.toString(sslEnabled)); settings.put("ldap.sslEnabled", Boolean.toString(sslEnabled));
...@@ -83,6 +90,21 @@ ...@@ -83,6 +90,21 @@
manager.setFollowReferralsEnabled(referralsEnabled); manager.setFollowReferralsEnabled(referralsEnabled);
manager.setFollowAliasReferralsEnabled(aliasReferralsEnabled); manager.setFollowAliasReferralsEnabled(aliasReferralsEnabled);
// Save the settings for later, if we're in setup
if (xmppSettings != null) {
xmppSettings.put("ldap.host", host);
xmppSettings.put("ldap.port", Integer.toString(port));
xmppSettings.put("ldap.baseDN", baseDN);
xmppSettings.put("ldap.adminDN", adminDN);
xmppSettings.put("ldap.adminPassword", adminPassword);
xmppSettings.put("ldap.connectionPoolEnabled", Boolean.toString(connectionPoolEnabled));
xmppSettings.put("ldap.sslEnabled", Boolean.toString(sslEnabled));
xmppSettings.put("ldap.debugEnabled", Boolean.toString(debugEnabled));
xmppSettings.put("ldap.autoFollowReferrals", Boolean.toString(referralsEnabled));
xmppSettings.put("ldap.autoFollowAliasReferrals", Boolean.toString(aliasReferralsEnabled));
session.setAttribute("xmppSettings", xmppSettings);
}
// Redirect to next step. // Redirect to next step.
response.sendRedirect(nextPage); response.sendRedirect(nextPage);
return; return;
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
LdapManager manager = LdapManager.getInstance(); LdapManager manager = LdapManager.getInstance();
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
// Determine the right default values based on the the server type. // Determine the right default values based on the the server type.
String defaultUsernameField; String defaultUsernameField;
String defaultSearchFields; String defaultSearchFields;
...@@ -38,9 +41,9 @@ ...@@ -38,9 +41,9 @@
} }
else { else {
// No info in the session so try stored XML values or default ones // No info in the session so try stored XML values or default ones
defaultUsernameField = JiveGlobals.getXMLProperty("ldap.usernameField"); defaultUsernameField = JiveGlobals.getProperty("ldap.usernameField");
defaultSearchFields = JiveGlobals.getXMLProperty("ldap.searchFields"); defaultSearchFields = JiveGlobals.getProperty("ldap.searchFields");
defaultSearchFilter = JiveGlobals.getXMLProperty("ldap.searchFilter"); defaultSearchFilter = JiveGlobals.getProperty("ldap.searchFilter");
vcardBean = new LdapUserProfile(); vcardBean = new LdapUserProfile();
if (vcardBean.loadFromProperties()) { if (vcardBean.loadFromProperties()) {
// Loaded from stored settings, no need to do anything else. // Loaded from stored settings, no need to do anything else.
...@@ -95,11 +98,8 @@ ...@@ -95,11 +98,8 @@
vcardBean.setAvatarStoredInDB(false); vcardBean.setAvatarStoredInDB(false);
} }
// Store the vcard db setting for later saving. // Store the vcard db setting for later saving.
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
if (xmppSettings != null) { if (xmppSettings != null) {
xmppSettings.put("ldap.override.avatar", vcardBean.getAvatarStoredInDB().toString()); xmppSettings.put("ldap.override.avatar", vcardBean.getAvatarStoredInDB().toString());
session.setAttribute("xmppSettings", xmppSettings);
} }
// Save settings and redirect. // Save settings and redirect.
...@@ -116,12 +116,17 @@ ...@@ -116,12 +116,17 @@
manager.setUsernameField(usernameField); manager.setUsernameField(usernameField);
if (searchFields != null) { if (searchFields != null) {
if ("org.jivesoftware.openfire.ldap.LdapUserProvider" if ("org.jivesoftware.openfire.ldap.LdapUserProvider"
.equals(JiveGlobals.getXMLProperty("provider.user.className"))) { .equals(JiveGlobals.getProperty("provider.user.className"))) {
// Update current instance being used // Update current instance being used
((LdapUserProvider) UserManager.getUserProvider()).setSearchFields(searchFields); ((LdapUserProvider) UserManager.getUserProvider()).setSearchFields(searchFields);
} else { } else {
// Just update the property. It will be later used by LdapUserProvider // Just update the property. It will be later used by LdapUserProvider
JiveGlobals.setXMLProperty("ldap.searchFields", searchFields); JiveGlobals.setProperty("ldap.searchFields", searchFields);
// Store in xmppSettings for later saving if we're in setup
if (xmppSettings != null) {
xmppSettings.put("ldap.searchFields", searchFields);
}
} }
} }
if (searchFilter != null) { if (searchFilter != null) {
...@@ -131,16 +136,29 @@ ...@@ -131,16 +136,29 @@
vcardBean.saveProperties(); vcardBean.saveProperties();
// Enable the LDAP auth and user providers. The group provider will be enabled on the next step. // Enable the LDAP auth and user providers. The group provider will be enabled on the next step.
JiveGlobals.setXMLProperty("provider.user.className", JiveGlobals.setProperty("provider.user.className",
"org.jivesoftware.openfire.ldap.LdapUserProvider"); "org.jivesoftware.openfire.ldap.LdapUserProvider");
JiveGlobals.setXMLProperty("provider.auth.className", JiveGlobals.setProperty("provider.auth.className",
"org.jivesoftware.openfire.ldap.LdapAuthProvider"); "org.jivesoftware.openfire.ldap.LdapAuthProvider");
// Store in xmppSettings for later saving if we're in setup
if (xmppSettings != null) {
xmppSettings.put("provider.user.className",
"org.jivesoftware.openfire.ldap.LdapUserProvider");
xmppSettings.put("provider.auth.className",
"org.jivesoftware.openfire.ldap.LdapAuthProvider");
}
// Redirect // Redirect
response.sendRedirect(nextPage + "?serverType=" + serverType); response.sendRedirect(nextPage + "?serverType=" + serverType);
return; return;
} }
} }
// Save the settings for later, if we're in setup
if (xmppSettings != null) {
session.setAttribute("xmppSettings", xmppSettings);
}
} }
%> %>
<html> <html>
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
boolean deleteAdmins = request.getParameter("deleteAdmins") != null; boolean deleteAdmins = request.getParameter("deleteAdmins") != null;
boolean ldapFinished = request.getParameter("ldapFinished") != null; boolean ldapFinished = request.getParameter("ldapFinished") != null;
@SuppressWarnings("unchecked")
Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings"); Map<String,String> xmppSettings = (Map<String,String>)session.getAttribute("xmppSettings");
String domain = xmppSettings.get("xmpp.domain"); String domain = xmppSettings.get("xmpp.domain");
...@@ -182,6 +183,10 @@ ...@@ -182,6 +183,10 @@
StringUtils.collectionToString(adminCollection)); StringUtils.collectionToString(adminCollection));
} }
} }
// Save the updated settings
session.setAttribute("xmppSettings", xmppSettings);
%> %>
<html> <html>
<head> <head>
......
...@@ -21,9 +21,9 @@ ...@@ -21,9 +21,9 @@
<% <%
// Get parameters // Get parameters
boolean isLDAP = "org.jivesoftware.openfire.ldap.LdapAuthProvider".equals( boolean isLDAP = "org.jivesoftware.openfire.ldap.LdapAuthProvider".equals(
JiveGlobals.getXMLProperty("provider.auth.className")); JiveGlobals.getProperty("provider.auth.className"));
boolean isCLEARSPACE = "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider".equals( boolean isCLEARSPACE = "org.jivesoftware.openfire.clearspace.ClearspaceAuthProvider".equals(
JiveGlobals.getXMLProperty("provider.auth.className")); JiveGlobals.getProperty("provider.auth.className"));
boolean next = request.getParameter("continue") != null; boolean next = request.getParameter("continue") != null;
if (next) { if (next) {
// Figure out where to send the user. // Figure out where to send the user.
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
if ("default".equals(mode)) { if ("default".equals(mode)) {
// Set to default providers by deleting any existing values. // Set to default providers by deleting any existing values.
JiveGlobals.deleteXMLProperty("provider.user.className"); JiveGlobals.deleteProperty("provider.user.className");
JiveGlobals.deleteXMLProperty("provider.group.className"); JiveGlobals.deleteProperty("provider.group.className");
JiveGlobals.deleteXMLProperty("provider.auth.className"); JiveGlobals.deleteProperty("provider.auth.className");
// Redirect // Redirect
response.sendRedirect("setup-admin-settings.jsp"); response.sendRedirect("setup-admin-settings.jsp");
return; 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