Openfire integrates existing system users

Source: Internet
Author: User
Tags md5 hash vcard

Http://blog.csdn.net/unicorn_520/article/details/7700018

Openfire server configuration, skip the introduction first. I want to insert some introduction when using it in the article.

Openfire Extension Test integration with existing system users

If I want to use the user/group (department) of an existing system instead of using openfire to manage a set of users/groups, it is very convenient to use openfire to integrate existing system users.

 

Note: After successful integration, the user you use is the database of your integrated system, instead of the database you configured in openfire. The original openfire database is still useful, the User table ofuser cannot be used, because if the user table can be used, the user account may be repeated, because the user table cannot be used for both.

Go to the openfire console-server-Service Manager-System Properties
You can find the following configurations:
Provider. Auth. classname
Org. jivesoftware. openfire. Auth. defaultauthprovider
* User verification


Provider. Group. classname
Org. jivesoftware. openfire. Group. defaultgroupprovider
* Obtain group-related data


Provider. User. classname
Org. jivesoftware. openfire. User. defaultuserprovider
* Getting user data


These providers are the Default User Groups managed by openfire.

Openfire also provides JDBC-related providers to obtain user/group data from other data sources.
Modify the preceding three attributes
Org. jivesoftware. openfire. Auth. jdbcauthprovider
Org. jivesoftware. openfire. Group. jdbcgroupprovider
Org. jivesoftware. openfire. User. jdbcuserprovider

Then, configure the data source and add the following attributes.
Jdbcprovider. Driver
* Data Source driver


Jdbcprovider. connectionstring
* Connection string

Configure related SQL statements and attributes for each JDBC provider (add a project to the system attribute)

Jdbcauthprovider
Jdbcauthprovider. passwordsql
* SQL statement for getting user passwords
* Input parameter: Logon Name
* Input column: Password
* Example: Select PWD from user where name =?
Jdbcauthprovider. passwordtype
* The password type can be plain (text), MD5, or sha1.
* If your password is not encrypted for the above three types, you need to provide an authprovider. The next chapter will introduce

Jdbcgroupprovider
Jdbcgroupprovider. allgroupssql
* Obtain the SQL statements of all groups.
* Input parameter: None
* Output column: Group Key
* Example: Select Sn from department

Jdbcgroupprovider. descriptionsql
* Get the group name (description)
* Input parameter: Key of the group record
* Output column: group name (description)
* Example: Select name from department where Sn =?

Jdbcgroupprovider. groupcountsql
* Obtain the number of groups.
* Input parameter: Group Key
* Output column: number of groups
* Example: Select count (SN) from department

Jdbcgroupprovider. loadadminssql
* Obtain the Group Administrator.
* Input parameter: Key of the group record
* Output column: Group Administrator's key
* Example: Select Admin from department where Sn =?

Jdbcgroupprovider. loadmemberssql
* Get group members
* Input parameter: Group Key
* Output column: group member key (SET)
* Example: Select usersn from department_user where departmentsn =?

Jdbcgroupprovider. usergroupssql
* Obtain a group of Members.
* Input parameter: Member key
* Output column: Key of the member group
* Example: Select departmentsn from department_user where usersn =?

Jdbcuserprovider
Jdbcuserprovider. alluserssql
* Retrieve all users
* Input parameter: None
* Output column: User's key
* Example: Select Sn from user

Jdbcuserprovider. usercountsql
* Obtain the number of all users
* Input parameter: None
* Output column: Number of users
* Example: Select count (SN) from user

Jdbcuserprovider. loadusersql
* Getting user information
* Input parameter: User's key
* Output column: Login Name, name, and email (at least these three columns should be used below)
* Example: Select loginname, name, email from user where Sn =?

Jdbcuserprovider. emailfield
* Name of the user's email column, for example, email
Jdbcuserprovider. namefield
* The column name of the specified user name, for example, name.
Jdbcuserprovider. usernamefield
* The name of the specified user login name, for example, loginname

Finally, you need to configure a new administrator user.
Admin. authorizedjids
* Specify the administrator user in the new data source. Note that the complete jid (user @ domain name) is used)
* Example: admin@server.cn

Restart openfire After configuring the above attributes
Use the username in Admin. authorizedjids to log on to the openfire console.
If the configuration is successful, go to the openfire console-user/group
You can see the user/group information in your data source.
You can also use spark to log on for testing.

In addition, if a problem occurs during debugging, you cannot log on to the openfire console.


(Note that the property amdin. if the value of authorizedjids is set to, the ABC here is the Administrator name of the openfire background management, and the Administrator information is not the administrator of the database specified by our original openfire, instead, the Administrator named ABC in the database of the system to be integrated. Of course, you can configure SQL to specify the table that the Administrator obtains from the information to be integrated .)


You can directly modify the ofproperty table in the openfire database.

 

After testing, you can integrate the existing system, for example:

My IP address is 192.168.1.102 and the MySQL database is used.

The existing system library is SNS, with a user table, field: ID, email, password, name

For integration, first:

Modify the ofproperty table. The modified content is as follows (here, boy is the Administrator name)

Admin. authorizedjids boy@192.168.1.102
Jdbcauthprovider. passwordsql select password from user where id =?
Jdbcauthprovider. passwordtype plain // other confidential encryption methods

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

Jdbcprovider. connectionstring JDBC: mysql: // localhost: 3306/SNS? User = root & Password = 123456
Jdbcprovider. Driver com. MySQL. JDBC. Driver
Jdbcuserprovider. alluserssql select ID from user
Jdbcuserprovider. emailfield email
Jdbcuserprovider. loadusersql select name, email from user where id =?
Jdbcuserprovider. namefield name
Jdbcuserprovider. usercountsql select count (*) from user
Jdbcuserprovider. usernamefield name
Passwordkey f46l75p2qsukcqy // encrypted string
Provider. admin. classname org. jivesoftware. openfire. admin. defaultadminprovider
Provider. Auth. classname org. jivesoftware. openfire. Auth. jdbcauthprovider
Provider. Group. classname org. jivesoftware. openfire. Group. defaultgroupprovider
Provider. lockout. classname org. jivesoftware. openfire. lockout. defaultlockoutprovider
Provider. securityaudit. classname org. jivesoftware. openfire. Security. defaultsecurityauditprovider
Provider. User. classname org. jivesoftware. openfire. User. jdbcuserprovider
Provider. vCard. classname org. jivesoftware. openfire. vCard. defaultvcardprovider
Update. lastcheck 1262616901497
XMPP. Auth. Anonymous true
XMPP. Domain 192.168.1.102
XMPP. session. Conflict-limit 0
XMPP. Socket. SSL. Active true

Note: red indicates the modified content.

Restart the openfire server.

In the future, you need to enter the ID, password. Someone will ask, why not use the ID instead of email?

This is because the email is signed, and openfire is used to record the Domain Name of the server. Therefore, there will be conflicts.

Besides, when openfire is integrated into the existing system as Im, the login method is implicit login, that is, embedded into the login method of the original system.

Transparent to users.

Problem:

However, the problem to be solved is that the existing spark is the display ID when the client is displayed, and the consumer chat is estimated to be the same. You need to modify it so that only the user name is displayed for the user! If it can be solved, there are basically no changes to the existing system.

 

 

The existing system library is myim, and there is a user table with fields: ID, email, password, name. The difference is that ID here I set it not to auto-increment, name

That is, the User display name is also used for Account Login (separate in actual use, here only for a small test), password is the user login password. You can execute the following SQL statement in the openfire database to integrate the user table of the existing system:

SQL code

Insert into ofproperty (name, propvalue) Values
('Jdbcprovider. Driver ', 'com. MySQL. JDBC. Driver '),
('Jdbc provider. ononstring', 'jdbc: mysql: // localhost/myim?

User = root & Password = & useunicode = true & characterencoding = utf8 '),
('Admin. authorizedjids ', 'admin @ 127.0.0.1 '),
('Jdbcauthprovider. passwordsql', 'select password from user where name =? '),
('Jdbcauthprovider. passwordtype', 'plain '),
('Jdbcuserprovider. loadusersql', 'select name, email from user where name =? '),
('Jdbcuserprovider. usercountsql', 'select count (*) from user '),
('Jdbcuserprovider. alluserssql', 'select name from user '),
('Jdbcuserprovider. usernamefield ', 'name '),
('Jdbcuserprovider. namefield ', 'name '),
('Jdbcuserprovider. emailfield ', 'email ');

Update ofproperty set propvalue = 'org. jivesoftware. openfire. User. jdbcuserprovider 'Where

Name = 'provider. User. classname ';
Update ofproperty set propvalue = 'org. jivesoftware. openfire. Auth. jdbcauthprovider 'Where

Name = 'provider. Auth. classname ';

In of the built-in documentation/db-integration-guide.html you can view the English version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.