db-integration-guide.html 10.4 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Jive Software - Wildfire: Custom Database Integration Guide</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>

<div id="pageContainer">

<a name="top"></a>

	<div id="pageHeader">
		<div id="logo"></div>
		<h1>Custom Database Integration Guide</h1>
	</div>
	<div class="navigation">
		<a href="index.html">&laquo; Back to documentation index</a>
	</div>

	<div id="pageBody">

<h2>Introduction</h2>

<p>
    This document provides instructions for integrating Wildfire authentication, users, and
    groups with your custom database tables. This is useful when your users already have
    accounts in an external system and you do not wish to duplicate those accounts in Wildfire.
    If your user information is available via an LDAP directory rather than custom database
    tables, see the <a href="ldap-guide.html">LDAP guide</a>.
</p>
<p>
    Simple integration with a custom database lets users authenticate using their existing
    username and password. Optionally, you can configure Wildfire to load user profile and
    group information from your custom database. Any group in Wildfire can be designated
    as a shared group, which means that you can pre-populate user's rosters using groups.
</p>

<h2>Background</h2>

<p>
    The integration requires that you enter customized database queries to access your
    database. You'll need to be familiar with your database table structure and simple SQL.
    Your custom database can be a different database on a different server from the Wildfire
    database -- you'll enter database connection information as part of the configuration.
</p>

<h2>Configuration</h2>

<p>
    In order to configure your server to integrate with your custom database tables:
    <ol>
        <li>Stop Wildfire.</li>
        <li>Edit <tt>conf/wildfire.xml</tt> in your Wildfire installation folder as
            described below using your favorite editor.
        </li>
        <li>Restart Wildfire.</li>
    </ol>

</p>

<h3>Database Connection Settings</h3>

<p>
    You must specify the connection string for your database as well as the JDBC driver.
</p>
<ul>
    <li>jdbcProvider.driver -- the class name of the JDBC driver used to connect to your
        custom database. The driver must also be in the Wildfire classpath (for example, by
        placing it into the "lib/" directory of your Wildfire installation. See the
        <a href="database.html">database guide</a> for common driver names for major databases.
    </li>
    <li>jdbcProvider.connectionString -- the full connection string for the database. Please
75 76 77 78
        consult your database driver documentation for syntax. <b>Warning:</b> it's common
        for connection string to contain "&" characters. That character has special meaning
        in XML, so you should escape it using "&amp;amp;".
    </li>
Matt Tucker's avatar
Matt Tucker committed
79 80 81
</ul>

<p>
Matt Tucker's avatar
Matt Tucker committed
82 83
    Below is a sample config file section (note: the "..." sections in the examples indicate areas
    where the rest of the config file would exist):
Matt Tucker's avatar
Matt Tucker committed
84 85 86 87 88 89
</p>
<pre>
&lt;jive&gt;
  ...
  &lt;jdbcProvider&gt;
    &lt;driver&gt;com.mysql.jdbc.Driver&lt;/driver&gt;
90 91
    &lt;connectionString&gt;jdbc:mysql://localhost/dbname?user=username&amp;amp;password=secret&lt;/connectionString&gt;
  &lt;/jdbcProvider&gt;
Matt Tucker's avatar
Matt Tucker committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
  ...
&lt;/jive&gt;
</pre>

<h3>Authentication Integration</h3>

<p>
    The simplest possible integration with a custom external database is authentication integration.
    Use the following settings to enable authentication integration.
</p>

<ul>
    <li>provider.auth.className -- set the value to <tt>org.jivesoftware.wildfire.auth.JDBCAuthProvider</tt>.</li>
    <li>jdbcAuthProvider.passwordSQL -- the SQL String to select a user's password. The SQL
        statement should contain a single "?" character, which will be dynamically replaced with
        a username when being executed.</li>
    <li>jdbcAuthProvider.passwordType -- the type of the password. Valid values are "plain" (the
        password is stored as plain text), "md5" (the password is stored as a hex-encoded MD5 hash)
        and "sha1" (the password is stored as a hex-encoded SHA-1 hash). If this value is not set,
        the password type is assumed to be plain.</li>
</ul>

<p>
    Below is a sample config file section:
</p>
<pre>
&lt;jive&gt;
  ...
  &lt;provider&gt;
    &lt;auth&gt;
      &lt;className&gt;org.jivesoftware.wildfire.auth.JDBCAuthProvider&lt;/className&gt;
    &lt;/auth&gt;
  &lt;/provider&gt;
  &lt;jdbcAuthProvider&gt;
Matt Tucker's avatar
Matt Tucker committed
126 127
     &lt;passwordSQL&gt;SELECT password FROM user_account WHERE username=?&lt;/passwordSQL&gt;
     &lt;passwordType&gt;plain&lt;/passwordType&gt;
Matt Tucker's avatar
Matt Tucker committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
   &lt;/jdbcAuthProvider&gt;
   ...
  &lt;/jive&gt;
</pre>

<p>You'll most likely want to change which usernames are authorized to login to the
    admin console. By default, only the user with username "admin" is allowed to login. However,
    you may have different users in your LDAP directory that you'd like to be administrators. The
    list of authorized usernames is controlled via the <tt>admin.authorizedUsernames</tt>
    property. For example, to let the usersnames "joe" and "jane" login to the admin console:</p>

<pre>
    &lt;jive&gt;
      ...
      &lt;admin&gt;
        ...
        &lt;authorizedUsernames&gt;joe, jane&lt;/authorizedUsernames&gt;
      &lt;/admin&gt;

      ...
    &lt;/jive&gt;
</pre>

<h3>User Integration</h3>

<p>Optionally, Wildfire can load user data from your custom database. If you enable user integration
you must also enable authentication integration (see above). Use the following settings to
enable user integration.</p>

<ul>
    <li>provider.user.className -- set the value to <tt>org.jivesoftware.wildfire.user.JDBCUserProvider</tt>.</li>
    <li>jdbcUserProvider.loadUserSQL -- the SQL statement to load the name and email address of a user (in
        that order) given a username. The SQL statement should contain a single "?" character,
        which will be dynamically replaced with a username when being executed.</li>
    <li>jdbcUserProvider.userCountSQL -- the SQL statement to load the total number of users in the database.</li>
    <li>jdbcUserProvider.allUsersSQL -- the SQL statement to load all usernames in the database.</li>
    <li>jdbcUserProvider.searchSQL -- the SQL statement fragment used to search your database for users.
        the statement should end with "WHERE" -- the username, name, and email fields will
        then be dynamically appended to the statement depending on the search. If this value
        is not set, searching will not be enabled.</li>
    <li>usernameField -- the name of the username database field, which will be used for searches.</li>
    <li>nameField -- the name of the name database field, which will be used for searches.</li>
    <li>emailField -- the name of the email database field, which will be used for searches.</li>
</ul>

<p>
    Below is a sample config file section:
</p>
<pre>
&lt;jive&gt;
  ...
  &lt;provider&gt;
    &lt;user&gt;
      &lt;className&gt;org.jivesoftware.wildfire.user.JDBCUserProvider&lt;/className&gt;
    &lt;/user&gt;
  &lt;/provider&gt;
  &lt;jdbcUserProvider&gt;
     &lt;loadUserSQL&gt;SELECT name,email FROM myUser WHERE username=?&lt;/loadUserSQL&gt;
     &lt;userCountSQL&gt;SELECT COUNT(*) FROM myUser&lt;/userCountSQL&gt;
     &lt;allUsersSQL&gt;SELECT username FROM myUser&lt;/allUsersSQL&gt;
     &lt;searchSQL&gt;SELECT username FROM myUser WHERE&lt;/searchSQL&gt;
     &lt;usernameField&gt;username&lt;/usernameField&gt;
     &lt;nameField&gt;name&lt;/nameField&gt;
     &lt;emailField&gt;email&lt;/emailField&gt;
  &lt;/jdbcUserProvider&gt;
   ...
 &lt;/jive&gt;
</pre>

<h3>Group Integration</h3>

<p>Wildfire can load group data from your custom database. If you enable group integration
you must also enable authentication integration; you'll also likely want to enable user
integration (see above). Use the following settings to enable group integration.</p>

<ul>
    <li>provider.group.className -- set the value to <tt>org.jivesoftware.wildfire.group.JDBCGroupProvider</tt>.</li>
    <li>jdbcGroupProvider.groupCountSQL -- the SQL statement to load the total number of groups in
        the database.</li>
    <li>jdbcGroupProvider.allGroupsSQL -- the SQL statement to load all groups in the database.</li>
    <li>jdbcGroupProvider.userGroupsSQL -- the SQL statement to load all groups for a particular user.
        The SQL statement should contain a single "?" character, which will be dynamically replaced
        with a username when being executed.</li>
    <li>jdbcGroupProvider.descriptionSQL -- the SQL statement to load the description of a group.
        The SQL statement should contain a single "?" character, which will be dynamically replaced
        with a group name when being executed.</li>
    <li>jdbcGroupProvider.loadMembersSQL -- the SQL statement to load all members in a group.
        The SQL statement should contain a single "?" character, which will be dynamically replaced
        with a group name when being executed.</li>
    <li>jdbcGroupProvider.loadAdminsSQL -- the SQL statement to load all administrators in a group.
        The SQL statement should contain a single "?" character, which will be dynamically replaced
        with a group name when being executed.</li>
</ul>

<p>
    Below is a sample config file section:
</p>
<pre>
&lt;jive&gt;
  ...
  &lt;provider&gt;
      &lt;group&gt;
          &lt;className&gt;org.jivesoftware.wildfire.group.JDBCGroupProvider&lt;/className&gt;
      &lt;/group&gt;
  &lt;/provider&gt;
  &lt;jdbcGroupProvider&gt;
       &lt;groupCountSQL&gt;SELECT count(*) FROM myGroups&lt;/groupCountSQL&gt;
       &lt;allGroupsSQL&gt;SELECT groupName FROM myGroups&lt;/allGroupsSQL&gt;
       &lt;userGroupsSQL&gt;SELECT groupName FORM myGroupUsers WHERE 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;
  ...
&lt;/jive&gt;
</pre>

    </div>

</div>

</body>
</html>