Source:
public void verifyAccessLayer(String layerName, ReferencedEnvelope boundingBox) throws ServiceException { LayerInfo layerInfo = getLayerInfoByName(layerName); if (layerInfo == null) { throw new ServiceException("Could not find layer " + layerName, "LayerNotDefined"); } if (layerInfo instanceof SecuredLayerInfo && boundingBox != null) { SecuredLayerInfo securedLayerInfo = (SecuredLayerInfo) layerInfo; WrapperPolicy policy = securedLayerInfo.getWrapperPolicy(); AccessLimits limits = policy.getLimits(); if (limits instanceof DataAccessLimits) { Filter filter = ((DataAccessLimits) limits).getReadFilter(); if (filter != null) { Envelope limitBox = (Envelope) filter.accept(ExtractBoundsFilterVisitor.BOUNDS_VISITOR, null); if (limitBox != null) { CoordinateReferenceSystem dataCrs = layerInfo.getResource().getCRS(); limitBox = new ReferencedEnvelope(limitBox, dataCrs); if (boundingBox.getCoordinateReferenceSystem()!=null && !CRS.equalsIgnoreMetadata(dataCrs, boundingBox.getCoordinateReferenceSystem())) { try { boundingBox = boundingBox.transform(dataCrs,true); } catch (Exception e) { boundingBox = null; } } if (boundingBox==null || !limitBox.contains(boundingBox)) { throw new ServiceException("Access denied to bounding box on layer " + layerName, "AccessDenied"); } } } } } }

Target:
public void verifyAccessLayer(String layerName, ReferencedEnvelope boundingBox) throws ServiceException { LayerInfo layerInfo = getLayerInfoByName(layerName); if (layerInfo == null) { throw new ServiceException("Could not find layer " + layerName, "LayerNotDefined"); } if (layerInfo instanceof SecuredLayerInfo && boundingBox != null) { SecuredLayerInfo securedLayerInfo = (SecuredLayerInfo) layerInfo; WrapperPolicy policy = securedLayerInfo.getWrapperPolicy(); AccessLimits limits = policy.getLimits(); if (limits instanceof DataAccessLimits) { CoordinateReferenceSystem dataCrs = layerInfo.getResource().getCRS(); if (boundingBox.getCoordinateReferenceSystem()!=null && !CRS.equalsIgnoreMetadata(dataCrs, boundingBox.getCoordinateReferenceSystem())) { try { boundingBox = boundingBox.transform(dataCrs,true); } catch (Exception e) { boundingBox = null; } } Envelope limitBox = new ReferencedEnvelope(ReferencedEnvelope.EVERYTHING, dataCrs); Filter filter = ((DataAccessLimits) limits).getReadFilter(); if (filter != null) { Envelope box = (Envelope) filter.accept(ExtractBoundsFilterVisitor.BOUNDS_VISITOR, null); if (box != null) { limitBox = new ReferencedEnvelope(limitBox.intersection(box), dataCrs); } } if (limits instanceof CoverageAccessLimits) { if (((CoverageAccessLimits) limits).getRasterFilter() != null) { Envelope box = ((CoverageAccessLimits) limits).getRasterFilter().getEnvelopeInternal(); if (box != null) { limitBox = new ReferencedEnvelope(limitBox.intersection(box), dataCrs); } } } if (limits instanceof WMSAccessLimits) { if (((WMSAccessLimits) limits).getRasterFilter() != null) { Envelope box = ((WMSAccessLimits) limits).getRasterFilter().getEnvelopeInternal(); if (box != null) { limitBox = new ReferencedEnvelope(limitBox.intersection(box), dataCrs); } } } if (!limitBox.covers(ReferencedEnvelope.EVERYTHING) && (boundingBox==null || !limitBox.contains(boundingBox))) { throw new ServiceException("Access denied to bounding box on layer " + layerName, "AccessDenied"); } } } }