Class JDBCUserPropertyProvider
java.lang.Object
org.jivesoftware.openfire.user.property.JDBCUserPropertyProvider
- All Implemented Interfaces:
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
jdbcUserPropertyProvider.driver = com.mysql.jdbc.DriverjdbcUserPropertyProvider.connectionString = jdbc:mysql://localhost/dbname?user=username&password=secretjdbcUserPropertyProvider.loadPropertySQL = SELECT propName, propValue FROM myUser WHERE user = ? AND propName = ?jdbcUserPropertyProvider.loadPropertiesSQL = SELECT propValue FROM myUser WHERE user = ?
jdbcUserPropertyProvider.useConnectionProvider = true- Author:
- Guus der Kinderen, guus.der.kinderen@gmail.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanXMPP disallows some characters in identifiers, requiring them to be escaped.voiddeleteProperty(String username, String propName) Removes one particular property for a particular user.voidinsertProperty(String username, String propName, String propValue) Adds a property for an user.booleanReturns true if this UserPropertyProvider is read-only.loadProperties(String username) Retrieves all properties for a particular user.loadProperty(String username, String propName) Retrieves a property value for a user.voidupdateProperty(String username, String propName, String propValue) Changes a property value for an user.
-
Constructor Details
-
JDBCUserPropertyProvider
public JDBCUserPropertyProvider()Constructs a new JDBC user property provider.
-
-
Method Details
-
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.
-
loadProperties
Description copied from interface:UserPropertyProviderRetrieves all properties for a particular user.- Specified by:
loadPropertiesin interfaceUserPropertyProvider- Parameters:
username- The identifier of the user (cannot be null or empty).- Returns:
- A collection, possibly empty, but never null.
- Throws:
UnsupportedOperationException
-
loadProperty
Description copied from interface:UserPropertyProviderRetrieves 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:
loadPropertyin interfaceUserPropertyProvider- 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).
-
insertProperty
public void insertProperty(String username, String propName, String propValue) throws UnsupportedOperationException Description copied from interface:UserPropertyProviderAdds a property for an user. The behavior of inserting a duplicate property name is not defined by this interface.- Specified by:
insertPropertyin interfaceUserPropertyProvider- Parameters:
username- The identifier of the user (cannot be null or empty).propName- The property name (cannot be null or empty).propValue- The property value (cannot be null).- Throws:
UnsupportedOperationException- if the property cannot be added
-
updateProperty
public void updateProperty(String username, String propName, String propValue) throws UnsupportedOperationException Description copied from interface:UserPropertyProviderChanges a property value for an user. The behavior of updating a non-existing property is not defined by this interface.- Specified by:
updatePropertyin interfaceUserPropertyProvider- Parameters:
username- The identifier of the user (cannot be null or empty).propName- The property name (cannot be null or empty).propValue- The property value (cannot be null).- Throws:
UnsupportedOperationException- if the property cannot be updated
-
deleteProperty
Description copied from interface:UserPropertyProviderRemoves one particular property for a particular user. The behavior of deleting a non-existing property is not defined by this interface.- Specified by:
deletePropertyin interfaceUserPropertyProvider- Parameters:
username- The identifier of the user (cannot be null or empty).propName- The property name (cannot be null or empty).- Throws:
UnsupportedOperationException- if the property cannot be deleted
-
isReadOnly
public boolean isReadOnly()Description copied from interface:UserPropertyProviderReturns 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 anUnsupportedOperationException.- Specified by:
isReadOnlyin interfaceUserPropertyProvider- Returns:
- true if the user provider is read-only.
-