[Geoserver-devel] WMS Request Intercept Extension

Good morning GeoServer-devel,

For a project I am currently working on I need to intercept incoming WMS getCapabilities/getMap requests and their outbound responses in order to perform some arbitrary pre- and post-processing. Is inserting my control flow into the WMS request/response capable via GeoServer extensions and, if so, could anyone provide some help in identifying the programmatic hooks I should be grabbing onto in order to get that level of control? If not, could I use a side-servlet to capture incoming responses and pass them to GeoServer programmatically? Again, if yes, identification of what classes/methods provide said access would aid me greatly.

Thanks,
David Marks

On Mon, Dec 8, 2014 at 2:12 PM, Marks, David <David.Marks@anonymised.com>
wrote:

Good morning GeoServer-devel,

For a project I am currently working on I need to intercept incoming WMS
getCapabilities/getMap requests and their outbound responses in order to
perform some arbitrary pre- and post-processing. Is inserting my control
flow into the WMS request/response capable via GeoServer extensions and, if
so, could anyone provide some help in identifying the programmatic hooks I
should be grabbing onto in order to get that level of control? If not,
could I use a side-servlet to capture incoming responses and pass them to
GeoServer programmatically? Again, if yes, identification of what
classes/methods provide said access would aid me greatly.

The generic OGC service lifecycle callback is called DispatcherCallback:

https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/ows/src/main/java/org/geoserver/ows/DispatcherCallback.java

There are several instances of these in GeoServer, for example to monitor
and log requests:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/extension/monitor/core/src/main/java/org/geoserver/monitor/ows/MonitorCallback.java
to check security:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/main/src/main/java/org/geoserver/security/OperationSecurityCallback.java
or to manipulate requests:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/community/wms-eo/src/main/java/org/geoserver/wms/eo/EOGetFeatureInfoChecker.java

All of them are registered in the Spring applicationContext.xml file
contained in the same module.

The main advantage of these is that you get the request already parsed into
a Java object, which is handy since each OGC
request can be sent in a variety of ways. If instead you want something
lower level, you can always implement a ServletFilter

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Please, notice that GeoSolutions will be closed for seasonal holidays
from December the 24th to January the 6th

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

*AVVERTENZE AI SENSI DEL D.Lgs. 196/2003*

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

-------------------------------------------------------

Andrea,

This looks like precisely what I was looking for but having trouble finding. Thanks a ton for assisting me in pinpointing how I needed to interface with the system.

Thanks again,
David Marks

From: Andrea Aime <andrea.aime@anonymised.com<mailto:andrea.aime@anonymised.com>>
Date: Monday, December 8, 2014 at 9:21 AM
To: David Marks <david.marks@anonymised.com<mailto:david.marks@anonymised.com>>
Cc: Geoserver-devel <geoserver-devel@lists.sourceforge.net<mailto:geoserver-devel@lists.sourceforge.net>>
Subject: Re: [Geoserver-devel] WMS Request Intercept Extension

On Mon, Dec 8, 2014 at 2:12 PM, Marks, David <David.Marks@anonymised.com<mailto:David.Marks@anonymised.com>> wrote:
Good morning GeoServer-devel,

For a project I am currently working on I need to intercept incoming WMS getCapabilities/getMap requests and their outbound responses in order to perform some arbitrary pre- and post-processing. Is inserting my control flow into the WMS request/response capable via GeoServer extensions and, if so, could anyone provide some help in identifying the programmatic hooks I should be grabbing onto in order to get that level of control? If not, could I use a side-servlet to capture incoming responses and pass them to GeoServer programmatically? Again, if yes, identification of what classes/methods provide said access would aid me greatly.

The generic OGC service lifecycle callback is called DispatcherCallback:

https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/ows/src/main/java/org/geoserver/ows/DispatcherCallback.java

There are several instances of these in GeoServer, for example to monitor and log requests:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/extension/monitor/core/src/main/java/org/geoserver/monitor/ows/MonitorCallback.java
to check security:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/main/src/main/java/org/geoserver/security/OperationSecurityCallback.java
or to manipulate requests:
https://github.com/geoserver/geoserver/blob/793476e348e906a2ee9db8fa8f73a4fb464f3288/src/community/wms-eo/src/main/java/org/geoserver/wms/eo/EOGetFeatureInfoChecker.java

All of them are registered in the Spring applicationContext.xml file contained in the same module.

The main advantage of these is that you get the request already parsed into a Java object, which is handy since each OGC
request can be sent in a variety of ways. If instead you want something lower level, you can always implement a ServletFilter

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.

Please, notice that GeoSolutions will be closed for seasonal holidays
from December the 24th to January the 6th

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.

-------------------------------------------------------