XMPP 之Openfire的用户数据库整合(openfire.xml配置参数)
如果手动一步步设置
删除默认,
首先停止正常运行的Openfire服务器
默认的库ofProperty的如下记录删除
provider.auth.classname
provider.user.classname
provider.group.classname
建立一个第三方的表
CREATE TABLE myUser (
username NVARCHAR(64) NOT NULL,
plainPassword NVARCHAR(32),
encryptedPassword NVARCHAR(255),
name NVARCHAR(100),
email VARCHAR(100),
creationDate CHAR(15) NOT NULL,
modificationDate CHAR(15) NOT NULL,
CONSTRAINT ofUser_pk PRIMARY KEY (username)
);
CREATE INDEX ofUser_cDate_idx ON myUser (creationDate ASC);
CREATE TABLE myGroupUser (
groupName NVARCHAR(50) NOT NULL,
username NVARCHAR(100) NOT NULL,
administrator INTEGER NOT NULL,
CONSTRAINT ofGroupUser_pk PRIMARY KEY (groupName, username, administrator)
);
CREATE TABLE myGroup (
groupName NVARCHAR(50) NOT NULL,
description NVARCHAR(255),
CONSTRAINT ofGroup_pk PRIMARY KEY (groupName)
);
密码加密方式:
plain md5 sha1 sha256 sha512
密码采用明文:
<passwordSQL>SELECT plainPassword FROM myUser WHERE username=?</passwordSQL>
<passwordType>palin</passwordType>
密码采用HASH:
<passwordSQL>SELECT encryptedPassword FROM myUser WHERE username=?</passwordSQL>
<passwordType>sha256</passwordType>
如下是一个myUser 中admin数据[myUser 插入admin/**数据,必须有一个,否则再次启动时使用这个验证时就没法登录]
admin |
admin |
8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918 |
admin |
2011-1-1 |
2011-1-1 |
配置文件
openfire.xml 加入如下内容
<!-- Use Custome Database for user/group
openfire_src/documentation/docs :: db-integration-guide.html database.html database-guide.html
-->
<jdbcProvider>
<!--
<driver>com.mysql.jdbc.Driver</driver>
<connectionString>jdbc:mysql://localhost:3306/of?user=root&password=</connectionString>
-->
<![CDATA[ SQL SERVER驱动 jtds.sourceforge.net/faq.html ]]>
<driver>net.sourceforge.jtds.jdbc.Driver</driver>
<connectionString>jdbc:jtds:sqlserver://localhost/cust;appName=cust;user=of;password=of</connectionString>
</jdbcProvider>
<admin/>
<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 plainPassword FROM myUser WHERE username=?</passwordSQL>
<passwordType>palin</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 myGroup</groupCountSQL>
<allGroupsSQL>SELECT groupName FROM myGroup</allGroupsSQL>
<descriptionSQL>SELECT groupDescription FROM myGroup WHERE groupName=?</descriptionSQL>
<userGroupsSQL>SELECT groupName FROM myGroupUser WHERE username=?</userGroupsSQL>
<loadMembersSQL>SELECT username FROM myGroupUser WHERE groupName=? AND isAdmin=‘N‘</loadMembersSQL>
<loadAdminsSQL>SELECT username FROM myGroupUser WHERE groupName=? AND isAdmin=‘Y‘</loadAdminsSQL>
</jdbcGroupProvider>
启动
再次启动后,使用admin可以登录进去
默认的数据库的[ofProperty]内容从配置文件导入了,openfire.xml恢复原来的形式,查看ofProperty
name |
propValue |
jdbcAuthProvider.passwordSQL |
SELECT plainPassword FROM myUser WHERE username=? |
jdbcAuthProvider.passwordType |
plain |
jdbcGroupProvider.allGroupsSQL |
SELECT groupName FROM myGroup |
jdbcGroupProvider.descriptionSQL |
SELECT groupDescription FROM myGroup WHERE groupName=? |
jdbcGroupProvider.groupCountSQL |
SELECT count(*) FROM myGroup |
jdbcGroupProvider.loadAdminsSQL |
SELECT username FROM myGroupUser WHERE groupName=? AND isAdmin=‘Y‘ |
jdbcGroupProvider.loadMembersSQL |
SELECT username FROM myGroupUser WHERE groupName=? AND isAdmin=‘N‘ |
jdbcGroupProvider.userGroupsSQL |
SELECT groupName FROM myGroupUser WHERE username=? |
jdbcProvider.connectionString |
jdbc:jtds:sqlserver://localhost/cust;appName=cust;user=of;password=of |
jdbcProvider.driver |
net.sourceforge.jtds.jdbc.Driver |
jdbcUserProvider.allUsersSQL |
SELECT username FROM myUser |
jdbcUserProvider.emailField |
|
jdbcUserProvider.loadUserSQL |
SELECT name,email FROM myUser WHERE username=? |
jdbcUserProvider.nameField |
name |
jdbcUserProvider.searchSQL |
SELECT username FROM myUser WHERE |
jdbcUserProvider.userCountSQL |
SELECT COUNT(*) FROM myUser |
jdbcUserProvider.usernameField |
username |
provider.auth.className |
org.jivesoftware.openfire.auth.JDBCAuthProvider |
provider.group.className |
org.jivesoftware.openfire.group.JDBCGroupProvider |
provider.user.className |
org.jivesoftware.openfire.user.JDBCUserProvider |
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。