Custom Database Integration Guide

Introduction


This document provides instructions for integrating Openfire 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 Openfire. If your user information is available via
an LDAP directory rather than custom database tables, see the LDAP
guide
.

Simple integration with a custom database lets users authenticate using their
existing username and password. Optionally, you can configure Openfire to load
user profile and group information from your custom database. Any group in
Openfire can be designated as a shared group, which means that you can
pre-populate user‘s rosters using groups.

Background

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 Openfire database -- you‘ll enter database connection
information as part of the configuration.

Configuration

In order to configure your server to integrate with your custom database
tables:

  1. Stop Openfire.

  2. Edit conf/openfire.xml in your Openfire installation
    folder as described below using your favorite editor.

  3. Restart Openfire.

Database Connection Settings


You must specify the connection string for your database as well as the JDBC
driver.

  • jdbcProvider.driver -- the class name of the JDBC driver used to connect
    to your custom database. The driver must also be in the Openfire classpath
    (for example, by placing it into the "lib/" directory of your Openfire
    installation. See the database
    guide
     for common driver names for major databases.

  • jdbcProvider.connectionString -- the full connection string for the
    database. Please consult your database driver documentation for
    syntax. Warning: it‘s common for connection string
    to contain "&" characters. That character has special meaning in XML, so
    you should escape it using "&".

Below is a sample config file section (note: the "..." sections in the
examples indicate areas where the rest of the config file would exist):

<jive>
...
<jdbcProvider>
<driver>com.mysql.jdbc.Driver</driver>
<connectionString>jdbc:mysql://localhost/dbname?user=username&amp;password=secret</connectionString>
</jdbcProvider>
...
</jive>

Authentication Integration

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

  • provider.auth.className -- set the value
    to org.jivesoftware.openfire.auth.JDBCAuthProvider.

  • 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.

  • 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)

    • "sha1" (the password is stored as a hex-encoded SHA-1 hash)

    • "sha256" (the password is stored as a hex-encoded SHA-256 hash)

    • "sha512" (the password is stored as a hex-encoded SHA-512 hash)

    If this value is not set, the password type is assumed to be plain.

Below is a sample config file section:

<jive>
...
<provider>
<auth>
<className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
</auth>
</provider>
<jdbcAuthProvider>
<passwordSQL>SELECT password FROM user_account WHERE username=?</passwordSQL>
<passwordType>plain</passwordType>
</jdbcAuthProvider>
...
</jive>

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 admin.authorizedUsernames property. For example, to let
the usersnames "joe" and "jane" login to the admin console:

    <jive>
...
<admin>
...
<authorizedUsernames>joe, jane</authorizedUsernames>
</admin>

...
</jive>


User Integration


Optionally, Openfire 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.

  • provider.user.className -- set the value
    to org.jivesoftware.openfire.user.JDBCUserProvider.

  • 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.

  • jdbcUserProvider.userCountSQL -- the SQL statement to load the total
    number of users in the database.

  • jdbcUserProvider.allUsersSQL -- the SQL statement to load all usernames in
    the database.

  • 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.

  • usernameField -- the name of the username database field, which will be
    used for searches.

  • nameField -- the name of the name database field, which will be used for
    searches.

  • emailField -- the name of the email database field, which will be used for
    searches.

Below is a sample config file section. Note that the single provider section
must include all providers that should be configured:

<jive>
...
<provider>
<auth>
<className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
</auth>
<user>
<className>org.jivesoftware.openfire.user.JDBCUserProvider</className>
</user>
</provider>
<jdbcAuthProvider>
<passwordSQL>SELECT password FROM user_account WHERE username=?</passwordSQL>
<passwordType>plain</passwordType>
</jdbcAuthProvider>
<jdbcUserProvider>
<loadUserSQL>SELECT name,email FROM myUser WHERE username=?</loadUserSQL>
<userCountSQL>SELECT COUNT(*) FROM myUser</userCountSQL>
<allUsersSQL>SELECT username FROM myUser</allUsersSQL>
<searchSQL>SELECT username FROM myUser WHERE</searchSQL>
<usernameField>username</usernameField>
<nameField>name</nameField>
<emailField>email</emailField>
</jdbcUserProvider>
...
</jive>

Group Integration

Openfire 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.

  • provider.group.className -- set the value
    to org.jivesoftware.openfire.group.JDBCGroupProvider.

  • jdbcGroupProvider.groupCountSQL -- the SQL statement to load the total
    number of groups in the database.

  • jdbcGroupProvider.allGroupsSQL -- the SQL statement to load all groups in
    the database.

  • 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.

  • 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.

  • 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.

  • 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.

Below is a sample config file section. Note that the single provider section
must include all providers that should be configured:

<jive>
...
<provider>
<auth>
<className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
</auth>
<user>
<className>org.jivesoftware.openfire.user.JDBCUserProvider</className>
</user>
<group>
<className>org.jivesoftware.openfire.group.JDBCGroupProvider</className>
</group>
</provider>
<jdbcAuthProvider>
<passwordSQL>SELECT password FROM user_account WHERE username=?</passwordSQL>
<passwordType>plain</passwordType>
</jdbcAuthProvider>
<jdbcUserProvider>
<loadUserSQL>SELECT name,email FROM myUser WHERE username=?</loadUserSQL>
<userCountSQL>SELECT COUNT(*) FROM myUser</userCountSQL>
<allUsersSQL>SELECT username FROM myUser</allUsersSQL>
<searchSQL>SELECT username FROM myUser WHERE</searchSQL>
<usernameField>username</usernameField>
<nameField>name</nameField>
<emailField>email</emailField>
</jdbcUserProvider>
<jdbcGroupProvider>
<groupCountSQL>SELECT count(*) FROM myGroups</groupCountSQL>
<allGroupsSQL>SELECT groupName FROM myGroups</allGroupsSQL>
<userGroupsSQL>SELECT groupName FROM myGroupUsers WHERE username=?</userGroupsSQL>
<descriptionSQL>SELECT groupDescription FROM myGroups WHERE groupName=?</descriptionSQL>
<loadMembersSQL>SELECT username FROM myGroupUsers WHERE groupName=? AND isAdmin=‘N‘</loadMembersSQL>
<loadAdminsSQL>SELECT username FROM myGroupUsers WHERE groupName=? AND isAdmin=‘Y‘</loadAdminsSQL>
</jdbcGroupProvider>
...
</jive>

时间: 2024-10-11 02:37:44

Custom Database Integration Guide的相关文章

openfire当中的Custom Database Integration Guide的配置

openfire官网配置的链接为:Custom Database Integration Guide 按照上面的步骤一步步配置在xml当中,发现始终不起作用,最后在stackoverflow找到的链接,发现直接在mysql数据库中的表ofproperty中配置好相关参数就可以了.

EMC Networker And VMware Integration Guide

一.环境介绍 主机名称 IP 角色 版本 vcenter.xzxj.edu.cn 172.16.255.36 vcenter服务器 5.5 node01.xzxj.edu.cn 172.16.255.153 vsphere esxi 5.5 node02.xzxj.edu.cn 172.16.255.154 vsphere esxi 5.5 tsmbak.xzxj.edu.cn 172.16.255.80 networker服务器 8.2 ebr.xzxj.edu.cn 172.16.255.7

Build a Custom Android Kernel Guide

1.package to install in ubuntu or Debian $ sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2 2.Prepare Kernel Source and excute the command $ make clean && make mrproper 3.Excute the command :the default config file loca

Spark1.1.0 Spark Streaming Programming Guide

Spark Streaming Programming Guide Overview A Quick Example Basic Concepts Linking Initializing StreamingContext Discretized Streams (DStreams) Input DStreams Transformations on DStreams Output Operations on DStreams Caching / Persistence Checkpointin

Oracle创建Physical Standby Database案例

The following is the detail steps of how to create a physical standby database: This case is created, operated and followed on the steps from oracle online help documentation. The configuration of the two sites server as following: Primary Database:

catalog database 管理:

转载请注明出处. 一.catalog 库: 官方文档:http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmcatdb.htm#BRADV89642 参考:http://blog.csdn.net/rlhua/article/details/13169205 二.建立catalog 数据库: 1.在要建立catalog database的数据库上操作 (库名:EMREP) ①.创建表空间 SQL> create tablespace r

oracle database 10.2.0.4 升级到 10.2.0.5

某发票开发测试库升级      升级前准备,此次升级只是很对测试环境数据库升级,所以没有事先一个月来获取系统,数据库的统计信息,机器性能比对 为了加快升级只是清理了以下信息 01.截断SYS.AUD$基表: SQL>TRUNCATE TABLE SYS.AUD$; 02.清理DBA回收站: SQL>purge DBA_RECYCLEBIN; 1.升级开始,升级前首先断开测试环境的中间件应用 查看本机的ORACLE_HOME [[email protected]_10 ~]$ echo $ORA

App Distribution Guide (一)

This guide contains everything you need to know to distribute an app through the App Store or Mac App Store. 这个guide包含了如何通过app stor或者mac app store来发布一个app. Get step-by-step guidance for enrolling in an Apple Developer Program and building, testing, a

在RHEL7 or OL7上安装oracle database 12c的要求

本文来自: Requirements for Installing Oracle Database 12.1on RHEL7 or OL7 64-bit (x86-64) (文档 ID 1961997.1) 本文不做翻译,仅作原文转载: Applies to: Oracle Database - Enterprise Edition - Version 12.1.0.2 and later Linux x86-64 Purpose This note explains the requireme