[Geoserver-devel] custom DataAccessManager with 2.1.x

Hi all.

I’m working on updating GeoNode’s GeoServer extensions to 2.1.x. I’ve managed to resolve all the API incompatibilities (acegi => springframework.security, etc) but now when I try to run our test suite I get a Spring context lookup error:

Caused by: java.lang.IllegalArgumentException: Multiple beans of type org.geoserver.security.DataAccessManager

It looks like there is now a DataAccessManager in the main module’s applicationContext; should GeoNode be hooking into that somehow?

I also looked at the geoxacml module to see whether it was updated to do things The Right Way but it doesn’t seem to compile any more.

For reference, our DataAccessManager is registered in this applicationSecurityContext: https://github.com/GeoNode/geonode/blob/master/src/geoserver-geonode-ext/src/main/resources/applicationSecurityContext.xml

Thanks.


David Winslow
OpenGeo - http://opengeo.org/

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

On Wed, Feb 16, 2011 at 10:54 AM, David Winslow <dwinslow@anonymised.com01…> wrote:

Hi all.

I’m working on updating GeoNode’s GeoServer extensions to 2.1.x. I’ve managed to resolve all the API incompatibilities (acegi => springframework.security, etc) but now when I try to run our test suite I get a Spring context lookup error:

Caused by: java.lang.IllegalArgumentException: Multiple beans of type org.geoserver.security.DataAccessManager

It looks like there is now a DataAccessManager in the main module’s applicationContext; should GeoNode be hooking into that somehow?

I also looked at the geoxacml module to see whether it was updated to do things The Right Way but it doesn’t seem to compile any more.

For reference, our DataAccessManager is registered in this applicationSecurityContext: https://github.com/GeoNode/geonode/blob/master/src/geoserver-geonode-ext/src/main/resources/applicationSecurityContext.xml

Thanks.


David Winslow
OpenGeo - http://opengeo.org/


The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb


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.

On Wed, Feb 16, 2011 at 7:04 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

Yes, the plugin system was created so that there can be only one security manager around.
Which makes sense, you don’t want to have a russian roulette of what the security subsystem will be in case
there is more than one, depending on the JVM chosen, the container and the eventual alignment of planets in
the solar system :wink:

Now, the virtual services thing as far as I can see is there to wrap and alter the security settings, it’s not
really the security manager, it’s a just wrapper around it.

So imho it should not be part of the app context, but be created around the chosen security manager
by the secure catalog impl instead.

Btw, I did not touch that part since I did not know exactly what it was doing, but the wrapper should
be updated to be a ResourceAccessManager instead

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Right, the virtual servies manager is a wrapper. I believe we put it in the app context to make it easy to disable on 2.0.x where we did not want it to engage by default (although the client that funded the work did need it on 2.0.x). So I am all for being explicit about creating it in SecureCatalogImpl.

On Wed, Feb 16, 2011 at 11:34 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Feb 16, 2011 at 7:04 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

Yes, the plugin system was created so that there can be only one security manager around.
Which makes sense, you don’t want to have a russian roulette of what the security subsystem will be in case
there is more than one, depending on the JVM chosen, the container and the eventual alignment of planets in
the solar system :wink:

Now, the virtual services thing as far as I can see is there to wrap and alter the security settings, it’s not
really the security manager, it’s a just wrapper around it.

So imho it should not be part of the app context, but be created around the chosen security manager
by the secure catalog impl instead.

Btw, I did not touch that part since I did not know exactly what it was doing, but the wrapper should
be updated to be a ResourceAccessManager instead

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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

I took a stab at addressing the issue (both the disabled extension point and the refactoring to ResourceAccessManager) in the patch attached to http://jira.codehaus.org/browse/GEOS-4397.


David Winslow
OpenGeo - http://opengeo.org/

On Wed, Feb 16, 2011 at 3:17 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Right, the virtual servies manager is a wrapper. I believe we put it in the app context to make it easy to disable on 2.0.x where we did not want it to engage by default (although the client that funded the work did need it on 2.0.x). So I am all for being explicit about creating it in SecureCatalogImpl.

On Wed, Feb 16, 2011 at 11:34 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Feb 16, 2011 at 7:04 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

Yes, the plugin system was created so that there can be only one security manager around.
Which makes sense, you don’t want to have a russian roulette of what the security subsystem will be in case
there is more than one, depending on the JVM chosen, the container and the eventual alignment of planets in
the solar system :wink:

Now, the virtual services thing as far as I can see is there to wrap and alter the security settings, it’s not
really the security manager, it’s a just wrapper around it.

So imho it should not be part of the app context, but be created around the chosen security manager
by the secure catalog impl instead.

Btw, I did not touch that part since I did not know exactly what it was doing, but the wrapper should
be updated to be a ResourceAccessManager instead

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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

On Wed, Feb 23, 2011 at 12:55 PM, David Winslow <dwinslow@anonymised.com01…> wrote:

I took a stab at addressing the issue (both the disabled extension point and the refactoring to ResourceAccessManager) in the patch attached to http://jira.codehaus.org/browse/GEOS-4397.

Hi David,
the overall structure of the patch looks good, but I think there is a problem with the values
returned from the ResourceAccessManager in that it really returns a DataAccessLimits,
but the secure catalog is expecting specific subclasses to be returned instead.

If you look at DataAccessManagerAdapter you should see what I mean, if the layer being
secured is vector a VectorAccessLimits is build, and so on

I only had very short time to look into it but the rest seems fine

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


I think the logic looks ok in in LocalWorkspaceResourceAccessManager based on my limited understanding of the new api. Unless I am mistaken however the intersection(WorkspaceAccessLimits,WorkspaceAccessLimits) method is unused?

Past that I have the same feedback as Andrea. It looks like some type narrowing methods are required. It might be nice to throw them in the wrapper subclass along with the intersection methods… since other wrappers will probably face the same issues. Maybe not. I leave that up to you.

On Wed, Feb 23, 2011 at 1:55 PM, David Winslow <dwinslow@anonymised.com…1501…> wrote:

I took a stab at addressing the issue (both the disabled extension point and the refactoring to ResourceAccessManager) in the patch attached to http://jira.codehaus.org/browse/GEOS-4397.


David Winslow
OpenGeo - http://opengeo.org/

On Wed, Feb 16, 2011 at 3:17 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Right, the virtual servies manager is a wrapper. I believe we put it in the app context to make it easy to disable on 2.0.x where we did not want it to engage by default (although the client that funded the work did need it on 2.0.x). So I am all for being explicit about creating it in SecureCatalogImpl.

On Wed, Feb 16, 2011 at 11:34 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Feb 16, 2011 at 7:04 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

Yes, the plugin system was created so that there can be only one security manager around.
Which makes sense, you don’t want to have a russian roulette of what the security subsystem will be in case
there is more than one, depending on the JVM chosen, the container and the eventual alignment of planets in
the solar system :wink:

Now, the virtual services thing as far as I can see is there to wrap and alter the security settings, it’s not
really the security manager, it’s a just wrapper around it.

So imho it should not be part of the app context, but be created around the chosen security manager
by the secure catalog impl instead.

Btw, I did not touch that part since I did not know exactly what it was doing, but the wrapper should
be updated to be a ResourceAccessManager instead

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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


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

On Wed, Feb 23, 2011 at 8:52 PM, Justin Deoliveira <jdeolive@anonymised.com.1501…> wrote:

I think the logic looks ok in in LocalWorkspaceResourceAccessManager based on my limited understanding of the new api. Unless I am mistaken however the intersection(WorkspaceAccessLimits,WorkspaceAccessLimits) method is unused?

That’s true (it’s not used) but I moved these to the ResourceAccessManagerWrapper and left it in for consistency. I also made them and the LocalWorkspaceResourceAccessManager aware of the narrower types of DataAccessLimits. An updated patch is attached to the same ticket.

One concern I had was in finding the intersection of the ROI for CoverageAccessInfo - the intersection of two MultiPolygons may be a Polygon (or other types? I am not sure). I suspect somewhere in GeoTools there is a method to correct for this, but in my patch I simply put in an if/else statement and ignored the possibility that they might intersect in a point or something.


David Winslow
OpenGeo - http://opengeo.org/

Past that I have the same feedback as Andrea. It looks like some type narrowing methods are required. It might be nice to throw them in the wrapper subclass along with the intersection methods… since other wrappers will probably face the same issues. Maybe not. I leave that up to you.

On Wed, Feb 23, 2011 at 1:55 PM, David Winslow <dwinslow@anonymised.com> wrote:

I took a stab at addressing the issue (both the disabled extension point and the refactoring to ResourceAccessManager) in the patch attached to http://jira.codehaus.org/browse/GEOS-4397.


David Winslow
OpenGeo - http://opengeo.org/

On Wed, Feb 16, 2011 at 3:17 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Right, the virtual servies manager is a wrapper. I believe we put it in the app context to make it easy to disable on 2.0.x where we did not want it to engage by default (although the client that funded the work did need it on 2.0.x). So I am all for being explicit about creating it in SecureCatalogImpl.

On Wed, Feb 16, 2011 at 11:34 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Wed, Feb 16, 2011 at 7:04 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

This is most likely due to the virtual services stuff which installs its own DataAccessManager. And as you can see the lookup is not prepared to handle multiple access managers. If i remember correctly when i made that change I figured this might come up.

Not sure how to best handle this. My first thought would be to do a look up for all of them in the application context and wrap them up in a composite manager. But would like to hear Andrea weigh in.

Yes, the plugin system was created so that there can be only one security manager around.
Which makes sense, you don’t want to have a russian roulette of what the security subsystem will be in case
there is more than one, depending on the JVM chosen, the container and the eventual alignment of planets in
the solar system :wink:

Now, the virtual services thing as far as I can see is there to wrap and alter the security settings, it’s not
really the security manager, it’s a just wrapper around it.

So imho it should not be part of the app context, but be created around the chosen security manager
by the secure catalog impl instead.

Btw, I did not touch that part since I did not know exactly what it was doing, but the wrapper should
be updated to be a ResourceAccessManager instead

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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


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

On Thu, Feb 24, 2011 at 2:01 PM, David Winslow <dwinslow@anonymised.com> wrote:

On Wed, Feb 23, 2011 at 8:52 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

I think the logic looks ok in in LocalWorkspaceResourceAccessManager based on my limited understanding of the new api. Unless I am mistaken however the intersection(WorkspaceAccessLimits,WorkspaceAccessLimits) method is unused?

That’s true (it’s not used) but I moved these to the ResourceAccessManagerWrapper and left it in for consistency. I also made them and the LocalWorkspaceResourceAccessManager aware of the narrower types of DataAccessLimits. An updated patch is attached to the same ticket.

One concern I had was in finding the intersection of the ROI for CoverageAccessInfo - the intersection of two MultiPolygons may be a Polygon (or other types? I am not sure). I suspect somewhere in GeoTools there is a method to correct for this, but in my patch I simply put in an if/else statement and ignored the possibility that they might intersect in a point or something.

A very unlucky intersection may end up being a mixed collection with polygons, lines and points.
So yeah, some code should be used to clean that up and get back to a multipolygon

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Ok, it is accounted for now (unless intersection produces a MultiGeometry containing nested MultiGeometries?).


David Winslow
OpenGeo - http://opengeo.org/

On Thu, Feb 24, 2011 at 5:50 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Thu, Feb 24, 2011 at 2:01 PM, David Winslow <dwinslow@anonymised.com> wrote:

On Wed, Feb 23, 2011 at 8:52 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

I think the logic looks ok in in LocalWorkspaceResourceAccessManager based on my limited understanding of the new api. Unless I am mistaken however the intersection(WorkspaceAccessLimits,WorkspaceAccessLimits) method is unused?

That’s true (it’s not used) but I moved these to the ResourceAccessManagerWrapper and left it in for consistency. I also made them and the LocalWorkspaceResourceAccessManager aware of the narrower types of DataAccessLimits. An updated patch is attached to the same ticket.

One concern I had was in finding the intersection of the ROI for CoverageAccessInfo - the intersection of two MultiPolygons may be a Polygon (or other types? I am not sure). I suspect somewhere in GeoTools there is a method to correct for this, but in my patch I simply put in an if/else statement and ignored the possibility that they might intersect in a point or something.

A very unlucky intersection may end up being a mixed collection with polygons, lines and points.
So yeah, some code should be used to clean that up and get back to a multipolygon

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


On Fri, Feb 25, 2011 at 8:21 AM, David Winslow <dwinslow@anonymised.com1…> wrote:

Ok, it is accounted for now (unless intersection produces a MultiGeometry containing nested MultiGeometries?).

I don’t believe I’ve ever seen that one, but if you want a generic solution I think you can implement
a geometry component visitor (that’s one of the JTS visitors) and collect only the polygon parts
hierarchically and rebuild them into a multipolygon at the end

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

-d

On Fri, Feb 25, 2011 at 1:05 PM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Fri, Feb 25, 2011 at 8:21 AM, David Winslow <dwinslow@anonymised.com> wrote:

Ok, it is accounted for now (unless intersection produces a MultiGeometry containing nested MultiGeometries?).

I don’t believe I’ve ever seen that one, but if you want a generic solution I think you can implement
a geometry component visitor (that’s one of the JTS visitors) and collect only the polygon parts
hierarchically and rebuild them into a multipolygon at the end

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


On Tue, Mar 1, 2011 at 1:19 AM, David Winslow <dwinslow@anonymised.com…> wrote:

Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

Hi,
had a look at the current patch, I think I spotted a couple other issues.

The most serious one is that LocalWorkspaceDataAccessManager perform alien logic
that was not part of the wrapped access manager in case the layer/resource can be
exposed: I don’t see a need to perform the intersection between the layer rights
and the wrapped resource rights, and same goes for the resource vs workspace.
The code should simply take what the wrapped resource access manager returned
and pass it back without extra processing, it’s not its role to ensure there is proper
right containment between workspace, layer and resource.
Also consider that the current system allows for overrides, so one can have no rights
to the workspace as a whole but there can be an override for a specific layer, as far
as I can see the current code will break that behavior.

The second issue is more of a worry. When intersecting two geometries you don’t
check whether the result is an empty collection (symptom of no intersection).
In that case the filter should probably be flipped to Filter.EXCLUDE instead of
asking for an intersection with an empty geometry.
However, about this one I’m not completely sure, it may end up working fine as is.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


I was hoping Justin would comment on this behavior, as it is there only because I was trying to emulate the behavior of the original LocalWorkspaceDataAccessManager in the LW ResourceAccessManager. As far as I can tell from reading code the changes you suggest should be fine, so I can work up a patch implementing them.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Mar 1, 2011 at 3:27 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Mar 1, 2011 at 1:19 AM, David Winslow <dwinslow@anonymised.com> wrote:

Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

Hi,
had a look at the current patch, I think I spotted a couple other issues.

The most serious one is that LocalWorkspaceDataAccessManager perform alien logic
that was not part of the wrapped access manager in case the layer/resource can be
exposed: I don’t see a need to perform the intersection between the layer rights
and the wrapped resource rights, and same goes for the resource vs workspace.
The code should simply take what the wrapped resource access manager returned
and pass it back without extra processing, it’s not its role to ensure there is proper
right containment between workspace, layer and resource.
Also consider that the current system allows for overrides, so one can have no rights
to the workspace as a whole but there can be an override for a specific layer, as far
as I can see the current code will break that behavior.

The second issue is more of a worry. When intersecting two geometries you don’t
check whether the result is an empty collection (symptom of no intersection).
In that case the filter should probably be flipped to Filter.EXCLUDE instead of
asking for an intersection with an empty geometry.
However, about this one I’m not completely sure, it may end up working fine as is.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Sorry, I am have kind of lost hold of this thread. And I am not really familiar with how the new ResourceAccessManager stuff works. The old api was easy to implement as it just involves returning true or false for each canAccess method.

I would think the LW wrapper should be simple… and no need to intersect or whatever access constraints. The logic should be more or less:

  • getAccessLimts(WOrkspace):

If the workspace being access does not match the local workspace, return limits that hide access. Otherwise pass through to the delegate

  • getAccessLimits(Layer):
  1. if the workspace of the layer does not match the local workspace, hide access
  2. if the layer does not match the local layer, same as (1)
  3. if none of the above delegate to the delegate
  • getAccessLimits(Resource):

Basically apply 1 and 2 from the layer case with every layer that publishes the resource. If any of them are not (since there are usually only one) hide the resource. Otherwise again continue to the delegate.

So I am not seeing where any mixing of access limits should come into play…

On Wed, Mar 2, 2011 at 9:17 AM, David Winslow <dwinslow@anonymised.com> wrote:

I was hoping Justin would comment on this behavior, as it is there only because I was trying to emulate the behavior of the original LocalWorkspaceDataAccessManager in the LW ResourceAccessManager. As far as I can tell from reading code the changes you suggest should be fine, so I can work up a patch implementing them.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Mar 1, 2011 at 3:27 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Mar 1, 2011 at 1:19 AM, David Winslow <dwinslow@anonymised.com> wrote:

Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

Hi,
had a look at the current patch, I think I spotted a couple other issues.

The most serious one is that LocalWorkspaceDataAccessManager perform alien logic
that was not part of the wrapped access manager in case the layer/resource can be
exposed: I don’t see a need to perform the intersection between the layer rights
and the wrapped resource rights, and same goes for the resource vs workspace.
The code should simply take what the wrapped resource access manager returned
and pass it back without extra processing, it’s not its role to ensure there is proper
right containment between workspace, layer and resource.
Also consider that the current system allows for overrides, so one can have no rights
to the workspace as a whole but there can be an override for a specific layer, as far
as I can see the current code will break that behavior.

The second issue is more of a worry. When intersecting two geometries you don’t
check whether the result is an empty collection (symptom of no intersection).
In that case the filter should probably be flipped to Filter.EXCLUDE instead of
asking for an intersection with an empty geometry.
However, about this one I’m not completely sure, it may end up working fine as is.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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

The “mixing” of limits comes from the existing DataAccessManager, where getAccessLimits(LayerInfo) depends on the result of getAccessLimits(ResourceInfo). Here’s the code as it is in LocalWorkspaceDataAccessManager on 2.1.x:

@anonymised.com
public boolean canAccess(Authentication user, LayerInfo layer, AccessMode mode) {
if (super.canAccess(user, layer, mode)) {
if (LocalLayer.get() != null && !LocalLayer.get().equals(layer)) {
return false;
}
return this.canAccess(user, layer.getResource(), mode);
}
return false;
}

If that should just be checking the workspace, then I can do the same in my patch.


David Winslow
OpenGeo - http://opengeo.org/

On Wed, Mar 2, 2011 at 7:50 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Sorry, I am have kind of lost hold of this thread. And I am not really familiar with how the new ResourceAccessManager stuff works. The old api was easy to implement as it just involves returning true or false for each canAccess method.

I would think the LW wrapper should be simple… and no need to intersect or whatever access constraints. The logic should be more or less:

  • getAccessLimts(WOrkspace):

If the workspace being access does not match the local workspace, return limits that hide access. Otherwise pass through to the delegate

  • getAccessLimits(Layer):
  1. if the workspace of the layer does not match the local workspace, hide access
  2. if the layer does not match the local layer, same as (1)
  3. if none of the above delegate to the delegate
  • getAccessLimits(Resource):

Basically apply 1 and 2 from the layer case with every layer that publishes the resource. If any of them are not (since there are usually only one) hide the resource. Otherwise again continue to the delegate.

So I am not seeing where any mixing of access limits should come into play…

On Wed, Mar 2, 2011 at 9:17 AM, David Winslow <dwinslow@anonymised.com> wrote:

I was hoping Justin would comment on this behavior, as it is there only because I was trying to emulate the behavior of the original LocalWorkspaceDataAccessManager in the LW ResourceAccessManager. As far as I can tell from reading code the changes you suggest should be fine, so I can work up a patch implementing them.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Mar 1, 2011 at 3:27 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Mar 1, 2011 at 1:19 AM, David Winslow <dwinslow@anonymised.com> wrote:

Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

Hi,
had a look at the current patch, I think I spotted a couple other issues.

The most serious one is that LocalWorkspaceDataAccessManager perform alien logic
that was not part of the wrapped access manager in case the layer/resource can be
exposed: I don’t see a need to perform the intersection between the layer rights
and the wrapped resource rights, and same goes for the resource vs workspace.
The code should simply take what the wrapped resource access manager returned
and pass it back without extra processing, it’s not its role to ensure there is proper
right containment between workspace, layer and resource.
Also consider that the current system allows for overrides, so one can have no rights
to the workspace as a whole but there can be an override for a specific layer, as far
as I can see the current code will break that behavior.

The second issue is more of a worry. When intersecting two geometries you don’t
check whether the result is an empty collection (symptom of no intersection).
In that case the filter should probably be flipped to Filter.EXCLUDE instead of
asking for an intersection with an empty geometry.
However, about this one I’m not completely sure, it may end up working fine as is.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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

The call though to checking resource from the getAccessLimits(Layer) need not go through to the delegate, although i understand that in the original it does. This is what I would expect with my understanding of the new api. There is probably some redundant checking here but I don’t understand the life cycle of the api and what we can be sure gets called when.

@anonymised.com
public DataAccessLimits getAccessLimits(Authentication user, LayerInfo layer) {
if (LocalLayer.get() != null && !LocalLayer.get().equals(layer)) {
return hide();
}
if (hideResource(layer.getResource())) {
return hide();
}
return super.getAccessLimits(user, layer);
}

@anonymised.com
public DataAccessLimits getAccessLimits(Authentication user, ResourceInfo resource) {
if (hideResource(resource)) {
return hide();

super.getAccessLimits(user, resource);
}

@anonymised.com
public WorkspaceAccessLimits getAccessLimits(Authentication user, WorkspaceInfo workspace) {
if (hideWorkspace(workspace)) {
return new WorkspaceAccessLimits(CatalogMode.HIDE, false, false);
} else {
return super.getAccessLimits(user, workspace);
}
}

boolean hideResource(ResourceInfo resource) {
if (LocalLayer.get() != null) {
for (LayerInfo l : resource.getCatalog().getLayers(resource)) {
if (!l.equals(LocalLayer.get())) {
return true;
}
}
}

return hideWorkspace(resource.getStore().getWorkspace());
}

boolean hideWorkspace(Workspace workspace) {
if (LocalWorkspace.get() != null && !LocalWorkspace.get().equals(workspace)) {
return true;
}
return false;
}

On Thu, Mar 3, 2011 at 7:45 AM, David Winslow <dwinslow@anonymised.com> wrote:

The “mixing” of limits comes from the existing DataAccessManager, where getAccessLimits(LayerInfo) depends on the result of getAccessLimits(ResourceInfo). Here’s the code as it is in LocalWorkspaceDataAccessManager on 2.1.x:

@anonymised.com
public boolean canAccess(Authentication user, LayerInfo layer, AccessMode mode) {
if (super.canAccess(user, layer, mode)) {
if (LocalLayer.get() != null && !LocalLayer.get().equals(layer)) {
return false;
}
return this.canAccess(user, layer.getResource(), mode);
}
return false;
}

If that should just be checking the workspace, then I can do the same in my patch.


David Winslow
OpenGeo - http://opengeo.org/

On Wed, Mar 2, 2011 at 7:50 PM, Justin Deoliveira <jdeolive@anonymised.com> wrote:

Sorry, I am have kind of lost hold of this thread. And I am not really familiar with how the new ResourceAccessManager stuff works. The old api was easy to implement as it just involves returning true or false for each canAccess method.

I would think the LW wrapper should be simple… and no need to intersect or whatever access constraints. The logic should be more or less:

  • getAccessLimts(WOrkspace):

If the workspace being access does not match the local workspace, return limits that hide access. Otherwise pass through to the delegate

  • getAccessLimits(Layer):
  1. if the workspace of the layer does not match the local workspace, hide access
  2. if the layer does not match the local layer, same as (1)
  3. if none of the above delegate to the delegate
  • getAccessLimits(Resource):

Basically apply 1 and 2 from the layer case with every layer that publishes the resource. If any of them are not (since there are usually only one) hide the resource. Otherwise again continue to the delegate.

So I am not seeing where any mixing of access limits should come into play…

On Wed, Mar 2, 2011 at 9:17 AM, David Winslow <dwinslow@anonymised.com> wrote:

I was hoping Justin would comment on this behavior, as it is there only because I was trying to emulate the behavior of the original LocalWorkspaceDataAccessManager in the LW ResourceAccessManager. As far as I can tell from reading code the changes you suggest should be fine, so I can work up a patch implementing them.


David Winslow
OpenGeo - http://opengeo.org/

On Tue, Mar 1, 2011 at 3:27 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Mar 1, 2011 at 1:19 AM, David Winslow <dwinslow@anonymised.com> wrote:

Ok this was simple and made the code smaller so I went ahead and refactored to use a GeometryFilter.

Unless there’s any objections, I’ll go ahead and commit the latest patch on the ticket tomorrow.

Hi,
had a look at the current patch, I think I spotted a couple other issues.

The most serious one is that LocalWorkspaceDataAccessManager perform alien logic
that was not part of the wrapped access manager in case the layer/resource can be
exposed: I don’t see a need to perform the intersection between the layer rights
and the wrapped resource rights, and same goes for the resource vs workspace.
The code should simply take what the wrapped resource access manager returned
and pass it back without extra processing, it’s not its role to ensure there is proper
right containment between workspace, layer and resource.
Also consider that the current system allows for overrides, so one can have no rights
to the workspace as a whole but there can be an override for a specific layer, as far
as I can see the current code will break that behavior.

The second issue is more of a worry. When intersecting two geometries you don’t
check whether the result is an empty collection (symptom of no intersection).
In that case the filter should probably be flipped to Filter.EXCLUDE instead of
asking for an intersection with an empty geometry.
However, about this one I’m not completely sure, it may end up working fine as is.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



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


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