Modify the configuration file using your own data table in OpenFire

Source: Internet
Author: User

Currently I use the OpenFire version is 3.10.3, the following instructions are also made in this version of the changes.

OpenFire provides two ways to use the User data table. One is the default implementation of Org.jivesoftware.openfire.user.DefaultUserProvider after installation, one is Org.jivesoftware.openfire.user.JDBCUserProvider, the same for The default implementation of Org.jivesoftware.openfire.auth.DefaultAuthProvider is also provided by the user authentication, which is Org.jivesoftware.openfire.auth.JDBCAuthProvider. The former is based on the database tables that are populated at the time of installation to create the user table. You need to use the latter if you want to use your own user table or based on an existing user table.

There are two ways to use a custom user table method, one is to modify the configuration file, and one is to modify the system properties by logging on to the system.

  Modifying a configuration file

  Open the OpenFire installation directory, locate the Conf/openfire.xml configuration file, this is the OpenFire load System Properties file, add the following configuration to modify some system properties.

    • Add Administrator

OpenFire The default login administrator name is admin and can be modified here.

1 < Admin > 2         < Authorizedusernames >Joe, Jane</authorizedusernames>3</ Admin >

The above definition has two users named Joe and Jane can log in to the admin console.

    • Using a custom database connection
1 <Jdbcprovider>2     <Driver>Com.mysql.jdbc.Driver</Driver>3     <connectionString>Jdbc:mysql://localhost/dbname?user=username&amp;Password=secret</connectionString>4  </Jdbcprovider>
    • Custom authentication integration, OpenFire is used by default in the MD5 encryption password.
1 <provider>2     <Auth>3       <ClassName>Org.jivesoftware.openfire.auth.JDBCAuthProvider</ClassName>4     </Auth>5   </provider>6   <Jdbcauthprovider>7      <Passwordsql>SELECT password from User_account WHERE username=?</Passwordsql>8      <Passwordtype>Plain</Passwordtype>9 </Jdbcauthprovider>

Here you need to explain that ClassName is a string that cannot be changed, PASSWORDSQL is the SQL statement that queries the data table, Passwordtype is the encryption method of the password, there are plain, MD5, SHA1, SHA256, sha512 and other strings can be filled in.

    • User Data integration, officially stated, if user data integration is used, then authentication integration must be used. Examples are as follows:
1 <provider>2     <Auth>3       <ClassName>Org.jivesoftware.openfire.auth.JDBCAuthProvider</ClassName>4     </Auth>5     <User>6       <ClassName>Org.jivesoftware.openfire.user.JDBCUserProvider</ClassName>7     </User>8   </provider>9   <Jdbcauthprovider>Ten      <Passwordsql>SELECT password from User_account WHERE username=?</Passwordsql> One      <Passwordtype>Plain</Passwordtype> A   </Jdbcauthprovider> -   <Jdbcuserprovider> -      <Loadusersql>SELECT name,email from MyUser WHERE username=?</Loadusersql> the      <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>

Among them, the user and auth inside the classname is OpenFire built-in class name, cannot change. Jdbcuserprovider is a method that OpenFire provides for obtaining user data. Because you use a table of your own definition, the fields and table names may be different, so you must customize SQL. The methods that need to be defined are

A. Loadusersql: Query user information based on user name, including name and message. Statement has a "? "This question mark will be replaced by username.

B. Usercountsql: Query The total number of users.

C. searchsql: Query the user. Where no strings are connected, Jdbcuserprovider will automatically add queries based on the username or name of the query. If no query criteria will not work.

D. Usernamefield: The field name username in the custom data table. Used for the above SQL query.

E. NameField: The name of the field in the Custom data table. Used for the above SQL query.

F. Emailfield: The field name of the email in the Custom data table. The SQL query above the user.

  

    • Grouping integration, if you want to use your own user groups, then also need to join the certification integration, where the certification integration is no longer written, only show the packet integration configuration.
1 <provider>2     <Group>3   <ClassName>Org.jivesoftware.openfire.group.JDBCGroupProvider</ClassName>4     </Group>5 </provider>

The classname in Group One is fixed.

1 <Jdbcgroupprovider>2        <Groupcountsql>SELECT Count (*) from mygroups</Groupcountsql>3        <Allgroupssql>SELECT GroupName from Mygroups</Allgroupssql>4        <Usergroupssql>SELECT groupName from Mygroupusers WHERE username=?</Usergroupssql>5        <Descriptionsql>SELECT groupdescription from Mygroups WHERE groupname=?</Descriptionsql>6        <Loadmemberssql>SELECT username from mygroupusers WHERE groupname=? and isadmin= ' N '</Loadmemberssql>7        <Loadadminssql>SELECT username from mygroupusers WHERE groupname=? and isadmin= ' Y '</Loadadminssql>8 </Jdbcgroupprovider>

The above configuration simple description:

A. Groupcountsql: Number of query groups,

B. Allgroupssql: All groupings are queried.

C. Usergroupssql: Group by user name query.

D. Descriptionsql: Query the group description according to its name.

E. Loadmemberssql: Loads all the members of the group according to their name.

F. Loadadminssql: Queries all administrators in the group based on their name.

 

Modify the configuration file using your own data table in OpenFire

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.