Class JDBCUserPropertyProvider

  • All Implemented Interfaces:
    UserPropertyProvider

    public class JDBCUserPropertyProvider
    extends Object
    implements UserPropertyProvider
    The JDBC user property provider allows you to use an external database to define the user properties. It is best used with the JDBCUserProvider, JDBCAuthProvider & JDBCGroupProvider to provide integration between your external system and Openfire. All data is treated as read-only so any set operations will result in an exception. This implementation will not explicitly verify if a user exists, when operating on its properties. The methods of this implementation will not throw UserNotFoundException. To enable this provider, set the following in the system properties:
    • provider.userproperty.className = org.jivesoftware.openfire.user.property.JDBCUserPropertyProvider
    Then you need to set your driver, connection string and SQL statements:
    • jdbcUserPropertyProvider.driver = com.mysql.jdbc.Driver
    • jdbcUserPropertyProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&password=secret
    • jdbcUserPropertyProvider.loadPropertySQL = SELECT propName, propValue FROM myUser WHERE user = ? AND propName = ?
    • jdbcUserPropertyProvider.loadPropertiesSQL = SELECT propValue FROM myUser WHERE user = ?
    In order to use the configured JDBC connection provider do not use a JDBCconnection string, set the following property: jdbcUserPropertyProvider.useConnectionProvider = true
    Author:
    Guus der Kinderen, guus.der.kinderen@gmail.com
    • Constructor Detail

      • JDBCUserPropertyProvider

        public JDBCUserPropertyProvider()
        Constructs a new JDBC user property provider.
    • Method Detail

      • assumePersistedDataIsEscaped

        protected boolean assumePersistedDataIsEscaped()
        XMPP disallows some characters in identifiers, requiring them to be escaped. This implementation assumes that the database returns properly escaped identifiers, but can apply escaping by setting the value of the 'jdbcUserPropertyProvider.isEscaped' property to 'false'.
        Returns:
        'false' if this implementation needs to escape database content before processing.
      • loadProperty

        public String loadProperty​(String username,
                                   String propName)
        Description copied from interface: UserPropertyProvider
        Retrieves a property value for a user. This method will return null when the desired property was not defined for the user (null values are not supported).
        Specified by:
        loadProperty in interface UserPropertyProvider
        Parameters:
        username - The identifier of the user (cannot be null or empty).
        propName - The property name (cannot be null or empty).
        Returns:
        The property value (possibly null).
      • isReadOnly

        public boolean isReadOnly()
        Description copied from interface: UserPropertyProvider
        Returns true if this UserPropertyProvider is read-only. When read-only, properties can not be created, deleted or modified. Invocation of the corresponding methods should result in an UnsupportedOperationException.
        Specified by:
        isReadOnly in interface UserPropertyProvider
        Returns:
        true if the user provider is read-only.