最近在看OPenfire的用户集成管理Custom Database Integration Guide,按照官方的文档资料无论如何也集成不了;我们现有的系统,最后几经周折终于搞定.别的就不多说了具体配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file stores bootstrap properties needed by Openfire.
Property names must be in the format: "prop.name.is.blah=value"
That will be stored as:
<prop>
<name>
<is>
<blah>value</blah>
</is>
</name>
</prop>
Most properties are stored in the Openfire database. A
property viewer and editor is included in the admin console.
-->
<!-- root element, all properties must be under this element -->
<jive>
<adminConsole>
<!-- Disable either port by setting the value to -1 -->
<port>9090</port>
<securePort>9091</securePort>
</adminConsole>
<admin>
<authorizedUsernames>liwei, admin</authorizedUsernames>
</admin>
<locale>zh_CN</locale>
<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>
<jdbcProvider> //需要集成系统的数据库;
<driver>com.mysql.jdbc.Driver</driver>
<connectionString>jdbc:mysql://localhost:3306/test?user=root&password=root</connectionString>
</jdbcProvider>
<jdbcAuthProvider>
<passwordSQL>SELECT password FROM user_account WHERE Username=?</passwordSQL>
<passwordType>plain</passwordType>
</jdbcAuthProvider>
<jdbcUserProvider> //集成用户
<loadUserSQL>SELECT name,email FROM user_account WHERE Username=?</loadUserSQL>
<userCountSQL>SELECT COUNT(*) FROM user_account</userCountSQL>
<allUsersSQL>SELECT username FROM user_account</allUsersSQL>
<searchSQL>SELECT username FROM user_account WHERE</searchSQL>
<usernameField>Username</usernameField>
<nameField>name</nameField>
<emailField>email</emailField>
</jdbcUserProvider> //------------
<connectionProvider>
<className>org.jivesoftware.database.DefaultConnectionProvider</className>
</connectionProvider>
<database>
<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverURL>jdbc:mysql://localhost:3306/openfire</serverURL>
<username>root</username>
<password>root</password>
<testSQL>select 1</testSQL>
<testBeforeUse>true</testBeforeUse>
<testAfterUse>true</testAfterUse>
<minConnections>5</minConnections>
<maxConnections>15</maxConnections>
<connectionTimeout>1.0</connectionTimeout>
</defaultProvider>
</database>
<!-- Fin configuration -->
<setup>true</setup>
<log>
<debug>
<enabled>true</enabled>
</debug>
</log>
</jive>