Skip to content

Building instructions

Emanuele Tajariol edited this page May 18, 2015 · 2 revisions

Getting the source

GeoFence is split in 2 main pieces:

  • The GeoFence webapp, containing the rule engine and the admin GUI
  • The probe, containing the logic that allows GeoServer to send auth requests to GeoFence.

You need to get the sources from different repositories for getting the different parts.

GeoFence main webapp

Get the source as usual from github.

The git command line should be something like

git clone [email protected]:geoserver/geofence.git geofence

GeoFence probe

The probe has been implemented as a GeoServer community module. It is a community module in GeoServer, so you'll have to checkout the normal GeoServer repository:

https://github.com/geoserver/geoserver

The probe is versioned along with GeoServer, so you'll have to checkout the branch you need, and then get into src/community/geofence

Building GeoFence

Create the GeoFence DB

  1. Create a PostGIS DB called "geofence" (with PostGis support enabled). You may need to run these commands as user postgres.
createdb geofence
createlang plpgsql geofence
psql -d geofence -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d geofence -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
psql -d geofence -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql

Your files may be in a different location than /usr/share/postgresql/9.1/contrib/postgis-1.5/ 2. Run the sql script doc/setup/sql/001_setup_db.sql on geofence db via psql -d geofence -f path_to_file; it will create the users:

  • geofence with pw geofence
  • geofence_test with pw geofence_test

and schemas geofence and geofence_test. You may need to run these commands as user postgres.

psql -d geofence -f YOUR_GEOFENCE_DIR/doc/setup/sql/001_setup_db.sql
  1. Run the sql script doc/setup/sql/002_create_schema_postgres.sql on geofence db, geofence schema; it will create the base tables, indices, etc. The geofence_test schema will be automatically recreated during tests.
psql -U geofence -d geofence -f YOUR_GEOFENCE_DIR/doc/setup/sql/002_create_schema_postgres.sql

Note that you are logging in postgres as usergeofence, so you will be asked for user password, that's set as geofence as noted above.

Build the webapps

You can build the application, specifying what kind of backend database you will use.

Enter the src/ directory and launch one of the following command (the one matching the database you wish to use).

H2 (default) backend

mvn clean install

Postgis backend

mvn clean install -Ppostgis

Oracle backend

mvn clean install -Poracle

This will create two wars:

  • src/gui/web/target/geofence.war : the geofence service and GUI webapp (see also ticket #8)
  • geoserver/web-app/target/geoserver.war : the geoserver webapp with the proper libs to communicate with geofence

Run the webapps

You can run the two webapps using the embedded Jetty http server.

In order to run GeoFence, enter into the directory src/gui/web and run the command

mvn jetty:run

If you also want to run GeoServer, enter the directory src/geoserver21x/web-app/ (or the directory src/geoserver22x/web-app/) and run the same command:

mvn jetty:run

You can optionally run the GUI from GWT by running this the following command from inside src/gui/web :

mvn gwt:run 

GWT host mode and Eclipse Plugin

Install Google Web Toolkit plugin on your Eclipse distribution following these instructions

Create Eclipse projects as follows:

mvn eclipse:clean eclipse:eclipse

On "gui/web" module, create GWT Eclipse project as follows:

mvn gwt:eclipse

Import the projects on your workspace, make sure all compiles.

Right click on "web" project and enable it as Google Web Toolkit module by selecting "Google > Web Toolkit settings".

Enable GWT 2.1.1 and add Entry point:

Application - org.geoserver.geofence.gui

From "Run Configurations" select edit "geofence" launcher properties and check that the "Arguments" are configured like the following:

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl Application.html -logLevel INFO -port 8888 -war YOUR_GEOFENCE_GIT_REPO_PATH/src/gui\web\target\geofence -codeServerPort 9997 org.geoserver.geofence.gui.Application

WARNING: Pay attention to the paths