-
Notifications
You must be signed in to change notification settings - Fork 55
GeoFence configuration
There are different aspects in GeoFence that may be configured:
- the backend DBMS and related database,
- the LDAP server,
- the background map in the client (for the standalone GeoFence version)
All configurations are performed by providing a property file to GeoFence, in which the various configurations will be set.
GeoFence comes with some default values which are quite good for a test run. You will want anyway to reconfigure at least the backend database. Since the custom configuration will override the default values, the configuration file will also be called the override file.
There are a couple of ways to setup the GeoFence override file:
-
If you are using the embedded version, use may use the fixed file inside the GeoServer data dir. It's located at
data/geofence/geofence-datasource-ovr.properties
. -
You may use a file located anywhere in the file system. You will set the file path using a system property named
geofence-ovr
. Such property can be set like that:java .... -Dgeofence-ovr=file:/PATH/TO/OVR/FILE.properties ...
This way of configuring the override file can be used both in the embedded and in the standalone version.
Please note that tomcat will run the file
CATALINA_BASE/bin/setenv.sh
if such file exists, so that's a good place to set system properties.e.g.:
export CATALINA_HOME=/usr/local/java/tomcat export CATALINA_BASE=/var/tomcat/geofence export JAVA_OPTS="-Dgeofence-ovr=file:${CATALINA_BASE}/conf/gf-ovr.properties"
By default GeoFence uses H2 as the backend DBMS; the database data files are created in the directory geofence_db/
, created in the current directory (i.e. the directory selected at the moment of the launch of the webapp).
You may configure the H2 db location, or configure a completely different DBMS backend (supported DBMS are PostgreSQL+postGIS and Oracle Spatial).
In order to configure a particular DBMS, you need to:
- specify the DBMS driver, dialect and DB access info in the ovr property file
- provide the JDBC drivers and the dialect jars to the webapp.
The web application uses the jar files contained in the WEB-INF/lib
directory.
Some JDBC drivers are free and are already bundled in the geofence.war file (version number may change):
- for H2
- h2-1.3.172.jar
- for PostGreSQL+PostGIS
- postgis-jdbc-1.3.3.jar
- postgresql-8.4-702.jdbc3.jar
No JDBC drivers are provided for Oracle, since they are not free and you need to sign a license agreement before downloading them from the Oracle site **TODO: provide link here **.
If you need to use Oracle, please download the jdbc jar file and put it into WEB-INF/lib
directory.
Jar files for different dialects can not be placed in the lib/
directory at the same time (at least for hibernate spatial 1.x), since this would cause issues in class loading.
This means that, if you need to use a DBMS different to the default one (that is H2), you need to provide the webapp the proper dialect jar file. You may do this by either:
- building a
.war
file for that database type (look at building instructions to learn how to get a.war
for your database); - replacing the default H2 hibernate spatial driver (
hibernate-spatial-h2-geodb-XXX.jar
) inWEB-INF/lib
with the one related to the DBMS you are going to use.
For your convenience, the geofence .war
file already packs some dialect jar files. You only need to replace the default one with the one you need.
In WEB-INF/spatial-lib/
you will find these files:
- hibernate-spatial-h2-geodb-1.1.1.jar
- hibernate-spatial-oracle-1.1.1.jar
- hibernate-spatial-postgis-1.1.1.jar
These are the main properties you need to configure in order to use a specific DBMS (this sample is for configuring a PostGIS DB):
geofenceVendorAdapter.databasePlatform=org.hibernatespatial.postgis.PostgisDialect
geofenceDataSource.driverClassName=org.postgresql.Driver
geofenceDataSource.url=jdbc:postgresql://localhost:5432/geofence
geofenceDataSource.username=geofence
geofenceDataSource.password=geofence
geofenceEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=gfschema
- the dialect tells the DB library how it should talk to the underlying DB; please make sure you have the proper jar file in your
lib/
directory; - the driver is needed to perform the connection to the DB; you need the proper JDBC driver in you
lib/
directory; - the url is a DBMS-specific way to set the target database instance
- the schema is the DB schema where the GeoFence tables will be located; the configured user should have insert/select/update grants on it; if hibernate is also requested to create the schema, some higher privileges are needed
- username and password are the access credentials to the db.
GeoFence is configured to use H2 as default DBMS, so you don't need to redefine all of the DB properties in order to make it work.
If you only need to configure the H2 DB file location, you only need to redefine the DB URL in the ovr file:
geofenceDataSource.url=jdbc:h2:/ABSOLUTE/DIRECTORY/PATH/FILENAME_TEMPLATE
- jdbc jar: should already be in the geofence webapp.
- hibernate spatial jar file: replace the dialect as explained above
- sample config:
geofenceVendorAdapter.databasePlatform=org.hibernatespatial.postgis.PostgisDialect
geofenceDataSource.driverClassName=org.postgresql.Driver
geofenceDataSource.url=jdbc:postgresql://localhost:5432/geofence
geofenceDataSource.username=geofence
geofenceDataSource.password=geofence
geofenceEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=gfschema
- jdbc jar: Oracle jdbc drivers are not freely distributable, so you'll need to download the one you need from Oracle website.
- hibernate spatial jar file: replace the dialect as explained above
- sample config:
geofenceVendorAdapter.databasePlatform=org.hibernatespatial.oracle.OracleSpatial10gDialect
geofenceDataSource.driverClassName=
geofenceDataSource.url=
geofenceDataSource.username=geofence
geofenceDataSource.password=geofence
geofenceEntityManagerFactory.jpaPropertyMap[hibernate.default_schema]=gfschema
TODO
geofenceLdapSource.url=ldap://localhost:10389
geofenceLdapSource.base=dc=example,dc=com
geofenceLdapSource.user=uid=admin,ou=system
geofenceLdapSource.password=secret
You may want to configure the base layer in the map client in GeoFence.
These are the keys you have to set in the ovr file; the values you see here are the default values:
geofenceGlobalConfiguration.baseLayerURL=http://vmap0.tiles.osgeo.org/wms/vmap0
geofenceGlobalConfiguration.baseLayerName=Vmap0
geofenceGlobalConfiguration.baseLayerTitle=OSGeo base map
geofenceGlobalConfiguration.baseLayerFormat=image/png
geofenceGlobalConfiguration.baseLayerStyle=
geofenceGlobalConfiguration.mapCenterLon=0
geofenceGlobalConfiguration.mapCenterLat=0
geofenceGlobalConfiguration.mapZoom=2
Please look at this file
https://github.com/geoserver/geofence/blob/master/src/gui/web/src/main/resources/geofence-datasource-ovr.properties.sample
to find out other more specific available configuration.