[Geoserver-devel] Include web-fragment.xml in custom security module

Hi all,

I'm trying to write a custom user group/role details service for
Geoserver. I've created my own implementations of the usergroup and role
services, which appear ok in the web interface, but I have a problem of
accessing the list of users and roles.

I get a lazy load exception when accessing referenced entities of my
user entities, because presumably the db session used has been closed
before the view is generated. The easiest solution appears to be to use
the "Open session in view" filter which would normally go in web.xml.

As this is supposed to be an add-on module, it would more approproately
go in the jar file, so I would be including META-INF/web-fragment.xml.
The problem is that Gepserver is using the 2.3 web application spec, and
web-fragment support is only in 3.0.

Could anyone suggest a solution to this?

Thanks,
Mark

On Wed, Aug 15, 2012 at 1:01 PM, Mark Paxton <mark@anonymised.com> wrote:

Hi all,

I’m trying to write a custom user group/role details service for
Geoserver. I’ve created my own implementations of the usergroup and role
services, which appear ok in the web interface, but I have a problem of
accessing the list of users and roles.

I get a lazy load exception when accessing referenced entities of my
user entities, because presumably the db session used has been closed
before the view is generated. The easiest solution appears to be to use
the “Open session in view” filter which would normally go in web.xml.

As this is supposed to be an add-on module, it would more approproately
go in the jar file, so I would be including META-INF/web-fragment.xml.
The problem is that Gepserver is using the 2.3 web application spec, and
web-fragment support is only in 3.0.

Could anyone suggest a solution to this?

GeoServer won’t be based on Servet 3.0 for some time, we try to keep
back a version in order to allow conservative deploys to still function.
Happily enough though we have an extension point in Spring that allows
a Servlet filter to be plugged in, you just have to make it implement
the org.geoserver.filters.GeoServerFilter interface and declare it as
a bean in the Spring application context (applicationContext.xml file,
in the root of your module classpath) and it will be picked up on startup
(well, provided your GeoServer is recent enough, it has been around
for more than one year now)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

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 962313
mob: +39 339 8844549

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


There is an example of doing exactly this in the monitoring module which uses hibernate.

https://github.com/geoserver/geoserver/blob/master/src/community/monitoring/src/main/java/applicationContext.xml#L47

On Wed, Aug 15, 2012 at 7:39 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Aug 15, 2012 at 1:01 PM, Mark Paxton <mark@anonymised.com> wrote:

Hi all,

I’m trying to write a custom user group/role details service for
Geoserver. I’ve created my own implementations of the usergroup and role
services, which appear ok in the web interface, but I have a problem of
accessing the list of users and roles.

I get a lazy load exception when accessing referenced entities of my
user entities, because presumably the db session used has been closed
before the view is generated. The easiest solution appears to be to use
the “Open session in view” filter which would normally go in web.xml.

As this is supposed to be an add-on module, it would more approproately
go in the jar file, so I would be including META-INF/web-fragment.xml.
The problem is that Gepserver is using the 2.3 web application spec, and
web-fragment support is only in 3.0.

Could anyone suggest a solution to this?

GeoServer won’t be based on Servet 3.0 for some time, we try to keep
back a version in order to allow conservative deploys to still function.
Happily enough though we have an extension point in Spring that allows
a Servlet filter to be plugged in, you just have to make it implement
the org.geoserver.filters.GeoServerFilter interface and declare it as
a bean in the Spring application context (applicationContext.xml file,
in the root of your module classpath) and it will be picked up on startup
(well, provided your GeoServer is recent enough, it has been around
for more than one year now)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

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 962313
mob: +39 339 8844549

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



Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Geoserver-devel mailing list
Geoserver-devel@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel


Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

I’ve just sent a pull request to add OpenEntityManagerInViewFilter, which should do the same as OpenSessionInViewFilter but for JPA. Hope it’s a sensible thing to do… Cheers, Mark

···

On 15/08/2012 15:09, Justin Deoliveira wrote:

There is an example of doing exactly this in the monitoring module which uses hibernate.

https://github.com/geoserver/geoserver/blob/master/src/community/monitoring/src/main/java/applicationContext.xml#L47

On Wed, Aug 15, 2012 at 7:39 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Aug 15, 2012 at 1:01 PM, Mark Paxton <mark@anonymised.com> wrote:

Hi all,

I’m trying to write a custom user group/role details service for
Geoserver. I’ve created my own implementations of the usergroup and role
services, which appear ok in the web interface, but I have a problem of
accessing the list of users and roles.

I get a lazy load exception when accessing referenced entities of my
user entities, because presumably the db session used has been closed
before the view is generated. The easiest solution appears to be to use
the “Open session in view” filter which would normally go in web.xml.

As this is supposed to be an add-on module, it would more approproately
go in the jar file, so I would be including META-INF/web-fragment.xml.
The problem is that Gepserver is using the 2.3 web application spec, and
web-fragment support is only in 3.0.

Could anyone suggest a solution to this?

GeoServer won’t be based on Servet 3.0 for some time, we try to keep
back a version in order to allow conservative deploys to still function.
Happily enough though we have an extension point in Spring that allows
a Servlet filter to be plugged in, you just have to make it implement
the org.geoserver.filters.GeoServerFilter interface and declare it as
a bean in the Spring application context (applicationContext.xml file,
in the root of your module classpath) and it will be picked up on startup
(well, provided your GeoServer is recent enough, it has been around
for more than one year now)

Cheers
Andrea

==
Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

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 962313
mob: +39 339 8844549

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



Live Security Virtual Conference
Exclusive live event will cover all the ways today’s security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/


Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel


Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.