openfire 开源即时消息扩展篇之自定义数据源

阅读更多

       本文档提供了指示为集成Openfire身份验证、用户和组与您的自定义数据库表。这是有用,当您的用户已经有账户在一个外部系统,你不希望重复这些账户在Openfire。简单的集成与定制数据库允许用户身份验证使用他们现有的用户名和密码。您可以加载用户配置文件配置Openfire和组信息从您的自定义数据库。具体的步骤如下:

1:数据源配置

 你需要指定数据源连接驱动和连接url.需要写在openfire/src/conf/openfire.xml


  ...
  
    com.mysql.jdbc.Driver
    jdbc:mysql://localhost/dbname?user=username&password=secret
  
  ...
2:认证集成

 你需要指定认证类,openfire提供了org.jivesoftware.openfire.auth.JDBCAuthProvider类


  ...
  
    
      org.jivesoftware.openfire.auth.JDBCAuthProvider
    
  
  
     SELECT password FROM user_account WHERE username=?
     plain
   
   ...
  
其中jdbcAuthProvider.passwordType 支持以下类型:
  1. plain
  2. md5
  3. sha1
  4. sha256
  5. sha512
3:用户信息整合

 你需要指定用户信息加载类,openfire提供了org.jivesoftware.openfire.user.JDBCUserProvider类。完整的配置:


  ...
  
    
      org.jivesoftware.openfire.auth.JDBCAuthProvider
    
    
      org.jivesoftware.openfire.user.JDBCUserProvider
    
  
  
     SELECT password FROM user_account WHERE username=?
     plain
  
  
     SELECT name,email FROM myUser WHERE username=?
     SELECT COUNT(*) FROM myUser
     SELECT username FROM myUser
     SELECT username FROM myUser WHERE
     username
     name
     email
  
   ...
 

 

4:用户组信息整合

 你需要指定用户信息加载类,openfire提供了 org.jivesoftware.openfire.group.JDBCGroupProvider类。完整的配置:

 


  ...
  
    
      org.jivesoftware.openfire.auth.JDBCAuthProvider
    
    
      org.jivesoftware.openfire.user.JDBCUserProvider
    
    
      org.jivesoftware.openfire.group.JDBCGroupProvider
    
  
  
     SELECT password FROM user_account WHERE username=?
     plain
  
  
     SELECT name,email FROM myUser WHERE username=?
     SELECT COUNT(*) FROM myUser
     SELECT username FROM myUser
     SELECT username FROM myUser WHERE
     username
     name
     email
  
  
       SELECT count(*) FROM myGroups
       SELECT groupName FROM myGroups
       SELECT groupName FROM myGroupUsers WHERE username=?
       SELECT groupDescription FROM myGroups WHERE groupName=?
       SELECT username FROM myGroupUsers WHERE groupName=? AND isAdmin='N'
       SELECT username FROM myGroupUsers WHERE groupName=? AND isAdmin='Y'
  
  ...

5:备注:

在openfire/src/conf/openfire.xml文件中配置好后,需要重置设置openfire安装步骤。在设置安装步骤之前,需要对安装值进行更改,打开文件openfire/src/web/setup/setup-profile-settings.jsp找到:

       if ("default".equals(mode)) {
            // Set to default providers by deleting any existing values.
            @SuppressWarnings("unchecked")
            Map xmppSettings = (Map)session.getAttribute("xmppSettings");
            xmppSettings.put("provider.auth.className",org.jivesoftware.openfire.auth.DefaultAuthProvider.class.getName());
            xmppSettings.put("provider.user.className",org.jivesoftware.openfire.user.DefaultUserProvider.class.getName());
            xmppSettings.put("provider.group.className", org.jivesoftware.openfire.group.DefaultGroupProvider.class.getName());
            xmppSettings.put("provider.vcard.className", org.jivesoftware.openfire.vcard.DefaultVCardProvider.class.getName());
            xmppSettings.put("provider.lockout.className", org.jivesoftware.openfire.lockout.DefaultLockOutProvider.class.getName());
            xmppSettings.put("provider.securityAudit.className", org.jivesoftware.openfire.security.DefaultSecurityAuditProvider.class.getName());
            xmppSettings.put("provider.admin.className", org.jivesoftware.openfire.admin.DefaultAdminProvider.class.getName());
            // Redirect
            response.sendRedirect("setup-admin-settings.jsp");
            return;
        }
把相应的:provider.auth.className,provider.user.className,provider.group.className三个属性更改为上面你配置的相应类。然后重新开启openfire进行登录http://localhost:9090/跳转到设置。设置成功后,就OK了

你可能感兴趣的:(openfire,xmpp,im,spark,openfire,Database,Integration)